feat: 프론트 상태 핸들러 추가 및 예약 턴 핸들러와 통합
This commit is contained in:
@@ -37,6 +37,7 @@ import {
|
||||
type DiplomacyPatch,
|
||||
} from '@sammo-ts/logic';
|
||||
import { buildCommandEnv, buildReservedTurnDefinitions } from './reservedTurnCommands.js';
|
||||
import { buildFrontStatePatches } from './frontStateHandler.js';
|
||||
import { buildActionContext } from './reservedTurnActionContext.js';
|
||||
import { GeneralAI, shouldUseAi } from './ai/generalAi.js';
|
||||
import type { AiReservedTurnProvider } from './ai/types.js';
|
||||
@@ -701,6 +702,31 @@ export const createReservedTurnHandler = async (options: {
|
||||
}
|
||||
}
|
||||
|
||||
const hasDiplomacyChange = diplomacyPatches.length > 0;
|
||||
const hasNationChange = (resolution.patches?.cities ?? []).some((patch) =>
|
||||
Object.prototype.hasOwnProperty.call(patch.patch ?? {}, 'nationId')
|
||||
);
|
||||
if (hasDiplomacyChange || hasNationChange) {
|
||||
const worldView = worldOverlay?.view ?? worldRef;
|
||||
if (worldView && options.map) {
|
||||
const frontPatches = buildFrontStatePatches({
|
||||
worldView,
|
||||
map: options.map,
|
||||
});
|
||||
if (frontPatches.length > 0) {
|
||||
for (const patch of frontPatches) {
|
||||
const existing = patches.cities.find((entry) => entry.id === patch.id);
|
||||
if (existing) {
|
||||
existing.patch = { ...existing.patch, ...patch.patch };
|
||||
} else {
|
||||
patches.cities.push({ id: patch.id, patch: patch.patch });
|
||||
}
|
||||
worldOverlay?.applyCityPatch(patch.id, patch.patch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { nextTurnAt: applyNextTurnAt ? resolution.nextTurnAt : undefined, actionKey, usedFallback, blockedReason };
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user