fix general founding and rebellion parity

This commit is contained in:
2026-07-26 17:50:56 +00:00
parent 80a2c9502f
commit 3fb75ccf03
16 changed files with 473 additions and 221 deletions
+1 -1
View File
@@ -268,7 +268,7 @@ export const noPenalty = (penaltyKey: string): Constraint => ({
return unknownOrDeny(ctx, [generalReq], '장수 정보가 없습니다.');
}
const penalty = general.meta.penalty;
const penalty = (general as General & { penalty?: unknown }).penalty ?? general.meta.penalty;
if (!penalty || typeof penalty !== 'object' || Array.isArray(penalty)) {
return allow();
}
+12 -11
View File
@@ -265,24 +265,16 @@ export const differentDestNation = (): Constraint => ({
export const reqNationGeneralCount = (min: number): Constraint => ({
name: 'reqNationGeneralCount',
requires: (ctx) => {
const reqs: RequirementKey[] = [{ kind: 'generalList' }];
const reqs: RequirementKey[] = [];
if (ctx.nationId !== undefined) {
reqs.push({ kind: 'nation', id: ctx.nationId });
} else {
reqs.push({ kind: 'general', id: ctx.actorId });
reqs.push({ kind: 'nationList' });
}
return reqs;
},
test: (ctx, view) => {
const listReq: RequirementKey = { kind: 'generalList' };
if (!view.has(listReq)) {
return unknownOrDeny(ctx, [listReq], '장수가 없습니다.');
}
const generals = view.get(listReq) as General[] | null;
if (!generals) {
return unknownOrDeny(ctx, [listReq], '장수가 없습니다.');
}
let baseNationId = ctx.nationId;
if (baseNationId === undefined) {
const general = readGeneral(ctx, view);
@@ -296,7 +288,16 @@ export const reqNationGeneralCount = (min: number): Constraint => ({
baseNationId = general.nationId;
}
const count = generals.filter((g) => g.nationId === baseNationId).length;
const nationReq: RequirementKey =
ctx.nationId !== undefined ? { kind: 'nation', id: baseNationId } : { kind: 'nationList' };
const nation =
ctx.nationId !== undefined
? (view.get(nationReq) as Nation | null)
: ((view.get(nationReq) as Nation[] | null)?.find((entry) => entry.id === baseNationId) ?? null);
if (!nation) {
return unknownOrDeny(ctx, [nationReq], '국가 정보가 없습니다.');
}
const count = typeof nation.meta.gennum === 'number' ? nation.meta.gennum : 0;
if (count >= min) {
return allow();
}