@pretty-chitty/core 1.2.18 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ClientTrustMatchViewer.d.ts +14 -1
- package/dist/components/ClientTrustMatchViewer.d.ts.map +1 -1
- package/dist/components/ClientTrustMatchViewer.js +25 -2
- package/dist/components/ClientTrustMatchViewer.js.map +1 -1
- package/dist/components/DemoWrapper.d.ts.map +1 -1
- package/dist/components/DemoWrapper.js +4 -11
- package/dist/components/DemoWrapper.js.map +1 -1
- package/dist/components/Gallery/BuiltItem.d.ts.map +1 -1
- package/dist/components/Gallery/BuiltItem.js +3 -0
- package/dist/components/Gallery/BuiltItem.js.map +1 -1
- package/dist/components/Gallery/GalleryController.d.ts.map +1 -1
- package/dist/components/Gallery/GalleryController.js +3 -1
- package/dist/components/Gallery/GalleryController.js.map +1 -1
- package/dist/components/Playground.d.ts.map +1 -1
- package/dist/components/Playground.js +37 -11
- package/dist/components/Playground.js.map +1 -1
- package/dist/components/TokenizedMessage.d.ts +2 -6
- package/dist/components/TokenizedMessage.d.ts.map +1 -1
- package/dist/components/TokenizedMessage.js +1 -35
- package/dist/components/TokenizedMessage.js.map +1 -1
- package/dist/components/TopBarPlayers.d.ts.map +1 -1
- package/dist/components/TopBarPlayers.js +1 -1
- package/dist/components/TopBarPlayers.js.map +1 -1
- package/dist/game/Chit.js +2 -2
- package/dist/game/Chit.js.map +1 -1
- package/dist/game/ConnectionTransport.d.ts +3 -0
- package/dist/game/ConnectionTransport.d.ts.map +1 -1
- package/dist/game/ConnectionTransport.js +13 -4
- package/dist/game/ConnectionTransport.js.map +1 -1
- package/dist/game/Game.d.ts +8 -1
- package/dist/game/Game.d.ts.map +1 -1
- package/dist/game/Match.d.ts +66 -0
- package/dist/game/Match.d.ts.map +1 -1
- package/dist/game/Match.js +151 -3
- package/dist/game/Match.js.map +1 -1
- package/dist/game/MatchStorage.d.ts +8 -1
- package/dist/game/MatchStorage.d.ts.map +1 -1
- package/dist/game/MatchStorage.js +11 -3
- package/dist/game/MatchStorage.js.map +1 -1
- package/dist/game/Pick.d.ts +14 -0
- package/dist/game/Pick.d.ts.map +1 -1
- package/dist/game/Pick.js +15 -0
- package/dist/game/Pick.js.map +1 -1
- package/dist/game/PlayerChit.d.ts +3 -0
- package/dist/game/PlayerChit.d.ts.map +1 -1
- package/dist/game/PlayerChit.js +3 -0
- package/dist/game/PlayerChit.js.map +1 -1
- package/dist/game/PlayerInfo.d.ts +8 -0
- package/dist/game/PlayerInfo.d.ts.map +1 -1
- package/dist/game/PlayerInfo.js +6 -3
- package/dist/game/PlayerInfo.js.map +1 -1
- package/dist/game/PlayerPromptStatusChit.d.ts.map +1 -1
- package/dist/game/PlayerPromptStatusChit.js +3 -1
- package/dist/game/PlayerPromptStatusChit.js.map +1 -1
- package/dist/game/Turn.d.ts +5 -0
- package/dist/game/Turn.d.ts.map +1 -1
- package/dist/game/Turn.js +18 -7
- package/dist/game/Turn.js.map +1 -1
- package/dist/game/TurnState.d.ts +8 -0
- package/dist/game/TurnState.d.ts.map +1 -1
- package/dist/game/TurnState.js +7 -0
- package/dist/game/TurnState.js.map +1 -1
- package/dist/game/ai/AiClientPrompts.d.ts +160 -0
- package/dist/game/ai/AiClientPrompts.d.ts.map +1 -0
- package/dist/game/ai/AiClientPrompts.js +525 -0
- package/dist/game/ai/AiClientPrompts.js.map +1 -0
- package/dist/game/ai/AiLiveView.d.ts +2 -0
- package/dist/game/ai/AiLiveView.d.ts.map +1 -0
- package/dist/game/ai/AiLiveView.js +48 -0
- package/dist/game/ai/AiLiveView.js.map +1 -0
- package/dist/game/ai/AiPlayerView.d.ts +2 -0
- package/dist/game/ai/AiPlayerView.d.ts.map +1 -0
- package/dist/game/ai/AiPlayerView.js +89 -0
- package/dist/game/ai/AiPlayerView.js.map +1 -0
- package/dist/game/ai/connectAiPlayer.d.ts +43 -0
- package/dist/game/ai/connectAiPlayer.d.ts.map +1 -0
- package/dist/game/ai/connectAiPlayer.js +58 -0
- package/dist/game/ai/connectAiPlayer.js.map +1 -0
- package/dist/game/ai/defineAi.d.ts +119 -0
- package/dist/game/ai/defineAi.d.ts.map +1 -0
- package/dist/game/ai/defineAi.js +122 -0
- package/dist/game/ai/defineAi.js.map +1 -0
- package/dist/game/ai/simulateMatches.d.ts +62 -0
- package/dist/game/ai/simulateMatches.d.ts.map +1 -0
- package/dist/game/ai/simulateMatches.js +108 -0
- package/dist/game/ai/simulateMatches.js.map +1 -0
- package/dist/game/badAiTransport/BadAIClientPrompts.d.ts +3 -0
- package/dist/game/badAiTransport/BadAIClientPrompts.d.ts.map +1 -1
- package/dist/game/badAiTransport/BadAIClientPrompts.js +3 -0
- package/dist/game/badAiTransport/BadAIClientPrompts.js.map +1 -1
- package/dist/hooks/useTokenMap.d.ts +2 -4
- package/dist/hooks/useTokenMap.d.ts.map +1 -1
- package/dist/hooks/useTokenMap.js +2 -5
- package/dist/hooks/useTokenMap.js.map +1 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/utilities/CanvasStack/CanvasStack.d.ts +11 -0
- package/dist/utilities/CanvasStack/CanvasStack.d.ts.map +1 -1
- package/dist/utilities/CanvasStack/CanvasStack.js +62 -15
- package/dist/utilities/CanvasStack/CanvasStack.js.map +1 -1
- package/dist/utilities/TokenizedText.d.ts +49 -0
- package/dist/utilities/TokenizedText.d.ts.map +1 -0
- package/dist/utilities/TokenizedText.js +47 -0
- package/dist/utilities/TokenizedText.js.map +1 -0
- package/package.json +1 -1
- package/src/library/components/ClientTrustMatchViewer.tsx +32 -2
- package/src/library/components/DemoWrapper.tsx +4 -12
- package/src/library/components/Gallery/BuiltItem.ts +4 -0
- package/src/library/components/Gallery/GalleryController.ts +3 -1
- package/src/library/components/Playground.tsx +77 -12
- package/src/library/components/TokenizedMessage.tsx +2 -63
- package/src/library/components/TopBarPlayers.tsx +6 -1
- package/src/library/game/Chit.ts +2 -2
- package/src/library/game/ConnectionTransport.ts +12 -3
- package/src/library/game/Game.ts +9 -1
- package/src/library/game/Match.ts +162 -3
- package/src/library/game/MatchStorage.ts +14 -4
- package/src/library/game/Pick.ts +20 -0
- package/src/library/game/PlayerChit.ts +4 -1
- package/src/library/game/PlayerInfo.ts +13 -3
- package/src/library/game/PlayerPromptStatusChit.ts +3 -1
- package/src/library/game/Turn.ts +19 -7
- package/src/library/game/TurnState.ts +8 -0
- package/src/library/game/ai/AI_GUIDE.md +434 -0
- package/src/library/game/ai/AiClientPrompts.ts +681 -0
- package/src/library/game/ai/AiLiveView.ts +63 -0
- package/src/library/game/ai/AiPlayerView.ts +112 -0
- package/src/library/game/ai/ai.test.ts +475 -0
- package/src/library/game/ai/connectAiPlayer.ts +88 -0
- package/src/library/game/ai/defineAi.ts +230 -0
- package/src/library/game/ai/simulateMatches.ts +172 -0
- package/src/library/game/badAiTransport/BadAIClientPrompts.ts +3 -0
- package/src/library/hooks/useTokenMap.ts +2 -6
- package/src/library/index.ts +34 -2
- package/src/library/utilities/CanvasStack/CanvasStack.ts +68 -28
- package/src/library/utilities/TokenizedText.test.ts +32 -0
- package/src/library/utilities/TokenizedText.ts +97 -0
|
@@ -51,15 +51,25 @@ export class LocalMatchStorage implements IMatchStorage {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export class EphemeralMatchStorage implements IMatchStorage {
|
|
54
|
-
|
|
54
|
+
/**
|
|
55
|
+
* @param lazy Headless runs only (simulations, testbeds): keep a reference to the saved state and
|
|
56
|
+
* turn it into JSON only when read. Saves get much cheaper (stringifying the whole match on every
|
|
57
|
+
* change cost ~10% of a headless game), but a read returns the match as it is *now*, not as of the
|
|
58
|
+
* last save. Off by default: every save is a snapshot.
|
|
59
|
+
*/
|
|
60
|
+
constructor(
|
|
61
|
+
private matchId: string,
|
|
62
|
+
private lazy = false,
|
|
63
|
+
) {}
|
|
55
64
|
private onChangeCallbacks: ((state: any) => void)[] = [];
|
|
56
65
|
|
|
57
|
-
private state:
|
|
66
|
+
private state: any = "{}";
|
|
58
67
|
|
|
59
68
|
async readState(): Promise<any> {
|
|
60
69
|
const result = this.state;
|
|
61
70
|
if (result) {
|
|
62
|
-
|
|
71
|
+
// A string is a snapshot (or the initial empty state); an object is a lazy reference.
|
|
72
|
+
return JSON.parse(typeof result === "string" ? result : JSON.stringify(result));
|
|
63
73
|
}
|
|
64
74
|
return null;
|
|
65
75
|
}
|
|
@@ -70,7 +80,7 @@ export class EphemeralMatchStorage implements IMatchStorage {
|
|
|
70
80
|
winners?: PlayerChit[],
|
|
71
81
|
notify = false,
|
|
72
82
|
): Promise<void> {
|
|
73
|
-
this.state = JSON.stringify(newState);
|
|
83
|
+
this.state = this.lazy ? newState : JSON.stringify(newState);
|
|
74
84
|
if (notify) {
|
|
75
85
|
this.notify(newState);
|
|
76
86
|
}
|
package/src/library/game/Pick.ts
CHANGED
|
@@ -8,12 +8,15 @@ import { MismatchError, Turn } from "./Turn";
|
|
|
8
8
|
|
|
9
9
|
export type FindChit = (id: string) => Chit;
|
|
10
10
|
export type PickType = "ChitPick" | "ButtonPick" | "DragPick";
|
|
11
|
+
/** Links a pick to a rule in the game's AI (see {@link Pick.ai}). `d` must be JSON and public. */
|
|
12
|
+
export type PickAiTag = { k: string; d?: unknown };
|
|
11
13
|
export type PickSerialization = {
|
|
12
14
|
type: PickType;
|
|
13
15
|
message?: string;
|
|
14
16
|
help?: string;
|
|
15
17
|
details: any;
|
|
16
18
|
context?: string;
|
|
19
|
+
ai?: PickAiTag;
|
|
17
20
|
};
|
|
18
21
|
|
|
19
22
|
export abstract class Pick {
|
|
@@ -30,6 +33,9 @@ export abstract class Pick {
|
|
|
30
33
|
/** @internal */
|
|
31
34
|
public contextChit?: Chit;
|
|
32
35
|
|
|
36
|
+
/** @internal */
|
|
37
|
+
public aiTag?: PickAiTag;
|
|
38
|
+
|
|
33
39
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
34
40
|
/** @internal */
|
|
35
41
|
confirmLock(_turn: Turn<any, any, any>) {
|
|
@@ -75,6 +81,18 @@ export abstract class Pick {
|
|
|
75
81
|
return this;
|
|
76
82
|
}
|
|
77
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Tags this pick so AI players score its options with the rule named `key` in the game's
|
|
86
|
+
* `ai` (see `defineAi`). Untagged picks fall back to the AI's `default` rule, or random.
|
|
87
|
+
* @param key Rule name, e.g. "market.buy"
|
|
88
|
+
* @param data Optional JSON hint passed to the rule. It is sent to every client, so it must
|
|
89
|
+
* only contain information the prompted player is allowed to see.
|
|
90
|
+
*/
|
|
91
|
+
ai(key: string, data?: unknown): this {
|
|
92
|
+
this.aiTag = data === undefined ? { k: key } : { k: key, d: data };
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
|
|
78
96
|
/** @internal */
|
|
79
97
|
serialize(): PickSerialization {
|
|
80
98
|
return {
|
|
@@ -83,6 +101,7 @@ export abstract class Pick {
|
|
|
83
101
|
message: this.messageContents,
|
|
84
102
|
details: this.serializeDetails(),
|
|
85
103
|
context: this.contextChit ? this.contextChit.id : undefined,
|
|
104
|
+
ai: this.aiTag,
|
|
86
105
|
};
|
|
87
106
|
}
|
|
88
107
|
|
|
@@ -108,6 +127,7 @@ export abstract class Pick {
|
|
|
108
127
|
p.contextChit = pick.context ? findChit(pick.context) : undefined;
|
|
109
128
|
p.messageContents = pick.message;
|
|
110
129
|
p.helpContents = pick.help;
|
|
130
|
+
p.aiTag = pick.ai;
|
|
111
131
|
p.deserializeDetails(pick.details, findChit, buttonLibrary);
|
|
112
132
|
return p;
|
|
113
133
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChildOutlet, NonEditable } from "../utilities/Annotations";
|
|
2
2
|
import { PlayerCanvas } from "../utilities/CanvasStack/PlayerCanvas";
|
|
3
3
|
import { Chit } from "./Chit";
|
|
4
|
-
import { PlayerInfo } from "./PlayerInfo";
|
|
4
|
+
import { AiSeatInfo, PlayerInfo } from "./PlayerInfo";
|
|
5
5
|
import { PlayerPromptStatusChit } from "./PlayerPromptStatusChit";
|
|
6
6
|
|
|
7
7
|
export class PlayerChit extends Chit {
|
|
@@ -11,6 +11,8 @@ export class PlayerChit extends Chit {
|
|
|
11
11
|
public playerId: string = "no id";
|
|
12
12
|
public name: string = "no name";
|
|
13
13
|
public color: string = "#000000";
|
|
14
|
+
/** Set when this seat is played by the engine's AI (copied from `PlayerInfo.ai`; public, so UIs can mark the seat) */
|
|
15
|
+
public ai?: AiSeatInfo = undefined;
|
|
14
16
|
|
|
15
17
|
/** @internal */
|
|
16
18
|
private myImageUrl?: string = undefined;
|
|
@@ -55,5 +57,6 @@ export class PlayerChit extends Chit {
|
|
|
55
57
|
this.name = playerInfo.name;
|
|
56
58
|
this.id = playerInfo.id;
|
|
57
59
|
this.imageUrl = playerInfo.imageUrl;
|
|
60
|
+
this.ai = playerInfo.ai;
|
|
58
61
|
}
|
|
59
62
|
}
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
import multiavatar from "@multiavatar/multiavatar";
|
|
2
2
|
import base64 from "base-64";
|
|
3
3
|
|
|
4
|
+
/** Marks a seat as played by the engine's AI (see `connectAiPlayer`). */
|
|
5
|
+
export type AiSeatInfo = {
|
|
6
|
+
/** 0–1; lower plays less predictably. Default 0.85 */
|
|
7
|
+
difficulty?: number;
|
|
8
|
+
};
|
|
9
|
+
|
|
4
10
|
export interface IPlayerInfo {
|
|
5
11
|
id: string;
|
|
6
12
|
name: string;
|
|
7
13
|
imageUrl?: string;
|
|
14
|
+
ai?: AiSeatInfo;
|
|
8
15
|
}
|
|
9
16
|
|
|
10
17
|
export class PlayerInfo {
|
|
11
18
|
public id: string;
|
|
12
19
|
public name: string;
|
|
20
|
+
/** Set when this seat is an AI player */
|
|
21
|
+
public ai?: AiSeatInfo;
|
|
13
22
|
|
|
14
23
|
/** @internal */
|
|
15
24
|
public generateAvatar() {
|
|
16
|
-
if (!this.myImageUrl && window
|
|
25
|
+
if (!this.myImageUrl && typeof window !== "undefined" && window.URL) {
|
|
17
26
|
const data = multiavatar(`${this.name} ${this.id}`, true).replace("<svg", '<svg width="231" height="231"');
|
|
18
27
|
return `data:image/svg+xml;base64,${base64.encode(data)}`;
|
|
19
28
|
}
|
|
@@ -23,7 +32,7 @@ export class PlayerInfo {
|
|
|
23
32
|
/** @internal */
|
|
24
33
|
private myImageUrl?: string;
|
|
25
34
|
get imageUrl() {
|
|
26
|
-
if (!this.myImageUrl && window
|
|
35
|
+
if (!this.myImageUrl && typeof window !== "undefined" && window.URL) {
|
|
27
36
|
return this.generateAvatar();
|
|
28
37
|
}
|
|
29
38
|
return this.myImageUrl;
|
|
@@ -40,9 +49,10 @@ export class PlayerInfo {
|
|
|
40
49
|
this.id = idOrPlayerInfo.id;
|
|
41
50
|
this.name = idOrPlayerInfo.name;
|
|
42
51
|
this.imageUrl = idOrPlayerInfo.imageUrl;
|
|
52
|
+
this.ai = idOrPlayerInfo.ai;
|
|
43
53
|
}
|
|
44
54
|
|
|
45
|
-
if (!this.imageUrl && window
|
|
55
|
+
if (!this.imageUrl && typeof window !== "undefined" && window.URL) {
|
|
46
56
|
this.imageUrl = this.generateAvatar();
|
|
47
57
|
}
|
|
48
58
|
}
|
|
@@ -5,8 +5,10 @@ import { Prompt } from "./Prompt";
|
|
|
5
5
|
import StaticChitTypeRegistry from "./StaticChitTypeRegistry";
|
|
6
6
|
|
|
7
7
|
export class PlayerPromptStatusChit extends Chit {
|
|
8
|
-
/** @internal */
|
|
8
|
+
/** The prompt the player is currently being asked to answer, with `:token:` markup intact. @internal */
|
|
9
9
|
public latestPromptMessage?: string;
|
|
10
|
+
/** Plain-text form of {@link latestPromptMessage} for storage, match lists and notifications. @internal */
|
|
11
|
+
public latestPromptMessageText?: string;
|
|
10
12
|
/** @internal */
|
|
11
13
|
@NonEditable public latestPrompt = new EventChannel<Prompt | undefined>(undefined, 50);
|
|
12
14
|
/** @internal */
|
package/src/library/game/Turn.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Chit } from "./Chit";
|
|
2
|
+
import { buildTokenMap, tokenizedMessageToText } from "../utilities/TokenizedText";
|
|
2
3
|
import { Match } from "./Match";
|
|
3
4
|
import { NoValidMovesPrompt, PickPrompt, Prompt } from "./Prompt";
|
|
4
5
|
import { PromptResponse, RngResponse, TurnState } from "./TurnState";
|
|
@@ -243,6 +244,20 @@ export class Turn<T, P extends PlayerChit, R extends RootChit<P>> {
|
|
|
243
244
|
};
|
|
244
245
|
}
|
|
245
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Records what a player is being asked for: the tokenized message for the in-game UI, and a plain-text version
|
|
249
|
+
* (player tokens become names, etc.) for anything that can only show text.
|
|
250
|
+
*/
|
|
251
|
+
private setPromptMessage(player: P, message: string | undefined) {
|
|
252
|
+
player.promptStatus.latestPromptMessage = message;
|
|
253
|
+
if (message === undefined) {
|
|
254
|
+
player.promptStatus.latestPromptMessageText = undefined;
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const tokenMap = buildTokenMap(this.match.game.tokenMap, this.rootChit.players.map((p) => p));
|
|
258
|
+
player.promptStatus.latestPromptMessageText = tokenizedMessageToText(message, tokenMap);
|
|
259
|
+
}
|
|
260
|
+
|
|
246
261
|
/**
|
|
247
262
|
* Add a game log message to the last flush step
|
|
248
263
|
* @param message
|
|
@@ -538,7 +553,7 @@ export class Turn<T, P extends PlayerChit, R extends RootChit<P>> {
|
|
|
538
553
|
action: (p: P, turn: Turn<A, P, R>) => Promise<A>,
|
|
539
554
|
): Promise<A[]> {
|
|
540
555
|
// the whole point of this function is so we can mark all players as having a prompt waiting for them
|
|
541
|
-
players.forEach((player) => (player
|
|
556
|
+
players.forEach((player) => this.setPromptMessage(player, "Waiting for turn to complete"));
|
|
542
557
|
|
|
543
558
|
const turns = players.map((player) =>
|
|
544
559
|
this.createTurn(chits(player), player, (turn: Turn<A, P, R>) => action(player, turn)),
|
|
@@ -971,10 +986,7 @@ export class Turn<T, P extends PlayerChit, R extends RootChit<P>> {
|
|
|
971
986
|
prompt.id = `${this.id} prompt ${this.decisionIndex}`;
|
|
972
987
|
prompt.clock = this.clock;
|
|
973
988
|
prompt.canReset = this.state.hasUserMadeChoiceSinceUserContextChangedOrRng(this.decisionIndex - 1);
|
|
974
|
-
this.player.
|
|
975
|
-
if (!this.player.promptStatus.latestPromptMessage.length) {
|
|
976
|
-
this.player.promptStatus.latestPromptMessage = "No prompt set";
|
|
977
|
-
}
|
|
989
|
+
this.setPromptMessage(this.player, prompt.message.length ? prompt.message : "No prompt set");
|
|
978
990
|
|
|
979
991
|
this.flush();
|
|
980
992
|
|
|
@@ -1039,7 +1051,7 @@ export class Turn<T, P extends PlayerChit, R extends RootChit<P>> {
|
|
|
1039
1051
|
this.state.setOrCreatePromptResponse(this.decisionIndex, resolution);
|
|
1040
1052
|
|
|
1041
1053
|
this.player.promptStatus.latestPromptResponseTime = this.absoluteClock(this.player.id);
|
|
1042
|
-
this.player
|
|
1054
|
+
this.setPromptMessage(this.player, undefined);
|
|
1043
1055
|
this.decisionIndex++;
|
|
1044
1056
|
}
|
|
1045
1057
|
|
|
@@ -1145,7 +1157,7 @@ export class Turn<T, P extends PlayerChit, R extends RootChit<P>> {
|
|
|
1145
1157
|
|
|
1146
1158
|
private cleanUp() {
|
|
1147
1159
|
if (this.player) {
|
|
1148
|
-
this.player
|
|
1160
|
+
this.setPromptMessage(this.player, undefined);
|
|
1149
1161
|
}
|
|
1150
1162
|
this.completed = true;
|
|
1151
1163
|
this.flush();
|
|
@@ -20,6 +20,13 @@ export class TurnState {
|
|
|
20
20
|
|
|
21
21
|
decisions: Decision[] = [];
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* AI players' plan memory, keyed by player id. Only the root turn state carries it. It rides
|
|
25
|
+
* along with the decisions so a bot that is re-seated after a reload (or in another process)
|
|
26
|
+
* picks up where it left off. Absent when no bot has committed a plan.
|
|
27
|
+
*/
|
|
28
|
+
ai?: { [playerId: string]: unknown };
|
|
29
|
+
|
|
23
30
|
private parentTurnState: TurnState | undefined;
|
|
24
31
|
private parentTurnIndex = 0;
|
|
25
32
|
|
|
@@ -120,6 +127,7 @@ export class TurnState {
|
|
|
120
127
|
this.playerId = serialized.playerId;
|
|
121
128
|
this.id = serialized.id;
|
|
122
129
|
this.createdDate = serialized.createdDate ?? Date.now();
|
|
130
|
+
this.ai = serialized.ai;
|
|
123
131
|
this.decisions = (serialized.decisions ?? []).map((d: Decision, i: number) => {
|
|
124
132
|
if (d.type === "turn") {
|
|
125
133
|
const existing = this.decisions[i];
|