refactor: use centralized getDayNumber() in inventionSystem
This commit is contained in:
@@ -77,6 +77,7 @@ export class GameLoop {
|
||||
this.narrationService,
|
||||
this.eventMemoryService,
|
||||
(summary) => this.onInventionCreated?.(summary),
|
||||
() => this.getDayNumber(),
|
||||
);
|
||||
this.desireGeneratorSystem = createDesireGeneratorSystem(this.llmService, this.eventMemoryService);
|
||||
|
||||
|
||||
@@ -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}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user