feat: enhance action context with diplomacy and map handling, add constraints for crew and route validation

This commit is contained in:
2026-01-02 19:52:17 +00:00
parent ea2ef91b31
commit edcfad4e40
6 changed files with 452 additions and 8 deletions
+19
View File
@@ -117,6 +117,25 @@ export const reqGeneralRice = (
},
});
export const reqGeneralCrew = (): Constraint => ({
name: 'ReqGeneralCrew',
requires: (ctx) => [{ kind: 'general', id: ctx.actorId }],
test: (ctx, view) => {
const generalReq: RequirementKey = { kind: 'general', id: ctx.actorId };
if (!view.has(generalReq)) {
return unknownOrDeny(ctx, [generalReq], '장수 정보가 없습니다.');
}
const general = view.get(generalReq) as General | null;
if (!general) {
return unknownOrDeny(ctx, [generalReq], '장수 정보가 없습니다.');
}
if (general.crew > 0) {
return allow();
}
return { kind: 'deny', reason: '병사가 모자랍니다.' };
},
});
export const reqGeneralCrewMargin = (
getCrewTypeId: (ctx: ConstraintContext, view: StateView) => number | null,
requirements: RequirementKey[] = []