diff options
author | Frans Bongers <fransbongers@franss-mbp.home> | 2024-11-30 22:18:21 +0100 |
---|---|---|
committer | Frans Bongers <fransbongers@franss-mbp.home> | 2024-11-30 22:18:21 +0100 |
commit | f05a9531508822f5dfb51105334444b53fe11b3e (patch) | |
tree | cf3b688ef5d05992a78a7e70942188f1a8712a13 /types.d.ts | |
parent | 629206f773d5fd4c9247db03e3a705c4dcdc77c4 (diff) | |
download | land-and-freedom-f05a9531508822f5dfb51105334444b53fe11b3e.tar.gz |
ui setup bonuses and medaillons
Diffstat (limited to 'types.d.ts')
-rw-r--r-- | types.d.ts | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/types.d.ts b/types.d.ts new file mode 100644 index 0000000..4ba17f7 --- /dev/null +++ b/types.d.ts @@ -0,0 +1,95 @@ +declare const brand: unique symbol; + +// branded typing +export type Brand<T, TBrand extends string> = T & { + [brand]: TBrand; +}; + +export type Player = Brand<string, 'Player'>; +export type CardId = Brand<number, 'CardId'>; +export type FactionId = Brand<string, 'FactionId'>; + +export interface Game { + [index: number]: any; + seed: number; + log: string[]; + undo: Game[]; + turn: number; + year: number; + active: Player | null; + state: string | null; + bag_of_glory: Record<FactionId, number>; + blank_markers: number[][]; + bonuses: number[]; + cards_in_play: Record<FactionId, CardId>; + current_events: CardId[]; + engine: EngineNode[]; + fronts: { + a: number; + m: number; + n: number; + s: number; + }; + hands: Record<FactionId, CardId[]>; + hero_points: Record<FactionId | 'pool', number>; + initiative: FactionId; + medaillons: Array<number | null>; + tableaus: Record<FactionId, CardId[]>; + tracks: number[]; + + result?: string; + victory?: string; + + location?: string; + selected?: string; + + state_data: any; + // played_card: CardId + + // turn: Turn +} + +export interface View { + engine: Game['engine']; + log: number | string[]; + active?: string | null; + prompt: string | null; + actions?: any; + victory?: string; + location?: string; + selected?: string; + + selected_card: CardId | null; + bonuses: Game['bonuses']; + current_events: CardId[]; + fronts: Game['fronts']; + hand: CardId[]; + medaillons: Game['medaillons']; + tracks: number[]; +} + +export type States = { + [key: string]: any; +}; + +export type EngineNode = FunctionNode | LeafNode | SeqNode; + +export interface FunctionNode { + t: 'f'; + f: string; // function to be triggered + a?: any; // args + r?: 0 | 1; // 1 if resolved +} + +export interface SeqNode { + t: 's'; // Type + c: EngineNode[]; +} + +export interface LeafNode { + t: 'l'; + s: string; // State + p: FactionId; // Player + a?: any; // args + r?: 0 | 1; // 1 if resolved +}
\ No newline at end of file |