summaryrefslogtreecommitdiff
path: root/types.d.ts
blob: a79c9517749da59c9a3ac89a55579401ebbc84f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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[];
  discard: Record<FactionId | 'f', number[]>;
  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
}