fix war command differential parity

This commit is contained in:
2026-07-26 22:26:09 +00:00
parent 1011822463
commit 789b9c8c8f
9 changed files with 69 additions and 52 deletions
+12 -5
View File
@@ -1035,7 +1035,7 @@ export class InMemoryTurnWorld {
// nation. Without this, a later conquest can award a city to a
// nation ID that no longer exists.
for (const city of this.cities.values()) {
const rawConflict = city.meta.conflict;
const rawConflict = city.conflict;
if (rawConflict === null || rawConflict === undefined) {
continue;
}
@@ -1056,10 +1056,7 @@ export class InMemoryTurnWorld {
delete conflict[key];
this.cities.set(city.id, {
...city,
meta: {
...city.meta,
conflict: JSON.stringify(conflict),
},
conflict: conflict as City['conflict'],
});
this.dirtyCityIds.add(city.id);
}
@@ -1073,10 +1070,20 @@ export class InMemoryTurnWorld {
if (general.nationId !== nationId) {
continue;
}
const belong = typeof general.meta.belong === 'number' ? general.meta.belong : 0;
const maxBelong = typeof general.meta.max_belong === 'number' ? general.meta.max_belong : 0;
const updated = applyGeneralPatch(general, {
nationId: 0,
officerLevel: 0,
troopId: 0,
meta: {
...general.meta,
belong: 0,
officer_city: 0,
officerCity: 0,
permission: 'normal',
...(general.npcState < 2 ? { max_belong: Math.max(belong, maxBelong) } : {}),
},
});
this.generals.set(general.id, normalizeGeneralTurnTime(updated, this.state.lastTurnTime));
this.dirtyGeneralIds.add(general.id);
@@ -129,8 +129,9 @@ const applyLegacyGeneralProgression = (
const preserveLevel = actionKey === 'che_은퇴' || actionKey === 'che_선양';
if (!preserveLevel && (forceRefreshLevel || general.experience !== previousGeneral.experience)) {
const previousExpLevel = readMetaNumber(previousGeneral.meta, 'explevel', 0);
const actionResolvedExpLevel = readMetaNumber(general.meta, 'explevel', previousExpLevel);
meta.explevel = expLevel;
if (expLevel !== previousExpLevel) {
if (expLevel !== previousExpLevel && actionResolvedExpLevel !== expLevel) {
const josaRo = JosaUtil.pick(String(expLevel), '로');
logs.push({
scope: LogScope.GENERAL,
@@ -1089,6 +1090,9 @@ export const createReservedTurnHandler = async (options: {
const lastTurnBeforeExecution = JSON.stringify(currentGeneral.lastTurn ?? {});
const generalBeforeExecution = currentGeneral;
const cityNationIdsBeforeExecution = new Map(
(worldView?.listCities() ?? []).map((city) => [city.id, city.nationId] as const)
);
const resolution = resolveGeneralAction(
definition,
actionContext,
@@ -1279,9 +1283,14 @@ export const createReservedTurnHandler = async (options: {
}
}
const hasNationChange = (resolution.patches?.cities ?? []).some((patch) =>
Object.prototype.hasOwnProperty.call(patch.patch ?? {}, 'nationId')
);
const hasNationChange = (resolution.patches?.cities ?? []).some((patch) => {
if (!Object.prototype.hasOwnProperty.call(patch.patch ?? {}, 'nationId')) {
return false;
}
const nextNationId = patch.patch.nationId;
const previousNationId = cityNationIdsBeforeExecution.get(patch.id);
return previousNationId === undefined || nextNationId !== previousNationId;
});
const refreshesFrontForDiplomacyState =
actionKey === 'che_이호경식' &&
resolution.effects.some(