castle-web-cli 0.4.238 → 0.4.240
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.js +5 -1
- package/dist/api.d.ts +20 -0
- package/dist/api.js +57 -0
- package/dist/bundle.d.ts +38 -1
- package/dist/bundle.js +309 -13
- package/dist/castle-host/host.js +218 -11
- package/dist/castleJson.d.ts +10 -0
- package/dist/castleJson.js +46 -2
- package/dist/check.js +5 -2
- package/dist/devSessionServer.js +4 -1
- package/dist/devSessionStorage.d.ts +1 -0
- package/dist/devSessionStorage.js +32 -7
- package/dist/importOrder.d.ts +2 -0
- package/dist/importOrder.js +29 -0
- package/dist/index.js +22 -3
- package/dist/init.js +24 -2
- package/dist/multiplayerDoc.d.ts +1 -1
- package/dist/multiplayerDoc.js +9 -0
- package/dist/platformDoc.js +4 -2
- package/dist/playPagePolicy.d.ts +1 -0
- package/dist/playPagePolicy.js +12 -3
- package/dist/resetLeaderboards.d.ts +8 -1
- package/dist/resetLeaderboards.js +43 -8
- package/dist/roomLogs.d.ts +39 -0
- package/dist/roomLogs.js +166 -0
- package/dist/save-deck.d.ts +32 -2
- package/dist/save-deck.js +240 -39
- package/kits/base/CLAUDE.md +2 -1
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +240 -8
- package/kits/base/sdk/analytics.d.ts +8 -0
- package/kits/base/sdk/analytics.js +92 -0
- package/kits/base/sdk/castle.d.ts +8 -2
- package/kits/base/sdk/castle.js +3 -0
- package/kits/base/sdk/commands.d.ts +79 -0
- package/kits/base/sdk/commands.js +1 -0
- package/kits/base/sdk/debugConsole.d.ts +17 -0
- package/kits/base/sdk/debugConsole.js +154 -0
- package/kits/base/sdk/experiments.js +24 -1
- package/kits/base/sdk/hostRetry.d.ts +7 -0
- package/kits/base/sdk/hostRetry.js +57 -0
- package/kits/base/sdk/hub.d.ts +20 -2
- package/kits/base/sdk/hub.js +99 -13
- package/kits/base/sdk/multiplayer.d.ts +2 -0
- package/kits/base/sdk/multiplayer.js +198 -26
- package/kits/base/sdk/reconnectBudget.d.ts +6 -0
- package/kits/base/sdk/reconnectBudget.js +41 -1
- package/kits/base/sdk/rooms.d.ts +11 -0
- package/kits/base/sdk/rooms.js +22 -0
- package/kits/base/sdk/runtime.js +36 -19
- package/kits/base/sdk/server/hub.d.ts +19 -0
- package/kits/base/sdk/server/hub.js +12 -0
- package/kits/base/sdk/server/platformHandle.d.ts +1 -0
- package/kits/base/sdk/server/wrapper.d.ts +1 -1
- package/kits/base/sdk/server/wrapper.js +26 -1
- package/kits/base/sdk/store.d.ts +8 -2
- package/kits/base/sdk/store.js +5 -1
- package/kits/base/sdk/transport.d.ts +2 -1
- package/kits/base/sdk/transport.js +35 -0
- package/kits/hub-game/CLAUDE.md +66 -19
- package/kits/hub-game/castle.json +4 -4
- package/kits/hub-game/code/client/act.js +9 -6
- package/kits/hub-game/code/client/actCore.js +26 -6
- package/kits/hub-game/code/client/actGateLog.js +36 -0
- package/kits/hub-game/code/client/actionOverflow.js +29 -8
- package/kits/hub-game/code/client/actionRailSurface.js +186 -0
- package/kits/hub-game/code/client/actionRailTree.js +173 -0
- package/kits/hub-game/code/client/askSurface.js +85 -0
- package/kits/hub-game/code/client/askTree.js +51 -0
- package/kits/hub-game/code/client/attention.js +31 -6
- package/kits/hub-game/code/client/ballot.js +42 -5
- package/kits/hub-game/code/client/ballotSurface.js +115 -0
- package/kits/hub-game/code/client/ballotTree.js +180 -0
- package/kits/hub-game/code/client/catchingUp.js +19 -0
- package/kits/hub-game/code/client/celebrate.js +66 -0
- package/kits/hub-game/code/client/chrome.js +474 -53
- package/kits/hub-game/code/client/companion.js +93 -23
- package/kits/hub-game/code/client/companionDress.js +1 -1
- package/kits/hub-game/code/client/cornerSurface.js +106 -0
- package/kits/hub-game/code/client/cornerTree.js +83 -0
- package/kits/hub-game/code/client/decor.js +20 -11
- package/kits/hub-game/code/client/deviceStorage.js +121 -0
- package/kits/hub-game/code/client/disguise.js +23 -0
- package/kits/hub-game/code/client/disguiseDraw.js +87 -0
- package/kits/hub-game/code/client/dockSurface.js +206 -0
- package/kits/hub-game/code/client/dockTree.js +232 -0
- package/kits/hub-game/code/client/earned.js +29 -0
- package/kits/hub-game/code/client/emoteSurface.js +188 -0
- package/kits/hub-game/code/client/emoteTree.js +264 -0
- package/kits/hub-game/code/client/farAvatars.js +4 -3
- package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
- package/kits/hub-game/code/client/grab.js +121 -50
- package/kits/hub-game/code/client/holdShow.js +19 -0
- package/kits/hub-game/code/client/hookLayer.js +96 -12
- package/kits/hub-game/code/client/hubControls.js +7 -1
- package/kits/hub-game/code/client/hudSurface.js +11 -3
- package/kits/hub-game/code/client/hudTree.js +7 -4
- package/kits/hub-game/code/client/idle.js +21 -3
- package/kits/hub-game/code/client/invites.js +24 -3
- package/kits/hub-game/code/client/keys.js +15 -0
- package/kits/hub-game/code/client/labelsNear.js +8 -1
- package/kits/hub-game/code/client/layoutCache.js +57 -8
- package/kits/hub-game/code/client/loadingCover.js +53 -4
- package/kits/hub-game/code/client/menuIcons.js +15 -0
- package/kits/hub-game/code/client/menuRows.js +8 -2
- package/kits/hub-game/code/client/menuSurface.js +102 -0
- package/kits/hub-game/code/client/menuTree.js +135 -0
- package/kits/hub-game/code/client/modelLook.js +41 -0
- package/kits/hub-game/code/client/pickerSurface.js +152 -0
- package/kits/hub-game/code/client/pickerTree.js +163 -0
- package/kits/hub-game/code/client/pushVisit.js +4 -2
- package/kits/hub-game/code/client/quality.js +188 -29
- package/kits/hub-game/code/client/qualityEntry.js +10 -1
- package/kits/hub-game/code/client/quickChatSurface.js +222 -0
- package/kits/hub-game/code/client/quickChatTree.js +201 -0
- package/kits/hub-game/code/client/rehello.js +75 -0
- package/kits/hub-game/code/client/renderVisibility.js +17 -0
- package/kits/hub-game/code/client/replay.js +118 -0
- package/kits/hub-game/code/client/role.js +3 -0
- package/kits/hub-game/code/client/safeLayout.js +441 -56
- package/kits/hub-game/code/client/safeStyle.js +13 -10
- package/kits/hub-game/code/client/say.js +2 -0
- package/kits/hub-game/code/client/soundSurface.js +77 -0
- package/kits/hub-game/code/client/soundTree.js +74 -0
- package/kits/hub-game/code/client/soundscape.js +12 -9
- package/kits/hub-game/code/client/soundscapeCues.js +1 -1
- package/kits/hub-game/code/client/state.js +67 -1
- package/kits/hub-game/code/client/stuckSurface.js +76 -0
- package/kits/hub-game/code/client/stuckTree.js +67 -0
- package/kits/hub-game/code/client/talk.js +42 -12
- package/kits/hub-game/code/client/talkTree.js +4 -2
- package/kits/hub-game/code/client/textAskSurface.js +147 -0
- package/kits/hub-game/code/client/textAskTree.js +67 -0
- package/kits/hub-game/code/client/tiers.js +252 -27
- package/kits/hub-game/code/client/together.js +4 -1
- package/kits/hub-game/code/client/uiDom.js +86 -8
- package/kits/hub-game/code/client/uiTree.js +33 -4
- package/kits/hub-game/code/client/vehicle.js +75 -52
- package/kits/hub-game/code/client/weakestTier.js +75 -31
- package/kits/hub-game/code/client/wear.js +159 -5
- package/kits/hub-game/code/client/worldLabels.js +215 -26
- package/kits/hub-game/code/companionSpec.js +4 -2
- package/kits/hub-game/code/server/act.js +3 -0
- package/kits/hub-game/code/server/actGate.js +83 -0
- package/kits/hub-game/code/server/actions.js +71 -15
- package/kits/hub-game/code/server/actors.js +20 -5
- package/kits/hub-game/code/server/analytics.js +40 -15
- package/kits/hub-game/code/server/ask.js +39 -3
- package/kits/hub-game/code/server/ballot.js +167 -4
- package/kits/hub-game/code/server/celebrate.js +64 -0
- package/kits/hub-game/code/server/companion.js +17 -2
- package/kits/hub-game/code/server/decor.js +11 -2
- package/kits/hub-game/code/server/disguise.js +63 -0
- package/kits/hub-game/code/server/doorAnalytics.js +2 -5
- package/kits/hub-game/code/server/earned.js +6 -2
- package/kits/hub-game/code/server/friendBests.js +13 -4
- package/kits/hub-game/code/server/friendsAmong.js +67 -8
- package/kits/hub-game/code/server/grab.js +12 -2
- package/kits/hub-game/code/server/heldOffers.js +142 -0
- package/kits/hub-game/code/server/holdShow.js +98 -0
- package/kits/hub-game/code/server/hub.js +854 -45
- package/kits/hub-game/code/server/idle.js +110 -9
- package/kits/hub-game/code/server/index.js +9 -0
- package/kits/hub-game/code/server/labels.js +13 -3
- package/kits/hub-game/code/server/loadAbandon.js +2 -5
- package/kits/hub-game/code/server/manifest.js +94 -6
- package/kits/hub-game/code/server/menu.js +26 -3
- package/kits/hub-game/code/server/npcs.js +55 -9
- package/kits/hub-game/code/server/observe.js +67 -6
- package/kits/hub-game/code/server/players.js +8 -1
- package/kits/hub-game/code/server/replay.js +135 -0
- package/kits/hub-game/code/server/storageLimit.js +4 -1
- package/kits/hub-game/code/server/townDay.js +74 -0
- package/kits/hub-game/code/server/trackQueue.js +29 -0
- package/kits/hub-game/code/server/vehicle.js +3 -0
- package/kits/hub-game/code/server/vis.js +26 -4
- package/kits/hub-game/code/server/wallet.js +677 -0
- package/kits/hub-game/code/server/wear.js +13 -3
- package/kits/hub-game/code/server/writerLease.js +191 -0
- package/kits/hub-game/code/shared/act.js +1 -1
- package/kits/hub-game/code/shared/expression.js +6 -0
- package/kits/hub-game/code/shared/replay.js +37 -0
- package/kits/hub-game/code/systems/hub.js +437 -57
- package/kits/hub-game/docs/analytics.md +20 -3
- package/kits/hub-game/docs/contract.md +942 -99
- package/kits/hub-game/docs/home-pieces.md +5 -6
- package/kits/hub-game/docs/observed-progress.md +49 -1
- package/kits/hub-game/docs/vehicle-preset.md +23 -0
- package/kits/hub-game/index.html +1 -0
- package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
- package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
- package/kits/hub-game/models/hats/cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/captain.pxmodel +3 -3
- package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
- package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
- package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
- package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
- package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
- package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
- package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
- package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
- package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
- package/kits/hub-game/models/hats/straw.pxmodel +3 -3
- package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
- package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
- package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
- package/kits/hub-game/models/hats/witch.pxmodel +3 -3
- package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
- package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
- package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
- package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
- package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
- package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
- package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
- package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
- package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
- package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
- package/kits/hub-game/package-lock.json +3 -3
- package/kits/hub-game/package.json +4 -3
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
- package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
- package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
- package/kits/hub-game/scripts/gen-hats.mjs +1 -1
- package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
- package/kits/hub-game/scripts/pack.mjs +89 -23
- package/kits/hub-game/scripts/test-act-client.mjs +5 -0
- package/kits/hub-game/scripts/test-act-core.mjs +32 -0
- package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
- package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
- package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
- package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
- package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
- package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
- package/kits/hub-game/scripts/test-actions.mjs +24 -0
- package/kits/hub-game/scripts/test-actors.mjs +19 -0
- package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
- package/kits/hub-game/scripts/test-analytics.mjs +80 -1
- package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
- package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
- package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
- package/kits/hub-game/scripts/test-attention.mjs +43 -1
- package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
- package/kits/hub-game/scripts/test-ballot.mjs +420 -3
- package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
- package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
- package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
- package/kits/hub-game/scripts/test-chat.mjs +73 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
- package/kits/hub-game/scripts/test-companion.mjs +110 -3
- package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
- package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
- package/kits/hub-game/scripts/test-decor.mjs +27 -0
- package/kits/hub-game/scripts/test-device-class.mjs +4 -1
- package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
- package/kits/hub-game/scripts/test-disguise.mjs +176 -0
- package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
- package/kits/hub-game/scripts/test-door-analytics.mjs +1 -1
- package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
- package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
- package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
- package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
- package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
- package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
- package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
- package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
- package/kits/hub-game/scripts/test-grab.mjs +10 -1
- package/kits/hub-game/scripts/test-hats.mjs +28 -0
- package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
- package/kits/hub-game/scripts/test-high-only.mjs +3 -3
- package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
- package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
- package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
- package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +147 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +260 -5
- package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
- package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
- package/kits/hub-game/scripts/test-idle.mjs +160 -0
- package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
- package/kits/hub-game/scripts/test-labels.mjs +11 -0
- package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
- package/kits/hub-game/scripts/test-load-abandon.mjs +2 -2
- package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
- package/kits/hub-game/scripts/test-manifest.mjs +27 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +55 -6
- package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
- package/kits/hub-game/scripts/test-npcs.mjs +128 -0
- package/kits/hub-game/scripts/test-observed.mjs +171 -3
- package/kits/hub-game/scripts/test-pack.mjs +166 -0
- package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
- package/kits/hub-game/scripts/test-placeat-server.mjs +395 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
- package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
- package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
- package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
- package/kits/hub-game/scripts/test-quality.mjs +312 -9
- package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
- package/kits/hub-game/scripts/test-rehello.mjs +237 -0
- package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
- package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
- package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
- package/kits/hub-game/scripts/test-replay.mjs +178 -0
- package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
- package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
- package/kits/hub-game/scripts/test-resync.mjs +13 -0
- package/kits/hub-game/scripts/test-role-client.mjs +10 -3
- package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
- package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
- package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
- package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
- package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
- package/kits/hub-game/scripts/test-stuck.mjs +31 -0
- package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
- package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
- package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
- package/kits/hub-game/scripts/test-tiers.mjs +453 -3
- package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-together.mjs +11 -0
- package/kits/hub-game/scripts/test-town-day.mjs +90 -0
- package/kits/hub-game/scripts/test-track-queue.mjs +64 -0
- package/kits/hub-game/scripts/test-try-on.mjs +39 -0
- package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
- package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
- package/kits/hub-game/scripts/test-vehicle-client.mjs +77 -1
- package/kits/hub-game/scripts/test-vis.mjs +145 -0
- package/kits/hub-game/scripts/test-wallet.mjs +650 -0
- package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
- package/kits/hub-game/scripts/test-world-labels.mjs +380 -0
- package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
- package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
- package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
- package/kits/hub-game/tools/hubScene/export.mjs +6 -5
- package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
- package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +48 -2
- package/kits/hub-game/tools/hubScene/validate-manifest.mjs +21 -3
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/resumeGate.js +49 -2
- package/kits/multiplayer-3d/code/server/ownership.js +25 -6
- package/kits/multiplayer-3d/code/server/world.js +19 -4
- package/kits/multiplayer-3d/code/systems/multiplayer.js +67 -11
- package/kits/multiplayer-3d/package-lock.json +1 -1
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
- package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
- package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +191 -5
- package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +10 -2
- package/kits/physics-3d/CLAUDE.md +14 -0
- package/kits/physics-3d/behaviors/Player.jsx +39 -3
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/engine-model-cache.md +109 -0
- package/kits/physics-3d/docs/engine-player.md +76 -0
- package/kits/physics-3d/docs/engine-skip-work.md +16 -0
- package/kits/physics-3d/docs/pxmodel-format.md +5 -1
- package/kits/physics-3d/engine3d/gait.js +16 -8
- package/kits/physics-3d/engine3d/groundsize.js +23 -0
- package/kits/physics-3d/engine3d/kithooks.js +50 -0
- package/kits/physics-3d/engine3d/look.js +110 -17
- package/kits/physics-3d/engine3d/lookbake.js +19 -1
- package/kits/physics-3d/engine3d/materialpresets.js +3 -2
- package/kits/physics-3d/engine3d/modelcache.js +280 -0
- package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
- package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
- package/kits/physics-3d/engine3d/modelrefs.js +13 -0
- package/kits/physics-3d/engine3d/optimize.js +20 -9
- package/kits/physics-3d/engine3d/playerRun.js +26 -1
- package/kits/physics-3d/engine3d/pxmodel.js +7 -3
- package/kits/physics-3d/engine3d/templatecache.js +722 -0
- package/kits/physics-3d/engine3d/world3d.js +211 -17
- package/kits/physics-3d/package-lock.json +1 -1
- package/kits/physics-3d/package.json +2 -1
- package/kits/physics-3d/play/behaviors/Player.js +43 -3
- package/kits/physics-3d/scripts/render.mjs +56 -8
- package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
- package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
- package/kits/physics-3d/scripts/test-gait.mjs +53 -9
- package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
- package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
- package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
- package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
- package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
- package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
- package/kits/physics-3d/systems/physics3d.js +51 -2
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +3 -0
- package/package.json +2 -2
- package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
|
@@ -311,13 +311,16 @@ export function marksOf(h) {
|
|
|
311
311
|
// dynamic Body (its ownership is the multiplayer kit's), nor a player, door or
|
|
312
312
|
// NPC. Bounded: MAX_SPAWNED copies alive (a deck's hub.spawnCap, v1.161), SPAWN_RATE spawns a second with
|
|
313
313
|
// bursts of SPAWN_BURST, so the snapshot and every client's actor count stay
|
|
314
|
-
// small.
|
|
314
|
+
// small. v1.162: `{ carer: playerId }` names the player a copy goes with (a
|
|
315
|
+
// pet beside its owner), kept for the copy's life, the carer leaving included
|
|
316
|
+
// (the place despawns it). A carer that is not a string or not a player in
|
|
317
|
+
// this place now is ignored and the copy is spawned without one.
|
|
315
318
|
export const MAX_SPAWNED = 96;
|
|
316
319
|
export const SPAWN_RATE = 10;
|
|
317
320
|
export const SPAWN_BURST = 40;
|
|
318
321
|
const NOT_TEMPLATES = ['Player', 'HubDoor', 'HubNpc', 'HubPad', 'Pickup'];
|
|
319
322
|
|
|
320
|
-
export function spawn(h, fromId, at, engine) {
|
|
323
|
+
export function spawn(h, fromId, at, engine, options) {
|
|
321
324
|
const template = typeof fromId === 'string' ? h.actors.find((a) => a.id === fromId) : null;
|
|
322
325
|
const c = template?.components;
|
|
323
326
|
if (!c || !c.Transform || !c.Shape || NOT_TEMPLATES.some((name) => c[name]) || c.Body?.type === 'dynamic') {
|
|
@@ -365,7 +368,8 @@ export function spawn(h, fromId, at, engine) {
|
|
|
365
368
|
} while (h.actors.some((a) => a.id === id) || h.spawned.has(id));
|
|
366
369
|
const components = { ...c, Transform: { ...t, x: point.x, y: point.y, z: point.z, rotationY: point.rotationY } };
|
|
367
370
|
const actor = { id, components };
|
|
368
|
-
|
|
371
|
+
const carer = options?.carer;
|
|
372
|
+
h.spawned.set(id, { from: fromId, at: point, actor, ...(typeof carer === 'string' && h.players.has(carer) ? { carer } : {}) });
|
|
369
373
|
// The copy's body, as the world builds a scene actor's: solid or a sensor,
|
|
370
374
|
// fixed or kinematic; a kinematic one's pose reaches every client.
|
|
371
375
|
if (h.sim && engine?.createBody) {
|
|
@@ -440,10 +444,21 @@ export function templatesOf(h) {
|
|
|
440
444
|
return out;
|
|
441
445
|
}
|
|
442
446
|
|
|
447
|
+
// v1.197: the decor templates of live copies, in a deck with no quality block
|
|
448
|
+
// of its own, sorted. Empty where there are none (and in every deck with one).
|
|
449
|
+
export function doorDecorOf(h) {
|
|
450
|
+
if (!h.doorDecor) {return [];}
|
|
451
|
+
const out = new Set();
|
|
452
|
+
for (const { from } of h.spawned.values()) {
|
|
453
|
+
if (h.doorDecor.has(from)) {out.add(from);}
|
|
454
|
+
}
|
|
455
|
+
return [...out].sort();
|
|
456
|
+
}
|
|
457
|
+
|
|
443
458
|
export function spawnedOf(h) {
|
|
444
459
|
const out = Object.create(null);
|
|
445
|
-
for (const [id, { from, at }] of h.spawned) {
|
|
446
|
-
out[id] = { from, ...at };
|
|
460
|
+
for (const [id, { from, at, carer }] of h.spawned) {
|
|
461
|
+
out[id] = carer === undefined ? { from, ...at } : { from, ...at, carer };
|
|
447
462
|
}
|
|
448
463
|
return out;
|
|
449
464
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// v1.93: server only. A place without analytics creates no state or messages.
|
|
2
|
+
import { send } from './trackQueue.js';
|
|
2
3
|
export const EVENTS = Object.freeze({ arrive: 1, door_enter: 2, door_exit: 3, game_result: 4,
|
|
3
4
|
activity_start: 5, activity_end: 6, outcome: 7, first_play: 8, pointer_stage: 9,
|
|
4
5
|
reconnect: 10, session_end: 11, furniture_placed: 12, furniture_moved: 13,
|
|
@@ -19,11 +20,7 @@ export function track(h, playerId, name, props = {}) {
|
|
|
19
20
|
if (!Number.isSafeInteger(n) || n < 0 || n > max) {return false;}
|
|
20
21
|
event[key] = n;
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
const pending = h.session?.hub?.track?.(playerId, event);
|
|
24
|
-
if (pending && typeof pending.catch === 'function') {pending.catch(() => {});}
|
|
25
|
-
return pending !== undefined && pending !== false;
|
|
26
|
-
} catch { return false; }
|
|
23
|
+
return send(h.session, playerId, event);
|
|
27
24
|
}
|
|
28
25
|
export function arrive(h, group) {
|
|
29
26
|
const a = h.analytics, now = h.sim.timeMs;
|
|
@@ -34,6 +31,9 @@ export function arrive(h, group) {
|
|
|
34
31
|
const back = !p.from && key && a.departed.has(key);
|
|
35
32
|
if (key) {a.departed.delete(key);}
|
|
36
33
|
a.visits.set(p.playerId, { at: now, userId: key });
|
|
34
|
+
// A resume that arrives still ended by its door (v1.169) was reported at
|
|
35
|
+
// that end: nothing counts until a stay continues it.
|
|
36
|
+
if (h.players.get(p.playerId)?.ended && !h.place.result) {a.visits.get(p.playerId).ended = true;}
|
|
37
37
|
if (back) {track(h, p.playerId, 'reconnect', { subject: h.manifest.house ? SUBJECTS.house : SUBJECTS.town });}
|
|
38
38
|
else if (h.firstVisit && !h.manifest.house) {a.visits.get(p.playerId).arrival = { subject: SUBJECTS.town, value: p.device ?? 0, result: p.from ? 2 : 1 };}
|
|
39
39
|
else {track(h, p.playerId, h.manifest.house ? 'house_visit' : 'arrive', { subject: h.manifest.house ? SUBJECTS.house : SUBJECTS.town, value: p.device ?? 0, result: p.from ? 2 : 1 });}
|
|
@@ -70,6 +70,7 @@ function end(h, playerId, visit, value, result) {
|
|
|
70
70
|
export function observe(h) {
|
|
71
71
|
const now = h.sim.timeMs;
|
|
72
72
|
for (const [playerId, visit] of h.analytics.visits) {
|
|
73
|
+
if (visit.ended) {continue;}
|
|
73
74
|
const body = h.sim.players.get(playerId);
|
|
74
75
|
if (h.session?.players.some((p) => p.playerId === playerId)) {
|
|
75
76
|
if (visit.droppedAt !== undefined) {resume(h, visit, now);}
|
|
@@ -99,10 +100,37 @@ function resume(h, visit, now) {
|
|
|
99
100
|
delete visit.droppedWall;
|
|
100
101
|
delete visit.reported;
|
|
101
102
|
}
|
|
103
|
+
// A place without a result that ends a visit (`hub.end`: the House's front
|
|
104
|
+
// door, the first room's way back) reports it now, while the player is still
|
|
105
|
+
// connected. The way back can keep this connection open long after the player
|
|
106
|
+
// has gone, and a single-player place's report after the drop never lands:
|
|
107
|
+
// the first room logged no session_end once its way out moved from `hub.go`
|
|
108
|
+
// to `hub.end` (Oct 21).
|
|
109
|
+
export function ended(h, playerId) {
|
|
110
|
+
const visit = h.analytics?.visits.get(playerId);
|
|
111
|
+
if (!visit || visit.ended || visit.reported) {return;}
|
|
112
|
+
const away = visit.droppedAt !== undefined;
|
|
113
|
+
end(h, playerId, visit, (away ? visit.droppedAt : h.sim.timeMs) - visit.at,
|
|
114
|
+
visit.continued ? END.continued : away ? END.dropped : END.left);
|
|
115
|
+
visit.ended = true;
|
|
116
|
+
}
|
|
117
|
+
// The player stayed after that end (v1.169 `hub-stay`): what follows is a
|
|
118
|
+
// continuation.
|
|
119
|
+
export function stayed(h, playerId) {
|
|
120
|
+
const visit = h.analytics?.visits.get(playerId);
|
|
121
|
+
if (!visit?.ended) {return;}
|
|
122
|
+
delete visit.ended;
|
|
123
|
+
delete visit.droppedAt;
|
|
124
|
+
delete visit.droppedWall;
|
|
125
|
+
visit.continued = true;
|
|
126
|
+
visit.at = h.sim.timeMs;
|
|
127
|
+
}
|
|
102
128
|
export function leave(h, playerId) {
|
|
103
129
|
const a = h.analytics, visit = a.visits.get(playerId);
|
|
104
130
|
if (!visit) {return;}
|
|
105
|
-
if (visit.
|
|
131
|
+
if (visit.ended) {
|
|
132
|
+
// Reported at the end.
|
|
133
|
+
} else if (visit.droppedAt !== undefined) {
|
|
106
134
|
if (!visit.reported) {end(h, playerId, visit, visit.droppedAt - visit.at, visit.continued ? END.continued : END.dropped);}
|
|
107
135
|
} else {end(h, playerId, visit, h.sim.timeMs - visit.at, visit.continued ? END.continued : END.left);}
|
|
108
136
|
a.visits.delete(playerId);
|
|
@@ -114,20 +142,17 @@ export function fps(h, session, player, data) {
|
|
|
114
142
|
const entry = h.players.get(player?.playerId);
|
|
115
143
|
if (h.place?.analytics !== true || !h.place.fpsTelemetry || !entry?.arrived || !session.players.some((p) => p.playerId === player.playerId) ||
|
|
116
144
|
data.scene !== h.place.fpsTelemetry.scene || typeof data.final !== 'boolean' ||
|
|
117
|
-
Object.keys(data).some((key) => !['k', 'scene', 'median', 'p10', 'tier', 'avatars', 'final'].includes(key))) {return false;}
|
|
145
|
+
Object.keys(data).some((key) => !['k', 'scene', 'median', 'p10', 'tier', 'avatars', 'final', 'quality'].includes(key))) {return false;}
|
|
118
146
|
for (const [key, max] of [['median', 4095], ['p10', 4095], ['tier', 3], ['avatars', 255]]) {
|
|
119
147
|
if (!Number.isInteger(data[key]) || data[key] < 0 || data[key] > max) {return false;}
|
|
120
148
|
}
|
|
121
|
-
if (data.p10 > data.median) {return false;}
|
|
149
|
+
if (data.p10 > data.median || (Object.hasOwn(data, 'quality') && data.quality !== 'hide' && data.quality !== 'skip')) {return false;}
|
|
122
150
|
const now = h.sim.timeMs;
|
|
123
151
|
const field = data.final ? 'fpsFinalAt' : 'fpsAt';
|
|
124
152
|
if (entry[field] !== undefined && now - entry[field] < 60000) {return false;}
|
|
125
153
|
entry[field] = now;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
pending?.catch?.(() => {});
|
|
131
|
-
return pending !== undefined && pending !== false;
|
|
132
|
-
} catch { return false; }
|
|
154
|
+
return send(h.session, player.playerId, {
|
|
155
|
+
kind: 26, subject: data.tier, value: data.median * 4096 + data.p10, result: data.avatars, flags: 0,
|
|
156
|
+
...(Object.hasOwn(data, 'quality') ? { quality: data.quality === 'hide' ? 1 : 2 } : {}),
|
|
157
|
+
});
|
|
133
158
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Private text prompts (contract v1.75). Only the place hook receives text;
|
|
2
2
|
// no answer is retained, echoed, included in state or used in an error line.
|
|
3
3
|
import { validPrivateText as textOk } from '../privateText.js';
|
|
4
|
+
import * as Held from './heldOffers.js';
|
|
4
5
|
|
|
5
6
|
const ID = /^[a-z][a-z0-9_-]{0,23}$/;
|
|
6
7
|
const SEND_EVERY_MS = 250;
|
|
@@ -51,15 +52,20 @@ export function set(h, playerId, spec) {
|
|
|
51
52
|
need(h.place.ask === true, 'this place does not declare ask');
|
|
52
53
|
need(typeof playerId === 'string', 'playerId must be a string');
|
|
53
54
|
const checked = check(spec);
|
|
54
|
-
|
|
55
|
+
// v1.180: a held visit away takes the call, recorded unsent.
|
|
56
|
+
const held = Held.on(h) ? Held.take(h, playerId) : null;
|
|
57
|
+
if (held === 'block' || (!held?.away && !arrived(h, playerId))) {
|
|
55
58
|
return false;
|
|
56
59
|
}
|
|
60
|
+
if (held && Held.gate(h, playerId, h.askMe?.get(playerId)) === 'drop') {
|
|
61
|
+
h.askMe.delete(playerId);
|
|
62
|
+
}
|
|
57
63
|
const state = current(h, playerId), json = JSON.stringify(checked);
|
|
58
|
-
if (state.json !== json) {
|
|
64
|
+
if (state.json !== json || state.hold !== held?.hold) {
|
|
59
65
|
// Every change invalidates the old version, even if it changes back
|
|
60
66
|
// before delivery. Delivery equality includes that new version.
|
|
61
67
|
const n = version(h);
|
|
62
|
-
(h.askMe ??= new Map()).set(playerId, { ...state, spec: checked, json, n });
|
|
68
|
+
(h.askMe ??= new Map()).set(playerId, { ...state, spec: checked, json, n, ...(held ? { hold: held.hold } : {}) });
|
|
63
69
|
}
|
|
64
70
|
return true;
|
|
65
71
|
}
|
|
@@ -112,6 +118,16 @@ export function message(h, playerId, data) {
|
|
|
112
118
|
return;
|
|
113
119
|
}
|
|
114
120
|
const promptId = data.id, n = data.n, state = current(h, playerId);
|
|
121
|
+
// v1.180: a held prompt is answered only by its own account, back on the
|
|
122
|
+
// visit's body and replayed to by a fresh hello.
|
|
123
|
+
const held = Held.on(h) ? Held.gate(h, playerId, h.askMe?.get(playerId)) : null;
|
|
124
|
+
if (held === 'drop' || held === 'block') {
|
|
125
|
+
h.askMe?.delete(playerId);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (held === 'away') {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
115
131
|
if (!state.spec || !id(promptId) || promptId !== state.spec.id || promptId !== state.sentId ||
|
|
116
132
|
!Number.isSafeInteger(n) || n !== state.n || n !== state.sentN) {
|
|
117
133
|
return;
|
|
@@ -133,6 +149,17 @@ export function message(h, playerId, data) {
|
|
|
133
149
|
}
|
|
134
150
|
}
|
|
135
151
|
export function joinedAfresh(h, playerId) {
|
|
152
|
+
if (Held.on(h)) {
|
|
153
|
+
const held = Held.gate(h, playerId, h.askMe?.get(playerId));
|
|
154
|
+
if (held === 'drop' || held === 'block') {
|
|
155
|
+
h.askMe?.delete(playerId);
|
|
156
|
+
} else if (held === 'away') {
|
|
157
|
+
return;
|
|
158
|
+
} else if (held === 'here' && h.askMe?.has(playerId)) {
|
|
159
|
+
// v1.180: a replay is a new prompt; answers to the old version are refused.
|
|
160
|
+
h.askMe.get(playerId).n = version(h);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
136
163
|
const state = current(h, playerId);
|
|
137
164
|
(h.askMe ??= new Map()).set(playerId, state);
|
|
138
165
|
send(h, playerId, state);
|
|
@@ -143,6 +170,15 @@ export function forget(h, playerId) {
|
|
|
143
170
|
}
|
|
144
171
|
export function prune(h) {
|
|
145
172
|
for (const playerId of new Set([...(h.askMe?.keys() ?? []), ...(h.askBudget?.keys() ?? [])])) {
|
|
173
|
+
const held = Held.on(h) ? Held.gate(h, playerId, h.askMe?.get(playerId)) : null;
|
|
174
|
+
if (held === 'drop' || held === 'block') {
|
|
175
|
+
forget(h, playerId);
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (held === 'away') {
|
|
179
|
+
h.askBudget?.delete(playerId);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
146
182
|
if (!present(h, playerId)) {
|
|
147
183
|
forget(h, playerId);
|
|
148
184
|
continue;
|
|
@@ -321,7 +321,11 @@ export function ballot(h, playerIds, spec) {
|
|
|
321
321
|
// as `words` (line id -> the line as this viewer reads it, only for a line
|
|
322
322
|
// the redaction changes). A lock on a face they cannot see stays a lock,
|
|
323
323
|
// `picked: {}`, without naming whom.
|
|
324
|
-
//
|
|
324
|
+
// v1.179 `ballot.keepAway`: a face of a player the place still retains (away)
|
|
325
|
+
// is on it too, `away: true`, when `d.awayOf(playerId)` gives their snapshot
|
|
326
|
+
// profile for this viewer (the invariant at `rememberSeen`); only faces, never
|
|
327
|
+
// feed rows. Without the key there is no `awayOf`.
|
|
328
|
+
// `d` is `{ usernameOf(playerId) | null, avatarOf(playerId) | null, awayOf?(playerId) | { name, avatar? } | null, hidden: Set | null, names: [usernames], lines: [manifest lines] }`.
|
|
325
329
|
export function viewFor(card, viewer, d) {
|
|
326
330
|
if (!card) {
|
|
327
331
|
return null;
|
|
@@ -351,9 +355,22 @@ export function viewFor(card, viewer, d) {
|
|
|
351
355
|
if (card.until !== undefined) {
|
|
352
356
|
view.until = card.until;
|
|
353
357
|
}
|
|
358
|
+
// An away face's name and avatar: the snapshot `d.awayOf` gives.
|
|
359
|
+
const knowAway = (playerId) => {
|
|
360
|
+
const profile = d.awayOf?.(playerId) ?? null;
|
|
361
|
+
if (!profile) {
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
who[playerId] = Number.isInteger(profile.avatar) ? { name: profile.name, avatar: profile.avatar } : { name: profile.name };
|
|
365
|
+
return true;
|
|
366
|
+
};
|
|
354
367
|
view.faces = [];
|
|
355
368
|
for (const face of card.faces) {
|
|
356
|
-
if (hidden?.has(face.playerId)
|
|
369
|
+
if (hidden?.has(face.playerId)) {
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
const away = !know(face.playerId);
|
|
373
|
+
if (away && !knowAway(face.playerId)) {
|
|
357
374
|
continue;
|
|
358
375
|
}
|
|
359
376
|
const out = { id: face.playerId };
|
|
@@ -365,6 +382,9 @@ export function viewFor(card, viewer, d) {
|
|
|
365
382
|
out[key] = face[key];
|
|
366
383
|
}
|
|
367
384
|
}
|
|
385
|
+
if (away) {
|
|
386
|
+
out.away = true;
|
|
387
|
+
}
|
|
368
388
|
view.faces.push(out);
|
|
369
389
|
}
|
|
370
390
|
view.options = card.options.map((option) => ({ id: option.id, text: redact(option.text) }));
|
|
@@ -404,7 +424,8 @@ export function viewFor(card, viewer, d) {
|
|
|
404
424
|
// The view of the card a player has now (theirs, else the shared one): a
|
|
405
425
|
// pure function of the card and of who is connected now. Blocks are the
|
|
406
426
|
// session's pairs among the players here (`hiddenPair` answers nothing about
|
|
407
|
-
// a player who has left), so nothing is remembered between sends
|
|
427
|
+
// a player who has left), so nothing is remembered between sends -- but for
|
|
428
|
+
// v1.179 `keepAway`, whose away faces go by `h.ballotSeen` (the invariant).
|
|
408
429
|
function currentView(h, playerId, deps, hidden) {
|
|
409
430
|
const s = h.ballotState;
|
|
410
431
|
const card = s.me.get(playerId) ?? s.shared;
|
|
@@ -412,18 +433,155 @@ function currentView(h, playerId, deps, hidden) {
|
|
|
412
433
|
return viewFor(card, playerId, {
|
|
413
434
|
usernameOf: deps.usernameOf,
|
|
414
435
|
avatarOf: deps.avatarOf,
|
|
436
|
+
...(deps.retained ? { awayOf: (id) => awayProfile(h, deps, playerId, id) } : {}),
|
|
415
437
|
hidden: hiddenIds,
|
|
416
438
|
names: hiddenIds ? deps.namesOf(hiddenIds) : [],
|
|
417
439
|
lines: h.place.ballot.lines,
|
|
418
440
|
});
|
|
419
441
|
}
|
|
420
442
|
|
|
443
|
+
// v1.179 `ballot.keepAway`. THE INVARIANT, from which every send and every
|
|
444
|
+
// tap is derived, from current state only (never from what a card carried):
|
|
445
|
+
//
|
|
446
|
+
// A face of target T is eligible for viewer V iff
|
|
447
|
+
// (1) T is present now (today's rules: in the world, in the session, and no
|
|
448
|
+
// block among players here hides them from V), or
|
|
449
|
+
// (2) T is retained away now (arrived, dropped, inside the resume
|
|
450
|
+
// deadline as prepareResume reckons it, not forgotten, not let go and
|
|
451
|
+
// not dropped right after their own Back -- read at the tap or send
|
|
452
|
+
// itself, not only when reconcile runs), and T's record -- written at the last
|
|
453
|
+
// send T was present -- holds V as present with T at that send, not
|
|
454
|
+
// hidden from T by a block then, under the account V is signed in as
|
|
455
|
+
// now, and the record's T account is the account T's retained visit is
|
|
456
|
+
// held for now. The away face is drawn from that record's snapshot of
|
|
457
|
+
// T's profile (username and avatar, taken at the same send under T's
|
|
458
|
+
// account then), never from the retained visit's entry.
|
|
459
|
+
// Any account change on either id invalidates its records: each id carries
|
|
460
|
+
// a generation that moves the moment its signed-in account is seen to
|
|
461
|
+
// change (any message from that id, a hello among them; a tap naming it; a
|
|
462
|
+
// send's roster read), from one counter per layer that never goes back, so
|
|
463
|
+
// no generation is ever reused; a record names V and T by generation and
|
|
464
|
+
// account. Blocks for (1) are the session's answer for the accounts on
|
|
465
|
+
// both ids now. A guest (anonymous, dev guests included) has no signed-in
|
|
466
|
+
// account and is never in a record. A tap on a face counts iff the face is eligible at
|
|
467
|
+
// tap time by this same rule, whatever `away` the delivered card had.
|
|
468
|
+
//
|
|
469
|
+
// State (`h.ballotSeen`, only in a keepAway place): `ids` playerId ->
|
|
470
|
+
// { account, gen } as last seen present; `records` T -> { tick, account,
|
|
471
|
+
// gen, name, avatar? }, where `tick` is that send's { keys: V -> "gen:account",
|
|
472
|
+
// hidden } shared by every record written at it. Kept from the first send,
|
|
473
|
+
// before any card, so a card made while someone is away still has their face;
|
|
474
|
+
// entries go once their player is neither present nor retained.
|
|
475
|
+
function seenState(h) {
|
|
476
|
+
h.ballotSeen ??= { counter: 0, ids: new Map(), records: new Map() };
|
|
477
|
+
return h.ballotSeen;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// An account change on a player id, the moment anything shows it (a send's
|
|
481
|
+
// roster read, any message from them, a tap naming them): their id takes a
|
|
482
|
+
// new generation and their own record goes. Generations come from one
|
|
483
|
+
// counter per layer that never goes back, so an id forgotten and seen again
|
|
484
|
+
// never takes a generation an older record names. Only for an id in the
|
|
485
|
+
// session roster now; one first seen gets its generation here too.
|
|
486
|
+
export function observe(h, deps, playerId) {
|
|
487
|
+
if (!h.ballotSeen || typeof playerId !== 'string' || !deps.inRoster(playerId)) {
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
const seen = h.ballotSeen;
|
|
491
|
+
const account = deps.identityOf(playerId);
|
|
492
|
+
const id = seen.ids.get(playerId);
|
|
493
|
+
if (!id) {
|
|
494
|
+
seen.counter += 1;
|
|
495
|
+
seen.ids.set(playerId, { account, gen: seen.counter });
|
|
496
|
+
} else if (id.account !== account) {
|
|
497
|
+
seen.counter += 1;
|
|
498
|
+
id.account = account;
|
|
499
|
+
id.gen = seen.counter;
|
|
500
|
+
seen.records.delete(playerId);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
function rememberSeen(h, deps, hidden) {
|
|
505
|
+
const seen = seenState(h);
|
|
506
|
+
const present = [];
|
|
507
|
+
for (const playerId of h.sim.players.keys()) {
|
|
508
|
+
if (!deps.usernameOf(playerId)) {
|
|
509
|
+
continue;
|
|
510
|
+
}
|
|
511
|
+
present.push(playerId);
|
|
512
|
+
observe(h, deps, playerId);
|
|
513
|
+
}
|
|
514
|
+
const tick = { keys: new Map(), hidden };
|
|
515
|
+
for (const playerId of present) {
|
|
516
|
+
const id = seen.ids.get(playerId);
|
|
517
|
+
if (typeof id.account === 'string') {
|
|
518
|
+
tick.keys.set(playerId, `${id.gen}:${id.account}`);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
for (const playerId of present) {
|
|
522
|
+
const id = seen.ids.get(playerId);
|
|
523
|
+
const profile = typeof id.account === 'string' ? deps.profileOf(playerId, id.account) : null;
|
|
524
|
+
if (profile) {
|
|
525
|
+
seen.records.set(playerId, { tick, account: id.account, gen: id.gen, ...profile });
|
|
526
|
+
} else {
|
|
527
|
+
seen.records.delete(playerId);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
const here = new Set(present);
|
|
531
|
+
for (const map of [seen.ids, seen.records]) {
|
|
532
|
+
for (const playerId of map.keys()) {
|
|
533
|
+
if (!here.has(playerId) && !deps.retained(playerId)) {
|
|
534
|
+
map.delete(playerId);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// Rule (2): T's away profile for V, `{ name, avatar? }`, or null.
|
|
541
|
+
function awayProfile(h, deps, viewer, target) {
|
|
542
|
+
const seen = h.ballotSeen;
|
|
543
|
+
const record = seen?.records.get(target);
|
|
544
|
+
if (!record || !deps.retained(target)) {
|
|
545
|
+
return null;
|
|
546
|
+
}
|
|
547
|
+
// V as signed in now: an account that moved since the last send has no
|
|
548
|
+
// generation yet, so nothing recorded can match it.
|
|
549
|
+
const account = deps.identityOf(viewer);
|
|
550
|
+
const id = seen.ids.get(viewer);
|
|
551
|
+
if (typeof account !== 'string' || id?.account !== account || record.tick.keys.get(viewer) !== `${id.gen}:${account}`) {
|
|
552
|
+
return null;
|
|
553
|
+
}
|
|
554
|
+
if (record.tick.hidden?.get(viewer)?.has(target)) {
|
|
555
|
+
return null;
|
|
556
|
+
}
|
|
557
|
+
// T's retained visit is held for the account the snapshot was taken under.
|
|
558
|
+
if (deps.awayIdentityOf(target) !== record.account || seen.ids.get(target)?.gen !== record.gen) {
|
|
559
|
+
return null;
|
|
560
|
+
}
|
|
561
|
+
return record.avatar === undefined ? { name: record.name } : { name: record.name, avatar: record.avatar };
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// The invariant, for a tap: rule (1) or rule (2), now, after noting any
|
|
565
|
+
// account change either id shows. Blocks are asked of the session as it is
|
|
566
|
+
// now (the pairs are cached by player id and account, never across a switch).
|
|
567
|
+
function eligible(h, deps, viewer, target) {
|
|
568
|
+
observe(h, deps, viewer);
|
|
569
|
+
observe(h, deps, target);
|
|
570
|
+
if (deps.usernameOf(target)) {
|
|
571
|
+
return !deps.blockedPairs()?.get(viewer)?.has(target);
|
|
572
|
+
}
|
|
573
|
+
return awayProfile(h, deps, viewer, target) !== null;
|
|
574
|
+
}
|
|
575
|
+
|
|
421
576
|
// Each player's card, to them alone, when it changes (and again to a client
|
|
422
577
|
// that joined afresh). Nothing in a place that has never shown one. Whatever
|
|
423
578
|
// is kept for a connection no longer in the world goes, whether or not it
|
|
424
579
|
// ever said hello (`forget` runs only for players who did).
|
|
425
580
|
export function send(h, deps) {
|
|
426
581
|
const s = h.ballotState;
|
|
582
|
+
if (deps.retained) {
|
|
583
|
+
rememberSeen(h, deps, deps.blockedPairs());
|
|
584
|
+
}
|
|
427
585
|
if (!s) {
|
|
428
586
|
return;
|
|
429
587
|
}
|
|
@@ -483,7 +641,7 @@ function allows(view, face, line, option, lines) {
|
|
|
483
641
|
// version of the card they have now, and the ids are allowed by that card as
|
|
484
642
|
// delivered; then the tap is limited and handed to the deck's `ballot` hook.
|
|
485
643
|
// Anything else is dropped unheard.
|
|
486
|
-
export function message(h, player, data, lines) {
|
|
644
|
+
export function message(h, player, data, lines, deps) {
|
|
487
645
|
const playerId = player?.playerId;
|
|
488
646
|
const s = h.ballotState;
|
|
489
647
|
const delivered = s?.views.get(playerId) ?? null;
|
|
@@ -508,6 +666,11 @@ export function message(h, player, data, lines) {
|
|
|
508
666
|
if (!allows(delivered, face, line, option, lines)) {
|
|
509
667
|
return;
|
|
510
668
|
}
|
|
669
|
+
// v1.179 keepAway: a face counts iff it is eligible now (the invariant
|
|
670
|
+
// above), whatever `away` the delivered card had.
|
|
671
|
+
if (face !== null && deps?.retained && !eligible(h, deps, playerId, face)) {
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
511
674
|
const now = Date.now();
|
|
512
675
|
const r = s.rate.get(playerId) ?? { tokens: BURST, at: now };
|
|
513
676
|
r.tokens = Math.min(BURST, r.tokens + (now - r.at) / EVERY_MS);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// v1.205. Server-only Town win moments; no state or wire work before a call.
|
|
2
|
+
import { townDay } from './townDay.js';
|
|
3
|
+
|
|
4
|
+
const GAP_MS = 4000;
|
|
5
|
+
const connected = (h, id) => !h.resumeDeparting?.has(id) && !h.actDeparting?.has(id) && h.players.get(id)?.arrived && !h.players.get(id)?.ended &&
|
|
6
|
+
h.sim?.players.has(id) && h.session?.players.some((p) => p.playerId === id);
|
|
7
|
+
const at = (h, id) => h.sim?.players.get(id)?.at;
|
|
8
|
+
|
|
9
|
+
export function tick(h) {
|
|
10
|
+
const state = h.celebrations;
|
|
11
|
+
if (!state || h.sim.timeMs < state.next) {return;}
|
|
12
|
+
while (state.queue.length) {
|
|
13
|
+
const item = state.queue.shift();
|
|
14
|
+
if (item.session !== h.session || !connected(h, item.player) || item.day !== townDay() || String(h.session.players.find((p) => p.playerId === item.player)?.userId) !== item.user) {continue;}
|
|
15
|
+
const origin = at(h, item.player);
|
|
16
|
+
if (!origin) {continue;}
|
|
17
|
+
const { session, day, user, ...message } = item;
|
|
18
|
+
// Hidden pairs never learn a blocked player's moment or position.
|
|
19
|
+
for (const p of session.players) {
|
|
20
|
+
const target = at(h, p.playerId);
|
|
21
|
+
if (!connected(h, p.playerId) || !target || session.hub?.hiddenPair?.(item.player, p.playerId)) {continue;}
|
|
22
|
+
if (Math.hypot(origin.x - target.x, origin.y - target.y, origin.z - target.z) <= 25) {session.send(p.playerId, { k: 'celebrate', ...message });}
|
|
23
|
+
}
|
|
24
|
+
state.next = h.sim.timeMs + GAP_MS;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function celebrate(h, playerId, spec, userIdOf) {
|
|
30
|
+
if (h.placeId !== 'main' || h.place.result || !connected(h, playerId) || !spec || typeof spec !== 'object' || Array.isArray(spec) ||
|
|
31
|
+
spec.kind !== 'win' || typeof spec.tokens !== 'number' || !Number.isFinite(spec.tokens) ||
|
|
32
|
+
(spec.streak !== undefined && spec.streak !== 3 && spec.streak !== 5) ||
|
|
33
|
+
Object.keys(spec).some((k) => !['kind', 'door', 'tokens', 'streak', 'unlock'].includes(k))) {return Promise.resolve(false);}
|
|
34
|
+
const door = h.actors.find((a) => a.components.HubDoor?.id === spec.door);
|
|
35
|
+
if (!door || (spec.unlock !== undefined && !h.manifest.unlocks?.some((i) => i.id === spec.unlock))) {return Promise.resolve(false);}
|
|
36
|
+
const user = userIdOf(h, playerId);
|
|
37
|
+
if (!user) {return Promise.resolve(false);}
|
|
38
|
+
const day = townDay(), session = h.session;
|
|
39
|
+
const state = h.celebrations ??= { queue: [], next: -Infinity, day, counts: new Map() };
|
|
40
|
+
if (state.day !== day) { state.day = day; state.counts.clear(); }
|
|
41
|
+
const used = state.counts.get(user) ?? 0;
|
|
42
|
+
if (used >= 6 || (state.counts.size >= 1000 && !state.counts.has(user))) {return Promise.resolve(false);}
|
|
43
|
+
state.counts.set(user, used + 1); // Includes outstanding reservations; reconnect never clears it.
|
|
44
|
+
const message = { player: playerId, kind: 'win', door: spec.door, tokens: Math.max(0, Math.min(40, Math.floor(spec.tokens))),
|
|
45
|
+
...(spec.streak !== undefined ? { streak: spec.streak } : {}), ...(spec.unlock !== undefined ? { unlock: spec.unlock } : {}) };
|
|
46
|
+
// Atomic daily count also bounds concurrent layers. An ambiguous failure
|
|
47
|
+
// consumes a reservation and shows nothing; it is never retried here.
|
|
48
|
+
const date = new Date(day * 86400000).toISOString().slice(0, 10);
|
|
49
|
+
let reservation;
|
|
50
|
+
try {
|
|
51
|
+
reservation = session.storage?.deck?.increment
|
|
52
|
+
? session.storage.deck.increment(`earn:${user}:${date}:celebrate`, 1)
|
|
53
|
+
: h.savedDeckId ? Promise.resolve(Infinity) : Promise.resolve(used + 1);
|
|
54
|
+
} catch { return Promise.resolve(false); }
|
|
55
|
+
return Promise.resolve(reservation).then((count) => {
|
|
56
|
+
if (!Number.isSafeInteger(count) || count < 1 || count > 6 || session !== h.session || !connected(h, playerId) || userIdOf(h, playerId) !== user || day !== townDay()) {return false;}
|
|
57
|
+
state.queue.push({ session, day, user, ...message });
|
|
58
|
+
if (state.queue.length > 3) {state.queue.shift();}
|
|
59
|
+
tick(h);
|
|
60
|
+
return true;
|
|
61
|
+
}, () => false);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function clear(h) { if (h.celebrations) { h.celebrations.queue.length = 0; h.celebrations.next = -Infinity; } }
|
|
@@ -24,7 +24,14 @@ function current(h, playerId) {
|
|
|
24
24
|
return h.companionMe?.get(playerId) ?? { c: null, n: 0, json: 'null', sentJson: 'null', sentN: 0, sentAt: -Infinity };
|
|
25
25
|
}
|
|
26
26
|
function send(h, playerId, state) {
|
|
27
|
-
|
|
27
|
+
// shown selects public dress on the server. Keep it off the private spec:
|
|
28
|
+
// older clients validate that spec strictly and ignore only hubChirp.
|
|
29
|
+
const c = state.c ? { ...state.c } : null;
|
|
30
|
+
if (c) { delete c.shown; }
|
|
31
|
+
h.session?.send(playerId, { k: 'hub-companion', c, n: state.n });
|
|
32
|
+
// Public dress follows the same coalesced version as the owner's follower.
|
|
33
|
+
state.chirp = state.c?.shown === true
|
|
34
|
+
? ['species', 'wear', 'tint'].map((key) => state.c.dress?.[key] ?? null) : null;
|
|
28
35
|
state.sentN = state.n;
|
|
29
36
|
state.sentJson = state.json;
|
|
30
37
|
state.sentAt = h.sim?.timeMs ?? 0;
|
|
@@ -54,6 +61,7 @@ export function set(h, playerId, c) {
|
|
|
54
61
|
(h.companionMe ??= new Map()).set(playerId, { ...state, c: checked, json, n });
|
|
55
62
|
if (checked) {
|
|
56
63
|
h.companionUsed = true;
|
|
64
|
+
if (checked.shown === true) { h.companionShownUsed = true; }
|
|
57
65
|
}
|
|
58
66
|
return true;
|
|
59
67
|
}
|
|
@@ -101,7 +109,14 @@ export function prune(h) {
|
|
|
101
109
|
}
|
|
102
110
|
}
|
|
103
111
|
|
|
104
|
-
// Public presence alone
|
|
112
|
+
// Public presence alone; opt-in dress travels separately in hubChirp.
|
|
105
113
|
export function glowOf(h) {
|
|
106
114
|
return [...(h.companionMe ?? [])].filter(([id, state]) => state.c && h.players.get(id)?.hello && arrived(h, id)).map(([id]) => id).sort();
|
|
107
115
|
}
|
|
116
|
+
|
|
117
|
+
export function chirpOf(h) {
|
|
118
|
+
return [...(h.companionMe ?? [])]
|
|
119
|
+
.filter(([id, state]) => state.chirp && h.players.get(id)?.hello && arrived(h, id))
|
|
120
|
+
.sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)
|
|
121
|
+
.map(([id, state]) => [id, ...state.chirp]);
|
|
122
|
+
}
|
|
@@ -108,7 +108,7 @@ export function checkSpec(h, value) {
|
|
|
108
108
|
const tabs = new Set(out.tabs.map((tab) => tab.id));
|
|
109
109
|
list(value.items, MAX_ITEMS, 'items');
|
|
110
110
|
out.items = value.items.map((item) => {
|
|
111
|
-
keys(item, ['id', 'tab', 'label', 'template', 'w', 'd', 'layer', 'count', 'locked'], 'item');
|
|
111
|
+
keys(item, ['id', 'tab', 'label', 'template', 'w', 'd', 'layer', 'count', 'locked', 'action'], 'item');
|
|
112
112
|
id(item.id, 'item.id');
|
|
113
113
|
need(tabs.has(item.tab), 'item.tab must name a tab');
|
|
114
114
|
need(text(item.label, 16), 'item.label must be 1..16 characters');
|
|
@@ -118,6 +118,10 @@ export function checkSpec(h, value) {
|
|
|
118
118
|
need(h.place.decor.layers.includes(item.layer), 'item.layer must name a decor layer');
|
|
119
119
|
need(int(item.count, 0, Number.MAX_SAFE_INTEGER), 'item.count must be a non-negative integer');
|
|
120
120
|
const entry = { id: item.id, tab: item.tab, label: item.label, template: item.template, w: item.w, d: item.d, layer: item.layer, count: item.count };
|
|
121
|
+
if (Object.hasOwn(item, 'action')) {
|
|
122
|
+
need(item.action === true, 'item.action must be true');
|
|
123
|
+
entry.action = true;
|
|
124
|
+
}
|
|
121
125
|
if (item.locked !== undefined) {
|
|
122
126
|
keys(item.locked, ['price'], 'item.locked');
|
|
123
127
|
need(text(item.locked.price, 12), 'locked.price must be 1..12 characters');
|
|
@@ -244,7 +248,7 @@ export function message(h, playerId, data) {
|
|
|
244
248
|
need(int(data.x, 0, grid.w - 1) && int(data.z, 0, grid.d - 1) && int(data.rot, 0, 3), 'invalid cells or rotation');
|
|
245
249
|
if (data.op === 'place') {
|
|
246
250
|
const item = spec.items.find((i) => i.id === data.item);
|
|
247
|
-
need(item && !item.locked && item.count > 0, 'item is unavailable');
|
|
251
|
+
need(item && !item.action && !item.locked && item.count > 0, 'item is unavailable');
|
|
248
252
|
op = { op: 'place', item: data.item, x: data.x, z: data.z, rot: data.rot };
|
|
249
253
|
} else {
|
|
250
254
|
need(spec.placed.some((p) => p.key === data.key), 'piece is not in this catalogue');
|
|
@@ -252,6 +256,11 @@ export function message(h, playerId, data) {
|
|
|
252
256
|
}
|
|
253
257
|
break;
|
|
254
258
|
}
|
|
259
|
+
case 'pick':
|
|
260
|
+
keys(data, ['k', 'op', 'item'], 'pick op');
|
|
261
|
+
need(spec.items.some((i) => i.id === data.item && i.action === true && !i.locked), 'action is unavailable');
|
|
262
|
+
op = { op: 'pick', item: data.item };
|
|
263
|
+
break;
|
|
255
264
|
case 'stash':
|
|
256
265
|
keys(data, ['k', 'op', 'key'], 'stash op');
|
|
257
266
|
need(spec.placed.some((p) => p.key === data.key), 'piece is not in this catalogue');
|