fix(logic): 징병과 모병에 추가 통솔 상한을 반영한다

병력 여유 제약이 실제 통솔 계산기를 사용하도록 연결하고, 명마 보정이 적용되는 징병·모병 회귀 테스트를 추가한다.
This commit is contained in:
2026-08-22 15:47:56 +00:00
parent 89eadb4834
commit c17861dd4b
3 changed files with 202 additions and 3 deletions
@@ -597,7 +597,20 @@ export class ActionDefinition<
reqCityTrust(20),
reqGeneralGold(getCost, requirements),
reqGeneralRice(getRice, requirements),
reqGeneralCrewMargin((context) => resolveCrewTypeId(context.args), requirements),
reqGeneralCrewMargin(
(context) => resolveCrewTypeId(context.args),
requirements,
(context, view) => {
const calcContext = buildCalcContext<TriggerState>(context, view);
if (!calcContext) {
return null;
}
// Ref ReqGeneralCrewMargin reconstructs General and calls
// getLeadership(), so the precondition must use the same
// injured, trait, and item-adjusted capacity as getCost().
return this.command.resolveLeadership(calcContext) * 100;
}
),
];
if (ctx.mode === 'full') {
+6 -2
View File
@@ -432,7 +432,8 @@ export const allowJoinDestNation = (relYear: number): Constraint => ({
export const reqGeneralCrewMargin = (
getCrewTypeId: (ctx: ConstraintContext, view: StateView) => number | null,
requirements: RequirementKey[] = []
requirements: RequirementKey[] = [],
getMaxCrew?: (ctx: ConstraintContext, view: StateView) => number | null
): Constraint => ({
name: 'reqGeneralCrewMargin',
requires: (ctx) => [{ kind: 'general', id: ctx.actorId }, ...requirements],
@@ -453,7 +454,10 @@ export const reqGeneralCrewMargin = (
if (crewTypeId !== general.crewTypeId) {
return allow();
}
const maxCrew = general.stats.leadership * 100;
const maxCrew = getMaxCrew ? getMaxCrew(ctx, view) : general.stats.leadership * 100;
if (maxCrew === null) {
return unknownOrDeny(ctx, requirements, '장수 정보가 없습니다.');
}
if (maxCrew > general.crew) {
return allow();
}