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:
@@ -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: '초반 제한 중에는 불가능합니다.' };
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user