fix live sortie legacy logs

This commit is contained in:
2026-07-26 13:13:10 +00:00
parent 3f1c2af3f9
commit 6dec59430a
6 changed files with 145 additions and 6 deletions
+31 -2
View File
@@ -36,6 +36,36 @@ const resolveNationVar = (nation: Nation | null, key: string): TriggerValue | nu
}
};
const isCityWarUnit = (unit: WarUnit): boolean =>
typeof (unit as WarUnit & { getCityId?: unknown }).getCityId === 'function';
const buildLegacySmallWarLog = (me: WarUnit, oppose: WarUnit): string => {
const warType = !me.isAttacker() ? 'defense' : isCityWarUnit(oppose) ? 'siege' : 'attack';
const warTypeStr = me.isAttacker() ? '→' : '←';
return [
'<div class="small_war_log"> ',
'<span class="me"> ',
'<span class="name_plate"> ',
`<span class="crew_type">${me.getCrewTypeShortName()}</span> `,
'<span class="name_plate_cover" >【',
`<span class="name">${me.getName()}</span>】 </span> </span> `,
'<span class="crew_plate" >',
`<span class="remain_crew">${me.getHP()}</span >`,
'<span class="killed_plate">(',
`<span class="killed_crew">${-me.getDeadCurrentBattle()}</span>)</span ></span> </span> `,
`<span class="war_type war_type_${warType}">${warTypeStr}</span> `,
'<span class="you"> ',
'<span class="crew_plate" >',
`<span class="remain_crew">${oppose.getHP()}</span >`,
'<span class="killed_plate">(',
`<span class="killed_crew">${-oppose.getDeadCurrentBattle()}</span>)</span ></span> `,
'<span class="name_plate"> ',
`<span class="crew_type">${oppose.getCrewTypeShortName()}</span> `,
'<span class="name_plate_cover" >【',
`<span class="name">${oppose.getName()}</span>】 </span> </span> </span></div>`,
].join('');
};
// 전투 유닛 공통 상태와 수치 계산(legacy WarUnit 계열 포팅).
export abstract class WarUnit<TriggerState extends GeneralTriggerState = GeneralTriggerState> {
private static nextUnitId = 1;
@@ -317,8 +347,7 @@ export abstract class WarUnit<TriggerState extends GeneralTriggerState = General
return;
}
const warTypeStr = this.isAttacker() ? '→' : '←';
const message = `${this.getCrewTypeShortName()} ${this.getName()} ${warTypeStr} ${oppose.getCrewTypeShortName()} ${oppose.getName()} (${this.getHP()} / ${oppose.getHP()})`;
const message = buildLegacySmallWarLog(this, oppose);
this.logger.pushGeneralBattleResultLog(message, LogFormat.EVENT_YEAR_MONTH);
this.logger.pushGeneralBattleDetailLog(message, LogFormat.EVENT_YEAR_MONTH);
this.logger.pushGeneralActionLog(message, LogFormat.EVENT_YEAR_MONTH);
+5 -1
View File
@@ -149,7 +149,11 @@ export class WarUnitCity extends WarUnit {
dead *= 1.05;
}
if (conflict[nationId] !== undefined) {
if (Object.keys(conflict).length === 0) {
// Legacy treats the first attacker as the conflict baseline and
// emits the "new participant" history only for later nations.
conflict[nationId] = dead;
} else if (conflict[nationId] !== undefined) {
conflict[nationId] += dead;
} else {
conflict[nationId] = dead;
+14 -2
View File
@@ -1,4 +1,4 @@
import type { RandUtil } from '@sammo-ts/common';
import { JosaUtil, type RandUtil } from '@sammo-ts/common';
import type {
City,
@@ -350,6 +350,7 @@ export class WarUnitGeneral<
}
public addLevelExp(value: number): void {
const previousExpLevel = getMetaNumber(this.general.meta, META_EXP_LEVEL);
const sideAdjusted = this.isAttacker() ? value : value * 0.8;
const adjusted = this.actionPipeline.onCalcStat(this.getActionContext(), 'experience', sideAdjusted);
this.general.experience += adjusted;
@@ -357,7 +358,18 @@ export class WarUnitGeneral<
this.general.experience < 1000
? Math.trunc(this.general.experience / 100)
: Math.trunc(Math.sqrt(this.general.experience / 10));
this.general.meta[META_EXP_LEVEL] = clamp(nextExpLevel, 0, MAX_EXP_LEVEL);
const resolvedExpLevel = clamp(nextExpLevel, 0, MAX_EXP_LEVEL);
this.general.meta[META_EXP_LEVEL] = resolvedExpLevel;
if (resolvedExpLevel === previousExpLevel) {
return;
}
const josaRo = JosaUtil.pick(String(resolvedExpLevel), '로');
this.logger.pushGeneralActionLog(
resolvedExpLevel > previousExpLevel
? `<C>Lv ${resolvedExpLevel}</>${josaRo} <C>레벨업</>!`
: `<C>Lv ${resolvedExpLevel}</>${josaRo} <R>레벨다운</>!`,
LogFormat.PLAIN
);
}
public addDedication(value: number): void {