fix faction disband state and log parity

This commit is contained in:
2026-07-26 20:13:10 +00:00
parent 0f9fa69e1f
commit a7de5778ed
10 changed files with 198 additions and 13 deletions
@@ -98,6 +98,8 @@ export class ActionResolver<
// 2. Recruiter Rewards
const recruiterExperience = destGeneral.experience + 100;
const recruiterDedication = destGeneral.dedication + 100;
const belong = readMetaNumberFromUnknown(general.meta, 'belong') ?? 0;
const maxBelong = readMetaNumberFromUnknown(general.meta, 'max_belong') ?? 0;
const recruiterExpLevel = Math.max(
0,
Math.min(
@@ -242,6 +244,7 @@ export class ActionResolver<
...(general.npcState < 2
? {
killturn: context.worldKillturn ?? general.meta.killturn,
max_belong: Math.max(belong, maxBelong),
}
: {}),
},
@@ -10,6 +10,7 @@ import type {
import {
createCityPatchEffect,
createGeneralPatchEffect,
createLogEffect,
createNationPatchEffect,
} from '@sammo-ts/logic/actions/engine.js';
import { LogCategory, LogFormat, LogScope } from '@sammo-ts/logic/logging/types.js';
@@ -22,6 +23,9 @@ import type { GeneralTurnCommandSpec } from './index.js';
const ACTION_NAME = '해산';
const ACTION_KEY = 'che_해산';
const readMetaNumber = (value: unknown): number =>
typeof value === 'number' && Number.isFinite(value) ? value : 0;
export interface DisbandFactionArgs {}
export interface DisbandFactionResolveContext<
@@ -76,6 +80,8 @@ export class ActionDefinition<
const nationGenerals = context.nationGenerals ?? [];
for (const targetGeneral of nationGenerals) {
const isActor = targetGeneral.id === general.id;
const belong = readMetaNumber(targetGeneral.meta.belong);
const maxBelong = readMetaNumber(targetGeneral.meta.max_belong);
effects.push(
createGeneralPatchEffect(
{
@@ -92,6 +98,8 @@ export class ActionDefinition<
belong: 0,
officer_city: 0,
officerCity: 0,
permission: 'normal',
...(targetGeneral.npcState < 2 ? { max_belong: Math.max(belong, maxBelong) } : {}),
...(isActor ? { makelimit: 12 } : {}),
},
},
@@ -135,13 +143,39 @@ export class ActionDefinition<
});
context.addLog(`<Y>${general.name}</>${josaYi} 세력을 해산했습니다.`, {
scope: LogScope.SYSTEM,
category: LogCategory.ACTION,
category: LogCategory.SUMMARY,
});
context.addLog(`<D><b>${nation.name}</b></>${josaUl} 해산`, {
scope: LogScope.GENERAL,
category: LogCategory.HISTORY,
});
const josaUn = JosaUtil.pick(nation.name, '은');
const josaNationYi = JosaUtil.pick(nation.name, '이');
effects.push(
createLogEffect(`<R><b>【멸망】</b></><D><b>${nation.name}</b></>${josaUn} <R>멸망</>했습니다.`, {
scope: LogScope.SYSTEM,
category: LogCategory.HISTORY,
format: LogFormat.YEAR_MONTH,
})
);
for (const targetGeneral of nationGenerals) {
effects.push(
createLogEffect(`<D><b>${nation.name}</b></>${josaNationYi} <R>멸망</>했습니다.`, {
scope: LogScope.GENERAL,
category: LogCategory.ACTION,
format: LogFormat.PLAIN,
generalId: targetGeneral.id,
}),
createLogEffect(`<D><b>${nation.name}</b></>${josaNationYi} <R>멸망</>`, {
scope: LogScope.GENERAL,
category: LogCategory.HISTORY,
format: LogFormat.YEAR_MONTH,
generalId: targetGeneral.id,
})
);
}
return { effects };
}
}