feat: add city, diplomacy, general, nation, and helper constraints

- Implemented various constraints for city management including occupied, supplied, and capacity checks.
- Added diplomacy constraints to manage relationships between nations.
- Introduced general constraints to validate general states and resources.
- Created helper functions for reading entities and resolving IDs.
- Enhanced the overall logic for managing game state and constraints.
This commit is contained in:
2026-01-02 06:06:33 +00:00
parent 6d421e81a0
commit 56495c65e3
7 changed files with 991 additions and 957 deletions
+22
View File
@@ -0,0 +1,22 @@
import { allow } from './helpers.js';
import type { Constraint } from './types.js';
export const alwaysFail = (reason: string): Constraint => ({
name: 'AlwaysFail',
requires: () => [],
test: () => ({ kind: 'deny', reason }),
});
export const notOpeningPart = (
relYear: number,
openingPartYear: number
): Constraint => ({
name: 'NotOpeningPart',
requires: () => [],
test: (_ctx) => {
if (relYear >= openingPartYear) {
return allow();
}
return { kind: 'deny', reason: '초반 제한 중에는 불가능합니다.' };
},
});