@pretty-chitty/core 2.0.0 → 2.1.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/README.md +8 -0
- package/dist/components/ActionLogDisplay.d.ts.map +1 -1
- package/dist/components/ActionLogDisplay.js +1 -1
- package/dist/components/ActionLogDisplay.js.map +1 -1
- package/dist/components/BottomBarButton.d.ts +3 -1
- package/dist/components/BottomBarButton.d.ts.map +1 -1
- package/dist/components/BottomBarButton.js +3 -2
- package/dist/components/BottomBarButton.js.map +1 -1
- package/dist/components/ContextGalleryDisplay.d.ts.map +1 -1
- package/dist/components/ContextGalleryDisplay.js +1 -1
- package/dist/components/ContextGalleryDisplay.js.map +1 -1
- package/dist/components/DemoWrapper.d.ts +30 -2
- package/dist/components/DemoWrapper.d.ts.map +1 -1
- package/dist/components/DemoWrapper.js +79 -36
- package/dist/components/DemoWrapper.js.map +1 -1
- package/dist/components/FullScreenGalleryDisplay.d.ts.map +1 -1
- package/dist/components/FullScreenGalleryDisplay.js +2 -2
- package/dist/components/FullScreenGalleryDisplay.js.map +1 -1
- package/dist/components/Gallery/BuiltItem.d.ts +6 -2
- package/dist/components/Gallery/BuiltItem.d.ts.map +1 -1
- package/dist/components/Gallery/BuiltItem.js +28 -9
- package/dist/components/Gallery/BuiltItem.js.map +1 -1
- package/dist/components/Gallery/GalleryController.d.ts +18 -0
- package/dist/components/Gallery/GalleryController.d.ts.map +1 -1
- package/dist/components/Gallery/GalleryController.js +67 -0
- package/dist/components/Gallery/GalleryController.js.map +1 -1
- package/dist/components/Gallery/GalleryViewer.d.ts +6 -1
- package/dist/components/Gallery/GalleryViewer.d.ts.map +1 -1
- package/dist/components/Gallery/GalleryViewer.js +48 -10
- package/dist/components/Gallery/GalleryViewer.js.map +1 -1
- package/dist/components/Gallery/LayoutManager.d.ts +6 -0
- package/dist/components/Gallery/LayoutManager.d.ts.map +1 -1
- package/dist/components/Gallery/LayoutManager.js +23 -3
- package/dist/components/Gallery/LayoutManager.js.map +1 -1
- package/dist/components/Gallery/constants.d.ts +2 -0
- package/dist/components/Gallery/constants.d.ts.map +1 -1
- package/dist/components/Gallery/constants.js +2 -0
- package/dist/components/Gallery/constants.js.map +1 -1
- package/dist/components/Gallery/registry.d.ts +34 -0
- package/dist/components/Gallery/registry.d.ts.map +1 -0
- package/dist/components/Gallery/registry.js +17 -0
- package/dist/components/Gallery/registry.js.map +1 -0
- package/dist/components/GameDesigner.d.ts.map +1 -1
- package/dist/components/GameDesigner.js +42 -10
- package/dist/components/GameDesigner.js.map +1 -1
- package/dist/components/InlineGalleryDisplay.d.ts.map +1 -1
- package/dist/components/InlineGalleryDisplay.js +2 -2
- package/dist/components/InlineGalleryDisplay.js.map +1 -1
- package/dist/components/LiveButton.d.ts.map +1 -1
- package/dist/components/LiveButton.js +5 -2
- package/dist/components/LiveButton.js.map +1 -1
- package/dist/components/MatchViewer.d.ts +6 -1
- package/dist/components/MatchViewer.d.ts.map +1 -1
- package/dist/components/MatchViewer.js +9 -3
- package/dist/components/MatchViewer.js.map +1 -1
- package/dist/components/Panel/MultiPanel.d.ts.map +1 -1
- package/dist/components/Panel/MultiPanel.js +18 -0
- package/dist/components/Panel/MultiPanel.js.map +1 -1
- package/dist/components/Panel/PanelContents.d.ts.map +1 -1
- package/dist/components/Panel/PanelContents.js +92 -23
- package/dist/components/Panel/PanelContents.js.map +1 -1
- package/dist/components/Panel/PanelTabStack.d.ts.map +1 -1
- package/dist/components/Panel/PanelTabStack.js +1 -1
- package/dist/components/Panel/PanelTabStack.js.map +1 -1
- package/dist/components/PanelSpark.d.ts.map +1 -1
- package/dist/components/PanelSpark.js +3 -2
- package/dist/components/PanelSpark.js.map +1 -1
- package/dist/components/Playground.d.ts.map +1 -1
- package/dist/components/Playground.js +10 -4
- package/dist/components/Playground.js.map +1 -1
- package/dist/components/PromptControls.d.ts.map +1 -1
- package/dist/components/PromptControls.js +4 -2
- package/dist/components/PromptControls.js.map +1 -1
- package/dist/components/SparkLineChart.d.ts.map +1 -1
- package/dist/components/SparkLineChart.js +22 -26
- package/dist/components/SparkLineChart.js.map +1 -1
- package/dist/components/TimeControlBar.d.ts.map +1 -1
- package/dist/components/TimeControlBar.js +5 -3
- package/dist/components/TimeControlBar.js.map +1 -1
- package/dist/components/TokenizedMarkdown.d.ts +23 -0
- package/dist/components/TokenizedMarkdown.d.ts.map +1 -0
- package/dist/components/TokenizedMarkdown.js +144 -0
- package/dist/components/TokenizedMarkdown.js.map +1 -0
- package/dist/components/TokenizedMessage.d.ts +6 -0
- package/dist/components/TokenizedMessage.d.ts.map +1 -1
- package/dist/components/TokenizedMessage.js +20 -19
- 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/components/Tutorial/BrowserNarration.d.ts +55 -0
- package/dist/components/Tutorial/BrowserNarration.d.ts.map +1 -0
- package/dist/components/Tutorial/BrowserNarration.js +240 -0
- package/dist/components/Tutorial/BrowserNarration.js.map +1 -0
- package/dist/components/Tutorial/TutorialBox.d.ts +26 -0
- package/dist/components/Tutorial/TutorialBox.d.ts.map +1 -0
- package/dist/components/Tutorial/TutorialBox.js +239 -0
- package/dist/components/Tutorial/TutorialBox.js.map +1 -0
- package/dist/components/Tutorial/TutorialDevPanel.d.ts +9 -0
- package/dist/components/Tutorial/TutorialDevPanel.d.ts.map +1 -0
- package/dist/components/Tutorial/TutorialDevPanel.js +92 -0
- package/dist/components/Tutorial/TutorialDevPanel.js.map +1 -0
- package/dist/components/Tutorial/TutorialOverlay.d.ts +7 -0
- package/dist/components/Tutorial/TutorialOverlay.d.ts.map +1 -0
- package/dist/components/Tutorial/TutorialOverlay.js +1132 -0
- package/dist/components/Tutorial/TutorialOverlay.js.map +1 -0
- package/dist/components/Tutorial/targetRects.d.ts +67 -0
- package/dist/components/Tutorial/targetRects.d.ts.map +1 -0
- package/dist/components/Tutorial/targetRects.js +241 -0
- package/dist/components/Tutorial/targetRects.js.map +1 -0
- package/dist/game/Chit.d.ts +7 -0
- package/dist/game/Chit.d.ts.map +1 -1
- package/dist/game/Chit.js +20 -5
- package/dist/game/Chit.js.map +1 -1
- package/dist/game/ClientTimeState.d.ts +14 -0
- package/dist/game/ClientTimeState.d.ts.map +1 -1
- package/dist/game/ClientTimeState.js +17 -0
- package/dist/game/ClientTimeState.js.map +1 -1
- package/dist/game/Game.d.ts +6 -0
- package/dist/game/Game.d.ts.map +1 -1
- package/dist/game/GameTheme.d.ts +3 -0
- package/dist/game/GameTheme.d.ts.map +1 -1
- package/dist/game/GameTheme.js +2 -0
- package/dist/game/GameTheme.js.map +1 -1
- package/dist/game/Match.d.ts +8 -2
- package/dist/game/Match.d.ts.map +1 -1
- package/dist/game/Match.js +4 -1
- package/dist/game/Match.js.map +1 -1
- package/dist/game/Pick.d.ts +2 -0
- package/dist/game/Pick.d.ts.map +1 -1
- package/dist/game/Pick.js +17 -1
- package/dist/game/Pick.js.map +1 -1
- package/dist/game/PlayerPromptStatusChit.d.ts +8 -0
- package/dist/game/PlayerPromptStatusChit.d.ts.map +1 -1
- package/dist/game/PlayerPromptStatusChit.js +5 -1
- package/dist/game/PlayerPromptStatusChit.js.map +1 -1
- package/dist/game/Prompt.d.ts +15 -0
- package/dist/game/Prompt.d.ts.map +1 -1
- package/dist/game/Prompt.js +16 -0
- package/dist/game/Prompt.js.map +1 -1
- package/dist/game/Turn.d.ts +15 -4
- package/dist/game/Turn.d.ts.map +1 -1
- package/dist/game/Turn.js +173 -60
- package/dist/game/Turn.js.map +1 -1
- package/dist/game/TurnState.d.ts +12 -1
- package/dist/game/TurnState.d.ts.map +1 -1
- package/dist/game/TurnState.js +15 -3
- package/dist/game/TurnState.js.map +1 -1
- package/dist/game/ai/AiClientPrompts.d.ts +20 -3
- package/dist/game/ai/AiClientPrompts.d.ts.map +1 -1
- package/dist/game/ai/AiClientPrompts.js +42 -6
- package/dist/game/ai/AiClientPrompts.js.map +1 -1
- package/dist/game/ai/AiPlayerView.js +2 -0
- package/dist/game/ai/AiPlayerView.js.map +1 -1
- package/dist/game/clientTransport/ClientPrompts.d.ts +20 -1
- package/dist/game/clientTransport/ClientPrompts.d.ts.map +1 -1
- package/dist/game/clientTransport/ClientPrompts.js +30 -1
- package/dist/game/clientTransport/ClientPrompts.js.map +1 -1
- package/dist/game/clientTransport/ClientTime.d.ts +13 -0
- package/dist/game/clientTransport/ClientTime.d.ts.map +1 -1
- package/dist/game/clientTransport/ClientTime.js +51 -11
- package/dist/game/clientTransport/ClientTime.js.map +1 -1
- package/dist/game/tutorial/TutorialController.d.ts +300 -0
- package/dist/game/tutorial/TutorialController.d.ts.map +1 -0
- package/dist/game/tutorial/TutorialController.js +1182 -0
- package/dist/game/tutorial/TutorialController.js.map +1 -0
- package/dist/game/tutorial/TutorialRuntime.d.ts +89 -0
- package/dist/game/tutorial/TutorialRuntime.d.ts.map +1 -0
- package/dist/game/tutorial/TutorialRuntime.js +261 -0
- package/dist/game/tutorial/TutorialRuntime.js.map +1 -0
- package/dist/game/tutorial/TutorialTheme.d.ts +28 -0
- package/dist/game/tutorial/TutorialTheme.d.ts.map +1 -0
- package/dist/game/tutorial/TutorialTheme.js +39 -0
- package/dist/game/tutorial/TutorialTheme.js.map +1 -0
- package/dist/game/tutorial/allowed.d.ts +2 -0
- package/dist/game/tutorial/allowed.d.ts.map +1 -0
- package/dist/game/tutorial/allowed.js +119 -0
- package/dist/game/tutorial/allowed.js.map +1 -0
- package/dist/game/tutorial/checks.d.ts +58 -0
- package/dist/game/tutorial/checks.d.ts.map +1 -0
- package/dist/game/tutorial/checks.js +144 -0
- package/dist/game/tutorial/checks.js.map +1 -0
- package/dist/game/tutorial/createDemoMatch.d.ts +47 -0
- package/dist/game/tutorial/createDemoMatch.d.ts.map +1 -0
- package/dist/game/tutorial/createDemoMatch.js +67 -0
- package/dist/game/tutorial/createDemoMatch.js.map +1 -0
- package/dist/game/tutorial/defineTutorial.d.ts +353 -0
- package/dist/game/tutorial/defineTutorial.d.ts.map +1 -0
- package/dist/game/tutorial/defineTutorial.js +86 -0
- package/dist/game/tutorial/defineTutorial.js.map +1 -0
- package/dist/game/tutorial/runTutorial.d.ts +63 -0
- package/dist/game/tutorial/runTutorial.d.ts.map +1 -0
- package/dist/game/tutorial/runTutorial.js +273 -0
- package/dist/game/tutorial/runTutorial.js.map +1 -0
- package/dist/hooks/usePanelNavigation.d.ts +28 -0
- package/dist/hooks/usePanelNavigation.d.ts.map +1 -0
- package/dist/hooks/usePanelNavigation.js +36 -0
- package/dist/hooks/usePanelNavigation.js.map +1 -0
- package/dist/hooks/useTimeController.d.ts +2 -1
- package/dist/hooks/useTimeController.d.ts.map +1 -1
- package/dist/hooks/useTimeController.js +6 -2
- package/dist/hooks/useTimeController.js.map +1 -1
- package/dist/hooks/useTutorial.d.ts +48 -0
- package/dist/hooks/useTutorial.d.ts.map +1 -0
- package/dist/hooks/useTutorial.js +16 -0
- package/dist/hooks/useTutorial.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.html +12 -0
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/main.0792d734cde2c688d5f7.hot-update.js +16991 -0
- package/dist/main.0792d734cde2c688d5f7.hot-update.js.map +1 -0
- package/dist/main.0792d734cde2c688d5f7.hot-update.json +1 -0
- package/dist/pretty-chitty.js +204513 -0
- package/dist/pretty-chitty.js.map +1 -0
- package/dist/rendering/CameraWrapperPerspective.d.ts +5 -0
- package/dist/rendering/CameraWrapperPerspective.d.ts.map +1 -1
- package/dist/rendering/CameraWrapperPerspective.js +16 -0
- package/dist/rendering/CameraWrapperPerspective.js.map +1 -1
- package/dist/rendering/ChitGalleryItemInstance.d.ts +1 -0
- package/dist/rendering/ChitGalleryItemInstance.d.ts.map +1 -1
- package/dist/rendering/ChitGalleryItemInstance.js +12 -0
- package/dist/rendering/ChitGalleryItemInstance.js.map +1 -1
- package/dist/rendering/ChitRenderInstance.d.ts +9 -1
- package/dist/rendering/ChitRenderInstance.d.ts.map +1 -1
- package/dist/rendering/ChitRenderInstance.js +28 -0
- package/dist/rendering/ChitRenderInstance.js.map +1 -1
- package/dist/rendering/RootChitRenderInstance.d.ts +2 -0
- package/dist/rendering/RootChitRenderInstance.d.ts.map +1 -1
- package/dist/rendering/RootChitRenderInstance.js +29 -0
- package/dist/rendering/RootChitRenderInstance.js.map +1 -1
- package/dist/utilities/Annotations.d.ts +15 -0
- package/dist/utilities/Annotations.d.ts.map +1 -1
- package/dist/utilities/Annotations.js +31 -7
- package/dist/utilities/Annotations.js.map +1 -1
- package/dist/utilities/CanvasStack/CanvasStack.d.ts +2 -0
- package/dist/utilities/CanvasStack/CanvasStack.d.ts.map +1 -1
- package/dist/utilities/CanvasStack/CanvasStack.js +4 -0
- package/dist/utilities/CanvasStack/CanvasStack.js.map +1 -1
- package/dist/utilities/TokenizedText.d.ts +6 -0
- package/dist/utilities/TokenizedText.d.ts.map +1 -1
- package/dist/utilities/TokenizedText.js.map +1 -1
- package/dist/utilities/zIndex.d.ts +1 -0
- package/dist/utilities/zIndex.d.ts.map +1 -1
- package/dist/utilities/zIndex.js +1 -0
- package/dist/utilities/zIndex.js.map +1 -1
- package/package.json +3 -2
- package/src/library/components/ActionLogDisplay.tsx +1 -0
- package/src/library/components/BottomBarButton.tsx +5 -0
- package/src/library/components/ContextGalleryDisplay.tsx +2 -0
- package/src/library/components/DemoWrapper.tsx +147 -44
- package/src/library/components/FullScreenGalleryDisplay.tsx +3 -0
- package/src/library/components/Gallery/BuiltItem.ts +30 -9
- package/src/library/components/Gallery/GalleryController.ts +72 -1
- package/src/library/components/Gallery/GalleryViewer.tsx +54 -10
- package/src/library/components/Gallery/LayoutManager.ts +30 -6
- package/src/library/components/Gallery/constants.ts +2 -0
- package/src/library/components/Gallery/registry.ts +44 -0
- package/src/library/components/GameDesigner.tsx +121 -12
- package/src/library/components/InlineGalleryDisplay.tsx +5 -0
- package/src/library/components/LiveButton.tsx +8 -5
- package/src/library/components/MatchViewer.tsx +14 -3
- package/src/library/components/Panel/MultiPanel.tsx +21 -0
- package/src/library/components/Panel/PanelContents.tsx +70 -1
- package/src/library/components/Panel/PanelTabStack.tsx +1 -0
- package/src/library/components/PanelSpark.tsx +9 -4
- package/src/library/components/Playground.tsx +48 -21
- package/src/library/components/PromptControls.tsx +7 -3
- package/src/library/components/SparkLineChart.tsx +23 -27
- package/src/library/components/TimeControlBar.tsx +5 -3
- package/src/library/components/TokenizedMarkdown.tsx +224 -0
- package/src/library/components/TokenizedMessage.tsx +28 -32
- package/src/library/components/TopBarPlayers.tsx +12 -9
- package/src/library/components/Tutorial/BrowserNarration.ts +233 -0
- package/src/library/components/Tutorial/TutorialBox.tsx +506 -0
- package/src/library/components/Tutorial/TutorialDevPanel.tsx +297 -0
- package/src/library/components/Tutorial/TutorialOverlay.tsx +1301 -0
- package/src/library/components/Tutorial/targetRects.ts +273 -0
- package/src/library/game/Chit.ts +21 -5
- package/src/library/game/ClientTimeState.ts +18 -0
- package/src/library/game/Game.ts +7 -0
- package/src/library/game/GameTheme.ts +4 -0
- package/src/library/game/Match.ts +12 -2
- package/src/library/game/Pick.ts +16 -1
- package/src/library/game/PlayerPromptStatusChit.ts +5 -1
- package/src/library/game/Prompt.ts +20 -0
- package/src/library/game/Turn.ts +179 -61
- package/src/library/game/TurnState.ts +26 -3
- package/src/library/game/ai/AI_GUIDE.md +10 -0
- package/src/library/game/ai/AiClientPrompts.ts +60 -11
- package/src/library/game/ai/AiPlayerView.ts +2 -0
- package/src/library/game/clientTransport/ClientPrompts.ts +31 -1
- package/src/library/game/clientTransport/ClientTime.ts +54 -13
- package/src/library/game/serialize.test.ts +275 -0
- package/src/library/game/tutorial/TUTORIAL_GUIDE.md +411 -0
- package/src/library/game/tutorial/TutorialController.test.ts +731 -0
- package/src/library/game/tutorial/TutorialController.ts +1286 -0
- package/src/library/game/tutorial/TutorialRuntime.ts +311 -0
- package/src/library/game/tutorial/TutorialTheme.ts +67 -0
- package/src/library/game/tutorial/allowed.ts +145 -0
- package/src/library/game/tutorial/checks.ts +186 -0
- package/src/library/game/tutorial/createDemoMatch.ts +115 -0
- package/src/library/game/tutorial/defineTutorial.ts +414 -0
- package/src/library/game/tutorial/runTutorial.ts +331 -0
- package/src/library/game/undo.test.ts +282 -0
- package/src/library/hooks/usePanelNavigation.tsx +65 -0
- package/src/library/hooks/useTimeController.tsx +6 -2
- package/src/library/hooks/useTutorial.tsx +76 -0
- package/src/library/index.ts +57 -2
- package/src/library/rendering/CameraWrapperPerspective.ts +17 -0
- package/src/library/rendering/ChitGalleryItemInstance.ts +12 -0
- package/src/library/rendering/ChitRenderInstance.ts +34 -0
- package/src/library/rendering/RootChitRenderInstance.ts +30 -1
- package/src/library/utilities/Annotations.ts +35 -7
- package/src/library/utilities/CanvasStack/CanvasStack.ts +6 -1
- package/src/library/utilities/TokenizedText.ts +6 -0
- package/src/library/utilities/zIndex.ts +1 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { Chit } from "../Chit";
|
|
2
|
+
import { OrderedOutlet } from "../OrderedOutlet";
|
|
3
|
+
import { PlayerChit } from "../PlayerChit";
|
|
4
|
+
import { RootChit } from "../RootChit";
|
|
5
|
+
import { PickPrompt } from "../Prompt";
|
|
6
|
+
import type { AiSeatInfo } from "../PlayerInfo";
|
|
7
|
+
import type { SeatAiPlayersOptions } from "../Match";
|
|
8
|
+
import type { Game } from "../Game";
|
|
9
|
+
import type { TutorialTheme } from "./TutorialTheme";
|
|
10
|
+
/**
|
|
11
|
+
* Names chits in the game: "my hand", "the market cards". Runs against the state the player sees, so
|
|
12
|
+
* it is re-evaluated whenever the board changes and can return nothing while a chit is not there yet.
|
|
13
|
+
*/
|
|
14
|
+
export type ChitSelector<P extends PlayerChit, R extends RootChit<P>> = (root: R, me: P) => Chit | Chit[] | OrderedOutlet<any> | undefined | null;
|
|
15
|
+
/** Something in the 2D UI (not a chit) that a step can point at. The names match `data-tutorial-target` attributes. */
|
|
16
|
+
export type UiTarget = `button:${string}` | "undo" | "log" | "time" | "players" | "prompt" | "gallery:inline" | "gallery:fullscreen" | "gallery:toFullscreen" | "gallery:toInline" | "gallery:modeButton" | "gallery:context" | `spark:${string}` | `panelTab:${string}` | (string & NonNullable<unknown>);
|
|
17
|
+
/** Where an arrow points or what a ring surrounds. */
|
|
18
|
+
export type Target<P extends PlayerChit, R extends RootChit<P>> = ChitSelector<P, R> | {
|
|
19
|
+
chit: ChitSelector<P, R>;
|
|
20
|
+
/** Offset from the chit's centre in units of its bounding box: `{ y: 0.3 }` is 30% of the way to the top edge. */
|
|
21
|
+
offset?: {
|
|
22
|
+
x?: number;
|
|
23
|
+
y?: number;
|
|
24
|
+
z?: number;
|
|
25
|
+
};
|
|
26
|
+
/** Scale the box around the chit: 0.5 rings the middle half of a card. */
|
|
27
|
+
scale?: {
|
|
28
|
+
x?: number;
|
|
29
|
+
y?: number;
|
|
30
|
+
};
|
|
31
|
+
} | {
|
|
32
|
+
ui: UiTarget | ((root: R, me: P) => UiTarget);
|
|
33
|
+
} | {
|
|
34
|
+
screen: {
|
|
35
|
+
x: number | string;
|
|
36
|
+
y: number | string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* One thing to draw on the overlay. A step's `focus` is a list, so highlight as many regions as you
|
|
41
|
+
* like: `[{ ring: hand }, { ring: tableau, arrow: true }, { arrow: { ui: "button:Pass" } }]`.
|
|
42
|
+
*/
|
|
43
|
+
export type Focus<P extends PlayerChit, R extends RootChit<P>> = {
|
|
44
|
+
/** Point an arrow at this. `true` means "at the ring" (each ring, with `separate`). */
|
|
45
|
+
arrow?: Target<P, R> | true;
|
|
46
|
+
/** Draw a ring (rounded box) around this. Several chits get one box around all of them, unless `separate`. */
|
|
47
|
+
ring?: Target<P, R>;
|
|
48
|
+
/** Ring each chit the target names on its own instead of one box around all of them. Default false */
|
|
49
|
+
separate?: boolean;
|
|
50
|
+
/** Ring shape; default "rect" */
|
|
51
|
+
shape?: "rect" | "ellipse";
|
|
52
|
+
/**
|
|
53
|
+
* Spotlight: darken the screen except what the step highlights. Every ring and every arrow target
|
|
54
|
+
* of the step stays lit, not just this entry's. Default false
|
|
55
|
+
*/
|
|
56
|
+
dim?: boolean;
|
|
57
|
+
/** Switch to the panel that holds the target and bring it into view. Default true */
|
|
58
|
+
reveal?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Frame the ring on a small screen: show its panel full screen, and zoom in on it when it is tiny
|
|
61
|
+
* (see the guide). Default true; false for a ring that is only on screen for a moment, or whose
|
|
62
|
+
* surroundings matter more than its size (it leaves the framing as it is). A number zooms in that
|
|
63
|
+
* much on the ring whatever its size (on a small screen), e.g. 1.6 for a group of things that are each
|
|
64
|
+
* small but together are not.
|
|
65
|
+
*/
|
|
66
|
+
zoom?: boolean | number;
|
|
67
|
+
};
|
|
68
|
+
export type BoxAnchor = "top-left" | "top-right" | "bottom-left" | "bottom-right" | "top" | "bottom" | "center";
|
|
69
|
+
export type BoxPlacement<P extends PlayerChit, R extends RootChit<P>> = {
|
|
70
|
+
anchor: BoxAnchor;
|
|
71
|
+
} | {
|
|
72
|
+
anchor: "near";
|
|
73
|
+
target: Target<P, R>;
|
|
74
|
+
side?: "above" | "below" | "left" | "right";
|
|
75
|
+
} | {
|
|
76
|
+
anchor: "keep";
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Opens, switches or closes a gallery, as the player could with the gallery buttons.
|
|
80
|
+
* - `{ of: hand }` shows a container's children (what tapping a gallery container does)
|
|
81
|
+
* - `{ items: (root) => root.market.cards }` shows exactly those chits
|
|
82
|
+
* - `{ mode: "fullscreen" }` moves whatever gallery is open to full screen (or back with "inline")
|
|
83
|
+
* - `"close"` closes any open gallery
|
|
84
|
+
* `mode` defaults to the player's own choice (the one the gallery buttons remember).
|
|
85
|
+
*/
|
|
86
|
+
export type GalleryCommand<P extends PlayerChit, R extends RootChit<P>> = "close" | {
|
|
87
|
+
of?: ChitSelector<P, R>;
|
|
88
|
+
items?: ChitSelector<P, R>;
|
|
89
|
+
mode?: "inline" | "fullscreen" | "preferred";
|
|
90
|
+
};
|
|
91
|
+
/** An open gallery, for checks: what it shows and how */
|
|
92
|
+
export type TutorialGalleryState = {
|
|
93
|
+
mode: "inline" | "fullscreen";
|
|
94
|
+
/** The container whose children it shows, when it was opened from one */
|
|
95
|
+
of?: string;
|
|
96
|
+
/** Ids of the chits it shows */
|
|
97
|
+
chitIds: string[];
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* A change to how chits look, in this player's view only. The properties are set on the client's copy
|
|
101
|
+
* of the chit and the engine renders (and animates) them like any other change: a card flips over, a
|
|
102
|
+
* token turns. The game never sees it, and it is put back when the step ends unless `keep` is set.
|
|
103
|
+
*
|
|
104
|
+
* ```ts
|
|
105
|
+
* pose: [{ chit: (root) => root.table.market.cards[0], set: { faceDown: true } }]
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export type Pose<P extends PlayerChit, R extends RootChit<P>> = {
|
|
109
|
+
/** The chit or chits to change */
|
|
110
|
+
chit: ChitSelector<P, R>;
|
|
111
|
+
/**
|
|
112
|
+
* Properties to set (`{ faceDown: true }`), or a function that changes the chit. Leave it out to put
|
|
113
|
+
* the chit back as the game has it. Only properties are put back: do not move chits with a pose.
|
|
114
|
+
*/
|
|
115
|
+
set?: {
|
|
116
|
+
[prop: string]: unknown;
|
|
117
|
+
} | ((chit: Chit) => void);
|
|
118
|
+
/**
|
|
119
|
+
* Keep the change after the step ends, until a later pose of the chit, Back, or the end of the
|
|
120
|
+
* tutorial. A change from the game to the same chit replaces it either way.
|
|
121
|
+
*/
|
|
122
|
+
keep?: boolean;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* What the board's timeline does. The board plays the game's moments (clocks) one after another;
|
|
126
|
+
* holding it freezes the board on a moment while the game carries on behind it, so the narration can
|
|
127
|
+
* talk about what just animated. Only this player's view is affected.
|
|
128
|
+
*
|
|
129
|
+
* - `"hold"`: stop at the moment on screen
|
|
130
|
+
* - `{ advance: n }`: play `n` more moments, then stop
|
|
131
|
+
* - `{ until: check }`: play on until the board shows a moment where the check passes, then stop
|
|
132
|
+
* (e.g. `checks.logged(/Robin buys/)`)
|
|
133
|
+
* - `"play"`: play on, catching up with the game and following it again
|
|
134
|
+
*
|
|
135
|
+
* A hold lasts until a later command changes it, Back, or the end of the tutorial.
|
|
136
|
+
*/
|
|
137
|
+
export type TimelineCommand<P extends PlayerChit, R extends RootChit<P>> = "hold" | "play" | {
|
|
138
|
+
advance: number;
|
|
139
|
+
} | {
|
|
140
|
+
until: Checker<P, R>;
|
|
141
|
+
};
|
|
142
|
+
export type Cue<P extends PlayerChit, R extends RootChit<P>> = {
|
|
143
|
+
/** Seconds into the narration, or the index (0-based) of the sentence this cue starts with. */
|
|
144
|
+
at: number | {
|
|
145
|
+
sentence: number;
|
|
146
|
+
};
|
|
147
|
+
/** Replaces the current set of arrows and rings. An empty array clears them. */
|
|
148
|
+
focus?: Focus<P, R>[];
|
|
149
|
+
box?: BoxPlacement<P, R>;
|
|
150
|
+
/** Opens, switches or closes a gallery at this point of the narration */
|
|
151
|
+
gallery?: GalleryCommand<P, R>;
|
|
152
|
+
/** Changes how chits look from this point of the narration (see `Pose`) */
|
|
153
|
+
pose?: Pose<P, R>[];
|
|
154
|
+
/** Holds or plays the board's timeline from this point of the narration (see `TimelineCommand`) */
|
|
155
|
+
timeline?: TimelineCommand<P, R>;
|
|
156
|
+
};
|
|
157
|
+
/** `true` = done. `false` = not yet. A string = not yet, and the hint to show the player. */
|
|
158
|
+
export type CheckResult = boolean | string;
|
|
159
|
+
export type TutorialContext<P extends PlayerChit, R extends RootChit<P>> = {
|
|
160
|
+
root: R;
|
|
161
|
+
me: P;
|
|
162
|
+
/** What the player is being asked right now, or undefined when it is not their turn */
|
|
163
|
+
prompt?: PickPrompt;
|
|
164
|
+
clock: number;
|
|
165
|
+
find: <C extends Chit = Chit>(id: string) => C | undefined;
|
|
166
|
+
/** Clock when the current step was entered */
|
|
167
|
+
stepStartClock: number;
|
|
168
|
+
/** Log lines written since the current step was entered, oldest first */
|
|
169
|
+
recentLog: string[];
|
|
170
|
+
/** Galleries open right now, full-screen first */
|
|
171
|
+
galleries: TutorialGalleryState[];
|
|
172
|
+
};
|
|
173
|
+
export type Checker<P extends PlayerChit, R extends RootChit<P>> = ((ctx: TutorialContext<P, R>) => CheckResult) & {
|
|
174
|
+
/** Called when the step is entered, so a check can remember what the board looked like then. */
|
|
175
|
+
reset?: (ctx: TutorialContext<P, R>) => void;
|
|
176
|
+
};
|
|
177
|
+
/** A move a bot is told to make (see `TutorialStep.ai`). Every field given must match. */
|
|
178
|
+
export type ForcedDecision<P extends PlayerChit, R extends RootChit<P>> = {
|
|
179
|
+
/** The pick's `.ai("key")` */
|
|
180
|
+
key?: string;
|
|
181
|
+
/** For chit and drag options: the chit (or one of the chits) to play */
|
|
182
|
+
chit?: ChitSelector<P, R>;
|
|
183
|
+
/** For drag options: where to drop it */
|
|
184
|
+
target?: ChitSelector<P, R>;
|
|
185
|
+
/** For button options: the button's label */
|
|
186
|
+
button?: string;
|
|
187
|
+
/** Only use this entry when this holds (checked against the bot's view) */
|
|
188
|
+
when?: (root: R, me: P) => boolean;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* A move the player is allowed to make during a "do it" step. Every field given must match the
|
|
192
|
+
* attempted move; `"any"` allows everything the game offers.
|
|
193
|
+
*/
|
|
194
|
+
export type AllowedAction<P extends PlayerChit, R extends RootChit<P>> = "any" | {
|
|
195
|
+
/** The pick's `.ai("key")` */
|
|
196
|
+
key?: string;
|
|
197
|
+
/** For taps and drags: the chit (or one of the chits) that may be played */
|
|
198
|
+
chit?: ChitSelector<P, R>;
|
|
199
|
+
/** For drags: where it may be dropped */
|
|
200
|
+
target?: ChitSelector<P, R>;
|
|
201
|
+
/** For buttons (the engine's Confirm included): the label */
|
|
202
|
+
button?: string;
|
|
203
|
+
/**
|
|
204
|
+
* A UI control the player is expected to use (`"button:Market"`, `"gallery:toFullscreen"`).
|
|
205
|
+
* Galleries and other UI are never blocked, so this only says the step waits for the player
|
|
206
|
+
* (not the bots) and matches no game move.
|
|
207
|
+
*/
|
|
208
|
+
ui?: UiTarget;
|
|
209
|
+
};
|
|
210
|
+
export type TutorialStep<P extends PlayerChit, R extends RootChit<P>> = {
|
|
211
|
+
id: string;
|
|
212
|
+
/** Markdown with the game's `:token:` icons inline. See TokenizedMarkdown. */
|
|
213
|
+
text: string;
|
|
214
|
+
/**
|
|
215
|
+
* Narration: a URL (relative to the game bundle) of an audio file, or `"tts"` to have the browser
|
|
216
|
+
* read the text aloud with speech synthesis (handy while authoring, before the recordings exist).
|
|
217
|
+
*/
|
|
218
|
+
audio?: string;
|
|
219
|
+
/** Start time of each sentence in the audio file, in seconds. Enables `{ sentence: n }` cues and sentence emphasis for file audio. */
|
|
220
|
+
sentenceTimes?: number[];
|
|
221
|
+
/** Where the box goes when the step starts. Default: where it was. */
|
|
222
|
+
box?: BoxPlacement<P, R>;
|
|
223
|
+
/** Arrows and rings to show from the start of the step (a cue at 0). */
|
|
224
|
+
focus?: Focus<P, R>[];
|
|
225
|
+
/**
|
|
226
|
+
* Opens, switches or closes a gallery when the step starts. A gallery the script opened stays
|
|
227
|
+
* until a later step or cue changes it; Back closes it.
|
|
228
|
+
*/
|
|
229
|
+
gallery?: GalleryCommand<P, R>;
|
|
230
|
+
/**
|
|
231
|
+
* Changes how chits look, in this player's view only, from the start of the step (see `Pose`): a
|
|
232
|
+
* card flipping over, a token turning. Put back when the step ends unless a pose sets `keep`.
|
|
233
|
+
*/
|
|
234
|
+
pose?: Pose<P, R>[];
|
|
235
|
+
/**
|
|
236
|
+
* Holds or plays the board's timeline when the step starts (see `TimelineCommand`): let the bots'
|
|
237
|
+
* moves animate up to a point and stop there while the narration explains them. The game itself
|
|
238
|
+
* plays on; a "do it" step usually wants `"play"` so the player's prompt is on the board.
|
|
239
|
+
*/
|
|
240
|
+
timeline?: TimelineCommand<P, R>;
|
|
241
|
+
/** Changes during the narration */
|
|
242
|
+
cues?: Cue<P, R>[];
|
|
243
|
+
/** Makes this a "do it" step: Next is locked until this passes, then the tutorial moves on by itself. */
|
|
244
|
+
waitFor?: Checker<P, R>;
|
|
245
|
+
/**
|
|
246
|
+
* The only moves the game accepts while this step is waiting. Anything else the player tries is
|
|
247
|
+
* dropped and the hint is shown. A narration step accepts nothing. Required on a "do it" step in
|
|
248
|
+
* practice: without it nothing is allowed and the step cannot be completed (the dev panel and
|
|
249
|
+
* `runTutorial` warn). Use `allow: []` on a step that waits for the bots or the world rather than
|
|
250
|
+
* the player, to say so explicitly.
|
|
251
|
+
*/
|
|
252
|
+
allow?: AllowedAction<P, R> | AllowedAction<P, R>[];
|
|
253
|
+
/**
|
|
254
|
+
* Wait for the player to tap Next after the narration instead of moving on by itself. Default false:
|
|
255
|
+
* a narration step auto-advances when its audio (or reading clock) ends; the last step always waits.
|
|
256
|
+
*/
|
|
257
|
+
pause?: boolean;
|
|
258
|
+
/** Shown if `waitFor` has not passed after `after` seconds (default 8). A plain string uses the default delay. */
|
|
259
|
+
hint?: string | {
|
|
260
|
+
after: number;
|
|
261
|
+
text: string;
|
|
262
|
+
};
|
|
263
|
+
/** Random draws the game makes while this step is active, in order. See `TutorialSpec.match.rng`. */
|
|
264
|
+
rng?: (number | number[])[];
|
|
265
|
+
/** Forced moves per bot (by player id) while this step is active, in order. */
|
|
266
|
+
ai?: {
|
|
267
|
+
[playerId: string]: ForcedDecision<P, R>[];
|
|
268
|
+
};
|
|
269
|
+
/** Bots hold their prompts while this step is showing. Default false */
|
|
270
|
+
pauseAi?: boolean;
|
|
271
|
+
onEnter?: (ctx: TutorialContext<P, R>) => void;
|
|
272
|
+
onExit?: (ctx: TutorialContext<P, R>) => void;
|
|
273
|
+
/** Marks the last step: what happens after it. "continue" keeps playing the match; "back" leaves it. */
|
|
274
|
+
end?: "continue" | "back";
|
|
275
|
+
};
|
|
276
|
+
export type TutorialMatchSetup<P extends PlayerChit, R extends RootChit<P>> = {
|
|
277
|
+
/** Seats. Default: `Root.setupDemoGame()` seats, "You" first and a bot in every other seat. */
|
|
278
|
+
players?: {
|
|
279
|
+
name: string;
|
|
280
|
+
ai?: AiSeatInfo;
|
|
281
|
+
imageUrl?: string;
|
|
282
|
+
}[];
|
|
283
|
+
/** Index into `players` of the seat the person plays. Default 0 */
|
|
284
|
+
humanSeat?: number;
|
|
285
|
+
/** Match options. Default: what `setupDemoGame()` selects */
|
|
286
|
+
options?: any;
|
|
287
|
+
/**
|
|
288
|
+
* Random draws made during setup, before the first step: the seating shuffle first (an array of
|
|
289
|
+
* 2 × seats values), then whatever `Game.run` draws before it first prompts the player.
|
|
290
|
+
*/
|
|
291
|
+
rng?: (number | number[])[];
|
|
292
|
+
/** How the bots play when no step forces a move. Default `{ temperature: 0, thinkMs: [500, 900] }` */
|
|
293
|
+
ai?: SeatAiPlayersOptions;
|
|
294
|
+
};
|
|
295
|
+
export type TutorialSpec<P extends PlayerChit, R extends RootChit<P>> = {
|
|
296
|
+
id: string;
|
|
297
|
+
/** BCP-47: "en", "es-MX" */
|
|
298
|
+
locale: string;
|
|
299
|
+
title: string;
|
|
300
|
+
/**
|
|
301
|
+
* Shown on the start card, before the player taps Start (markdown, `:token:` icons). Default: the
|
|
302
|
+
* first step's text. Use it for a welcome line rather than adding a title-card step.
|
|
303
|
+
*/
|
|
304
|
+
intro?: string;
|
|
305
|
+
/** Feature flags a host must have on to offer this tutorial. Informational. */
|
|
306
|
+
requires?: string[];
|
|
307
|
+
match?: TutorialMatchSetup<P, R>;
|
|
308
|
+
theme?: Partial<TutorialTheme>;
|
|
309
|
+
/** Throw on a stale pinned draw or an unmatched forced move instead of warning. Default false */
|
|
310
|
+
strict?: boolean;
|
|
311
|
+
steps: TutorialStep<P, R>[];
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* Declares a scripted tutorial. List it on `Game.tutorials`.
|
|
315
|
+
*
|
|
316
|
+
* ```ts
|
|
317
|
+
* export const intro = defineTutorial<Player, Root>({
|
|
318
|
+
* id: "intro",
|
|
319
|
+
* locale: "en",
|
|
320
|
+
* title: "How to play",
|
|
321
|
+
* steps: [
|
|
322
|
+
* { id: "hand", text: "This is your hand.", focus: [{ ring: (root, me) => me.hand }] },
|
|
323
|
+
* { id: "buy", text: "Buy a card.", waitFor: checks.countChanged((r, me) => me.hand, 1) },
|
|
324
|
+
* ],
|
|
325
|
+
* });
|
|
326
|
+
* ```
|
|
327
|
+
*
|
|
328
|
+
* A tutorial runs the way a demo does: an in-process match, one human seat and bots in the rest.
|
|
329
|
+
* See TUTORIAL_GUIDE.md.
|
|
330
|
+
*
|
|
331
|
+
* @group Tutorials
|
|
332
|
+
*/
|
|
333
|
+
export declare function defineTutorial<P extends PlayerChit, R extends RootChit<P>>(spec: TutorialSpec<P, R>): TutorialSpec<P, R>;
|
|
334
|
+
export type TutorialSummary = {
|
|
335
|
+
id: string;
|
|
336
|
+
locale: string;
|
|
337
|
+
title: string;
|
|
338
|
+
requires?: string[];
|
|
339
|
+
steps: number;
|
|
340
|
+
};
|
|
341
|
+
/** What a game offers, for a host choosing by language and feature flags. @group Tutorials */
|
|
342
|
+
export declare function listTutorials(game: Game<any, any>): TutorialSummary[];
|
|
343
|
+
/** Finds a tutorial by id, and locale when given. @group Tutorials */
|
|
344
|
+
export declare function findTutorial(game: Game<any, any>, id: string, locale?: string): TutorialSpec<any, any> | undefined;
|
|
345
|
+
/**
|
|
346
|
+
* Splits step text into sentences exactly the way `{ sentence: n }` cues and the narration emphasis
|
|
347
|
+
* count them. Use it in narration tooling (rendering one clip per sentence, measuring `sentenceTimes`)
|
|
348
|
+
* so the counts always agree. Markdown punctuation is left alone.
|
|
349
|
+
*
|
|
350
|
+
* @group Tutorials
|
|
351
|
+
*/
|
|
352
|
+
export declare function splitSentences(text: string): string[];
|
|
353
|
+
//# sourceMappingURL=defineTutorial.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineTutorial.d.ts","sourceRoot":"","sources":["../../../src/library/game/tutorial/defineTutorial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;GAGG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,IAAI,CACtE,IAAI,EAAE,CAAC,EACP,EAAE,EAAE,CAAC,KACF,IAAI,GAAG,IAAI,EAAE,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;AAE3D,uHAAuH;AACvH,MAAM,MAAM,QAAQ,GAChB,UAAU,MAAM,EAAE,GAClB,MAAM,GACN,KAAK,GACL,MAAM,GACN,SAAS,GACT,QAAQ,GACR,gBAAgB,GAChB,oBAAoB,GACpB,sBAAsB,GACtB,kBAAkB,GAClB,oBAAoB,GACpB,iBAAiB,GACjB,SAAS,MAAM,EAAE,GACjB,YAAY,MAAM,EAAE,GACpB,CAAC,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;AAEpC,sDAAsD;AACtD,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,U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,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,eAAe,EAAE,CAQrE;AAED,sEAAsE;AACtE,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS,CAUlH;AAqBD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAGrD"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { OrderedOutlet } from "../OrderedOutlet";
|
|
2
|
+
/**
|
|
3
|
+
* Declares a scripted tutorial. List it on `Game.tutorials`.
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* export const intro = defineTutorial<Player, Root>({
|
|
7
|
+
* id: "intro",
|
|
8
|
+
* locale: "en",
|
|
9
|
+
* title: "How to play",
|
|
10
|
+
* steps: [
|
|
11
|
+
* { id: "hand", text: "This is your hand.", focus: [{ ring: (root, me) => me.hand }] },
|
|
12
|
+
* { id: "buy", text: "Buy a card.", waitFor: checks.countChanged((r, me) => me.hand, 1) },
|
|
13
|
+
* ],
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* A tutorial runs the way a demo does: an in-process match, one human seat and bots in the rest.
|
|
18
|
+
* See TUTORIAL_GUIDE.md.
|
|
19
|
+
*
|
|
20
|
+
* @group Tutorials
|
|
21
|
+
*/
|
|
22
|
+
export function defineTutorial(spec) {
|
|
23
|
+
const ids = new Set();
|
|
24
|
+
spec.steps.forEach((step) => {
|
|
25
|
+
if (ids.has(step.id)) {
|
|
26
|
+
throw new Error(`Tutorial "${spec.id}": duplicate step id "${step.id}"`);
|
|
27
|
+
}
|
|
28
|
+
ids.add(step.id);
|
|
29
|
+
});
|
|
30
|
+
return spec;
|
|
31
|
+
}
|
|
32
|
+
/** What a game offers, for a host choosing by language and feature flags. @group Tutorials */
|
|
33
|
+
export function listTutorials(game) {
|
|
34
|
+
return (game.tutorials ?? []).map((t) => ({
|
|
35
|
+
id: t.id,
|
|
36
|
+
locale: t.locale,
|
|
37
|
+
title: t.title,
|
|
38
|
+
requires: t.requires,
|
|
39
|
+
steps: t.steps.length,
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
/** Finds a tutorial by id, and locale when given. @group Tutorials */
|
|
43
|
+
export function findTutorial(game, id, locale) {
|
|
44
|
+
const matches = (game.tutorials ?? []).filter((t) => t.id === id);
|
|
45
|
+
if (locale) {
|
|
46
|
+
const exact = matches.find((t) => t.locale === locale);
|
|
47
|
+
if (exact)
|
|
48
|
+
return exact;
|
|
49
|
+
const language = locale.split("-")[0];
|
|
50
|
+
const sameLanguage = matches.find((t) => t.locale.split("-")[0] === language);
|
|
51
|
+
if (sameLanguage)
|
|
52
|
+
return sameLanguage;
|
|
53
|
+
}
|
|
54
|
+
return matches[0];
|
|
55
|
+
}
|
|
56
|
+
/** Normalises a selector's result to a list of chits with ids. @internal */
|
|
57
|
+
export function selectChits(selector, root, me) {
|
|
58
|
+
if (!selector || !root || !me)
|
|
59
|
+
return [];
|
|
60
|
+
let result;
|
|
61
|
+
try {
|
|
62
|
+
result = selector(root, me);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
if (!result)
|
|
68
|
+
return [];
|
|
69
|
+
if (result instanceof OrderedOutlet)
|
|
70
|
+
return result.copy();
|
|
71
|
+
if (Array.isArray(result))
|
|
72
|
+
return result.filter((c) => !!c);
|
|
73
|
+
return [result];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Splits step text into sentences exactly the way `{ sentence: n }` cues and the narration emphasis
|
|
77
|
+
* count them. Use it in narration tooling (rendering one clip per sentence, measuring `sentenceTimes`)
|
|
78
|
+
* so the counts always agree. Markdown punctuation is left alone.
|
|
79
|
+
*
|
|
80
|
+
* @group Tutorials
|
|
81
|
+
*/
|
|
82
|
+
export function splitSentences(text) {
|
|
83
|
+
const parts = text.split(/(?<=[.!?][")'\]]*)\s+(?=\S)/);
|
|
84
|
+
return parts.map((p) => p.trim()).filter((p) => p.length > 0);
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=defineTutorial.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineTutorial.js","sourceRoot":"","sources":["../../../src/library/game/tutorial/defineTutorial.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAsUjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,cAAc,CAA8C,IAAwB;IAClG,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC1B,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,aAAa,IAAI,CAAC,EAAE,yBAAyB,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QAC3E,CAAC;QACD,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC;AAID,8FAA8F;AAC9F,MAAM,UAAU,aAAa,CAAC,IAAoB;IAChD,OAAO,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACxC,EAAE,EAAE,CAAC,CAAC,EAAE;QACR,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,QAAQ,EAAE,CAAC,CAAC,QAAQ;QACp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AO,EAAE,CAAC;IACvB,IAAI,MAAM,YAAY,aAAa;QAAE,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IAC1D,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAa,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvE,OAAO,CAAC,MAAM,CAAC,CAAC;AAClB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACxD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Game } from "../Game";
|
|
2
|
+
import { PlayerChit } from "../PlayerChit";
|
|
3
|
+
import { RootChit } from "../RootChit";
|
|
4
|
+
import type { AiContext, AiOption } from "../ai/defineAi";
|
|
5
|
+
import { GalleryCommand, TutorialSpec, TutorialStep } from "./defineTutorial";
|
|
6
|
+
import type { TutorialRuntime } from "./TutorialRuntime";
|
|
7
|
+
export type RunTutorialOptions<P extends PlayerChit, R extends RootChit<P>> = {
|
|
8
|
+
/**
|
|
9
|
+
* Plays the human seat: given the step the tutorial is on and the legal options, return the index
|
|
10
|
+
* to play, or undefined to take the first option the step's `allow` list accepts (a player
|
|
11
|
+
* following instructions). A step that allows nothing is never answered.
|
|
12
|
+
*/
|
|
13
|
+
answer?: (step: TutorialStep<P, R> | undefined, options: {
|
|
14
|
+
option: AiOption;
|
|
15
|
+
score: number;
|
|
16
|
+
}[], ctx: AiContext<P, R, any>) => number | undefined;
|
|
17
|
+
/** Give up on a step after this long. Default 10000 ms */
|
|
18
|
+
stepTimeoutMs?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Does what the player would do outside the game itself when a step starts: open or switch a
|
|
21
|
+
* gallery (`ui.gallery({ of: (root, me) => me.hand })`). Headless runs have no gallery buttons, so a
|
|
22
|
+
* step that waits for one needs this.
|
|
23
|
+
*/
|
|
24
|
+
ui?: (step: TutorialStep<P, R>, ui: {
|
|
25
|
+
gallery: (command: GalleryCommand<P, R>) => void;
|
|
26
|
+
}) => void;
|
|
27
|
+
/** Let the bots log. Default false */
|
|
28
|
+
log?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Stop as soon as this step (an id) goes live, and keep going past steps that wait on the screen
|
|
31
|
+
* (a gallery button…) rather than the game: the run is there to reach the step, not to test the
|
|
32
|
+
* script. `DemoWrapper` uses it to skip ahead, from the run's `runtime` snapshots.
|
|
33
|
+
*/
|
|
34
|
+
until?: string;
|
|
35
|
+
};
|
|
36
|
+
export type RunTutorialResult<P extends PlayerChit = PlayerChit, R extends RootChit<P> = RootChit<P>> = {
|
|
37
|
+
outcome: "completed" | "stuck" | "error";
|
|
38
|
+
/** Step ids in the order they were entered */
|
|
39
|
+
visited: string[];
|
|
40
|
+
/** The step the run got stuck on, if any */
|
|
41
|
+
stuckOn?: string;
|
|
42
|
+
error?: string;
|
|
43
|
+
warnings: string[];
|
|
44
|
+
rngRemaining: number;
|
|
45
|
+
/** The run's runtime: its snapshots hold the match as each visited step went live */
|
|
46
|
+
runtime: TutorialRuntime<P, R>;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Plays a tutorial headlessly: builds its match like `DemoWrapper` does, seats the bots, drives the
|
|
50
|
+
* human seat with `answer` (or the game's AI rules), and walks the steps, asserting every `waitFor`
|
|
51
|
+
* becomes satisfiable. Use it in a test so a rules change that breaks a script fails CI.
|
|
52
|
+
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* test("intro tutorial can be completed", async () => {
|
|
55
|
+
* const result = await runTutorial(new MyGame(), intro);
|
|
56
|
+
* expect(result.outcome).toBe("completed");
|
|
57
|
+
* });
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @group Tutorials
|
|
61
|
+
*/
|
|
62
|
+
export declare function runTutorial<P extends PlayerChit, R extends RootChit<P>>(game: Game<P, R>, spec: TutorialSpec<P, R>, options?: RunTutorialOptions<P, R>): Promise<RunTutorialResult<P, R>>;
|
|
63
|
+
//# sourceMappingURL=runTutorial.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runTutorial.d.ts","sourceRoot":"","sources":["../../../src/library/game/tutorial/runTutorial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIvC,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAwB,YAAY,EAAE,YAAY,EAAe,MAAM,kBAAkB,CAAC;AAIjH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,IAAI;IAC5E;;;;OAIG;IACH,MAAM,CAAC,EAAE,CACP,IAAI,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,EACpC,OAAO,EAAE;QAAE,MAAM,EAAE,QAAQ,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,EAC9C,GAAG,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,KACtB,MAAM,GAAG,SAAS,CAAC;IACxB,0DAA0D;IAC1D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;O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