Merge branch 'main' into feature/survey-unique-parity

This commit is contained in:
2026-07-26 04:18:00 +00:00
20 changed files with 1973 additions and 608 deletions
@@ -46,6 +46,10 @@ const ARGS_SCHEMA = z.object({
});
export type AgitateArgs = z.infer<typeof ARGS_SCHEMA>;
// 레거시 city.trust는 MariaDB FLOAT이며 다음 명령에서 6자리 유효숫자로
// 재조회된다. 메모리 상태도 같은 persistence 경계로 정규화한다.
const toLegacyStoredTrust = (value: number): number => Number(value.toPrecision(6));
export class ActionResolver<
TriggerState extends GeneralTriggerState = GeneralTriggerState,
> implements GeneralActionResolver<TriggerState, AgitateArgs> {
@@ -95,7 +99,7 @@ export class ActionResolver<
general.meta.firenum = (typeof general.meta.firenum === 'number' ? general.meta.firenum : 0) + 1;
const newSecu = Math.max(0, destCity.security - result.agriDamage);
const currentTrust = typeof destCity.meta.trust === 'number' ? destCity.meta.trust : 50;
const newTrust = Math.max(0, currentTrust - result.commDamage);
const newTrust = toLegacyStoredTrust(Math.max(0, currentTrust - result.commDamage));
// Log
const commandName = ACTION_NAME;
@@ -118,7 +122,6 @@ export class ActionResolver<
effects.push(
createCityPatchEffect(
{
...destCity,
security: newSecu,
state: 32,
meta: {
@@ -133,6 +136,10 @@ export class ActionResolver<
consumeSuccessfulStrategyItem(this.pipeline, context);
for (const injured of result.injuredGenerals) {
effects.push(createGeneralPatchEffect(injured.patch, injured.id));
ctx.addLog('<M>계략</>으로 인해 <R>부상</>을 당했습니다.', {
generalId: injured.id,
format: LogFormat.MONTH,
});
}
return { effects };
@@ -140,14 +140,12 @@ export class ActionResolver<
)
);
} else {
const commDmg = stolenGold / 12;
const agriDmg = stolenRice / 12;
// 레거시는 미보급 도시 자원을 먼저 감소시키지만 같은 명령 끝의
// 원본 destCity 전체 저장이 이를 덮어쓴다. 관찰 가능한 최종
// 상태는 자원 변화 없이 state 32만 남는다.
effects.push(
createCityPatchEffect(
{
commerce: Math.round(Math.max(0, destCity.commerce - commDmg)),
agriculture: Math.round(Math.max(0, destCity.agriculture - agriDmg)),
state: 32,
},
args.destCityId
@@ -106,7 +106,6 @@ export class ActionResolver<
effects.push(
createCityPatchEffect(
{
...destCity,
defence: newDef,
wall: newWall,
state: 32, // Legacy sabotage state
@@ -118,6 +117,10 @@ export class ActionResolver<
consumeSuccessfulStrategyItem(this.pipeline, context);
for (const injured of result.injuredGenerals) {
effects.push(createGeneralPatchEffect(injured.patch, injured.id));
ctx.addLog('<M>계략</>으로 인해 <R>부상</>을 당했습니다.', {
generalId: injured.id,
format: LogFormat.MONTH,
});
}
return { effects };
@@ -1,12 +1,5 @@
import type { RandomGenerator } from '@sammo-ts/common';
import type {
City,
General,
GeneralMeta,
GeneralTriggerState,
Nation,
TriggerValue,
} from '@sammo-ts/logic/domain/entities.js';
import type { City, General, GeneralMeta, GeneralTriggerState, Nation } from '@sammo-ts/logic/domain/entities.js';
import type { Constraint, ConstraintContext } from '@sammo-ts/logic/constraints/types.js';
import {
disallowDiplomacyBetweenStatus,
@@ -219,9 +212,9 @@ export class CommandResolver<TriggerState extends GeneralTriggerState = GeneralT
id: defender.id,
patch: {
injury: clamp(defender.injury + injuryAmount, 0, INJURY_MAX),
crew: Math.floor(defender.crew * 0.98),
atmos: Math.floor(defender.atmos * 0.98),
train: Math.floor(defender.train * 0.98),
crew: Math.round(defender.crew * 0.98),
atmos: Math.round(defender.atmos * 0.98),
train: Math.round(defender.train * 0.98),
},
});
}
@@ -350,18 +343,13 @@ export class ActionResolver<
return { effects: [] };
}
const updatedCityMeta: Record<string, TriggerValue> = {
...context.destCity.meta,
state: CITY_STATE_BURNING,
};
// 타겟 도시는 Draft가 아니므로 Effect 반환
effects.push(
createCityPatchEffect(
{
agriculture: context.destCity.agriculture - result.agriDamage,
commerce: context.destCity.commerce - result.commDamage,
meta: updatedCityMeta,
state: CITY_STATE_BURNING,
},
context.destCity.id
)
@@ -398,7 +386,7 @@ export class ActionResolver<
for (const injured of result.injuredGenerals) {
// 타겟 장수는 Draft가 아니므로 Effect 반환
effects.push(createGeneralPatchEffect(injured.patch, injured.id));
context.addLog(`<M>${ACTION_KEY}</>로 인해 <R>부상</>을 당했습니다.`, {
context.addLog('<M>계략</>로 인해 <R>부상</>을 당했습니다.', {
generalId: injured.id,
format: LogFormat.MONTH,
});