refactor: use centralized getDayNumber() in inventionSystem

This commit is contained in:
root
2026-03-10 19:14:04 +00:00
parent c71640fd3b
commit 70ce82302a
2 changed files with 3 additions and 6 deletions

View File

@@ -77,6 +77,7 @@ export class GameLoop {
this.narrationService,
this.eventMemoryService,
(summary) => this.onInventionCreated?.(summary),
() => this.getDayNumber(),
);
this.desireGeneratorSystem = createDesireGeneratorSystem(this.llmService, this.eventMemoryService);

View File

@@ -11,7 +11,6 @@ import { parseInventionResponse } from '../industry/inventionParser.js';
import { validateInvention } from '../industry/inventionValidator.js';
import { registerInvention } from '../industry/inventionRegistrar.js';
import { industryConfig } from '../config/industryConfig.js';
import { ENERGY_DECAY_PER_TICK, DAY_NIGHT_RATIO } from '@dflike/shared';
import { logLlmDebug } from '../llm/llmDebugLog.js';
export interface InventionSystem {
@@ -23,6 +22,7 @@ export function createInventionSystem(
narrationService: NarrationService,
eventMemoryService: EventMemoryService,
onInventionCreated?: (summary: InventionSummary) => void,
getDayNumber?: () => number,
): InventionSystem {
// Track in-flight requests to avoid duplicates
const pendingEntities = new Set<EntityId>();
@@ -145,11 +145,7 @@ export function createInventionSystem(
}
pendingItemIds.add(validation.itemId!);
// Compute current day
const dayTicks = 100 / ENERGY_DECAY_PER_TICK;
const nightTicks = dayTicks / DAY_NIGHT_RATIO;
const cycleTicks = Math.round(dayTicks + nightTicks);
const day = Math.floor(tick / cycleTicks) + 1;
const day = getDayNumber ? getDayNumber() : 1;
console.log(`[Invention] SUCCESS npc=${name} (${entityId}) invented "${parsed.name}" (${validation.itemId}) cat=${parsed.category}`);