@pretty-chitty/core 2.0.0 → 2.3.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 +33 -2
- package/dist/components/DemoWrapper.d.ts.map +1 -1
- package/dist/components/DemoWrapper.js +77 -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 +16 -2
- package/dist/components/Gallery/BuiltItem.d.ts.map +1 -1
- package/dist/components/Gallery/BuiltItem.js +92 -16
- package/dist/components/Gallery/BuiltItem.js.map +1 -1
- package/dist/components/Gallery/GalleryController.d.ts +26 -0
- package/dist/components/Gallery/GalleryController.d.ts.map +1 -1
- package/dist/components/Gallery/GalleryController.js +106 -6
- 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 +139 -12
- package/dist/components/Gallery/GalleryViewer.js.map +1 -1
- package/dist/components/Gallery/LayoutManager.d.ts +10 -0
- package/dist/components/Gallery/LayoutManager.d.ts.map +1 -1
- package/dist/components/Gallery/LayoutManager.js +49 -3
- package/dist/components/Gallery/LayoutManager.js.map +1 -1
- package/dist/components/Gallery/constants.d.ts +6 -0
- package/dist/components/Gallery/constants.d.ts.map +1 -1
- package/dist/components/Gallery/constants.js +6 -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/Gallery/types.d.ts +5 -0
- package/dist/components/Gallery/types.d.ts.map +1 -1
- package/dist/components/GameDesigner.d.ts.map +1 -1
- package/dist/components/GameDesigner.js +84 -10
- package/dist/components/GameDesigner.js.map +1 -1
- package/dist/components/InlineGalleryDisplay.d.ts.map +1 -1
- package/dist/components/InlineGalleryDisplay.js +35 -8
- 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/ExternalDrag.d.ts +30 -0
- package/dist/components/Panel/ExternalDrag.d.ts.map +1 -0
- package/dist/components/Panel/ExternalDrag.js +87 -0
- package/dist/components/Panel/ExternalDrag.js.map +1 -0
- 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 +3 -0
- package/dist/components/Panel/PanelContents.d.ts.map +1 -1
- package/dist/components/Panel/PanelContents.js +116 -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 +6 -3
- 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/TopBar.d.ts.map +1 -1
- package/dist/components/TopBar.js +3 -1
- package/dist/components/TopBar.js.map +1 -1
- package/dist/components/TopBarPlayers.d.ts.map +1 -1
- package/dist/components/TopBarPlayers.js +2 -2
- 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 +1147 -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/components/Viewer.d.ts.map +1 -1
- package/dist/components/Viewer.js +1 -0
- package/dist/components/Viewer.js.map +1 -1
- package/dist/game/Chit.d.ts +10 -1
- package/dist/game/Chit.d.ts.map +1 -1
- package/dist/game/Chit.js +24 -6
- 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/GalleryItemChitChildrenSource.d.ts +1 -0
- package/dist/game/GalleryItemChitChildrenSource.d.ts.map +1 -1
- package/dist/game/GalleryItemChitChildrenSource.js +1 -0
- package/dist/game/GalleryItemChitChildrenSource.js.map +1 -1
- package/dist/game/GalleryItemRawSource.d.ts +1 -0
- package/dist/game/GalleryItemRawSource.d.ts.map +1 -1
- package/dist/game/GalleryItemRawSource.js +1 -0
- package/dist/game/GalleryItemRawSource.js.map +1 -1
- package/dist/game/Game.d.ts +6 -0
- package/dist/game/Game.d.ts.map +1 -1
- package/dist/game/GameButton.d.ts +8 -0
- package/dist/game/GameButton.d.ts.map +1 -1
- package/dist/game/GameButton.js +13 -1
- package/dist/game/GameButton.js.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/ModalState.d.ts +3 -0
- package/dist/game/ModalState.d.ts.map +1 -1
- package/dist/game/ModalState.js +2 -0
- package/dist/game/ModalState.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 +18 -4
- 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 +6 -4
- package/dist/game/PlayerPromptStatusChit.js.map +1 -1
- package/dist/game/Prompt.d.ts +18 -1
- package/dist/game/Prompt.d.ts.map +1 -1
- package/dist/game/Prompt.js +29 -1
- package/dist/game/Prompt.js.map +1 -1
- package/dist/game/SparkChit.d.ts +6 -0
- package/dist/game/SparkChit.d.ts.map +1 -1
- package/dist/game/SparkChit.js +8 -0
- package/dist/game/SparkChit.js.map +1 -1
- package/dist/game/Turn.d.ts +17 -6
- package/dist/game/Turn.d.ts.map +1 -1
- package/dist/game/Turn.js +179 -69
- 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 +22 -1
- package/dist/game/clientTransport/ClientPrompts.d.ts.map +1 -1
- package/dist/game/clientTransport/ClientPrompts.js +72 -5
- 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 +71 -12
- package/dist/game/clientTransport/ClientTime.js.map +1 -1
- package/dist/game/tutorial/TutorialController.d.ts +308 -0
- package/dist/game/tutorial/TutorialController.d.ts.map +1 -0
- package/dist/game/tutorial/TutorialController.js +1195 -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 +64 -0
- package/dist/game/tutorial/runTutorial.d.ts.map +1 -0
- package/dist/game/tutorial/runTutorial.js +293 -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 +4 -1
- package/dist/hooks/useTimeController.d.ts.map +1 -1
- package/dist/hooks/useTimeController.js +10 -2
- package/dist/hooks/useTimeController.js.map +1 -1
- package/dist/hooks/useTutorial.d.ts +51 -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 +37 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- 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 +14 -3
- package/dist/rendering/ChitGalleryItemInstance.d.ts.map +1 -1
- package/dist/rendering/ChitGalleryItemInstance.js +29 -1
- package/dist/rendering/ChitGalleryItemInstance.js.map +1 -1
- package/dist/rendering/ChitRenderInstance.d.ts +15 -1
- package/dist/rendering/ChitRenderInstance.d.ts.map +1 -1
- package/dist/rendering/ChitRenderInstance.js +49 -4
- package/dist/rendering/ChitRenderInstance.js.map +1 -1
- package/dist/rendering/LightWrapper.d.ts.map +1 -1
- package/dist/rendering/LightWrapper.js +10 -1
- package/dist/rendering/LightWrapper.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/rendering/Splay.d.ts +11 -0
- package/dist/rendering/Splay.d.ts.map +1 -1
- package/dist/rendering/Splay.js +20 -10
- package/dist/rendering/Splay.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/CanvasStack/RichTextRenderer.d.ts.map +1 -1
- package/dist/utilities/CanvasStack/RichTextRenderer.js +12 -0
- package/dist/utilities/CanvasStack/RichTextRenderer.js.map +1 -1
- package/dist/utilities/Dice.d.ts +2 -0
- package/dist/utilities/Dice.d.ts.map +1 -1
- package/dist/utilities/Dice.js +5 -1
- package/dist/utilities/Dice.js.map +1 -1
- package/dist/utilities/GalleryItemConversion.d.ts.map +1 -1
- package/dist/utilities/GalleryItemConversion.js +5 -7
- package/dist/utilities/GalleryItemConversion.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 +150 -44
- package/src/library/components/FullScreenGalleryDisplay.tsx +3 -0
- package/src/library/components/Gallery/BuiltItem.ts +92 -16
- package/src/library/components/Gallery/GalleryController.ts +111 -10
- package/src/library/components/Gallery/GalleryViewer.tsx +144 -12
- package/src/library/components/Gallery/LayoutManager.ts +55 -6
- package/src/library/components/Gallery/constants.ts +6 -0
- package/src/library/components/Gallery/registry.ts +44 -0
- package/src/library/components/Gallery/types.ts +6 -0
- package/src/library/components/GameDesigner.tsx +165 -12
- package/src/library/components/InlineGalleryDisplay.tsx +41 -6
- package/src/library/components/LiveButton.tsx +8 -5
- package/src/library/components/MatchViewer.tsx +14 -3
- package/src/library/components/Panel/ExternalDrag.ts +122 -0
- package/src/library/components/Panel/MultiPanel.tsx +21 -0
- package/src/library/components/Panel/PanelContents.tsx +96 -1
- package/src/library/components/Panel/PanelTabStack.tsx +1 -0
- package/src/library/components/PanelSpark.tsx +12 -5
- 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/TopBar.tsx +2 -1
- package/src/library/components/TopBarPlayers.tsx +13 -15
- 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 +1316 -0
- package/src/library/components/Tutorial/targetRects.ts +273 -0
- package/src/library/components/Viewer.tsx +1 -0
- package/src/library/game/Chit.ts +28 -7
- package/src/library/game/ClientTimeState.ts +18 -0
- package/src/library/game/GalleryItemChitChildrenSource.ts +1 -0
- package/src/library/game/GalleryItemRawSource.ts +1 -0
- package/src/library/game/Game.ts +7 -0
- package/src/library/game/GameButton.ts +13 -1
- package/src/library/game/GameTheme.ts +4 -0
- package/src/library/game/Match.ts +12 -2
- package/src/library/game/ModalState.ts +3 -0
- package/src/library/game/Pick.ts +17 -4
- package/src/library/game/PlayerPromptStatusChit.ts +6 -4
- package/src/library/game/Prompt.ts +33 -2
- package/src/library/game/SparkChit.ts +9 -0
- package/src/library/game/Turn.ts +185 -70
- 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 +76 -5
- package/src/library/game/clientTransport/ClientTime.ts +75 -14
- package/src/library/game/serialize.test.ts +275 -0
- package/src/library/game/tutorial/TUTORIAL_GUIDE.md +416 -0
- package/src/library/game/tutorial/TutorialController.test.ts +731 -0
- package/src/library/game/tutorial/TutorialController.ts +1299 -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 +350 -0
- package/src/library/game/undo.test.ts +282 -0
- package/src/library/hooks/usePanelNavigation.tsx +65 -0
- package/src/library/hooks/useTimeController.tsx +10 -2
- package/src/library/hooks/useTutorial.tsx +80 -0
- package/src/library/index.ts +58 -2
- package/src/library/rendering/CameraWrapperPerspective.ts +17 -0
- package/src/library/rendering/ChitGalleryItemInstance.ts +30 -1
- package/src/library/rendering/ChitRenderInstance.ts +57 -4
- package/src/library/rendering/LightWrapper.ts +10 -1
- package/src/library/rendering/RootChitRenderInstance.ts +30 -1
- package/src/library/rendering/Splay.test.ts +60 -0
- package/src/library/rendering/Splay.ts +30 -9
- package/src/library/utilities/Annotations.ts +35 -7
- package/src/library/utilities/CanvasStack/CanvasStack.ts +6 -1
- package/src/library/utilities/CanvasStack/RichTextRenderer.ts +13 -0
- package/src/library/utilities/Dice.tsx +5 -1
- package/src/library/utilities/GalleryItemConversion.ts +5 -6
- package/src/library/utilities/TokenizedText.ts +6 -0
- package/src/library/utilities/zIndex.ts +1 -0
|
@@ -55,10 +55,22 @@ export type AiPlayerOptions = {
|
|
|
55
55
|
*/
|
|
56
56
|
temperature?: number;
|
|
57
57
|
/**
|
|
58
|
-
* Override the choice: return the index into `scored` to take,
|
|
59
|
-
*
|
|
58
|
+
* Override the choice: return the index into `scored` to take, undefined for the normal choice,
|
|
59
|
+
* or null to leave the prompt unanswered for now (call `recheck()` when that may have changed).
|
|
60
|
+
* Consulted for every prompt, the engine's Confirm included. For harnesses (forced moves in
|
|
61
|
+
* playouts, scripted openings, tutorials), not for game rules.
|
|
60
62
|
*/
|
|
61
|
-
choose?: (
|
|
63
|
+
choose?: (
|
|
64
|
+
scored: { option: AiOption; score: number }[],
|
|
65
|
+
ctx: AiContext<any, any, any>,
|
|
66
|
+
) => number | null | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* While this returns true for the current prompt, the bot leaves it unanswered (call `recheck()`
|
|
69
|
+
* when that may have changed). For harnesses that hold a bot back, like a tutorial waiting for the
|
|
70
|
+
* step that scripts its next move. It sees the prompt so it can let some through (the engine's own
|
|
71
|
+
* Confirm, which ends a turn the script never mentions).
|
|
72
|
+
*/
|
|
73
|
+
hold?: (prompt: PromptSerialization) => boolean;
|
|
62
74
|
/** Called after every decision with each option's score and the chosen index (for logging and audits). */
|
|
63
75
|
onDecision?: (decision: AiDecision) => void;
|
|
64
76
|
/**
|
|
@@ -232,7 +244,13 @@ export class AiClientPrompts<P extends PlayerChit, R extends RootChit<P>, M = an
|
|
|
232
244
|
}
|
|
233
245
|
this.running = true;
|
|
234
246
|
try {
|
|
235
|
-
while (
|
|
247
|
+
while (
|
|
248
|
+
this.latest &&
|
|
249
|
+
this.latest.seq !== this.handledSeq &&
|
|
250
|
+
!this.disposed &&
|
|
251
|
+
this._enabled &&
|
|
252
|
+
!this.options.hold?.(this.latest.prompt)
|
|
253
|
+
) {
|
|
236
254
|
const current = this.latest;
|
|
237
255
|
this.handledSeq = current.seq;
|
|
238
256
|
try {
|
|
@@ -252,6 +270,22 @@ export class AiClientPrompts<P extends PlayerChit, R extends RootChit<P>, M = an
|
|
|
252
270
|
}
|
|
253
271
|
}
|
|
254
272
|
|
|
273
|
+
/** Seq of a prompt `choose` chose to leave unanswered */
|
|
274
|
+
private heldSeq = -1;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Looks at the current prompt again: answers it if `hold` no longer holds the bot and `choose` no
|
|
278
|
+
* longer leaves it unanswered. Does nothing to a prompt the bot already answered.
|
|
279
|
+
*/
|
|
280
|
+
public recheck() {
|
|
281
|
+
if (this.disposed) return;
|
|
282
|
+
if (this.latest && this.heldSeq === this.latest.seq) {
|
|
283
|
+
this.heldSeq = -1;
|
|
284
|
+
this.handledSeq = -1;
|
|
285
|
+
}
|
|
286
|
+
void this.pump();
|
|
287
|
+
}
|
|
288
|
+
|
|
255
289
|
private isCurrent(entry: QueuedPrompt) {
|
|
256
290
|
return !this.disposed && this._enabled && this.latest?.seq === entry.seq;
|
|
257
291
|
}
|
|
@@ -328,6 +362,11 @@ export class AiClientPrompts<P extends PlayerChit, R extends RootChit<P>, M = an
|
|
|
328
362
|
}
|
|
329
363
|
|
|
330
364
|
const chosen = this.choose(prompt, candidates);
|
|
365
|
+
if (!chosen) {
|
|
366
|
+
// The harness wants this prompt left alone for now (see `recheck`)
|
|
367
|
+
this.heldSeq = entry.seq;
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
331
370
|
const memoryBefore = this.memory;
|
|
332
371
|
// Written before the answer is sent, so the save that follows the answer carries it
|
|
333
372
|
this.setMemory(applyPlan(memoryBefore, chosen.plan));
|
|
@@ -429,17 +468,12 @@ export class AiClientPrompts<P extends PlayerChit, R extends RootChit<P>, M = an
|
|
|
429
468
|
return button;
|
|
430
469
|
}
|
|
431
470
|
|
|
432
|
-
private choose(prompt: PromptSerialization, candidates: AiOption[]): Scored<M> {
|
|
471
|
+
private choose(prompt: PromptSerialization, candidates: AiOption[]): Scored<M> | null {
|
|
433
472
|
const ai = this.game.ai;
|
|
434
473
|
const rules: { [key: string]: AiRule<P, R, M> } = (ai?.rules as any) ?? {};
|
|
435
474
|
const defaultRule = ai?.default as AiRule<P, R, M> | undefined;
|
|
436
475
|
const ruleFor = (o: AiOption) => (o.key ? rules[o.key] : undefined) ?? defaultRule;
|
|
437
476
|
|
|
438
|
-
if (!candidates.some((o) => ruleFor(o))) {
|
|
439
|
-
candidates.forEach((o) => this.noteUntagged(o));
|
|
440
|
-
return { option: this.chooseLegacy(prompt, candidates), score: 0 };
|
|
441
|
-
}
|
|
442
|
-
|
|
443
477
|
const root = this.view.root as R;
|
|
444
478
|
const ctx: AiContext<P, R, M> = {
|
|
445
479
|
view: root,
|
|
@@ -452,6 +486,19 @@ export class AiClientPrompts<P extends PlayerChit, R extends RootChit<P>, M = an
|
|
|
452
486
|
params: this.options.params,
|
|
453
487
|
};
|
|
454
488
|
|
|
489
|
+
if (!candidates.some((o) => ruleFor(o))) {
|
|
490
|
+
// No rule applies (an untagged pick, or the engine's own Confirm): the harness still decides
|
|
491
|
+
candidates.forEach((o) => this.noteUntagged(o));
|
|
492
|
+
const unscored: Scored<M>[] = candidates.map((option) => ({ option, score: 0 }));
|
|
493
|
+
const forced = this.options.choose?.(unscored, ctx);
|
|
494
|
+
if (forced === null) return null;
|
|
495
|
+
if (forced !== undefined && forced >= 0 && forced < unscored.length) {
|
|
496
|
+
this.options.onDecision?.({ playerId: this.playerId, prompt: ctx.prompt, scored: unscored, chosen: forced, ctx });
|
|
497
|
+
return unscored[forced];
|
|
498
|
+
}
|
|
499
|
+
return { option: this.chooseLegacy(prompt, candidates), score: 0 };
|
|
500
|
+
}
|
|
501
|
+
|
|
455
502
|
const scored: Scored<M>[] = candidates.map((option) => {
|
|
456
503
|
const rule = ruleFor(option);
|
|
457
504
|
if (!rule) {
|
|
@@ -468,7 +515,9 @@ export class AiClientPrompts<P extends PlayerChit, R extends RootChit<P>, M = an
|
|
|
468
515
|
});
|
|
469
516
|
|
|
470
517
|
const scores = scored.map((s) => s.score);
|
|
471
|
-
|
|
518
|
+
const forced = this.options.choose?.(scored, ctx);
|
|
519
|
+
if (forced === null) return null;
|
|
520
|
+
let index = forced;
|
|
472
521
|
if (index === undefined || index < 0 || index >= scored.length) {
|
|
473
522
|
const temperature = this.options.temperature ?? this.game.ai?.temperature;
|
|
474
523
|
index =
|
|
@@ -85,6 +85,8 @@ export class AiPlayerView extends ConnectionObject {
|
|
|
85
85
|
|
|
86
86
|
Object.values(this.chitLookup).forEach((chit) => {
|
|
87
87
|
if (chit.id && !serialized[chit.id] && this.lastSerializedState[chit.id] !== undefined) {
|
|
88
|
+
// Back into its bag if it came from one; otherwise gone, as a visible fallback would keep it drawn
|
|
89
|
+
chit.forgetFallbackUnlessHidden();
|
|
88
90
|
if (chit.parentFallback) {
|
|
89
91
|
chit.beginDeserializing();
|
|
90
92
|
chit.setParent(chit.parentFallback, chit.parentOutlet ?? "graveyard");
|
|
@@ -3,7 +3,9 @@ import { ClockDetails, samePasses } from "../ClockDetails";
|
|
|
3
3
|
import { Connection } from "../Connection";
|
|
4
4
|
import { ConnectionObject } from "../ConnectionObject";
|
|
5
5
|
import { PlayerChit } from "../PlayerChit";
|
|
6
|
-
import { Prompt, PromptSerialization } from "../Prompt";
|
|
6
|
+
import { PickPrompt, Prompt, PromptAction, PromptSerialization } from "../Prompt";
|
|
7
|
+
import type { Chit } from "../Chit";
|
|
8
|
+
import type { FindChit } from "../Pick";
|
|
7
9
|
import { RootChit } from "../RootChit";
|
|
8
10
|
import { ServerPrompts } from "../serverTransport/ServerPrompts";
|
|
9
11
|
import { ClientTime } from "./ClientTime";
|
|
@@ -13,6 +15,20 @@ export class ClientPrompts<P extends PlayerChit, R extends RootChit<P>> extends
|
|
|
13
15
|
private serverPrompts: ServerPrompts<P, R>;
|
|
14
16
|
public currentPrompt = new EventChannel<Prompt | undefined>(undefined);
|
|
15
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Vets the player's answers before they are sent. Undefined (the default) lets everything through.
|
|
20
|
+
* A tutorial sets this so only the moves its current step asks for go through; everything else
|
|
21
|
+
* is dropped and `blocked` fires so the UI can say so.
|
|
22
|
+
*/
|
|
23
|
+
public guard?: (prompt: PickPrompt, action: PromptAction) => boolean | "handled";
|
|
24
|
+
/**
|
|
25
|
+
* Replaces what Undo does while set (a tutorial maps it to its Back). Whether Undo is offered does
|
|
26
|
+
* not change: it still shows only when the current prompt can be undone.
|
|
27
|
+
*/
|
|
28
|
+
public undoOverride = new EventChannel<{ undo: () => void } | undefined>(undefined);
|
|
29
|
+
/** Fires with the attempted action each time the guard drops one */
|
|
30
|
+
public blocked = new EventChannel<{ prompt: PickPrompt; action: PromptAction; at: number } | undefined>(undefined);
|
|
31
|
+
|
|
16
32
|
private _currentPromptSpec?: PromptSerialization;
|
|
17
33
|
|
|
18
34
|
constructor(
|
|
@@ -37,9 +53,59 @@ export class ClientPrompts<P extends PlayerChit, R extends RootChit<P>> extends
|
|
|
37
53
|
}
|
|
38
54
|
}
|
|
39
55
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
56
|
+
/** The staged prompt was inflated without some of its chits (staged in early): it is staged in again on time */
|
|
57
|
+
private _provisional = false;
|
|
58
|
+
|
|
59
|
+
private stageInPrompt(promptSpec: PromptSerialization, early = false) {
|
|
60
|
+
// A chit the prompt names that the client has not got. Staged in early (a pick asked for it, so the piece is
|
|
61
|
+
// still animating in), the board is a clock behind the prompt and a chit made in the prompt's own flush (a
|
|
62
|
+
// fresh drop target) is not here yet: it is left out, and the prompt is staged in again, whole, once the
|
|
63
|
+
// board catches up. On time, a missing chit is a bug to report, never an exception: this runs inside the
|
|
64
|
+
// client's state update (a clock listener), and an exception here left the board half-updated with the
|
|
65
|
+
// previous prompt still up, which swallowed every later move ("it gets stuck on me dragging my dealer").
|
|
66
|
+
const missing: string[] = [];
|
|
67
|
+
const find: FindChit = (id) => {
|
|
68
|
+
const chit = this.clientTime.findChitUnsafe(id);
|
|
69
|
+
if (!chit) missing.push(id);
|
|
70
|
+
return chit as Chit; // every pick drops a falsy chit (`.filter((d) => d)`)
|
|
71
|
+
};
|
|
72
|
+
let prompt: Prompt;
|
|
73
|
+
try {
|
|
74
|
+
prompt = Prompt.deserialize(promptSpec, find, this.clientTime.game.buttonLibrary);
|
|
75
|
+
} catch (e) {
|
|
76
|
+
console.error(`[prompt] could not inflate "${promptSpec.id}" at clock ${JSON.stringify(this.clientTime.currentClock.value)}:`, e);
|
|
77
|
+
// the caller already staged the previous prompt out: it must not stay up as the current one
|
|
78
|
+
this._currentPromptSpec = undefined;
|
|
79
|
+
this._provisional = false;
|
|
80
|
+
this.currentPrompt.value = undefined;
|
|
81
|
+
this.fixActiveLog();
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (missing.length && !early) {
|
|
85
|
+
console.error(
|
|
86
|
+
`[prompt] "${promptSpec.id}" names chits the client has not got at clock ${JSON.stringify(this.clientTime.currentClock.value)} (latest ${JSON.stringify(this.clientTime.maxClock.value)}): ${missing.join(", ")}`,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
// Only an early stage-in is provisional: on time the board will not catch up any further, so restaging it on every
|
|
90
|
+
// later clock event would only tear it down and log the same error again
|
|
91
|
+
this._provisional = early && missing.length > 0;
|
|
92
|
+
this._currentPromptSpec = this._provisional ? undefined : promptSpec;
|
|
93
|
+
if (prompt instanceof PickPrompt) {
|
|
94
|
+
prompt.guard = (action) => {
|
|
95
|
+
if (!this.guard) {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
const verdict = this.guard(prompt, action);
|
|
99
|
+
if (verdict === true) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
if (verdict === false) {
|
|
103
|
+
this.blocked.value = { prompt, action, at: Date.now() };
|
|
104
|
+
}
|
|
105
|
+
// "handled": the guard did something else with it (a tutorial's Undo is its Back)
|
|
106
|
+
return false;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
43
109
|
prompt.onResolve(async (success) => {
|
|
44
110
|
try {
|
|
45
111
|
this.fixActiveLog();
|
|
@@ -79,6 +145,11 @@ export class ClientPrompts<P extends PlayerChit, R extends RootChit<P>> extends
|
|
|
79
145
|
!isWaitingOnAnimations &&
|
|
80
146
|
samePasses(this.clientTime.currentClock.value, this.clientTime.maxClock.value)
|
|
81
147
|
) {
|
|
148
|
+
// Staged in early and whole: it is the prompt
|
|
149
|
+
if (this.currentPrompt.value && !this._provisional && this.currentPrompt.value.isSameSerialization(promptSpec)) {
|
|
150
|
+
this._currentPromptSpec = promptSpec;
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
82
153
|
if (this.currentPrompt.value) {
|
|
83
154
|
this.currentPrompt.value.stageOut();
|
|
84
155
|
}
|
|
@@ -99,7 +170,7 @@ export class ClientPrompts<P extends PlayerChit, R extends RootChit<P>> extends
|
|
|
99
170
|
if (this.currentPrompt.value) {
|
|
100
171
|
this.currentPrompt.value.stageOut();
|
|
101
172
|
}
|
|
102
|
-
this.stageInPrompt(promptSpec);
|
|
173
|
+
this.stageInPrompt(promptSpec, true);
|
|
103
174
|
} else {
|
|
104
175
|
this._currentPromptSpec = undefined;
|
|
105
176
|
if (this.currentPrompt.value) {
|
|
@@ -6,6 +6,7 @@ import { ClockDetails, samePasses } from "../ClockDetails";
|
|
|
6
6
|
import { Connection } from "../Connection";
|
|
7
7
|
import { ConnectionObject } from "../ConnectionObject";
|
|
8
8
|
import { Game } from "../Game";
|
|
9
|
+
import { OrderedOutlet } from "../OrderedOutlet";
|
|
9
10
|
import { RootChit } from "../RootChit";
|
|
10
11
|
import { ServerTime } from "../serverTransport/ServerTime";
|
|
11
12
|
import { ClientPrompts } from "./ClientPrompts";
|
|
@@ -27,15 +28,11 @@ export class ClientTime extends ConnectionObject {
|
|
|
27
28
|
this.register(this.clientTimeState.targetClock.on(() => this.processNewTargetClock()));
|
|
28
29
|
this.register(
|
|
29
30
|
this.clientTimeState.isWaitingOnAnimations.on((isWaiting) => {
|
|
30
|
-
if (
|
|
31
|
-
!isWaiting &&
|
|
32
|
-
this.clientTimeState.live.value &&
|
|
33
|
-
this.clientTimeState.targetClock.value < this.maxClock.value.clock
|
|
34
|
-
) {
|
|
35
|
-
this.clientTimeState.targetClock.value++;
|
|
36
|
-
}
|
|
31
|
+
if (!isWaiting) this.playOn();
|
|
37
32
|
}),
|
|
38
33
|
);
|
|
34
|
+
// A hold that is raised or lifted lets the board carry on from where it stopped
|
|
35
|
+
this.register(this.clientTimeState.timelineHold.on(() => this.playOn(), false));
|
|
39
36
|
|
|
40
37
|
this.clientTimeState.animationSpeedMultiplier.value =
|
|
41
38
|
parseFloat(localStorage["animationSpeedMultiplier"] ?? "1") || 1;
|
|
@@ -74,7 +71,7 @@ export class ClientTime extends ConnectionObject {
|
|
|
74
71
|
public readonly findChit: (id: string) => Chit = (id: string) => {
|
|
75
72
|
const result = this.chitLookup[id];
|
|
76
73
|
if (!result) {
|
|
77
|
-
throw new Error(
|
|
74
|
+
throw new Error(`Cannot find chit ${id}`);
|
|
78
75
|
}
|
|
79
76
|
return result;
|
|
80
77
|
};
|
|
@@ -89,7 +86,9 @@ export class ClientTime extends ConnectionObject {
|
|
|
89
86
|
if (this.clientTimeState.targetClock.value <= newTime || newTime === 0) {
|
|
90
87
|
this.clientTimeState.isLoading.value = true;
|
|
91
88
|
|
|
92
|
-
|
|
89
|
+
const skip = this.clientTimeState.skipReplay.value || this.clientTimeState.skipInitialReplay;
|
|
90
|
+
this.clientTimeState.skipInitialReplay = false;
|
|
91
|
+
if (!skip) {
|
|
93
92
|
this.startTime = newTime;
|
|
94
93
|
this.clientTimeState.targetClock.value = newTime;
|
|
95
94
|
} else {
|
|
@@ -98,6 +97,22 @@ export class ClientTime extends ConnectionObject {
|
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
99
|
|
|
100
|
+
/** The furthest clock the board may play to right now (the game's latest, or a tutorial's hold) */
|
|
101
|
+
private get playableClock() {
|
|
102
|
+
return this.clientTimeState.playableClock(this.maxClock.value.clock);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Moves the board one clock on, if it is live, idle and allowed further */
|
|
106
|
+
private playOn() {
|
|
107
|
+
if (
|
|
108
|
+
!this.clientTimeState.isWaitingOnAnimations.value &&
|
|
109
|
+
this.clientTimeState.live.value &&
|
|
110
|
+
this.clientTimeState.targetClock.value < this.playableClock
|
|
111
|
+
) {
|
|
112
|
+
this.clientTimeState.targetClock.value++;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
101
116
|
public async newMaxClock(newMaxClock: ClockDetails) {
|
|
102
117
|
const oldClock = this.maxClock.value;
|
|
103
118
|
const isSamePass = samePasses(oldClock, newMaxClock);
|
|
@@ -110,15 +125,15 @@ export class ClientTime extends ConnectionObject {
|
|
|
110
125
|
if (this.clientTimeState.live.value || !isSamePass) {
|
|
111
126
|
if (
|
|
112
127
|
!this.clientTimeState.isWaitingOnAnimations.value &&
|
|
113
|
-
this.clientTimeState.targetClock.value < this.
|
|
128
|
+
this.clientTimeState.targetClock.value < this.playableClock
|
|
114
129
|
) {
|
|
115
130
|
this.clientTimeState.targetClock.value++;
|
|
116
131
|
} else if (!isSamePass && !this.clientTimeState.isWaitingOnAnimations.value) {
|
|
117
|
-
this.clientTimeState.targetClock.value = this.
|
|
132
|
+
this.clientTimeState.targetClock.value = this.playableClock;
|
|
118
133
|
this.processNewTargetClock();
|
|
119
134
|
} else if (!this.clientTimeState.isWaitingOnAnimations.value) {
|
|
120
135
|
// some other use has reset...
|
|
121
|
-
this.clientTimeState.targetClock.value = this.
|
|
136
|
+
this.clientTimeState.targetClock.value = this.playableClock;
|
|
122
137
|
} else {
|
|
123
138
|
this.processNewTargetClock();
|
|
124
139
|
}
|
|
@@ -135,8 +150,9 @@ export class ClientTime extends ConnectionObject {
|
|
|
135
150
|
const newTargetClock = this.clientTimeState.targetClock.value;
|
|
136
151
|
const currentClock = this.currentClock.value;
|
|
137
152
|
|
|
138
|
-
if (newTargetClock > this.
|
|
139
|
-
|
|
153
|
+
if (newTargetClock > this.playableClock) {
|
|
154
|
+
// past the game's latest clock, or past a tutorial's hold (the Live and Forward buttons too)
|
|
155
|
+
this.clientTimeState.targetClock.value = this.playableClock;
|
|
140
156
|
return;
|
|
141
157
|
}
|
|
142
158
|
if (newTargetClock < 1) {
|
|
@@ -175,6 +191,8 @@ export class ClientTime extends ConnectionObject {
|
|
|
175
191
|
|
|
176
192
|
Object.values(this.chitLookup).forEach((chit) => {
|
|
177
193
|
if (chit.id && !serializedChits[chit.id]) {
|
|
194
|
+
// Back into its bag if it came from one; otherwise gone, as a visible fallback would keep it drawn
|
|
195
|
+
chit.forgetFallbackUnlessHidden();
|
|
178
196
|
if (chit.parentFallback) {
|
|
179
197
|
chit.beginDeserializing();
|
|
180
198
|
chit.setParent(chit.parentFallback, chit.parentOutlet ?? "graveyard");
|
|
@@ -211,6 +229,25 @@ export class ClientTime extends ConnectionObject {
|
|
|
211
229
|
|
|
212
230
|
chits.forEach((chit) => chit.doneDeserializing());
|
|
213
231
|
|
|
232
|
+
// A dragged chit is moved onto its drop target here as the drag ends, before the server answers. Its state
|
|
233
|
+
// then puts it back under its real parent, but into an ordered outlet only the parent's own state fills: when
|
|
234
|
+
// the parent did not change (a piece moved within a factory), the chit was its child yet missing from the
|
|
235
|
+
// list, so anything reading the list lost it ("it gets stuck on me dragging my dealer"). Load such a parent
|
|
236
|
+
// again from its current state.
|
|
237
|
+
const owners = new Set<Chit>();
|
|
238
|
+
chits.forEach((chit) => {
|
|
239
|
+
const parent = chit.parent;
|
|
240
|
+
const outlet = parent && chit.parentOutlet ? (parent as any)[chit.parentOutlet] : undefined;
|
|
241
|
+
if (outlet instanceof OrderedOutlet && !outlet.some((c) => c === chit) && parent!.id && this.lastSerializedState[parent!.id]) {
|
|
242
|
+
owners.add(parent!);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
owners.forEach((owner) => {
|
|
246
|
+
owner.beginDeserializing();
|
|
247
|
+
owner.deserialize(this.lastSerializedState[owner.id!], this.findChit, true);
|
|
248
|
+
owner.doneDeserializing();
|
|
249
|
+
});
|
|
250
|
+
|
|
214
251
|
this.rootChit.value = this.findChit("root") as RootChit<any>;
|
|
215
252
|
|
|
216
253
|
// sometimes deserializing chits does not result in animations (maybe a pure texture change?)
|
|
@@ -225,6 +262,30 @@ export class ClientTime extends ConnectionObject {
|
|
|
225
262
|
}
|
|
226
263
|
}
|
|
227
264
|
|
|
265
|
+
/**
|
|
266
|
+
* Changes a chit in this client's view only: `change` sets properties on the local copy and the
|
|
267
|
+
* renderer picks it up (and animates it) like any change from the server. The server never hears
|
|
268
|
+
* of it. A later server change to the same chit overwrites it; `restoreChit` puts it back sooner.
|
|
269
|
+
* For tutorials and demos (a card flipping over while the narration talks about it).
|
|
270
|
+
*/
|
|
271
|
+
public poseChit(chit: Chit, change: (chit: Chit) => void) {
|
|
272
|
+
chit.beginDeserializing();
|
|
273
|
+
try {
|
|
274
|
+
change(chit);
|
|
275
|
+
} finally {
|
|
276
|
+
chit.doneDeserializing();
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** Puts a chit's properties back to the server's state for the moment on screen, undoing `poseChit`. */
|
|
281
|
+
public restoreChit(chit: Chit) {
|
|
282
|
+
const value = chit.id ? this.lastSerializedState[chit.id] : undefined;
|
|
283
|
+
if (!value) return;
|
|
284
|
+
chit.beginDeserializing();
|
|
285
|
+
chit.deserialize(value, this.findChit, true);
|
|
286
|
+
chit.doneDeserializing();
|
|
287
|
+
}
|
|
288
|
+
|
|
228
289
|
public async chitHistory(chits: Chit[]) {
|
|
229
290
|
const sparkHistory = await this.serverTime.chitHistory(chits.map((s) => s.id!));
|
|
230
291
|
const result: { [id: string]: { clock: number; chit: Chit }[] } = {};
|