@pretty-chitty/core 1.2.18 → 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/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/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 -43
- 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 +31 -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 +70 -1
- 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 +46 -14
- 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 +8 -6
- package/dist/components/TokenizedMessage.d.ts.map +1 -1
- package/dist/components/TokenizedMessage.js +21 -54
- package/dist/components/TokenizedMessage.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 +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 +22 -7
- 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/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 +14 -1
- 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 +74 -2
- package/dist/game/Match.d.ts.map +1 -1
- package/dist/game/Match.js +155 -4
- 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 +16 -0
- package/dist/game/Pick.d.ts.map +1 -1
- package/dist/game/Pick.js +32 -1
- 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 +8 -0
- package/dist/game/PlayerPromptStatusChit.d.ts.map +1 -1
- package/dist/game/PlayerPromptStatusChit.js +8 -2
- 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 +20 -4
- package/dist/game/Turn.d.ts.map +1 -1
- package/dist/game/Turn.js +191 -67
- package/dist/game/Turn.js.map +1 -1
- package/dist/game/TurnState.d.ts +20 -1
- package/dist/game/TurnState.d.ts.map +1 -1
- package/dist/game/TurnState.js +22 -3
- package/dist/game/TurnState.js.map +1 -1
- package/dist/game/ai/AiClientPrompts.d.ts +177 -0
- package/dist/game/ai/AiClientPrompts.d.ts.map +1 -0
- package/dist/game/ai/AiClientPrompts.js +561 -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 +91 -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/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/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/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 +57 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.html +12 -0
- package/dist/index.js +27 -3
- 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 +13 -0
- package/dist/utilities/CanvasStack/CanvasStack.d.ts.map +1 -1
- package/dist/utilities/CanvasStack/CanvasStack.js +66 -15
- package/dist/utilities/CanvasStack/CanvasStack.js.map +1 -1
- package/dist/utilities/TokenizedText.d.ts +55 -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/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/ClientTrustMatchViewer.tsx +32 -2
- package/src/library/components/ContextGalleryDisplay.tsx +2 -0
- package/src/library/components/DemoWrapper.tsx +147 -52
- package/src/library/components/FullScreenGalleryDisplay.tsx +3 -0
- package/src/library/components/Gallery/BuiltItem.ts +34 -9
- package/src/library/components/Gallery/GalleryController.ts +75 -2
- 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 +125 -33
- 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 +30 -95
- package/src/library/components/TopBarPlayers.tsx +18 -10
- 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 +23 -7
- package/src/library/game/ClientTimeState.ts +18 -0
- package/src/library/game/ConnectionTransport.ts +12 -3
- package/src/library/game/Game.ts +16 -1
- package/src/library/game/GameTheme.ts +4 -0
- package/src/library/game/Match.ts +174 -5
- package/src/library/game/MatchStorage.ts +14 -4
- package/src/library/game/Pick.ts +36 -1
- package/src/library/game/PlayerChit.ts +4 -1
- package/src/library/game/PlayerInfo.ts +13 -3
- package/src/library/game/PlayerPromptStatusChit.ts +8 -2
- package/src/library/game/Prompt.ts +20 -0
- package/src/library/game/Turn.ts +198 -68
- package/src/library/game/TurnState.ts +34 -3
- package/src/library/game/ai/AI_GUIDE.md +444 -0
- package/src/library/game/ai/AiClientPrompts.ts +730 -0
- package/src/library/game/ai/AiLiveView.ts +63 -0
- package/src/library/game/ai/AiPlayerView.ts +114 -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/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/useTokenMap.ts +2 -6
- package/src/library/hooks/useTutorial.tsx +76 -0
- package/src/library/index.ts +91 -4
- 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 +74 -29
- package/src/library/utilities/TokenizedText.test.ts +32 -0
- package/src/library/utilities/TokenizedText.ts +103 -0
- package/src/library/utilities/zIndex.ts +1 -0
package/dist/game/Turn.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Chit } from "./Chit";
|
|
2
|
+
import { buildTokenMap, tokenizedMessageToText } from "../utilities/TokenizedText";
|
|
2
3
|
import { NoValidMovesPrompt, PickPrompt } from "./Prompt";
|
|
3
4
|
import { Pick } from "./Pick";
|
|
4
5
|
import { Confirm, GameButton } from "./GameButton";
|
|
@@ -37,13 +38,27 @@ import { Confirm, GameButton } from "./GameButton";
|
|
|
37
38
|
* @group Core Game Elements
|
|
38
39
|
*/
|
|
39
40
|
export class Turn {
|
|
41
|
+
/** Drop every checkpoint that includes the step at `index`, which is about to change. */
|
|
42
|
+
dropCheckpointsFrom(index) {
|
|
43
|
+
if (this._checkpoints.length && this._checkpoints[this._checkpoints.length - 1].nextIndex > index) {
|
|
44
|
+
this._checkpoints = this._checkpoints.filter((c) => c.nextIndex <= index);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
40
47
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
48
|
+
* Checkpoints stay at least `serializeCheckpointInterval` steps apart, except the last one,
|
|
49
|
+
* which marks wherever the latest walk ended and is replaced as walks reach further.
|
|
43
50
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
addCheckpoint(checkpoint) {
|
|
52
|
+
const checkpoints = this._checkpoints;
|
|
53
|
+
const last = checkpoints[checkpoints.length - 1];
|
|
54
|
+
if (last && last.nextIndex >= checkpoint.nextIndex) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const previous = checkpoints.length >= 2 ? checkpoints[checkpoints.length - 2].nextIndex : 0;
|
|
58
|
+
if (last && last.nextIndex - previous < Turn.serializeCheckpointInterval) {
|
|
59
|
+
checkpoints.pop();
|
|
60
|
+
}
|
|
61
|
+
checkpoints.push(checkpoint);
|
|
47
62
|
}
|
|
48
63
|
get statePool() {
|
|
49
64
|
if (this.parent)
|
|
@@ -118,9 +133,20 @@ export class Turn {
|
|
|
118
133
|
this.lockedChitStates = {};
|
|
119
134
|
this.lastChitStates = {};
|
|
120
135
|
this.dirtyChitIds = new Set();
|
|
136
|
+
// Locked roots of absorbed sub-turns. A sub-turn never deletes its own locked roots, so the next
|
|
137
|
+
// flush here checks whether any of them lost their parent.
|
|
138
|
+
this.absorbedRootIds = new Set();
|
|
121
139
|
this.pendingNewChits = new Set();
|
|
122
140
|
this._statePool = undefined;
|
|
123
|
-
this.
|
|
141
|
+
// serialize() replays this turn's diffs from its locked snapshot. Checkpoints are that replay
|
|
142
|
+
// captured part-way, so a request walks only the steps after the nearest one. They cover only
|
|
143
|
+
// steps that can no longer change (flushes, and sub-turn steps every turn of which the parent
|
|
144
|
+
// has absorbed) and merge sub-turns in absorption order, so they hold the same chit states for
|
|
145
|
+
// every player and are shared by every connection to the match.
|
|
146
|
+
this._checkpoints = [];
|
|
147
|
+
// Set once the parent has absorbed this turn. From then on we are only walked by the parent, which
|
|
148
|
+
// holds the chit map we started from, so we keep neither our locked snapshot nor checkpoints.
|
|
149
|
+
this.absorbed = false;
|
|
124
150
|
/**
|
|
125
151
|
* Locates a chit by its ID. If not found, will throw.
|
|
126
152
|
* @param id
|
|
@@ -166,12 +192,18 @@ export class Turn {
|
|
|
166
192
|
}
|
|
167
193
|
return p.id;
|
|
168
194
|
});
|
|
169
|
-
// now serialize all chits in their "locked" state
|
|
195
|
+
// now serialize all chits in their "locked" state. createTurn flushes the parent right before
|
|
196
|
+
// building us, so a clean chit's state there is already current and interned.
|
|
197
|
+
const parentStates = this.parent?.lastChitStates;
|
|
170
198
|
Object.values(this.chitLookup).forEach((c) => {
|
|
171
199
|
if (!c.id) {
|
|
172
200
|
throw new Error("Cannot serialize a chit without an id");
|
|
173
201
|
}
|
|
174
|
-
|
|
202
|
+
const parentState = parentStates?.[c.id];
|
|
203
|
+
this.lastChitStates[c.id] = this.lockedChitStates[c.id] =
|
|
204
|
+
parentState !== undefined && parentState !== Chit.deletedIfSerialized() && !c._dirty
|
|
205
|
+
? parentState
|
|
206
|
+
: this.internState(c.serialize(this._playerIds));
|
|
175
207
|
});
|
|
176
208
|
}
|
|
177
209
|
/**
|
|
@@ -206,6 +238,19 @@ export class Turn {
|
|
|
206
238
|
return results[counter++];
|
|
207
239
|
};
|
|
208
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* Records what a player is being asked for: the tokenized message for the in-game UI, and a plain-text version
|
|
243
|
+
* (player tokens become names, etc.) for anything that can only show text.
|
|
244
|
+
*/
|
|
245
|
+
setPromptMessage(player, message) {
|
|
246
|
+
player.promptStatus.latestPromptMessage = message;
|
|
247
|
+
if (message === undefined) {
|
|
248
|
+
player.promptStatus.latestPromptMessageText = undefined;
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const tokenMap = buildTokenMap(this.match.game.tokenMap, this.rootChit.players.map((p) => p));
|
|
252
|
+
player.promptStatus.latestPromptMessageText = tokenizedMessageToText(message, tokenMap);
|
|
253
|
+
}
|
|
209
254
|
/**
|
|
210
255
|
* Add a game log message to the last flush step
|
|
211
256
|
* @param message
|
|
@@ -222,6 +267,7 @@ export class Turn {
|
|
|
222
267
|
}
|
|
223
268
|
const flushStep = step;
|
|
224
269
|
flushStep.log = message;
|
|
270
|
+
this.dropCheckpointsFrom(this.clockSteps.length - 1);
|
|
225
271
|
}
|
|
226
272
|
/**
|
|
227
273
|
* Append a game log message to the last flush step that has a game log message
|
|
@@ -243,6 +289,7 @@ export class Turn {
|
|
|
243
289
|
message = message(step.log);
|
|
244
290
|
}
|
|
245
291
|
step.log = message;
|
|
292
|
+
this.dropCheckpointsFrom(lastIndex);
|
|
246
293
|
}
|
|
247
294
|
/**
|
|
248
295
|
* Compress the history in the timeline such that a user with maybe many moves (and changing their minds) won't
|
|
@@ -266,8 +313,8 @@ export class Turn {
|
|
|
266
313
|
hasChange = true;
|
|
267
314
|
}
|
|
268
315
|
if (hasChange) {
|
|
269
|
-
//
|
|
270
|
-
this.
|
|
316
|
+
// The merged step changed in place: checkpoints that include it are stale.
|
|
317
|
+
this.dropCheckpointsFrom(this.clockSteps.length - 1);
|
|
271
318
|
this.pass++;
|
|
272
319
|
// No trailing force-flush: it would only push an empty FlushClockStep (no chit
|
|
273
320
|
// diff, no log) that the client has to walk through for no visual change. The
|
|
@@ -334,17 +381,22 @@ export class Turn {
|
|
|
334
381
|
sawChange = true;
|
|
335
382
|
}
|
|
336
383
|
}
|
|
337
|
-
|
|
338
|
-
//
|
|
339
|
-
const deletedRoots =
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
384
|
+
// 3. Detect deleted chits — orphans in lastChitStates. Losing a parent marks a chit dirty, so
|
|
385
|
+
// only this flush's dirty chits and the roots of absorbed sub-turns can have become orphans.
|
|
386
|
+
const deletedRoots = new Set();
|
|
387
|
+
const checkOrphan = (id) => {
|
|
388
|
+
const lastState = this.lastChitStates[id];
|
|
389
|
+
if (lastState === undefined || lastState === Chit.deletedIfSerialized())
|
|
390
|
+
return;
|
|
343
391
|
const chit = this.chitLookup[id];
|
|
344
392
|
if (chit && !chit.parent && !this.chitsToLock.includes(chit)) {
|
|
345
|
-
deletedRoots.
|
|
393
|
+
deletedRoots.add(chit);
|
|
346
394
|
}
|
|
347
|
-
}
|
|
395
|
+
};
|
|
396
|
+
this.dirtyChitIds.forEach(checkOrphan);
|
|
397
|
+
this.absorbedRootIds.forEach(checkOrphan);
|
|
398
|
+
this.dirtyChitIds.clear();
|
|
399
|
+
this.absorbedRootIds.clear();
|
|
348
400
|
for (const chit of deletedRoots) {
|
|
349
401
|
if (chit.id) {
|
|
350
402
|
sawChange = true;
|
|
@@ -366,9 +418,9 @@ export class Turn {
|
|
|
366
418
|
if (this.activeSubTurns.length) {
|
|
367
419
|
throw new Error("Cannot flush while subturns are active");
|
|
368
420
|
}
|
|
421
|
+
// Appending leaves every checkpoint valid, ours and our ancestors': theirs stop before the
|
|
422
|
+
// step that holds us until we have been absorbed.
|
|
369
423
|
this.clockSteps.push(new FlushClockStep(this.clock, newStates));
|
|
370
|
-
// Ancestors' caches included our prior contribution; the new step makes them stale.
|
|
371
|
-
this.parent?.invalidateSerializeCache();
|
|
372
424
|
}
|
|
373
425
|
}
|
|
374
426
|
/**
|
|
@@ -414,8 +466,10 @@ export class Turn {
|
|
|
414
466
|
Chit.walk(chits, (chit) => chit.unlock(this));
|
|
415
467
|
const turn = new Turn(id, this.match, s, cb, chits, player, this);
|
|
416
468
|
this.decisionIndex++;
|
|
469
|
+
let step;
|
|
417
470
|
if (this.activeSubTurns.length === 0) {
|
|
418
|
-
|
|
471
|
+
step = new SubTurnsClockStep(this.clock, [turn]);
|
|
472
|
+
this.clockSteps.push(step);
|
|
419
473
|
}
|
|
420
474
|
else {
|
|
421
475
|
const lastStep = this.clockSteps[this.clockSteps.length - 1];
|
|
@@ -423,9 +477,9 @@ export class Turn {
|
|
|
423
477
|
throw new Error("Unexpected clocksteps stage");
|
|
424
478
|
}
|
|
425
479
|
lastStep.turns.push(turn);
|
|
480
|
+
step = lastStep;
|
|
426
481
|
}
|
|
427
|
-
//
|
|
428
|
-
this.invalidateSerializeCache();
|
|
482
|
+
// Neither case touches a checkpoint: none reaches a step with a turn still to absorb.
|
|
429
483
|
this.activeSubTurns.push(turn);
|
|
430
484
|
//make sure flow goes to next tick
|
|
431
485
|
await new Promise((resolve) => queueMicrotask(() => resolve(true)));
|
|
@@ -440,14 +494,18 @@ export class Turn {
|
|
|
440
494
|
}
|
|
441
495
|
});
|
|
442
496
|
this.lastChitStates = { ...this.lastChitStates, ...turn.lastChitStates };
|
|
497
|
+
turn.chitsToLock.forEach((chit) => chit.id && this.absorbedRootIds.add(chit.id));
|
|
498
|
+
// serialize() merges the step's turns in this order, so a chit written by several parallel
|
|
499
|
+
// turns serializes as the engine now holds it.
|
|
500
|
+
step.absorbed.push(turn);
|
|
443
501
|
turn.releasePostAbsorptionRefs();
|
|
444
502
|
return result;
|
|
445
503
|
}
|
|
446
504
|
/**
|
|
447
505
|
* Called by the parent right after it has absorbed our `chitLookup` and `lastChitStates`.
|
|
448
506
|
* After this we will only ever be walked via `serialize` / `chitsHistory` / `gameLog`,
|
|
449
|
-
*
|
|
450
|
-
* bookkeeping to keep finished sub-turns from pinning hundreds of chit references.
|
|
507
|
+
* and only by the parent, which needs nothing of ours but `clockSteps` — so drop the heavy
|
|
508
|
+
* per-chit bookkeeping to keep finished sub-turns from pinning hundreds of chit references.
|
|
451
509
|
* @internal
|
|
452
510
|
*/
|
|
453
511
|
releasePostAbsorptionRefs() {
|
|
@@ -456,11 +514,19 @@ export class Turn {
|
|
|
456
514
|
this.lastChitStates = {};
|
|
457
515
|
this.pendingNewChits.clear();
|
|
458
516
|
this.dirtyChitIds.clear();
|
|
459
|
-
this.
|
|
517
|
+
this.absorbedRootIds.clear();
|
|
518
|
+
if (!Turn.releaseAbsorbedTurns)
|
|
519
|
+
return;
|
|
520
|
+
// The locked snapshot and every checkpoint are full copies of the chit map, and a long game
|
|
521
|
+
// has hundreds of finished turns. The parent walks into us with its own map, which at our
|
|
522
|
+
// step holds exactly what the snapshot held, so a finished turn keeps neither.
|
|
523
|
+
this.absorbed = true;
|
|
524
|
+
this.lockedChitStates = {};
|
|
525
|
+
this._checkpoints = [];
|
|
460
526
|
}
|
|
461
527
|
async runParallelTurns(players, chits, action) {
|
|
462
528
|
// the whole point of this function is so we can mark all players as having a prompt waiting for them
|
|
463
|
-
players.forEach((player) => (player
|
|
529
|
+
players.forEach((player) => this.setPromptMessage(player, "Waiting for turn to complete"));
|
|
464
530
|
const turns = players.map((player) => this.createTurn(chits(player), player, (turn) => action(player, turn)));
|
|
465
531
|
return await Promise.all(turns);
|
|
466
532
|
}
|
|
@@ -684,7 +750,8 @@ export class Turn {
|
|
|
684
750
|
}
|
|
685
751
|
};
|
|
686
752
|
// Seed with the initial locked state so chits that never diff in this turn still
|
|
687
|
-
// surface their starting form (flush steps now hold diffs only).
|
|
753
|
+
// surface their starting form (flush steps now hold diffs only). A finished turn has no
|
|
754
|
+
// snapshot; the parent already logged that state before walking into it.
|
|
688
755
|
ids.forEach((id) => {
|
|
689
756
|
const initial = this.lockedChitStates[id];
|
|
690
757
|
if (initial !== undefined) {
|
|
@@ -708,32 +775,53 @@ export class Turn {
|
|
|
708
775
|
});
|
|
709
776
|
return result;
|
|
710
777
|
}
|
|
711
|
-
/**
|
|
712
|
-
|
|
778
|
+
/**
|
|
779
|
+
* `into` is the parent's working chit map while it walks this turn. A finished turn has no
|
|
780
|
+
* snapshot of its own and writes its diffs straight into it; the parent then needs no merge.
|
|
781
|
+
* @internal
|
|
782
|
+
*/
|
|
783
|
+
serialize(playerId, clock, into) {
|
|
713
784
|
clock = Math.max(0, Math.min(clock, this.playerVisibleClockTime(playerId)));
|
|
714
785
|
let chits;
|
|
715
786
|
let subTurns;
|
|
716
787
|
let log;
|
|
717
788
|
let resultingClock;
|
|
718
789
|
let index;
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
790
|
+
// Resume from the furthest checkpoint that ends at or before the target clock
|
|
791
|
+
let checkpoint;
|
|
792
|
+
for (let i = this._checkpoints.length - 1; i >= 0; i--) {
|
|
793
|
+
if (this._checkpoints[i].resultingClock <= clock) {
|
|
794
|
+
checkpoint = this._checkpoints[i];
|
|
795
|
+
break;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
if (checkpoint) {
|
|
799
|
+
chits = { ...checkpoint.chits };
|
|
800
|
+
subTurns = checkpoint.subTurns ? { ...checkpoint.subTurns } : undefined;
|
|
801
|
+
log = checkpoint.log ? { ...checkpoint.log } : undefined;
|
|
802
|
+
resultingClock = checkpoint.resultingClock;
|
|
803
|
+
index = checkpoint.nextIndex;
|
|
726
804
|
}
|
|
727
805
|
else {
|
|
728
806
|
// Diff-replay: seed with the initial locked snapshot and merge every flush diff
|
|
729
|
-
// up to (but not including) the target clock.
|
|
730
|
-
|
|
807
|
+
// up to (but not including) the target clock. A finished turn's snapshot was the parent's
|
|
808
|
+
// map at this step, which is what the parent hands us.
|
|
809
|
+
chits = this.absorbed ? (into ?? {}) : { ...this.lockedChitStates };
|
|
731
810
|
subTurns = undefined;
|
|
732
811
|
log = undefined;
|
|
733
812
|
resultingClock = -1;
|
|
734
813
|
index = 0;
|
|
735
814
|
}
|
|
736
|
-
|
|
815
|
+
const snapshot = () => ({
|
|
816
|
+
nextIndex: index,
|
|
817
|
+
chits: { ...chits },
|
|
818
|
+
subTurns: subTurns ? { ...subTurns } : undefined,
|
|
819
|
+
log: log ? { ...log } : undefined,
|
|
820
|
+
resultingClock: resultingClock === -1 ? clock : resultingClock,
|
|
821
|
+
});
|
|
822
|
+
// True while every step walked is final and was consumed whole, so the walk may be checkpointed
|
|
823
|
+
let checkpointable = Turn.serializeCheckpoints && !this.absorbed;
|
|
824
|
+
let lastCheckpointIndex = index;
|
|
737
825
|
while (index < this.clockSteps.length) {
|
|
738
826
|
const clockStep = this.clockSteps[index];
|
|
739
827
|
if (clockStep.startClock >= clock)
|
|
@@ -751,13 +839,21 @@ export class Turn {
|
|
|
751
839
|
subTurns = {};
|
|
752
840
|
resultingClock = clockStep.startClock;
|
|
753
841
|
let remainingClocksToSpend = clock - clockStep.startClock;
|
|
754
|
-
|
|
842
|
+
// A step every turn of which has been absorbed is final, and asked for in full it reads the
|
|
843
|
+
// same for every player: its turns merge in absorption order, the order their changes
|
|
844
|
+
// landed in `lastChitStates`, so a chit written by two parallel turns serializes as the
|
|
845
|
+
// engine holds it. A step still in motion, or asked for part-way, is walked as this player
|
|
846
|
+
// may see it, and the walk stops there: a later request has to re-walk it.
|
|
847
|
+
const final = clockStep.fullyAbsorbed && clock >= clockStep.endClock();
|
|
848
|
+
for (const turn of final ? clockStep.absorbed : clockStep.visibleTurns(playerId)) {
|
|
755
849
|
const time = Math.max(remainingClocksToSpend, 0);
|
|
756
850
|
if (time <= 0)
|
|
757
851
|
break;
|
|
758
852
|
// we are going forward so we never want to have a turn go backwards. ever.
|
|
759
|
-
const serialized = turn.serialize(playerId, time);
|
|
760
|
-
|
|
853
|
+
const serialized = turn.serialize(playerId, time, chits);
|
|
854
|
+
if (serialized.chits !== chits) {
|
|
855
|
+
Object.assign(chits, serialized.chits);
|
|
856
|
+
}
|
|
761
857
|
resultingClock += serialized.clockDetails.clock;
|
|
762
858
|
remainingClocksToSpend -= serialized.clockDetails.clock;
|
|
763
859
|
subTurns[turn.id] = serialized.clockDetails;
|
|
@@ -765,13 +861,8 @@ export class Turn {
|
|
|
765
861
|
log = { message: serialized.log.message, clock: serialized.log.clock + clockStep.startClock };
|
|
766
862
|
}
|
|
767
863
|
}
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
// sub-turn was asked for at least its full clock time. Otherwise a future
|
|
771
|
-
// request at a higher `clock` needs to re-ask the sub-turn for more time,
|
|
772
|
-
// which means re-processing this same step.
|
|
773
|
-
if (clock < clockStep.endClock(playerId)) {
|
|
774
|
-
cacheable = false;
|
|
864
|
+
if (!final) {
|
|
865
|
+
checkpointable = false;
|
|
775
866
|
break;
|
|
776
867
|
}
|
|
777
868
|
index++;
|
|
@@ -779,16 +870,14 @@ export class Turn {
|
|
|
779
870
|
else {
|
|
780
871
|
index++;
|
|
781
872
|
}
|
|
873
|
+
if (checkpointable && index - lastCheckpointIndex >= Turn.serializeCheckpointInterval) {
|
|
874
|
+
this.addCheckpoint(snapshot());
|
|
875
|
+
lastCheckpointIndex = index;
|
|
876
|
+
}
|
|
782
877
|
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
nextIndex: index,
|
|
787
|
-
chits: { ...chits },
|
|
788
|
-
subTurns: subTurns ? { ...subTurns } : undefined,
|
|
789
|
-
log: log ? { ...log } : undefined,
|
|
790
|
-
resultingClock: resultingClock === -1 ? clock : resultingClock,
|
|
791
|
-
};
|
|
878
|
+
// Remember where this walk ended, so a request for a later clock continues from here
|
|
879
|
+
if (checkpointable && index > lastCheckpointIndex) {
|
|
880
|
+
this.addCheckpoint(snapshot());
|
|
792
881
|
}
|
|
793
882
|
return {
|
|
794
883
|
log,
|
|
@@ -842,10 +931,7 @@ export class Turn {
|
|
|
842
931
|
prompt.id = `${this.id} prompt ${this.decisionIndex}`;
|
|
843
932
|
prompt.clock = this.clock;
|
|
844
933
|
prompt.canReset = this.state.hasUserMadeChoiceSinceUserContextChangedOrRng(this.decisionIndex - 1);
|
|
845
|
-
this.player.
|
|
846
|
-
if (!this.player.promptStatus.latestPromptMessage.length) {
|
|
847
|
-
this.player.promptStatus.latestPromptMessage = "No prompt set";
|
|
848
|
-
}
|
|
934
|
+
this.setPromptMessage(this.player, prompt.message.length ? prompt.message : "No prompt set");
|
|
849
935
|
this.flush();
|
|
850
936
|
return prompt;
|
|
851
937
|
}
|
|
@@ -898,7 +984,7 @@ export class Turn {
|
|
|
898
984
|
// to an object -- MAY be writing to the OLD state
|
|
899
985
|
this.state.setOrCreatePromptResponse(this.decisionIndex, resolution);
|
|
900
986
|
this.player.promptStatus.latestPromptResponseTime = this.absoluteClock(this.player.id);
|
|
901
|
-
this.player
|
|
987
|
+
this.setPromptMessage(this.player, undefined);
|
|
902
988
|
this.decisionIndex++;
|
|
903
989
|
}
|
|
904
990
|
/*
|
|
@@ -990,7 +1076,7 @@ export class Turn {
|
|
|
990
1076
|
}
|
|
991
1077
|
cleanUp() {
|
|
992
1078
|
if (this.player) {
|
|
993
|
-
this.player
|
|
1079
|
+
this.setPromptMessage(this.player, undefined);
|
|
994
1080
|
}
|
|
995
1081
|
this.completed = true;
|
|
996
1082
|
this.flush();
|
|
@@ -1027,8 +1113,33 @@ export class Turn {
|
|
|
1027
1113
|
}
|
|
1028
1114
|
return result;
|
|
1029
1115
|
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Takes every chit this turn made (and those a sub-turn still running under it made) off the board,
|
|
1118
|
+
* ahead of a parent's restart. The parent never absorbed us, so its own reset knows nothing of them:
|
|
1119
|
+
* left alone they would stay on the board, and the next sub-turn would lock them as if they had
|
|
1120
|
+
* always been there. Chits we only changed are the parent's to restore.
|
|
1121
|
+
*/
|
|
1122
|
+
discardCreatedChits() {
|
|
1123
|
+
this.activeSubTurns.forEach((t) => t.discardCreatedChits());
|
|
1124
|
+
for (const chit of Object.values(this.chitLookup)) {
|
|
1125
|
+
if (chit.id && this.lockedChitStates[chit.id] === undefined) {
|
|
1126
|
+
chit.forgetFallbackUnlessHidden();
|
|
1127
|
+
chit.removeFromParent();
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
for (const chit of this.pendingNewChits) {
|
|
1131
|
+
if (!chit.id) {
|
|
1132
|
+
chit.forgetFallbackUnlessHidden();
|
|
1133
|
+
chit.removeFromParent();
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
this.pendingNewChits.clear();
|
|
1137
|
+
}
|
|
1030
1138
|
restartExecution() {
|
|
1031
|
-
this.activeSubTurns.forEach((t) =>
|
|
1139
|
+
this.activeSubTurns.forEach((t) => {
|
|
1140
|
+
t.discardCreatedChits();
|
|
1141
|
+
t.destroy();
|
|
1142
|
+
});
|
|
1032
1143
|
const chits = Object.values(this.chitLookup).filter((chit) => chit.id);
|
|
1033
1144
|
chits.forEach((chit) => chit.beginDeserializing());
|
|
1034
1145
|
chits.forEach((chit) => {
|
|
@@ -1038,6 +1149,7 @@ export class Turn {
|
|
|
1038
1149
|
chit.deserialize(lockedState, this.findChit);
|
|
1039
1150
|
}
|
|
1040
1151
|
else {
|
|
1152
|
+
chit.forgetFallbackUnlessHidden(); // a chit made to come from another piece must not linger beside it
|
|
1041
1153
|
chit.removeFromParent(); // effectively "deletes" it. In practice, the `fn` will recreate a new chit which will have the new ID, which replaces this one.
|
|
1042
1154
|
}
|
|
1043
1155
|
});
|
|
@@ -1053,6 +1165,7 @@ export class Turn {
|
|
|
1053
1165
|
});
|
|
1054
1166
|
this.lastChitStates = { ...this.lockedChitStates }; // reset our known chit states
|
|
1055
1167
|
this.dirtyChitIds.clear();
|
|
1168
|
+
this.absorbedRootIds.clear();
|
|
1056
1169
|
this.pendingNewChits.clear();
|
|
1057
1170
|
// chits were deserialized back to locked state — mark them clean so future
|
|
1058
1171
|
// modifications correctly trigger markDirty() → notifyChitDirty()
|
|
@@ -1065,12 +1178,21 @@ export class Turn {
|
|
|
1065
1178
|
this.unresolvedPrompt = undefined;
|
|
1066
1179
|
this.activeSubTurns = [];
|
|
1067
1180
|
this.pass++;
|
|
1068
|
-
this.
|
|
1181
|
+
this._checkpoints = [];
|
|
1069
1182
|
}
|
|
1070
1183
|
}
|
|
1184
|
+
/** Tests only: false keeps every finished turn's snapshot and checkpoints. @internal */
|
|
1185
|
+
Turn.releaseAbsorbedTurns = true;
|
|
1186
|
+
/** Steps between checkpoints: the most a request walks before it reaches the live step. @internal */
|
|
1187
|
+
Turn.serializeCheckpointInterval = 32;
|
|
1188
|
+
/** Tests only: false makes every serialize() replay from the locked snapshot. @internal */
|
|
1189
|
+
Turn.serializeCheckpoints = true;
|
|
1071
1190
|
class ClockStep {
|
|
1072
1191
|
}
|
|
1073
1192
|
class SubTurnsClockStep extends ClockStep {
|
|
1193
|
+
get fullyAbsorbed() {
|
|
1194
|
+
return this.absorbed.length === this.turns.length;
|
|
1195
|
+
}
|
|
1074
1196
|
visibleTurns(playerId) {
|
|
1075
1197
|
if (this.turns.length === 1 || playerId === undefined) {
|
|
1076
1198
|
return this.turns;
|
|
@@ -1096,6 +1218,8 @@ class SubTurnsClockStep extends ClockStep {
|
|
|
1096
1218
|
super();
|
|
1097
1219
|
this.startClock = startClock;
|
|
1098
1220
|
this.turns = turns;
|
|
1221
|
+
/** The turns the parent has absorbed, in that order: the order their changes landed in its state */
|
|
1222
|
+
this.absorbed = [];
|
|
1099
1223
|
}
|
|
1100
1224
|
}
|
|
1101
1225
|
class FlushClockStep extends ClockStep {
|