feat(game-engine): port city changes and NPC troop leaders

This commit is contained in:
2026-07-25 19:49:51 +00:00
parent 18a39ec612
commit 09e4a2233c
8 changed files with 1020 additions and 7 deletions
+18 -1
View File
@@ -59,6 +59,8 @@ import {
createInvaderEndingHandler,
createRaiseInvaderHandler,
} from './monthlyInvaderAction.js';
import { createChangeCityHandler } from './monthlyChangeCityAction.js';
import { createProvideNpcTroopLeaderHandler } from './monthlyProvideNpcTroopLeaderAction.js';
import { buildCommandEnv } from './reservedTurnCommands.js';
import { DatabaseTurnDaemonLease, TurnDaemonLeaseUnavailableError } from '../lifecycle/databaseTurnDaemonLease.js';
@@ -183,7 +185,8 @@ const createTurnDaemonRuntimeWithLease = async (
hasEventAction('RegNeutralNPC') ||
hasEventAction('RaiseNPCNation') ||
hasEventAction('RaiseInvader') ||
hasEventAction('AutoDeleteInvader');
hasEventAction('AutoDeleteInvader') ||
hasEventAction('ProvideNPCTroopLeader');
const reservedTurnStoreHandle =
options.generalTurnHandler && !eventRequiresReservedTurns
? null
@@ -299,6 +302,14 @@ const createTurnDaemonRuntimeWithLease = async (
reservedTurns: reservedTurnStoreHandle.store,
})
);
eventActions.set(
'ProvideNPCTroopLeader',
createProvideNpcTroopLeaderHandler({
getWorld: () => worldRef,
reservedTurns: reservedTurnStoreHandle.store,
env: monthlyCommandEnv,
})
);
eventActions.set(
'UpdateNationLevel',
createUpdateNationLevelHandler({
@@ -315,6 +326,12 @@ const createTurnDaemonRuntimeWithLease = async (
getWorld: () => worldRef,
})
);
eventActions.set(
'ChangeCity',
createChangeCityHandler({
getWorld: () => worldRef,
})
);
eventActions.set('ProcessIncome', async (_args, environment) => {
await incomeHandler.onMonthChanged?.({
previousYear: environment.month === 1 ? environment.year - 1 : environment.year,