feat: 여러 액션의 로그 메시지 개선 및 템플릿 카운트 비교 기능 추가

This commit is contained in:
2026-02-07 07:52:00 +00:00
parent 15989e0436
commit 14da014a6f
11 changed files with 166 additions and 52 deletions
@@ -15,6 +15,7 @@ import type { GeneralActionDefinition } from '@sammo-ts/logic/actions/definition
import type { GeneralActionOutcome, GeneralActionResolveContext } from '@sammo-ts/logic/actions/engine.js';
import { createDiplomacyPatchEffect, createLogEffect } from '@sammo-ts/logic/actions/engine.js';
import { LogCategory, LogFormat, LogScope } from '@sammo-ts/logic/logging/types.js';
import { JosaUtil } from '@sammo-ts/common';
export interface NonAggressionAcceptArgs {
destNationId: number;
@@ -175,6 +176,8 @@ export class ActionDefinition<
const currentMonth = resolveMonthIndex(context.currentYear, context.currentMonth);
const targetMonth = args.year * 12 + args.month;
const term = Math.max(0, targetMonth - currentMonth);
const destNationName = String(args.destNationId);
const josaWa = JosaUtil.pick(destNationName, '와');
return {
effects: [
@@ -186,11 +189,14 @@ export class ActionDefinition<
state: DIPLOMACY_NON_AGGRESSION,
term,
}),
createLogEffect(`${ACTION_NAME}을 실행했습니다. (국가 ${args.destNationId})`, {
createLogEffect(
`<D><b>${destNationName}</b></>${josaWa} <C>${args.year}</>년 <C>${args.month}</>월까지 불가침에 성공했습니다.`,
{
scope: LogScope.GENERAL,
category: LogCategory.ACTION,
format: LogFormat.MONTH,
}),
}
),
],
};
}
@@ -12,6 +12,7 @@ import type { GeneralActionDefinition } from '@sammo-ts/logic/actions/definition
import type { GeneralActionOutcome, GeneralActionResolveContext } from '@sammo-ts/logic/actions/engine.js';
import { createDiplomacyPatchEffect, createLogEffect } from '@sammo-ts/logic/actions/engine.js';
import { LogCategory, LogFormat, LogScope } from '@sammo-ts/logic/logging/types.js';
import { JosaUtil } from '@sammo-ts/common';
export interface NonAggressionCancelAcceptArgs {
destNationId: number;
@@ -81,6 +82,9 @@ export class ActionDefinition<
};
}
const destNationName = String(args.destNationId);
const josaWa = JosaUtil.pick(destNationName, '와');
return {
effects: [
createDiplomacyPatchEffect(nationId, args.destNationId, {
@@ -91,7 +95,7 @@ export class ActionDefinition<
state: DIPLOMACY_NEUTRAL,
term: 0,
}),
createLogEffect(`${ACTION_NAME}을 실행했습니다. (국가 ${args.destNationId})`, {
createLogEffect(`<D><b>${destNationName}</b></>${josaWa}의 불가침을 파기했습니다.`, {
scope: LogScope.GENERAL,
category: LogCategory.ACTION,
format: LogFormat.MONTH,
@@ -88,9 +88,9 @@ export class ActionDefinition<
general.gold = Math.max(0, general.gold - sellAmount);
general.rice += buyAmount;
context.addLog(
`군량 ${Math.round(buyAmount).toLocaleString()}을 사서 자금 ${Math.round(
`군량 <C>${Math.round(buyAmount).toLocaleString()}</>을 사서 자금 <C>${Math.round(
sellAmount
).toLocaleString()}을 썼습니다.`,
).toLocaleString()}</>을 썼습니다.`,
{ format: LogFormat.PLAIN }
);
} else {
@@ -101,9 +101,9 @@ export class ActionDefinition<
general.rice = Math.max(0, general.rice - sellAmount);
general.gold += buyAmount;
context.addLog(
`군량 ${Math.round(sellAmount).toLocaleString()}을 팔아 자금 ${Math.round(
`군량 <C>${Math.round(sellAmount).toLocaleString()}</>을 팔아 자금 <C>${Math.round(
buyAmount
).toLocaleString()}을 얻었습니다.`,
).toLocaleString()}</>을 얻었습니다.`,
{ format: LogFormat.PLAIN }
);
}
@@ -18,7 +18,7 @@ import type {
GeneralActionEffect,
} from '@sammo-ts/logic/actions/engine.js';
import { createGeneralPatchEffect, createNationPatchEffect } from '@sammo-ts/logic/actions/engine.js';
import { LogCategory, LogFormat } from '@sammo-ts/logic/logging/types.js';
import { LogCategory, LogFormat, LogScope } from '@sammo-ts/logic/logging/types.js';
import { JosaUtil } from '@sammo-ts/common';
import { z } from 'zod';
import type { TurnCommandEnv } from '@sammo-ts/logic/actions/turn/commandEnv.js';
@@ -76,6 +76,7 @@ export class ActionResolver<
// Global Log
context.addLog(`<Y>${generalName}</>${josaYi} <D><b>${destNationName}</b></>${josaRo} <S>망명</>하였습니다.`, {
scope: LogScope.SYSTEM,
category: LogCategory.ACTION,
format: LogFormat.PLAIN,
});
@@ -72,6 +72,7 @@ export class ActionResolver<
const actualSecuDmg = destCity.security - newSecu;
const actualTrustDmg = currentTrust - newTrust;
const injuryCount = 0;
// Log
const commandName = ACTION_NAME;
@@ -80,10 +81,15 @@ export class ActionResolver<
category: LogCategory.ACTION,
format: LogFormat.MONTH,
});
ctx.addLog(`치안이 ${actualSecuDmg}, 민심이 ${actualTrustDmg.toFixed(1)} 만큼 감소했습니다.`, {
ctx.addLog(
`도시의 치안이 <C>${actualSecuDmg}</>, 민심이 <C>${actualTrustDmg.toFixed(
1
)}</>만큼 감소하고, 장수 <C>${injuryCount}</>명이 부상 당했습니다.`,
{
category: LogCategory.ACTION,
format: LogFormat.PLAIN,
});
}
);
// City Update
effects.push(
@@ -72,6 +72,7 @@ export class ActionResolver<
const actualDefDmg = destCity.defence - newDef;
const actualWallDmg = destCity.wall - newWall;
const injuryCount = 0;
// Log
const commandName = ACTION_NAME;
@@ -80,10 +81,13 @@ export class ActionResolver<
category: LogCategory.ACTION,
format: LogFormat.MONTH,
});
ctx.addLog(`수비가 ${actualDefDmg}, 성벽이 ${actualWallDmg} 만큼 감소했습니다.`, {
category: LogCategory.ACTION,
format: LogFormat.PLAIN,
});
ctx.addLog(
`도시의 수비가 <C>${actualDefDmg}</>, 성벽이 <C>${actualWallDmg}</>만큼 감소하고, 장수 <C>${injuryCount}</>명이 부상 당했습니다.`,
{
category: LogCategory.ACTION,
format: LogFormat.PLAIN,
}
);
// City Update
effects.push(
@@ -325,7 +325,8 @@ export class ActionResolver<
)
);
context.addLog(`<G><b>${context.destCity.name}</b></>이 불타고 있습니다.`, {
const destCityName = context.destCity.name;
context.addLog(`<G><b>${destCityName}</b></>${JosaUtil.pick(destCityName, '이')} 불타고 있습니다.`, {
scope: LogScope.SYSTEM,
category: LogCategory.SUMMARY,
format: LogFormat.MONTH,
@@ -343,6 +344,13 @@ export class ActionResolver<
}
);
const itemCode = general.role.items.item;
if (typeof itemCode === 'string' && itemCode.length > 0) {
context.addLog(`<C>${itemCode}</>${JosaUtil.pick(itemCode, '을')} 사용!`, {
format: LogFormat.PLAIN,
});
}
for (const injured of result.injuredGenerals) {
// 타겟 장수는 Draft가 아니므로 Effect 반환
effects.push(createGeneralPatchEffect(injured.patch, injured.id));
@@ -116,7 +116,7 @@ export class ActionDefinition<
),
// Global Action Log
createLogEffect(
`<Y>${generalName}</>${josaYi} <G><b>${destCityName}</b></>${josaRo} <M>수도 이전</}하였습니다.`,
`<Y>${generalName}</>${josaYi} <G><b>${destCityName}</b></>${josaRo} <M>수도 이전</>하였습니다.`,
{
scope: LogScope.SYSTEM,
category: LogCategory.ACTION,
@@ -125,7 +125,7 @@ export class ActionDefinition<
),
// Global History Log
createLogEffect(
`<S><b>【${ACTION_NAME}】</b></><D><b>${nationName}</b></>${josaYiNation} <G><b>${destCityName}</b></>${josaRo} <M>수도 이전</}하였습니다.`,
`<S><b>【${ACTION_NAME}】</b></><D><b>${nationName}</b></>${josaYiNation} <G><b>${destCityName}</b></>${josaRo} <M>수도 이전</>하였습니다.`,
{
scope: LogScope.SYSTEM,
category: LogCategory.HISTORY,
@@ -134,7 +134,7 @@ export class ActionDefinition<
),
// Actor Nation History Log
createLogEffect(
`<Y>${generalName}</>${josaYi} <G><b>${destCityName}</b></>${josaRo} <M>${ACTION_NAME}</} `,
`<Y>${generalName}</>${josaYi} <G><b>${destCityName}</b></>${josaRo} <M>${ACTION_NAME}</>`,
{
scope: LogScope.NATION,
nationId: nation.id,
@@ -157,7 +157,7 @@ export class ActionDefinition<
),
// Dest Nation History Log
createLogEffect(
`<D><b>${nationName}</b></>로부터 금<C>${goldText}</> 쌀<C>${riceText}</>${josaUlRice} 지원 받음`,
`<D><b>${nationName}</b></>${JosaUtil.pick(nationName, '부터')} 금<C>${goldText}</> 쌀<C>${riceText}</>${josaUlRice} 지원 받음`,
{
scope: LogScope.NATION,
nationId: destNation.id,
@@ -171,6 +171,11 @@ export class ActionDefinition<
category: LogCategory.ACTION,
format: LogFormat.MONTH,
}),
createLogEffect(`<D><b>${destNation.name}</b></>${josaRo} 물자를 지원합니다.`, {
scope: LogScope.GENERAL,
category: LogCategory.ACTION,
format: LogFormat.PLAIN,
}),
];
general.experience += 5;
@@ -118,11 +118,8 @@ export class ActionDefinition<
const nationName = context.nation?.name ?? '아국';
const destNationName = context.destNation.name;
const generalName = context.general.name;
const josaGa = JosaUtil.pick(nationName, '');
const josaGaGeneral = JosaUtil.pick(generalName, '이');
const broadcastMessage = `<Y>${nationName}</>${josaGa} <Y>${destNationName}</>에게 <R>${ACTION_NAME}</>하였습니다!`;
const historyMessage = `<Y>${nationName}</>${josaGa} <Y>${destNationName}</>에게 <R>${ACTION_NAME}</>`;
const josaYiGeneral = JosaUtil.pick(generalName, '');
const josaYiNation = JosaUtil.pick(nationName, '이');
const effects: Array<GeneralActionEffect<TriggerState>> = [
createDiplomacyPatchEffect(nationId, args.destNationId, {
@@ -133,35 +130,47 @@ export class ActionDefinition<
state: DIPLOMACY_DECLARE,
term: DECLARE_TERM,
}),
// Global Action Log
createLogEffect(broadcastMessage, {
scope: LogScope.SYSTEM,
// General Action Log
createLogEffect(`<D><b>${destNationName}</b></>에 선전 포고 했습니다.`, {
scope: LogScope.GENERAL,
category: LogCategory.ACTION,
format: LogFormat.PLAIN,
format: LogFormat.MONTH,
}),
// Global History Log
createLogEffect(historyMessage, {
scope: LogScope.SYSTEM,
// General History Log
createLogEffect(`<D><b>${destNationName}</b></>에 선전 포고`, {
scope: LogScope.GENERAL,
category: LogCategory.HISTORY,
format: LogFormat.YEAR_MONTH,
}),
// Actor Nation History Log
createLogEffect(historyMessage, {
createLogEffect(`<Y>${generalName}</>${josaYiGeneral} <D><b>${destNationName}</b></>에 선전 포고`, {
scope: LogScope.NATION,
nationId: nationId,
category: LogCategory.HISTORY,
format: LogFormat.YEAR_MONTH,
}),
// Target Nation History Log
createLogEffect(historyMessage, {
createLogEffect(`<D><b>${nationName}</b></>의 <Y>${generalName}</>${josaYiGeneral} 아국에 선전 포고`, {
scope: LogScope.NATION,
nationId: args.destNationId,
category: LogCategory.HISTORY,
format: LogFormat.YEAR_MONTH,
}),
// Global Action Log
createLogEffect(`<Y>${generalName}</>${josaYiGeneral} <D><b>${destNationName}</b></>에 <M>선전 포고</> 하였습니다.`, {
scope: LogScope.SYSTEM,
category: LogCategory.ACTION,
format: LogFormat.PLAIN,
}),
// Global History Log
createLogEffect(`<R><b>【선포】</b></><D><b>${nationName}</b></>${josaYiNation} <D><b>${destNationName}</b></>에 선전 포고 하였습니다.`, {
scope: LogScope.SYSTEM,
category: LogCategory.HISTORY,
format: LogFormat.YEAR_MONTH,
}),
// National Message (국메)
createLogEffect(
`【국메】<Y>${generalName}</>${josaGaGeneral} <Y>${destNationName}</>에게 <R>${ACTION_NAME}</>하였습니다!`,
`【국메】<Y>${generalName}</>${josaYiGeneral} <Y>${destNationName}</>에게 <R>${ACTION_NAME}</>하였습니다!`,
{
scope: LogScope.NATION,
nationId: nationId,