castle-web-cli 0.4.232 → 0.4.234
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-failures.d.ts +8 -0
- package/dist/agent-failures.js +19 -2
- package/dist/agent-prompts.d.ts +1 -1
- package/dist/agent-prompts.js +10 -3
- package/dist/agent.d.ts +64 -3
- package/dist/agent.js +170 -81
- package/dist/api.d.ts +11 -0
- package/dist/api.js +43 -0
- package/dist/bundle.d.ts +64 -0
- package/dist/bundle.js +558 -2
- package/dist/castle-host/host.d.ts +18 -2
- package/dist/castle-host/host.js +844 -39
- package/dist/castleJson.d.ts +23 -2
- package/dist/castleJson.js +46 -2
- package/dist/check.d.ts +3 -1
- package/dist/check.js +20 -3
- package/dist/chunkLoader.d.ts +3 -0
- package/dist/chunkLoader.js +111 -0
- package/dist/devParty.d.ts +26 -0
- package/dist/devParty.js +231 -0
- package/dist/devSaveStorage.js +4 -0
- package/dist/devSessionStorage.js +50 -2
- package/dist/devSocial.d.ts +24 -0
- package/dist/devSocial.js +70 -0
- package/dist/ide.d.ts +2 -0
- package/dist/ide.js +119 -15
- package/dist/importPinMismatch.d.ts +22 -0
- package/dist/importPinMismatch.js +77 -0
- package/dist/importRegression.js +3 -15
- package/dist/imports.d.ts +10 -3
- package/dist/imports.js +88 -20
- package/dist/index.js +11 -4
- package/dist/init.js +1 -1
- package/dist/platformDoc.js +22 -0
- package/dist/routerFences.d.ts +5 -0
- package/dist/routerFences.js +12 -2
- package/dist/save-deck.d.ts +25 -1
- package/dist/save-deck.js +178 -9
- package/dist/serve.js +32 -11
- package/dist/shell/assets/{index-D2tWM896.js → index-DulbYIJm.js} +97 -97
- package/dist/shell/assets/index-MVLfNYd9.css +1 -0
- package/dist/shell/index.html +2 -2
- package/dist/taskSteer.d.ts +13 -0
- package/dist/taskSteer.js +22 -2
- package/dist/vitePlugins.d.ts +2 -1
- package/dist/vitePlugins.js +13 -0
- package/kits/base/castle.json +1 -1
- package/kits/base/package-lock.json +1 -1
- package/kits/base/sdk/README.md +339 -5
- package/kits/base/sdk/avatar.d.ts +6 -2
- package/kits/base/sdk/avatar.js +12 -4
- package/kits/base/sdk/castle.d.ts +7 -3
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +176 -1
- package/kits/base/sdk/commands.js +3 -0
- package/kits/base/sdk/display.d.ts +3 -0
- package/kits/base/sdk/display.js +9 -3
- package/kits/base/sdk/hub.d.ts +37 -6
- package/kits/base/sdk/hub.js +63 -4
- package/kits/base/sdk/multiplayer.d.ts +7 -1
- package/kits/base/sdk/multiplayer.js +148 -32
- package/kits/base/sdk/multiplayerProtocol.d.ts +2 -0
- package/kits/base/sdk/party.d.ts +23 -0
- package/kits/base/sdk/party.js +91 -0
- package/kits/base/sdk/reconnectBudget.d.ts +23 -0
- package/kits/base/sdk/reconnectBudget.js +96 -0
- package/kits/base/sdk/save.d.ts +38 -1
- package/kits/base/sdk/save.js +81 -7
- package/kits/base/sdk/server/hub.d.ts +117 -0
- package/kits/base/sdk/server/hub.js +119 -2
- package/kits/base/sdk/server/platformHandle.d.ts +43 -1
- package/kits/base/sdk/server/storage.d.ts +17 -0
- package/kits/base/sdk/server/storage.js +65 -3
- package/kits/base/sdk/server/wrapper.d.ts +43 -6
- package/kits/base/sdk/server/wrapper.js +93 -9
- package/kits/base/sdk/social.d.ts +9 -0
- package/kits/base/sdk/social.js +5 -0
- package/kits/hub-game/CLAUDE.md +451 -13
- package/kits/hub-game/README.md +63 -0
- package/kits/hub-game/blueprints/avatar-10.scene +28 -0
- package/kits/hub-game/blueprints/avatar-11.scene +28 -0
- package/kits/hub-game/blueprints/avatar-12.scene +28 -0
- package/kits/hub-game/blueprints/avatar-13.scene +28 -0
- package/kits/hub-game/blueprints/avatar-14.scene +28 -0
- package/kits/hub-game/blueprints/avatar-15.scene +28 -0
- package/kits/hub-game/blueprints/avatar-4.scene +28 -0
- package/kits/hub-game/blueprints/avatar-5.scene +28 -0
- package/kits/hub-game/blueprints/avatar-6.scene +28 -0
- package/kits/hub-game/blueprints/avatar-7.scene +28 -0
- package/kits/hub-game/blueprints/avatar-8.scene +28 -0
- package/kits/hub-game/blueprints/avatar-9.scene +28 -0
- package/kits/hub-game/castle.json +5 -5
- package/kits/hub-game/code/client/act.js +312 -0
- package/kits/hub-game/code/client/actionLayout.js +147 -0
- package/kits/hub-game/code/client/actionOverflow.js +556 -0
- package/kits/hub-game/code/client/actorBudget.js +47 -0
- package/kits/hub-game/code/client/arrivalCamera.js +50 -0
- package/kits/hub-game/code/client/askSlot.js +117 -0
- package/kits/hub-game/code/client/attention.js +11 -2
- package/kits/hub-game/code/client/avatar.js +311 -35
- package/kits/hub-game/code/client/avatarCap.js +228 -0
- package/kits/hub-game/code/client/avatarColors.js +70 -0
- package/kits/hub-game/code/client/avatarFaces.js +21 -0
- package/kits/hub-game/code/client/avatarShare.js +253 -0
- package/kits/hub-game/code/client/backVisibility.js +13 -0
- package/kits/hub-game/code/client/ballot.js +472 -0
- package/kits/hub-game/code/client/build.js +38 -0
- package/kits/hub-game/code/client/chat.js +41 -5
- package/kits/hub-game/code/client/chatModeration.js +5 -0
- package/kits/hub-game/code/client/chrome.js +2144 -160
- package/kits/hub-game/code/client/companion.js +716 -0
- package/kits/hub-game/code/client/companionDress.js +99 -0
- package/kits/hub-game/code/client/crowdNames.js +241 -0
- package/kits/hub-game/code/client/decor.js +515 -0
- package/kits/hub-game/code/client/defaultEnvironment.js +194 -0
- package/kits/hub-game/code/client/doorErrors.js +39 -0
- package/kits/hub-game/code/client/earned.js +131 -0
- package/kits/hub-game/code/client/emoteBubble.js +75 -0
- package/kits/hub-game/code/client/fall.js +18 -0
- package/kits/hub-game/code/client/farAvatars.js +233 -0
- package/kits/hub-game/code/client/firstJoin.js +9 -2
- package/kits/hub-game/code/client/fpsTelemetry.js +50 -0
- package/kits/hub-game/code/client/frameBatch.js +5 -0
- package/kits/hub-game/code/client/grab.js +368 -29
- package/kits/hub-game/code/client/hookLayer.js +385 -20
- package/kits/hub-game/code/client/hudCopy.js +51 -0
- package/kits/hub-game/code/client/hudRate.js +20 -0
- package/kits/hub-game/code/client/idle.js +177 -24
- package/kits/hub-game/code/client/interestCap.js +81 -0
- package/kits/hub-game/code/client/invites.js +231 -0
- package/kits/hub-game/code/client/joinError.js +9 -0
- package/kits/hub-game/code/client/keys.js +36 -0
- package/kits/hub-game/code/client/labelsNear.js +234 -0
- package/kits/hub-game/code/client/landscapeLayout.js +17 -0
- package/kits/hub-game/code/client/layoutCache.js +264 -0
- package/kits/hub-game/code/client/loadTelemetry.js +20 -0
- package/kits/hub-game/code/client/loadingCover.js +148 -0
- package/kits/hub-game/code/client/loadingEntry.js +8 -0
- package/kits/hub-game/code/client/menuIcons.js +34 -0
- package/kits/hub-game/code/client/menuRows.js +43 -0
- package/kits/hub-game/code/client/modelReady.js +7 -0
- package/kits/hub-game/code/client/pack.js +6 -2
- package/kits/hub-game/code/client/packFormat.js +3 -3
- package/kits/hub-game/code/client/padCueArrival.js +23 -0
- package/kits/hub-game/code/client/padCues.js +112 -0
- package/kits/hub-game/code/client/padOccupancy.js +88 -0
- package/kits/hub-game/code/client/padReadability.js +26 -0
- package/kits/hub-game/code/client/padRings.js +69 -0
- package/kits/hub-game/code/client/pushVisit.js +14 -0
- package/kits/hub-game/code/client/quality.js +205 -0
- package/kits/hub-game/code/client/qualityEntry.js +55 -0
- package/kits/hub-game/code/client/rehello.js +167 -0
- package/kits/hub-game/code/client/safeLayout.js +338 -0
- package/kits/hub-game/code/client/safeStyle.js +42 -0
- package/kits/hub-game/code/client/say.js +12 -3
- package/kits/hub-game/code/client/shot.js +146 -0
- package/kits/hub-game/code/client/shotFit.js +56 -0
- package/kits/hub-game/code/client/signIn.js +28 -0
- package/kits/hub-game/code/client/sound.js +63 -8
- package/kits/hub-game/code/client/soundscape.js +1151 -0
- package/kits/hub-game/code/client/soundscapeActions.js +99 -0
- package/kits/hub-game/code/client/soundscapeAmbience.js +453 -0
- package/kits/hub-game/code/client/soundscapeBaked.js +143 -0
- package/kits/hub-game/code/client/soundscapeBusker.js +217 -0
- package/kits/hub-game/code/client/soundscapeCourt.js +200 -0
- package/kits/hub-game/code/client/soundscapeCrowd.js +331 -0
- package/kits/hub-game/code/client/soundscapeCues.js +362 -0
- package/kits/hub-game/code/client/soundscapeMap.js +181 -0
- package/kits/hub-game/code/client/soundscapeMarket.js +176 -0
- package/kits/hub-game/code/client/soundscapeMusic.js +126 -0
- package/kits/hub-game/code/client/soundscapeMusicEngine.js +460 -0
- package/kits/hub-game/code/client/soundscapeSimlish.js +737 -0
- package/kits/hub-game/code/client/soundscapeSongs.js +127 -0
- package/kits/hub-game/code/client/soundscapeSongsRound3.js +63 -0
- package/kits/hub-game/code/client/soundscapeSynthesis.js +168 -0
- package/kits/hub-game/code/client/soundscapeUi.js +211 -0
- package/kits/hub-game/code/client/soundscapeVoice.js +1209 -0
- package/kits/hub-game/code/client/soundscapeWaves.js +206 -0
- package/kits/hub-game/code/client/spin.js +101 -0
- package/kits/hub-game/code/client/state.js +162 -1
- package/kits/hub-game/code/client/stuck.js +259 -0
- package/kits/hub-game/code/client/talk.js +714 -59
- package/kits/hub-game/code/client/tiers.js +543 -52
- package/kits/hub-game/code/client/toastBand.js +37 -0
- package/kits/hub-game/code/client/together.js +39 -2
- package/kits/hub-game/code/client/visibility.js +43 -0
- package/kits/hub-game/code/client/weakestLookBake.js +92 -0
- package/kits/hub-game/code/client/weakestTier.js +295 -0
- package/kits/hub-game/code/client/wear.js +461 -170
- package/kits/hub-game/code/client/worldLabels.js +241 -0
- package/kits/hub-game/code/client/yours.js +200 -0
- package/kits/hub-game/code/companionSpec.js +45 -0
- package/kits/hub-game/code/npcDisplayText.js +55 -0
- package/kits/hub-game/code/privateText.js +7 -0
- package/kits/hub-game/code/server/act.js +124 -0
- package/kits/hub-game/code/server/actions.js +138 -0
- package/kits/hub-game/code/server/actors.js +11 -2
- package/kits/hub-game/code/server/analytics.js +83 -0
- package/kits/hub-game/code/server/anonymousEntry.js +49 -0
- package/kits/hub-game/code/server/arrivalPose.js +36 -0
- package/kits/hub-game/code/server/ask.js +155 -0
- package/kits/hub-game/code/server/ballot.js +539 -0
- package/kits/hub-game/code/server/cells.js +100 -0
- package/kits/hub-game/code/server/companion.js +107 -0
- package/kits/hub-game/code/server/cues.js +70 -0
- package/kits/hub-game/code/server/decor.js +269 -0
- package/kits/hub-game/code/server/doorAnalytics.js +52 -0
- package/kits/hub-game/code/server/earned.js +478 -0
- package/kits/hub-game/code/server/frameBatch.js +183 -0
- package/kits/hub-game/code/server/friendBests.js +166 -0
- package/kits/hub-game/code/server/friendsAmong.js +272 -0
- package/kits/hub-game/code/server/history.js +7 -0
- package/kits/hub-game/code/server/hub.js +2510 -95
- package/kits/hub-game/code/server/idle.js +60 -12
- package/kits/hub-game/code/server/index.js +28 -6
- package/kits/hub-game/code/server/invites.js +19 -0
- package/kits/hub-game/code/server/labels.js +36 -2
- package/kits/hub-game/code/server/loadAbandon.js +106 -0
- package/kits/hub-game/code/server/manifest.js +586 -7
- package/kits/hub-game/code/server/menu.js +161 -0
- package/kits/hub-game/code/server/npcs.js +1025 -113
- package/kits/hub-game/code/server/observe.js +408 -0
- package/kits/hub-game/code/server/padOccupancy.js +85 -0
- package/kits/hub-game/code/server/party.js +2 -2
- package/kits/hub-game/code/server/players.js +30 -0
- package/kits/hub-game/code/server/resumePose.js +152 -0
- package/kits/hub-game/code/server/say.js +1 -1
- package/kits/hub-game/code/server/shot.js +110 -0
- package/kits/hub-game/code/server/standing.js +123 -0
- package/kits/hub-game/code/server/storageLimit.js +187 -0
- package/kits/hub-game/code/server/vis.js +175 -0
- package/kits/hub-game/code/server/wear.js +12 -0
- package/kits/hub-game/code/server/yours.js +59 -0
- package/kits/hub-game/code/shared/act.js +35 -0
- package/kits/hub-game/code/shared/cues.js +9 -0
- package/kits/hub-game/code/shared/danceIdle.js +28 -0
- package/kits/hub-game/code/shared/decor.js +41 -0
- package/kits/hub-game/code/shared/loadStages.js +12 -0
- package/kits/hub-game/code/shared/quality.js +74 -0
- package/kits/hub-game/code/shared/say.js +2 -0
- package/kits/hub-game/code/shared/shot.js +53 -0
- package/kits/hub-game/code/shared/spin.js +57 -0
- package/kits/hub-game/code/systems/hub.js +1753 -202
- package/kits/hub-game/docs/analytics.md +279 -0
- package/kits/hub-game/docs/content-pack.md +1 -1
- package/kits/hub-game/docs/contract.md +3475 -77
- package/kits/hub-game/docs/home-pieces.md +71 -0
- package/kits/hub-game/docs/observed-progress.md +252 -0
- package/kits/hub-game/main.jsx +2 -0
- package/kits/hub-game/models/avatar-10.pxmodel +28 -0
- package/kits/hub-game/models/avatar-11.pxmodel +28 -0
- package/kits/hub-game/models/avatar-12.pxmodel +27 -0
- package/kits/hub-game/models/avatar-13.pxmodel +24 -0
- package/kits/hub-game/models/avatar-14.pxmodel +29 -0
- package/kits/hub-game/models/avatar-15.pxmodel +24 -0
- package/kits/hub-game/models/avatar-4.pxmodel +29 -0
- package/kits/hub-game/models/avatar-5.pxmodel +27 -0
- package/kits/hub-game/models/avatar-6.pxmodel +26 -0
- package/kits/hub-game/models/avatar-7.pxmodel +25 -0
- package/kits/hub-game/models/avatar-8.pxmodel +24 -0
- package/kits/hub-game/models/avatar-9.pxmodel +30 -0
- package/kits/hub-game/models/earned/badge-round.pxmodel +100 -0
- package/kits/hub-game/models/earned/badge-shield.pxmodel +117 -0
- package/kits/hub-game/models/earned/badge-star.pxmodel +87 -0
- package/kits/hub-game/models/earned/belt-plain.pxmodel +72 -0
- package/kits/hub-game/models/earned/held-ball.pxmodel +43 -0
- package/kits/hub-game/models/earned/held-lantern.pxmodel +85 -0
- package/kits/hub-game/models/earned/held-net.pxmodel +57 -0
- package/kits/hub-game/models/earned/held-trophy.pxmodel +109 -0
- package/kits/hub-game/models/earned/pin-round.pxmodel +62 -0
- package/kits/hub-game/models/earned/sash-plain.pxmodel +66 -0
- package/kits/hub-game/models/earned/square/belt-plain.pxmodel +104 -0
- package/kits/hub-game/models/earned/square/sash-plain.pxmodel +98 -0
- package/kits/hub-game/models/hats/bat-clip.pxmodel +206 -0
- package/kits/hub-game/models/hats/beekeeper.pxmodel +149 -0
- package/kits/hub-game/models/hats/cap.pxmodel +162 -0
- package/kits/hub-game/models/hats/captain.pxmodel +178 -0
- package/kits/hub-game/models/hats/crooked-top.pxmodel +172 -0
- package/kits/hub-game/models/hats/flower-crown.pxmodel +451 -0
- package/kits/hub-game/models/hats/foam-crown.pxmodel +179 -0
- package/kits/hub-game/models/hats/lantern.pxmodel +230 -0
- package/kits/hub-game/models/hats/laurel.pxmodel +533 -0
- package/kits/hub-game/models/hats/lighthouse.pxmodel +96 -0
- package/kits/hub-game/models/hats/sailor.pxmodel +141 -0
- package/kits/hub-game/models/hats/souwester.pxmodel +131 -0
- package/kits/hub-game/models/hats/straw.pxmodel +139 -0
- package/kits/hub-game/models/hats/sunflower.pxmodel +406 -0
- package/kits/hub-game/models/hats/sweatband.pxmodel +112 -0
- package/kits/hub-game/models/hats/witch.pxmodel +147 -0
- package/kits/hub-game/package-lock.json +10 -1
- package/kits/hub-game/package.json +6 -2
- package/kits/hub-game/play/player.js +142 -0
- package/kits/hub-game/play/registry.js +47 -0
- package/kits/hub-game/play.jsx +37 -0
- package/kits/hub-game/scripts/check.mjs +117 -16
- package/kits/hub-game/scripts/companion-follower-wire.json +1 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +132 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless.json +293 -0
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +26 -0
- package/kits/hub-game/scripts/fixtures/fake-dom.mjs +123 -0
- package/kits/hub-game/scripts/fixtures/interest-legacy.json +385 -0
- package/kits/hub-game/scripts/fixtures/npc-notes-v1.77.jsonl +4 -0
- package/kits/hub-game/scripts/fixtures/vis-shared-wire.json +1 -0
- package/kits/hub-game/scripts/gen-avatars.mjs +933 -16
- package/kits/hub-game/scripts/gen-earned.mjs +285 -0
- package/kits/hub-game/scripts/gen-hats.mjs +827 -0
- package/kits/hub-game/scripts/grab.before-orbit.mjs +400 -0
- package/kits/hub-game/scripts/pose-storage-fixture.mjs +46 -0
- package/kits/hub-game/scripts/soundscape-wave-analysis.mjs +125 -0
- package/kits/hub-game/scripts/test-act-client.mjs +186 -0
- package/kits/hub-game/scripts/test-act.mjs +171 -0
- package/kits/hub-game/scripts/test-action-layout.mjs +80 -0
- package/kits/hub-game/scripts/test-action-observers.mjs +46 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +853 -0
- package/kits/hub-game/scripts/test-actions.mjs +298 -0
- package/kits/hub-game/scripts/test-actor-budget.mjs +44 -0
- package/kits/hub-game/scripts/test-actors.mjs +38 -23
- package/kits/hub-game/scripts/test-analytics.mjs +76 -0
- package/kits/hub-game/scripts/test-anonymous-entry.mjs +28 -0
- package/kits/hub-game/scripts/test-arrival-pose-server.mjs +196 -0
- package/kits/hub-game/scripts/test-arrival-pose.mjs +24 -0
- package/kits/hub-game/scripts/test-ask-client.mjs +358 -0
- package/kits/hub-game/scripts/test-ask-slot.mjs +85 -0
- package/kits/hub-game/scripts/test-ask.mjs +269 -0
- package/kits/hub-game/scripts/test-attention.mjs +10 -1
- package/kits/hub-game/scripts/test-avatar-cap.mjs +379 -0
- package/kits/hub-game/scripts/test-avatar-colors.mjs +72 -0
- package/kits/hub-game/scripts/test-avatar-models.mjs +181 -0
- package/kits/hub-game/scripts/test-avatar-share.mjs +318 -0
- package/kits/hub-game/scripts/test-avatar-wire.mjs +792 -0
- package/kits/hub-game/scripts/test-avatar.mjs +584 -7
- package/kits/hub-game/scripts/test-back-visibility.mjs +82 -0
- package/kits/hub-game/scripts/test-ballot.mjs +1008 -0
- package/kits/hub-game/scripts/test-ban-join.mjs +121 -13
- package/kits/hub-game/scripts/test-build.mjs +49 -0
- package/kits/hub-game/scripts/test-cells.mjs +71 -0
- package/kits/hub-game/scripts/test-chat.mjs +863 -0
- package/kits/hub-game/scripts/test-classic.mjs +2 -0
- package/kits/hub-game/scripts/test-companion-chat.mjs +216 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +1167 -0
- package/kits/hub-game/scripts/test-companion.mjs +259 -0
- package/kits/hub-game/scripts/test-control-layout-dom.mjs +120 -0
- package/kits/hub-game/scripts/test-crowd-names.mjs +205 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +344 -0
- package/kits/hub-game/scripts/test-decor.mjs +464 -0
- package/kits/hub-game/scripts/test-default-environment-root.mjs +95 -0
- package/kits/hub-game/scripts/test-default-environment.mjs +267 -0
- package/kits/hub-game/scripts/test-door-analytics.mjs +58 -0
- package/kits/hub-game/scripts/test-door-jump.mjs +100 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +459 -0
- package/kits/hub-game/scripts/test-earned.mjs +1224 -0
- package/kits/hub-game/scripts/test-emote-bubble.mjs +110 -0
- package/kits/hub-game/scripts/test-far-avatars.mjs +340 -0
- package/kits/hub-game/scripts/test-fps-telemetry.mjs +112 -0
- package/kits/hub-game/scripts/test-frame-batch.mjs +252 -0
- package/kits/hub-game/scripts/test-fresh-friends.mjs +118 -0
- package/kits/hub-game/scripts/test-friend-bests.mjs +435 -0
- package/kits/hub-game/scripts/test-grab-orbit.mjs +961 -0
- package/kits/hub-game/scripts/test-grab.mjs +7 -0
- package/kits/hub-game/scripts/test-hats.mjs +422 -168
- package/kits/hub-game/scripts/test-high-only.mjs +170 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +203 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +758 -2
- package/kits/hub-game/scripts/test-hub-trip.mjs +1594 -12
- package/kits/hub-game/scripts/test-hud-clear.mjs +484 -57
- package/kits/hub-game/scripts/test-hud-defects-dom.mjs +100 -0
- package/kits/hub-game/scripts/test-hud-rate.mjs +224 -0
- package/kits/hub-game/scripts/test-hud-safe-visibility-dom.mjs +83 -0
- package/kits/hub-game/scripts/test-idle.mjs +427 -1
- package/kits/hub-game/scripts/test-interest-cap.mjs +36 -0
- package/kits/hub-game/scripts/test-interest-cells.mjs +513 -0
- package/kits/hub-game/scripts/test-interest-client.mjs +118 -0
- package/kits/hub-game/scripts/test-interest.mjs +15 -0
- package/kits/hub-game/scripts/test-invites-client.mjs +430 -0
- package/kits/hub-game/scripts/test-invites.mjs +109 -0
- package/kits/hub-game/scripts/test-keys.mjs +46 -1
- package/kits/hub-game/scripts/test-labels.mjs +664 -0
- package/kits/hub-game/scripts/test-landscape-layout.mjs +194 -0
- package/kits/hub-game/scripts/test-list-scroll-dom.mjs +49 -0
- package/kits/hub-game/scripts/test-load-abandon.mjs +246 -0
- package/kits/hub-game/scripts/test-loading-cover.mjs +162 -0
- package/kits/hub-game/scripts/test-manifest.mjs +472 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +585 -0
- package/kits/hub-game/scripts/test-menu.mjs +319 -0
- package/kits/hub-game/scripts/test-npcs.mjs +2528 -13
- package/kits/hub-game/scripts/test-object-entry.mjs +76 -0
- package/kits/hub-game/scripts/test-observed.mjs +745 -0
- package/kits/hub-game/scripts/test-pack.mjs +7 -0
- package/kits/hub-game/scripts/test-pad-cues.mjs +304 -0
- package/kits/hub-game/scripts/test-pad-occupancy.mjs +177 -0
- package/kits/hub-game/scripts/test-picker.mjs +541 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +690 -0
- package/kits/hub-game/scripts/test-progress-reset.mjs +559 -0
- package/kits/hub-game/scripts/test-push-visit.mjs +26 -0
- package/kits/hub-game/scripts/test-quality.mjs +385 -0
- package/kits/hub-game/scripts/test-rehello.mjs +1733 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +222 -0
- package/kits/hub-game/scripts/test-relations-refresh.mjs +188 -0
- package/kits/hub-game/scripts/test-resume-action-order.mjs +598 -0
- package/kits/hub-game/scripts/test-resume-held.mjs +239 -0
- package/kits/hub-game/scripts/test-resume-pose.mjs +142 -0
- package/kits/hub-game/scripts/test-safe-events-dom.mjs +116 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +330 -0
- package/kits/hub-game/scripts/test-say.mjs +1 -1
- package/kits/hub-game/scripts/test-shot.mjs +901 -0
- package/kits/hub-game/scripts/test-signin-client.mjs +45 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +5437 -0
- package/kits/hub-game/scripts/test-spin.mjs +314 -0
- package/kits/hub-game/scripts/test-standing.mjs +449 -0
- package/kits/hub-game/scripts/test-storage-limit.mjs +333 -0
- package/kits/hub-game/scripts/test-stuck.mjs +1904 -0
- package/kits/hub-game/scripts/test-talk-overlay-dom.mjs +130 -0
- package/kits/hub-game/scripts/test-tier-cells.mjs +706 -0
- package/kits/hub-game/scripts/test-tiers-render.mjs +412 -0
- package/kits/hub-game/scripts/test-tiers.mjs +476 -2
- package/kits/hub-game/scripts/test-toast-band.mjs +61 -0
- package/kits/hub-game/scripts/test-try-on.mjs +22 -22
- package/kits/hub-game/scripts/test-vis.mjs +770 -0
- package/kits/hub-game/scripts/test-visibility.mjs +134 -0
- package/kits/hub-game/scripts/test-weakest-tier.mjs +924 -0
- package/kits/hub-game/scripts/test-world-labels.mjs +367 -0
- package/kits/hub-game/scripts/test-yours-chrome.mjs +210 -0
- package/kits/hub-game/scripts/test-yours.mjs +403 -0
- package/kits/multiplayer-3d/CLAUDE.md +50 -0
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/avatars.js +7 -0
- package/kits/multiplayer-3d/code/client/gait.js +65 -0
- package/kits/multiplayer-3d/code/client/joinFailure.js +27 -0
- package/kits/multiplayer-3d/code/client/nameTags.js +59 -4
- package/kits/multiplayer-3d/code/client/resumeGate.js +139 -0
- package/kits/multiplayer-3d/code/options.js +5 -0
- package/kits/multiplayer-3d/code/server/ownership.js +10 -2
- package/kits/multiplayer-3d/code/server/sceneBodies.js +12 -0
- package/kits/multiplayer-3d/code/server/world.js +7 -0
- package/kits/multiplayer-3d/code/systems/multiplayer.js +443 -34
- package/kits/multiplayer-3d/package-lock.json +8 -1
- package/kits/multiplayer-3d/package.json +3 -1
- package/kits/multiplayer-3d/scripts/fixtures/README.md +11 -0
- package/kits/multiplayer-3d/scripts/fixtures/ownership-legacy.json +2 -0
- package/kits/multiplayer-3d/scripts/ownership-harness.mjs +102 -0
- package/kits/multiplayer-3d/scripts/ownership-loader.mjs +46 -0
- package/kits/multiplayer-3d/scripts/ownership-worker.mjs +15 -0
- package/kits/multiplayer-3d/scripts/record-ownership-session.mjs +98 -0
- package/kits/multiplayer-3d/scripts/test-eligible-claims.mjs +167 -0
- package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +436 -0
- package/kits/multiplayer-3d/scripts/test-own-name-tag.mjs +247 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +624 -0
- package/kits/physics-2d/CLAUDE.md +19 -1
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/frozenActors.js +233 -0
- package/kits/physics-2d/engine/scene.js +337 -3
- package/kits/physics-2d/engine/skyKey.js +129 -0
- package/kits/physics-2d/engine/stillClock.js +106 -0
- package/kits/physics-2d/engine/updateBudget.js +21 -0
- package/kits/physics-2d/eslint.config.js +1 -1
- package/kits/physics-2d/play/behaviors/AnalogStick.js +198 -0
- package/kits/physics-2d/play/behaviors/Camera.js +40 -0
- package/kits/physics-2d/play/behaviors/Collider.js +122 -0
- package/kits/physics-2d/play/behaviors/Draggable.js +115 -0
- package/kits/physics-2d/play/behaviors/Goal.js +46 -0
- package/kits/physics-2d/play/behaviors/Joints.js +126 -0
- package/kits/physics-2d/play/behaviors/Layout.js +71 -0
- package/kits/physics-2d/play/behaviors/RigidBody.js +57 -0
- package/kits/physics-2d/play/behaviors/Slingshot.js +142 -0
- package/kits/physics-2d/play/behaviors/SoundPlayer.js +263 -0
- package/kits/physics-2d/play/behaviors/Sprite.js +406 -0
- package/kits/physics-2d/play/behaviors/Style.js +209 -0
- package/kits/physics-2d/play/behaviors/Text.js +85 -0
- package/kits/physics-2d/play/behaviors/Video.js +93 -0
- package/kits/physics-2d/scripts/test-skip-unchanged.mjs +326 -1
- package/kits/physics-3d/CLAUDE.md +42 -529
- package/kits/physics-3d/behaviors/Body.jsx +3 -0
- package/kits/physics-3d/behaviors/Model.jsx +3 -0
- package/kits/physics-3d/behaviors/Player.jsx +661 -87
- package/kits/physics-3d/behaviors/Shape.jsx +3 -0
- package/kits/physics-3d/behaviors/Solid.jsx +3 -0
- package/kits/physics-3d/behaviors/Transform.jsx +3 -0
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/engine-camera.md +542 -0
- package/kits/physics-3d/docs/engine-frame-cap.md +136 -0
- package/kits/physics-3d/docs/engine-load.md +149 -0
- package/kits/physics-3d/docs/engine-look.md +114 -0
- package/kits/physics-3d/docs/engine-shadows.md +372 -0
- package/kits/physics-3d/docs/engine-skip-work.md +187 -0
- package/kits/physics-3d/docs/engine-sky.md +198 -0
- package/kits/physics-3d/docs/engine-static-actors.md +226 -0
- package/kits/physics-3d/docs/engine-view.md +37 -0
- package/kits/physics-3d/docs/pxmodel-format.md +9 -1
- package/kits/physics-3d/engine3d/PlayOnly3D.jsx +5 -1
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +19 -277
- package/kits/physics-3d/engine3d/actornode.js +87 -0
- package/kits/physics-3d/engine3d/animationBudget.js +23 -0
- package/kits/physics-3d/engine3d/branches.js +3 -13
- package/kits/physics-3d/engine3d/cage.js +2 -7
- package/kits/physics-3d/engine3d/cageops.js +2 -17
- package/kits/physics-3d/engine3d/dataBehaviors.js +12 -0
- package/kits/physics-3d/engine3d/editorWorld.js +6 -0
- package/kits/physics-3d/engine3d/emptynodes.js +232 -0
- package/kits/physics-3d/engine3d/framecap.js +99 -0
- package/kits/physics-3d/engine3d/frozenphysics.js +140 -0
- package/kits/physics-3d/engine3d/frozenstatics.js +273 -0
- package/kits/physics-3d/engine3d/gait.js +126 -0
- package/kits/physics-3d/engine3d/initialModelFiles.js +18 -0
- package/kits/physics-3d/engine3d/kithooks.js +47 -0
- package/kits/physics-3d/engine3d/look.js +514 -48
- package/kits/physics-3d/engine3d/lookbake.js +208 -0
- package/kits/physics-3d/engine3d/materialpresets.js +2 -0
- package/kits/physics-3d/engine3d/modelFiles.js +3 -17
- package/kits/physics-3d/engine3d/modelMath.js +49 -0
- package/kits/physics-3d/engine3d/modelready.js +16 -0
- package/kits/physics-3d/engine3d/motion.js +39 -10
- package/kits/physics-3d/engine3d/nearshadows.js +106 -21
- package/kits/physics-3d/engine3d/optimize.js +9 -5
- package/kits/physics-3d/engine3d/orbitinput.js +522 -10
- package/kits/physics-3d/engine3d/orbitlens.js +48 -0
- package/kits/physics-3d/engine3d/ownmodel.js +213 -0
- package/kits/physics-3d/engine3d/partgeometry.js +1 -16
- package/kits/physics-3d/engine3d/paths.js +1 -9
- package/kits/physics-3d/engine3d/playTimings.js +50 -0
- package/kits/physics-3d/engine3d/playerRun.js +372 -0
- package/kits/physics-3d/engine3d/pxmodel.js +42 -11
- package/kits/physics-3d/engine3d/rapier.js +27 -0
- package/kits/physics-3d/engine3d/scatter.js +1 -11
- package/kits/physics-3d/engine3d/shadowfade.js +890 -0
- package/kits/physics-3d/engine3d/sky.js +547 -0
- package/kits/physics-3d/engine3d/skylife.js +306 -0
- package/kits/physics-3d/engine3d/squarefirst.js +177 -0
- package/kits/physics-3d/engine3d/stillshadows.js +399 -0
- package/kits/physics-3d/engine3d/sweep.js +1 -25
- package/kits/physics-3d/engine3d/unchanged.js +11 -0
- package/kits/physics-3d/engine3d/viewrange.js +52 -0
- package/kits/physics-3d/engine3d/world3d.js +1253 -76
- package/kits/physics-3d/eslint.config.js +2 -1
- package/kits/physics-3d/main.jsx +10 -2
- package/kits/physics-3d/package-lock.json +7 -0
- package/kits/physics-3d/package.json +5 -1
- package/kits/physics-3d/play/behaviors/Body.js +31 -0
- package/kits/physics-3d/play/behaviors/Door.js +37 -0
- package/kits/physics-3d/play/behaviors/Lookable.js +16 -0
- package/kits/physics-3d/play/behaviors/Model.js +23 -0
- package/kits/physics-3d/play/behaviors/Pickup.js +46 -0
- package/kits/physics-3d/play/behaviors/Player.js +1204 -0
- package/kits/physics-3d/play/behaviors/Shape.js +47 -0
- package/kits/physics-3d/play/behaviors/Solid.js +16 -0
- package/kits/physics-3d/play/behaviors/Transform.js +29 -0
- package/kits/physics-3d/pnpm-lock.yaml +8 -0
- package/kits/physics-3d/scripts/bench-shadow-fade.mjs +37 -0
- package/kits/physics-3d/scripts/build-rapier-gz.mjs +56 -0
- package/kits/physics-3d/scripts/frozen-statics-fixture.mjs +141 -0
- package/kits/physics-3d/scripts/look-baseline.mjs +155 -0
- package/kits/physics-3d/scripts/test-camera-follow.mjs +5 -1
- package/kits/physics-3d/scripts/test-camera-orbit.mjs +2613 -82
- package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +2 -2
- package/kits/physics-3d/scripts/test-empty-gait-hints.mjs +89 -0
- package/kits/physics-3d/scripts/test-frame-cap-bob.mjs +438 -0
- package/kits/physics-3d/scripts/test-frame-cap.mjs +452 -0
- package/kits/physics-3d/scripts/test-frozen-nested.mjs +49 -0
- package/kits/physics-3d/scripts/test-frozen-statics-legacy-physics2d.mjs +123 -0
- package/kits/physics-3d/scripts/test-frozen-statics.mjs +434 -0
- package/kits/physics-3d/scripts/test-gait.mjs +387 -0
- package/kits/physics-3d/scripts/test-look-bake.mjs +1056 -0
- package/kits/physics-3d/scripts/test-model-parse-cache.mjs +92 -0
- package/kits/physics-3d/scripts/test-near-shadows.mjs +5 -2
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +2001 -0
- package/kits/physics-3d/scripts/test-orbit-shift-lock.mjs +582 -0
- package/kits/physics-3d/scripts/test-orbit-shot.mjs +657 -0
- package/kits/physics-3d/scripts/test-orbit-view.mjs +230 -0
- package/kits/physics-3d/scripts/test-rapier-gz.mjs +106 -0
- package/kits/physics-3d/scripts/test-skip-empty-nodes.mjs +845 -0
- package/kits/physics-3d/scripts/test-sky.mjs +2470 -0
- package/kits/physics-3d/scripts/test-square-first.mjs +921 -0
- package/kits/physics-3d/scripts/test-static-actors.mjs +10 -1
- package/kits/physics-3d/scripts/test-static-physics.mjs +4 -1
- package/kits/physics-3d/scripts/test-static-scenery.mjs +2174 -0
- package/kits/physics-3d/scripts/test-steady-hover.mjs +7 -2
- package/kits/physics-3d/scripts/test-still-shadows.mjs +477 -0
- package/kits/physics-3d/scripts/test-view-range.mjs +260 -0
- package/kits/physics-3d/systems/physics3d.js +419 -9
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +33 -10
- package/kits/real-time/code/client/gameHooks.js +2 -0
- package/kits/real-time/code/client/joinOverlay.js +9 -4
- package/kits/real-time/code/server/gameHooks.js +7 -0
- package/kits/real-time/code/server/session.js +102 -22
- package/kits/real-time/package-lock.json +1 -1
- package/package.json +2 -2
- package/dist/shell/assets/index-Cf61cNfT.css +0 -1
|
@@ -102,7 +102,7 @@ function platformHub(answers = {}) {
|
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
function boot(s, hooks = {}) {
|
|
105
|
+
function boot(s, hooks = {}, json = castleJson, ground = null) {
|
|
106
106
|
let ctx = null;
|
|
107
107
|
const arrived = [];
|
|
108
108
|
const deck = {
|
|
@@ -114,7 +114,7 @@ function boot(s, hooks = {}) {
|
|
|
114
114
|
},
|
|
115
115
|
...hooks,
|
|
116
116
|
};
|
|
117
|
-
const h = layer(
|
|
117
|
+
const h = layer(json, deck, {}, sceneExists, () => ground);
|
|
118
118
|
h.sceneFor(s.session);
|
|
119
119
|
const world = sim();
|
|
120
120
|
h.ready(world);
|
|
@@ -183,6 +183,139 @@ await test("arrival, result and avatar come from ghost, not the client's hello",
|
|
|
183
183
|
assert.equal(h.join().hubAv.p1, 2);
|
|
184
184
|
});
|
|
185
185
|
|
|
186
|
+
await test('weekly Cup is opt-in, private, periodically refreshed and fenced to the requested identity', async () => {
|
|
187
|
+
let resolveCup;
|
|
188
|
+
const combined = [];
|
|
189
|
+
const p = platformHub({
|
|
190
|
+
read(input) {
|
|
191
|
+
if (input.userIds && input.doorIds) {
|
|
192
|
+
combined.push(input);
|
|
193
|
+
return new Promise((resolve) => { resolveCup = resolve; });
|
|
194
|
+
}
|
|
195
|
+
return { players: Object.fromEntries((input.userIds ?? []).map((id) => [id, { avatar: 1, records: [], recent: [] }])), boards: {} };
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
const s = session({ hub: p.hub });
|
|
199
|
+
const enabled = { ...castleJson, deckId: 'town-deck', hub: { ...castleJson.hub, weeklyCup: true } };
|
|
200
|
+
const { h, world, ctx } = boot(s, {}, enabled);
|
|
201
|
+
hello(h, s, 'p1');
|
|
202
|
+
hello(h, s, 'p2');
|
|
203
|
+
h.place(world);
|
|
204
|
+
assert.equal(typeof ctx().cup, 'function');
|
|
205
|
+
assert.equal(typeof ctx().cupNow, 'function');
|
|
206
|
+
assert.equal(ctx().cupDeckId, 'town-deck', 'the saved awarding namespace is server-only context authority');
|
|
207
|
+
assert.equal(ctx().cup('p1', 'race'), null, 'pending result bits are unavailable');
|
|
208
|
+
assert.deepEqual(combined, [{ doorIds: ['race'], userIds: ['101', '102'] }], 'only connected signed-in host identities are requested');
|
|
209
|
+
const clockAt = Date.now();
|
|
210
|
+
resolveCup({
|
|
211
|
+
boards: { race: { event: { day: '2026-10-10', validResultCount: 3, cupNow: clockAt } } },
|
|
212
|
+
players: {
|
|
213
|
+
101: { cup: { race: {
|
|
214
|
+
'2026-10-10': { participated: true, champion: false },
|
|
215
|
+
'2026-10-03': { participated: true, champion: true },
|
|
216
|
+
'2026-09-26': { participated: true, champion: true },
|
|
217
|
+
bad: { participated: true, champion: true },
|
|
218
|
+
} } },
|
|
219
|
+
102: { cup: { race: { '2026-10-10': { participated: false, champion: false } } } },
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
await flush();
|
|
223
|
+
assert.deepEqual(ctx().cup('p1', 'race'), {
|
|
224
|
+
'2026-10-10': { participated: true, champion: false },
|
|
225
|
+
'2026-10-03': { participated: true, champion: true },
|
|
226
|
+
}, 'only two valid occurrence rows survive');
|
|
227
|
+
const copy = ctx().cup('p1', 'race');
|
|
228
|
+
copy['2026-10-10'].participated = false;
|
|
229
|
+
assert.equal(ctx().cup('p1', 'race')['2026-10-10'].participated, true, 'the server-only cache is copied');
|
|
230
|
+
assert.equal(ctx().board('race').event.validResultCount, 3);
|
|
231
|
+
assert.equal(Object.hasOwn(ctx().board('race').event, 'cupNow'), false, 'raw clock metadata is stripped from the stored board');
|
|
232
|
+
assert.ok(ctx().cupNow('race') >= clockAt && ctx().cupNow('race') < clockAt + 1000, 'the paired clock advances from receipt time');
|
|
233
|
+
assert.equal('cup' in h.join(), false, 'private eligibility never enters shared wire');
|
|
234
|
+
|
|
235
|
+
const realNow = Date.now;
|
|
236
|
+
Date.now = () => realNow() + 61_000;
|
|
237
|
+
try {
|
|
238
|
+
h.place(world);
|
|
239
|
+
assert.equal(combined.length, 2, 'connected result bits are refreshed on the board cadence');
|
|
240
|
+
assert.equal(ctx().cup('p1', 'race'), null, 'the old map cannot be used during refresh');
|
|
241
|
+
assert.equal(ctx().cupNow('race'), null, 'the old clock cannot be combined with a refresh in flight');
|
|
242
|
+
s.session.players = s.session.players.map((player) => player.playerId === 'p1' ? { ...player, userId: '999' } : player);
|
|
243
|
+
hello(h, s, 'p1');
|
|
244
|
+
resolveCup({
|
|
245
|
+
boards: { race: { event: { day: '2026-10-10', validResultCount: 4, cupNow: clockAt + 61_000 } } },
|
|
246
|
+
players: { 101: { cup: { race: { '2026-10-10': { participated: true, champion: true } } } } },
|
|
247
|
+
});
|
|
248
|
+
await flush();
|
|
249
|
+
assert.equal(ctx().cup('p1', 'race'), null, 'an answer for the replaced account cannot cross the identity boundary');
|
|
250
|
+
assert.ok(ctx().cupNow('race') >= clockAt + 61_000, 'the shared clock does not depend on one player result row');
|
|
251
|
+
h.sceneFor({ ...s.session, sessionId: 's-2' });
|
|
252
|
+
assert.equal(ctx().cupNow('race'), null, 'a clock never crosses a session replacement');
|
|
253
|
+
} finally {
|
|
254
|
+
Date.now = realNow;
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
await test('the paired Cup clock expires and malformed or failed board reads keep it unavailable', async () => {
|
|
259
|
+
const realNow = Date.now;
|
|
260
|
+
let wall = 1_800_000_000_000;
|
|
261
|
+
Date.now = () => wall;
|
|
262
|
+
const responses = [
|
|
263
|
+
{ boards: { race: { event: { day: '2027-01-02', cupNow: 2_000_000_000_000 } } }, players: { 101: { cup: {} } } },
|
|
264
|
+
{ boards: { race: { event: { day: '2027-01-02', cupNow: 2_000_000_060_000.5 } } }, players: { 101: { cup: {} } } },
|
|
265
|
+
new Error('clock worker unavailable'),
|
|
266
|
+
];
|
|
267
|
+
const p = platformHub({
|
|
268
|
+
read(input) {
|
|
269
|
+
if (input.userIds && input.doorIds) {
|
|
270
|
+
const answer = responses.shift();
|
|
271
|
+
if (answer instanceof Error) return Promise.reject(answer);
|
|
272
|
+
return answer;
|
|
273
|
+
}
|
|
274
|
+
return { players: Object.fromEntries((input.userIds ?? []).map((id) => [id, { avatar: 1, records: [], recent: [] }])), boards: {} };
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
try {
|
|
278
|
+
const s = session({ hub: p.hub });
|
|
279
|
+
const enabled = { ...castleJson, deckId: 'town-deck', hub: { ...castleJson.hub, weeklyCup: true } };
|
|
280
|
+
const { h, world, ctx } = boot(s, {}, enabled);
|
|
281
|
+
hello(h, s, 'p1');
|
|
282
|
+
h.place(world);
|
|
283
|
+
assert.equal(ctx().cupNow('race'), null, 'a clock is unavailable while its paired board read is pending');
|
|
284
|
+
await flush();
|
|
285
|
+
assert.equal(ctx().cupNow('race'), 2_000_000_000_000);
|
|
286
|
+
|
|
287
|
+
wall += 119_999;
|
|
288
|
+
assert.equal(ctx().cupNow('race'), 2_000_000_119_999, 'a fresh clock advances by elapsed wall time');
|
|
289
|
+
wall += 2;
|
|
290
|
+
assert.equal(ctx().cupNow('race'), null, 'two missed one-minute refreshes make the clock stale');
|
|
291
|
+
|
|
292
|
+
h.place(world);
|
|
293
|
+
await flush();
|
|
294
|
+
assert.equal(ctx().cupNow('race'), null, 'a non-integer host clock is rejected');
|
|
295
|
+
assert.equal(Object.hasOwn(ctx().board('race').event, 'cupNow'), false, 'malformed raw metadata is still private');
|
|
296
|
+
|
|
297
|
+
wall += 60_001;
|
|
298
|
+
h.place(world);
|
|
299
|
+
await flush();
|
|
300
|
+
assert.equal(ctx().cupNow('race'), null, 'a failed paired board read cannot revive the clock');
|
|
301
|
+
} finally {
|
|
302
|
+
Date.now = realNow;
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
await test('a deck without weeklyCup keeps the legacy server API and read shapes', async () => {
|
|
307
|
+
const p = platformHub();
|
|
308
|
+
const s = session({ hub: p.hub });
|
|
309
|
+
const { h, world, ctx } = boot(s);
|
|
310
|
+
hello(h, s, 'p1');
|
|
311
|
+
h.place(world);
|
|
312
|
+
assert.equal(Object.hasOwn(ctx(), 'cup'), false);
|
|
313
|
+
assert.equal(Object.hasOwn(ctx(), 'cupNow'), false);
|
|
314
|
+
assert.equal(Object.hasOwn(ctx(), 'cupDeckId'), false);
|
|
315
|
+
assert.deepEqual(p.calls.filter(([op]) => op === 'read').map(([, input]) => Object.keys(input)), [['userIds'], ['doorIds']]);
|
|
316
|
+
assert.equal('cup' in h.join(), false);
|
|
317
|
+
});
|
|
318
|
+
|
|
186
319
|
await test("a production door to another deck reads its title and group from ghost's board, its props until then", async () => {
|
|
187
320
|
const actors = globalThis.__hubTestActors;
|
|
188
321
|
globalThis.__hubTestActors = [
|
|
@@ -263,6 +396,268 @@ await test("a board that leaves the group unsaid keeps the door's props", async
|
|
|
263
396
|
}
|
|
264
397
|
});
|
|
265
398
|
|
|
399
|
+
await test("a 46-door place reads every board, including the 17th door's event and group", async () => {
|
|
400
|
+
const actors = globalThis.__hubTestActors;
|
|
401
|
+
const ids = Array.from({ length: 46 }, (_, i) => `game-${i}`);
|
|
402
|
+
const event = { open: true };
|
|
403
|
+
const boards = Object.fromEntries(ids.map((id, i) => [id, {
|
|
404
|
+
title: `Game ${i}`, minPlayers: 1, maxPlayers: 8, lateJoin: true, top: [],
|
|
405
|
+
...(i === 16 ? { event } : {}),
|
|
406
|
+
}]));
|
|
407
|
+
globalThis.__hubTestActors = [actors[0], ...ids.map((id, i) => ({
|
|
408
|
+
id: `${id}-door`,
|
|
409
|
+
components: {
|
|
410
|
+
HubDoor: { id, to: `deck:${id}`, title: i === 16 ? 'Foot Race' : id, minPlayers: 2, lateJoin: false },
|
|
411
|
+
Transform: { x: 5, y: 0, z: 5 },
|
|
412
|
+
},
|
|
413
|
+
}))];
|
|
414
|
+
try {
|
|
415
|
+
const p = platformHub({ read: (input) => ({
|
|
416
|
+
players: {}, boards: Object.fromEntries((input.doorIds ?? []).map((id) => [id, boards[id]])),
|
|
417
|
+
}) });
|
|
418
|
+
const s = session({ hub: p.hub });
|
|
419
|
+
const { h, world, ctx } = boot(s);
|
|
420
|
+
const race = ctx().doors()[16];
|
|
421
|
+
assert.deepEqual(
|
|
422
|
+
{ title: race.title, minPlayers: race.minPlayers, lateJoin: race.lateJoin },
|
|
423
|
+
{ title: 'Foot Race', minPlayers: 2, lateJoin: false },
|
|
424
|
+
);
|
|
425
|
+
h.place(world);
|
|
426
|
+
await flush();
|
|
427
|
+
const reads = p.calls.filter(([k]) => k === 'read').map(([, input]) => input.doorIds);
|
|
428
|
+
assert.deepEqual(reads.map((doorIds) => doorIds.length), [16, 16, 14]);
|
|
429
|
+
assert.deepEqual(reads.flat(), ids);
|
|
430
|
+
assert.deepEqual(ctx().doors().map((door) => ({
|
|
431
|
+
id: door.id, title: door.title, minPlayers: door.minPlayers, maxPlayers: door.maxPlayers, lateJoin: door.lateJoin,
|
|
432
|
+
})), ids.map((id, i) => ({
|
|
433
|
+
id, title: `Game ${i}`, minPlayers: 1, maxPlayers: 8, lateJoin: true,
|
|
434
|
+
})));
|
|
435
|
+
assert.deepEqual(
|
|
436
|
+
{ minPlayers: race.minPlayers, lateJoin: race.lateJoin },
|
|
437
|
+
{ minPlayers: 1, lateJoin: true },
|
|
438
|
+
);
|
|
439
|
+
assert.deepEqual(ctx().board(ids[16]).event, event);
|
|
440
|
+
assert.equal(h.join().hubDoors.find((door) => door.id === ids[16]).title, 'Event · Game 16');
|
|
441
|
+
} finally {
|
|
442
|
+
globalThis.__hubTestActors = actors;
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
await test('a small place keeps the same board read inputs, doors before cabinets', async () => {
|
|
447
|
+
const actors = globalThis.__hubTestActors;
|
|
448
|
+
const ids = ['race', 'cab-a', 'hill', 'tag', 'cab-b', 'maze', 'ball'];
|
|
449
|
+
globalThis.__hubTestActors = [actors[0], ...ids.map((id) => ({
|
|
450
|
+
id: `${id}-door`,
|
|
451
|
+
components: {
|
|
452
|
+
HubDoor: { id, to: `deck:${id}`, ...(id.startsWith('cab-') ? { kind: 'cabinet' } : {}) },
|
|
453
|
+
Transform: { x: 5, y: 0, z: 5 },
|
|
454
|
+
},
|
|
455
|
+
}))];
|
|
456
|
+
try {
|
|
457
|
+
const p = platformHub();
|
|
458
|
+
const s = session({ hub: p.hub });
|
|
459
|
+
const { h, world } = boot(s);
|
|
460
|
+
h.place(world);
|
|
461
|
+
await flush();
|
|
462
|
+
assert.deepEqual(p.calls.filter(([k]) => k === 'read').map(([, input]) => input), [
|
|
463
|
+
{ doorIds: ['race', 'hill', 'tag', 'maze', 'ball'] },
|
|
464
|
+
{ doorIds: ['cab-a', 'cab-b'] },
|
|
465
|
+
]);
|
|
466
|
+
} finally {
|
|
467
|
+
globalThis.__hubTestActors = actors;
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
await test('a place reads every cabinet board, six cabinets per read', async () => {
|
|
472
|
+
const actors = globalThis.__hubTestActors;
|
|
473
|
+
const ids = Array.from({ length: 17 }, (_, i) => `cab-${i}`);
|
|
474
|
+
globalThis.__hubTestActors = [actors[0], ...ids.map((id) => ({
|
|
475
|
+
id: `${id}-door`,
|
|
476
|
+
components: { HubDoor: { id, to: 'deck:classic', kind: 'cabinet' }, Transform: { x: 5, y: 0, z: 5 } },
|
|
477
|
+
}))];
|
|
478
|
+
try {
|
|
479
|
+
const p = platformHub({ read: (input) => ({
|
|
480
|
+
players: {}, boards: Object.fromEntries((input.doorIds ?? []).map((id) => [id, { title: id, top: [] }])),
|
|
481
|
+
}) });
|
|
482
|
+
const s = session({ hub: p.hub });
|
|
483
|
+
const { h, world, ctx } = boot(s);
|
|
484
|
+
h.place(world);
|
|
485
|
+
await flush();
|
|
486
|
+
const reads = p.calls.filter(([k]) => k === 'read').map(([, input]) => input.doorIds);
|
|
487
|
+
assert.deepEqual(reads.map((doorIds) => doorIds.length), [6, 6, 5]);
|
|
488
|
+
assert.deepEqual(reads.flat(), ids);
|
|
489
|
+
assert.deepEqual(ctx().doors().map((door) => door.title), ids);
|
|
490
|
+
} finally {
|
|
491
|
+
globalThis.__hubTestActors = actors;
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
await test('board batches run one at a time, even when a scan takes more than a minute', async () => {
|
|
496
|
+
const actors = globalThis.__hubTestActors;
|
|
497
|
+
const realNow = Date.now;
|
|
498
|
+
const doorIds = Array.from({ length: 46 }, (_, i) => `game-${i}`);
|
|
499
|
+
const cabinetIds = Array.from({ length: 31 }, (_, i) => `cab-${i}`);
|
|
500
|
+
const ids = [...doorIds, ...cabinetIds];
|
|
501
|
+
globalThis.__hubTestActors = [actors[0], ...ids.map((id) => ({
|
|
502
|
+
id: `${id}-door`,
|
|
503
|
+
components: {
|
|
504
|
+
HubDoor: { id, to: `deck:${id}`, ...(id.startsWith('cab-') ? { kind: 'cabinet' } : {}) },
|
|
505
|
+
Transform: { x: 5, y: 0, z: 5 },
|
|
506
|
+
},
|
|
507
|
+
}))];
|
|
508
|
+
let inFlight = 0;
|
|
509
|
+
let mostInFlight = 0;
|
|
510
|
+
const pending = [];
|
|
511
|
+
try {
|
|
512
|
+
const p = platformHub({ read: () => new Promise((resolve) => {
|
|
513
|
+
inFlight += 1;
|
|
514
|
+
mostInFlight = Math.max(mostInFlight, inFlight);
|
|
515
|
+
pending.push(() => {
|
|
516
|
+
inFlight -= 1;
|
|
517
|
+
resolve({ players: {}, boards: {} });
|
|
518
|
+
});
|
|
519
|
+
}) });
|
|
520
|
+
const s = session({ hub: p.hub });
|
|
521
|
+
const { h, world } = boot(s);
|
|
522
|
+
h.place(world);
|
|
523
|
+
await flush();
|
|
524
|
+
assert.equal(p.calls.length, 1, 'only the first batch starts before it settles');
|
|
525
|
+
Date.now = () => realNow() + 61000;
|
|
526
|
+
h.place(world);
|
|
527
|
+
await flush();
|
|
528
|
+
assert.equal(p.calls.length, 1, 'a new minute does not overlap the unfinished scan');
|
|
529
|
+
for (let i = 0; i < 9; i += 1) {
|
|
530
|
+
assert.equal(p.calls.length, i + 1);
|
|
531
|
+
assert.equal(inFlight, 1);
|
|
532
|
+
pending.shift()();
|
|
533
|
+
await flush();
|
|
534
|
+
}
|
|
535
|
+
assert.equal(mostInFlight, 1);
|
|
536
|
+
assert.equal(inFlight, 0);
|
|
537
|
+
const reads = p.calls.map(([, input]) => input.doorIds);
|
|
538
|
+
assert.deepEqual(reads.map((batch) => batch.length), [16, 16, 14, 6, 6, 6, 6, 6, 1]);
|
|
539
|
+
assert.deepEqual(reads.flat(), ids);
|
|
540
|
+
} finally {
|
|
541
|
+
Date.now = realNow;
|
|
542
|
+
globalThis.__hubTestActors = actors;
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
await test('a failed board chunk keeps its previous rows while other chunks and cabinet cards refresh', async () => {
|
|
547
|
+
const actors = globalThis.__hubTestActors;
|
|
548
|
+
const realNow = Date.now;
|
|
549
|
+
const warn = console.warn;
|
|
550
|
+
const warnings = [];
|
|
551
|
+
console.warn = (message) => warnings.push(message);
|
|
552
|
+
let now = realNow();
|
|
553
|
+
Date.now = () => now;
|
|
554
|
+
const ids = [...Array.from({ length: 46 }, (_, i) => `game-${i}`), 'cab-a'];
|
|
555
|
+
globalThis.__hubTestActors = [actors[0], ...ids.map((id) => ({
|
|
556
|
+
id: `${id}-door`,
|
|
557
|
+
components: {
|
|
558
|
+
HubDoor: { id, to: `deck:${id}`, title: id, ...(id === 'cab-a' ? { kind: 'cabinet' } : {}) },
|
|
559
|
+
Transform: { x: 5, y: 0, z: 5 },
|
|
560
|
+
},
|
|
561
|
+
}))];
|
|
562
|
+
let refresh = false;
|
|
563
|
+
try {
|
|
564
|
+
const p = platformHub({ read: (input) => {
|
|
565
|
+
if (!input.doorIds) {
|
|
566
|
+
return { players: {}, boards: {} };
|
|
567
|
+
}
|
|
568
|
+
if (refresh && input.doorIds.includes('game-20')) {
|
|
569
|
+
throw Object.assign(new Error('middle chunk failed'), { code: 'CAULDRON_STORAGE_TIMEOUT' });
|
|
570
|
+
}
|
|
571
|
+
const prefix = refresh ? 'New' : 'Old';
|
|
572
|
+
return { players: {}, boards: Object.fromEntries(input.doorIds
|
|
573
|
+
.filter((id) => !refresh || id !== 'game-2')
|
|
574
|
+
.map((id) => [id, {
|
|
575
|
+
title: `${prefix} ${id}`, minPlayers: 1, lateJoin: true, top: [],
|
|
576
|
+
...(id === 'cab-a' ? { classic: { deckId: 'classic-a', title: `${prefix} cabinet`, label: 'Daily Score', top: [] } } : {}),
|
|
577
|
+
}])) };
|
|
578
|
+
} });
|
|
579
|
+
const s = session({ hub: p.hub });
|
|
580
|
+
const { h, world, ctx } = boot(s);
|
|
581
|
+
hello(h, s, 'p1');
|
|
582
|
+
h.place(world);
|
|
583
|
+
await flush();
|
|
584
|
+
h.place(world);
|
|
585
|
+
h.step(world, []);
|
|
586
|
+
assert.equal(ctx().board('game-20').title, 'Old game-20');
|
|
587
|
+
assert.equal(ctx().board('game-45').title, 'Old game-45');
|
|
588
|
+
assert.equal(s.sent.find(([, msg]) => msg.k === 'hub-cabinet')[1].card.title, 'Old cabinet');
|
|
589
|
+
const previous = ids.slice(16, 32).map((id) => ctx().board(id));
|
|
590
|
+
s.sent.length = 0;
|
|
591
|
+
p.calls.length = 0;
|
|
592
|
+
refresh = true;
|
|
593
|
+
// This actor no longer names a destination, so it leaves doors(h).
|
|
594
|
+
globalThis.__hubTestActors.find((actor) => actor.id === 'game-45-door').components.HubDoor.to = 'removed';
|
|
595
|
+
now += 61000;
|
|
596
|
+
world.timeMs += 61000;
|
|
597
|
+
h.place(world);
|
|
598
|
+
await flush();
|
|
599
|
+
h.step(world, []);
|
|
600
|
+
const reads = p.calls.filter(([, input]) => input.doorIds).map(([, input]) => input.doorIds);
|
|
601
|
+
assert.deepEqual(reads.map((batch) => batch.length), [16, 16, 13, 1]);
|
|
602
|
+
assert.equal(ctx().board('game-0').title, 'New game-0');
|
|
603
|
+
assert.equal(ctx().board('game-32').title, 'New game-32');
|
|
604
|
+
assert.deepEqual(ids.slice(16, 32).map((id) => ctx().board(id)), previous);
|
|
605
|
+
assert.equal(ctx().board('game-2'), null, 'a successful read that omits a row removes the old board');
|
|
606
|
+
assert.equal(ctx().board('game-45'), null, 'a removed door loses its old board');
|
|
607
|
+
assert.equal(s.sent.find(([, msg]) => msg.k === 'hub-cabinet')[1].card.title, 'New cabinet');
|
|
608
|
+
assert.deepEqual(warnings, ['[hub] boards refused (CAULDRON_STORAGE_TIMEOUT): middle chunk failed']);
|
|
609
|
+
h.place(world);
|
|
610
|
+
await flush();
|
|
611
|
+
assert.deepEqual(ids.slice(16, 32).map((id) => ctx().board(id)), previous, 'failed rows survive the next tick');
|
|
612
|
+
assert.equal(p.calls.filter(([, input]) => input.doorIds).length, 4, 'no retry before the next minute');
|
|
613
|
+
} finally {
|
|
614
|
+
console.warn = warn;
|
|
615
|
+
Date.now = realNow;
|
|
616
|
+
globalThis.__hubTestActors = actors;
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
|
|
620
|
+
await test('an arrival is kept where it was put while late move reports pull at it (v1.40)', async () => {
|
|
621
|
+
const p = platformHub({ read: () => ({ players: {}, boards: {} }) });
|
|
622
|
+
const s = session({ hub: p.hub });
|
|
623
|
+
const { h, world, arrived, ctx } = boot(s, {
|
|
624
|
+
arrive(hub, group) {
|
|
625
|
+
arrived.push(...group);
|
|
626
|
+
for (const g of group) {
|
|
627
|
+
hub.placeAt(g.playerId, { x: -3.2, y: 1.2, z: -28.67 }, 90);
|
|
628
|
+
}
|
|
629
|
+
},
|
|
630
|
+
});
|
|
631
|
+
hello(h, s, 'p1');
|
|
632
|
+
h.place(world);
|
|
633
|
+
await flush();
|
|
634
|
+
h.place(world);
|
|
635
|
+
assert.equal(arrived.length, 1);
|
|
636
|
+
const body = world.players.get('p1');
|
|
637
|
+
assert.deepEqual([body.at.x, body.at.z], [-3.2, -28.67], 'where the place put them');
|
|
638
|
+
// The client's reports still name the spawn: the movement clamp lets each
|
|
639
|
+
// pull the body a step toward it. The next tick puts it back.
|
|
640
|
+
for (let i = 0; i < 5; i += 1) {
|
|
641
|
+
body.at = { x: body.at.x + 0.1, y: body.at.y, z: body.at.z + 0.9 };
|
|
642
|
+
world.timeMs += 50;
|
|
643
|
+
h.place(world);
|
|
644
|
+
assert.deepEqual([body.at.x, body.at.z], [-3.2, -28.67], `put back on tick ${i}`);
|
|
645
|
+
}
|
|
646
|
+
// Not a hold: a small step is the player's own, and after the moment so is any.
|
|
647
|
+
body.at = { x: -3.25, y: body.at.y, z: -28.67 };
|
|
648
|
+
h.place(world);
|
|
649
|
+
assert.equal(body.at.x, -3.25, 'a step inside the slack stands');
|
|
650
|
+
const realNow = Date.now;
|
|
651
|
+
Date.now = () => realNow() + 700;
|
|
652
|
+
try {
|
|
653
|
+
body.at = { x: -1, y: body.at.y, z: -26 };
|
|
654
|
+
h.place(world);
|
|
655
|
+
assert.deepEqual([body.at.x, body.at.z], [-1, -26], 'free to walk once the moment is over');
|
|
656
|
+
} finally {
|
|
657
|
+
Date.now = realNow;
|
|
658
|
+
}
|
|
659
|
+
});
|
|
660
|
+
|
|
266
661
|
await test('a player who jumped to a friend arrives beside them, facing them', async () => {
|
|
267
662
|
const s = session();
|
|
268
663
|
const { h, world } = boot(s);
|
|
@@ -280,6 +675,86 @@ await test('a player who jumped to a friend arrives beside them, facing them', a
|
|
|
280
675
|
assert.ok(Math.abs(me.facing - Math.atan2(-1.6, 0)) < 1e-9);
|
|
281
676
|
});
|
|
282
677
|
|
|
678
|
+
await test('invite target survives an avatar hello before initial placement', async () => {
|
|
679
|
+
castleJson.hub.invite = true;
|
|
680
|
+
try {
|
|
681
|
+
const s = session();
|
|
682
|
+
const { h, world, arrived } = boot(s);
|
|
683
|
+
hello(h, s, 'p2'); h.place(world);
|
|
684
|
+
world.players.get('p2').at = { x: 10, y: 1, z: 5 };
|
|
685
|
+
hello(h, s, 'p1', { near: '102', invited: true });
|
|
686
|
+
// Platform avatar loading can replace the hello before progress is read.
|
|
687
|
+
hello(h, s, 'p1', { avatar: 2, again: true, invited: true });
|
|
688
|
+
h.place(world);
|
|
689
|
+
assert.equal(arrived.find((p) => p.playerId === 'p1').near, '102');
|
|
690
|
+
assert.equal(arrived.find((p) => p.playerId === 'p1').invited, true);
|
|
691
|
+
assert.ok(Math.abs(world.players.get('p1').at.x - 11.6) < 1e-9);
|
|
692
|
+
} finally { delete castleJson.hub.invite; }
|
|
693
|
+
});
|
|
694
|
+
|
|
695
|
+
// The v1.113 floor repair must not perturb established ground-backed town
|
|
696
|
+
// or game placement, nor invite-only authored-floor fallback.
|
|
697
|
+
function floorInvite({ optIn = true, ground = null, shape = null, at = { x: 0, y: 0.74, z: 0 }, run = false } = {}) {
|
|
698
|
+
const json = structuredClone(castleJson);
|
|
699
|
+
json.hub.invite = true;
|
|
700
|
+
if (optIn) {json.hub.bringFriend = true;}
|
|
701
|
+
if (run) {Object.assign(json.hub.places.race, { minPlayers: 1, lateJoin: true });}
|
|
702
|
+
const s = session({ sessionId: run ? 'dev:hub.race.test' : 'dev:test' });
|
|
703
|
+
const { h, world } = boot(s, {}, json, ground);
|
|
704
|
+
if (shape) {world.template = { shape };}
|
|
705
|
+
hello(h, s, 'p2'); h.place(world);
|
|
706
|
+
Object.assign(world.players.get('p2'), { at: { ...at }, facing: 0 });
|
|
707
|
+
hello(h, s, 'p1', { near: '102', invited: true }); h.place(world);
|
|
708
|
+
return { pose: world.players.get('p1').at, facing: world.players.get('p1').facing,
|
|
709
|
+
wire: s.sent, manifest: h.join() };
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
await test('bringFriend leaves ground-backed town and run placement byte-identical', async () => {
|
|
713
|
+
for (const run of [false, true]) {
|
|
714
|
+
const options = { run, at: { x: 10, y: 1, z: 5 }, shape: { kind: 'capsule', radius: 0.35, height: 1.4 } };
|
|
715
|
+
const before = floorInvite({ ...options, optIn: false });
|
|
716
|
+
const after = floorInvite(options);
|
|
717
|
+
assert.equal(JSON.stringify(after), JSON.stringify(before));
|
|
718
|
+
assert.deepEqual(after.pose, { x: 11.6, y: 1, z: 5 });
|
|
719
|
+
assert.equal(after.facing, -Math.PI / 2);
|
|
720
|
+
}
|
|
721
|
+
});
|
|
722
|
+
|
|
723
|
+
await test('opted-in authored floor supports an invited player beside and facing their friend', async () => {
|
|
724
|
+
const saved = globalThis.__hubTestActors;
|
|
725
|
+
const floor = { id: 'floor', components: { Solid: {}, Transform: { x: 0, y: -0.07, z: 0 }, Shape: { kind: 'box', width: 8, height: 0.14, depth: 7 } } };
|
|
726
|
+
globalThis.__hubTestActors = [saved[0], floor];
|
|
727
|
+
try {
|
|
728
|
+
const options = { ground: { none: true } };
|
|
729
|
+
const legacy = floorInvite({ ...options, optIn: false });
|
|
730
|
+
assert.notEqual(legacy.pose.x, 1.6, 'absent marker retains old fallback');
|
|
731
|
+
const fixed = floorInvite(options);
|
|
732
|
+
assert.deepEqual(fixed.pose, { x: 1.6, y: 0.74, z: 0 });
|
|
733
|
+
assert.equal(fixed.facing, -Math.PI / 2);
|
|
734
|
+
|
|
735
|
+
const wall = { id: 'wall', components: { Solid: {}, Transform: { x: 1.6, y: 1, z: 0 }, Shape: { kind: 'box', width: 0.8, height: 2, depth: 7 } } };
|
|
736
|
+
globalThis.__hubTestActors.push(wall);
|
|
737
|
+
assert.equal(floorInvite(options).pose.x, -1.6, 'real wall still rejects the right side');
|
|
738
|
+
globalThis.__hubTestActors.pop();
|
|
739
|
+
|
|
740
|
+
globalThis.__hubTestActors.push({ id: 'pad', components: { HubPad: { radius: 1 }, Transform: { x: 1.6, y: 0, z: 0 } } });
|
|
741
|
+
assert.equal(floorInvite(options).pose.x, -1.6, 'never arrive on a pad');
|
|
742
|
+
globalThis.__hubTestActors.pop();
|
|
743
|
+
|
|
744
|
+
globalThis.__hubTestActors.push({ id: 'roof', components: { Solid: {}, Transform: { x: 1.6, y: 1.6, z: 0 }, Shape: { kind: 'box', width: 1, height: 0.1, depth: 1 } } });
|
|
745
|
+
assert.equal(floorInvite(options).pose.x, 1.6, 'default 1.4m body fits below roof');
|
|
746
|
+
assert.equal(floorInvite({ ...options, shape: { kind: 'capsule', radius: 0.35, height: 1.8 }, at: { x: 0, y: 0.96, z: 0 } }).pose.x, -1.6, 'trusted taller body does not fit');
|
|
747
|
+
globalThis.__hubTestActors.pop();
|
|
748
|
+
|
|
749
|
+
floor.components.Shape.width = 1; floor.components.Shape.depth = 1;
|
|
750
|
+
const unsupported = floorInvite(options);
|
|
751
|
+
assert.notEqual(unsupported.pose.x, 1.6, 'no placement beside friend over a hole');
|
|
752
|
+
const invalid = floorInvite({ ...options, shape: { kind: 'capsule', radius: NaN, height: 1.4 } });
|
|
753
|
+
assert.equal(invalid.pose.x, unsupported.pose.x, 'invalid template keeps group placement');
|
|
754
|
+
assert.equal(invalid.pose.z, unsupported.pose.z);
|
|
755
|
+
} finally { globalThis.__hubTestActors = saved; }
|
|
756
|
+
});
|
|
757
|
+
|
|
283
758
|
await test('a jump beside a friend takes a clear side, and none beside someone a block hides', async () => {
|
|
284
759
|
const actors = globalThis.__hubTestActors;
|
|
285
760
|
// A wall right of the friend (facing +z, right is +x).
|
|
@@ -387,6 +862,32 @@ await test('pads gather on change, fire with the gathered id, and the next gathe
|
|
|
387
862
|
assert.equal(hub.go('race', ['p3']), null);
|
|
388
863
|
});
|
|
389
864
|
|
|
865
|
+
await test('a guest ghost admitted, with a real user id, gathers, fires and goes; a playerless id does not', async () => {
|
|
866
|
+
const p = platformHub();
|
|
867
|
+
const s = session({ hub: p.hub });
|
|
868
|
+
s.session.players = [...PLAYERS, { playerId: 'g1', userId: '243', username: 'guest', isAnonymous: true }];
|
|
869
|
+
const { ctx } = boot(s);
|
|
870
|
+
const hub = ctx();
|
|
871
|
+
hub.pad('race', ['p1', 'g1', 'p3']);
|
|
872
|
+
const gathered = p.calls.filter((c) => c[0] === 'pad').at(-1)[1];
|
|
873
|
+
assert.deepEqual(gathered.memberUserIds, ['101', '243'], 'the guest counts on the pad; a dev-serve guest without an id does not');
|
|
874
|
+
const padId = gathered.padId;
|
|
875
|
+
assert.equal(hub.go('race', ['p1', 'g1']), padId);
|
|
876
|
+
await flush();
|
|
877
|
+
assert.deepEqual(p.calls.filter((c) => c[0] === 'pad').at(-1)[1].memberUserIds, ['101', '243']);
|
|
878
|
+
assert.deepEqual(
|
|
879
|
+
s.sent.filter(([, d]) => d.k === 'hub-go').map(([id]) => id).sort(),
|
|
880
|
+
['g1', 'p1'],
|
|
881
|
+
'the guest is sent through with the group',
|
|
882
|
+
);
|
|
883
|
+
const alone = platformHub();
|
|
884
|
+
const solo = session({ hub: alone.hub });
|
|
885
|
+
solo.session.players = [{ playerId: 'g1', userId: '243', username: 'guest', isAnonymous: true }];
|
|
886
|
+
const lone = boot(solo).ctx();
|
|
887
|
+
lone.pad('race', ['g1']);
|
|
888
|
+
assert.ok(lone.go('race', ['g1']), 'a guest alone can go through');
|
|
889
|
+
});
|
|
890
|
+
|
|
390
891
|
await test('a fire whose answer is lost is retried on the same pad', async () => {
|
|
391
892
|
const p = platformHub();
|
|
392
893
|
let lose = true;
|
|
@@ -832,4 +1333,259 @@ await test("a goal label is one player's own; for everyone it is a sign", async
|
|
|
832
1333
|
assert.equal(h.labelsMe.get('p1').has('door'), false);
|
|
833
1334
|
});
|
|
834
1335
|
|
|
1336
|
+
await test('v1.81: only exactly edge:false on a private goal round-trips; absent keeps the old bytes', async () => {
|
|
1337
|
+
const { setLabel, wireLabel } = await import('../code/server/labels.js');
|
|
1338
|
+
const h = { labels: new Map(), labelsMe: new Map(), sim: { timeMs: 1000 } };
|
|
1339
|
+
const options = { style: 'goal', to: ['p1'] };
|
|
1340
|
+
const mine = () => h.labelsMe.get('p1').get('shop');
|
|
1341
|
+
const stored = { text: 'Hats', style: 'goal', until: null, npc: false };
|
|
1342
|
+
const wire = { text: 'Hats', style: 'goal' };
|
|
1343
|
+
setLabel(h, 'shop', 'Hats', options);
|
|
1344
|
+
assert.deepEqual(mine(), stored);
|
|
1345
|
+
assert.equal(JSON.stringify(wireLabel(mine())), JSON.stringify(wire));
|
|
1346
|
+
setLabel(h, 'shop', 'Hats', { ...options, edge: false });
|
|
1347
|
+
assert.deepEqual(mine(), { ...stored, edge: false });
|
|
1348
|
+
assert.deepEqual(wireLabel(mine()), { ...wire, edge: false });
|
|
1349
|
+
setLabel(h, 'shop', 'Hats', { ...options, edge: false, distanceM: 42 });
|
|
1350
|
+
assert.deepEqual(wireLabel(mine()), { ...wire, distanceM: 42, edge: false });
|
|
1351
|
+
setLabel(h, 'shop', 'Hats', { ...options, edge: false, distance: false });
|
|
1352
|
+
assert.deepEqual(wireLabel(mine()), { ...wire, distance: false, edge: false });
|
|
1353
|
+
for (const edge of [undefined, null, true, 0, '', 'false', {}, []]) {
|
|
1354
|
+
setLabel(h, 'shop', 'Hats', { ...options, edge });
|
|
1355
|
+
assert.deepEqual(mine(), stored);
|
|
1356
|
+
assert.equal(JSON.stringify(wireLabel(mine())), JSON.stringify(wire));
|
|
1357
|
+
}
|
|
1358
|
+
for (const style of ['tag', 'sign', 'speech']) {
|
|
1359
|
+
setLabel(h, 'shop', 'Hats', { ...options, style, edge: false });
|
|
1360
|
+
assert.ok(!('edge' in mine()));
|
|
1361
|
+
assert.deepEqual(wireLabel(mine()), { text: 'Hats', style });
|
|
1362
|
+
}
|
|
1363
|
+
setLabel(h, 'shop', 'Hats', { style: 'goal', edge: false });
|
|
1364
|
+
assert.ok(!('edge' in h.labels.get('shop')));
|
|
1365
|
+
assert.deepEqual(wireLabel(h.labels.get('shop')), { text: 'Hats', style: 'sign' });
|
|
1366
|
+
});
|
|
1367
|
+
|
|
1368
|
+
await test('v1.39: a goal may say which distance its pointer shows, and no other label carries the keys', async () => {
|
|
1369
|
+
const { setLabel, wireLabel } = await import('../code/server/labels.js');
|
|
1370
|
+
const h = { labels: new Map(), labelsMe: new Map(), sim: { timeMs: 1000 } };
|
|
1371
|
+
const mine = () => h.labelsMe.get('p1').get('corner');
|
|
1372
|
+
// Without the option a goal is stored and sent exactly as it was.
|
|
1373
|
+
setLabel(h, 'corner', 'Mill', { style: 'goal', to: ['p1'] });
|
|
1374
|
+
assert.deepEqual(mine(), { text: 'Mill', style: 'goal', until: null, npc: false });
|
|
1375
|
+
assert.deepEqual(wireLabel(mine()), { text: 'Mill', style: 'goal' });
|
|
1376
|
+
// A number of metres to show instead of the measured one, to the whole metre.
|
|
1377
|
+
setLabel(h, 'corner', 'Mill', { style: 'goal', to: ['p1'], distanceM: 83.6 });
|
|
1378
|
+
assert.deepEqual(wireLabel(mine()), { text: 'Mill', style: 'goal', distanceM: 84 });
|
|
1379
|
+
setLabel(h, 'corner', 'Mill', { style: 'goal', to: ['p1'], distanceM: 0 });
|
|
1380
|
+
assert.deepEqual(wireLabel(mine()), { text: 'Mill', style: 'goal', distanceM: 0 });
|
|
1381
|
+
// None at all.
|
|
1382
|
+
setLabel(h, 'corner', 'Mill', { style: 'goal', to: ['p1'], distance: false });
|
|
1383
|
+
assert.deepEqual(wireLabel(mine()), { text: 'Mill', style: 'goal', distance: false });
|
|
1384
|
+
setLabel(h, 'corner', 'Mill', { style: 'goal', to: ['p1'], distance: false, distanceM: 12 });
|
|
1385
|
+
assert.deepEqual(wireLabel(mine()), { text: 'Mill', style: 'goal', distance: false }, 'none wins');
|
|
1386
|
+
// Anything else is ignored: measured, as today.
|
|
1387
|
+
for (const junk of [{ distanceM: -1 }, { distanceM: NaN }, { distanceM: Infinity }, { distanceM: '40' }, { distanceM: null }, { distance: true }, { distance: 0 }, { distance: 'no' }]) {
|
|
1388
|
+
setLabel(h, 'corner', 'Mill', { style: 'goal', to: ['p1'], ...junk });
|
|
1389
|
+
assert.deepEqual(wireLabel(mine()), { text: 'Mill', style: 'goal' }, JSON.stringify(junk));
|
|
1390
|
+
}
|
|
1391
|
+
// Only a goal: a tag, a sign, speech and a goal for everyone (a sign) carry neither.
|
|
1392
|
+
for (const options of [{ to: ['p1'] }, { style: 'sign', to: ['p1'] }, { style: 'speech', to: ['p1'] }]) {
|
|
1393
|
+
setLabel(h, 'corner', 'Mill', { ...options, distanceM: 40, distance: false });
|
|
1394
|
+
assert.deepEqual(Object.keys(wireLabel(mine())).sort(), ['style', 'text']);
|
|
1395
|
+
}
|
|
1396
|
+
setLabel(h, 'corner', 'Mill', { style: 'goal', distanceM: 40 });
|
|
1397
|
+
assert.deepEqual(wireLabel(h.labels.get('corner')), { text: 'Mill', style: 'sign' });
|
|
1398
|
+
// Expiry is what it was: `ttlMs` from now each time the label is set, none without it.
|
|
1399
|
+
setLabel(h, 'corner', 'Mill', { style: 'goal', to: ['p1'], distanceM: 40, ttlMs: 5000 });
|
|
1400
|
+
assert.equal(mine().until, 6000);
|
|
1401
|
+
h.sim.timeMs = 2000;
|
|
1402
|
+
setLabel(h, 'corner', 'Mill', { style: 'goal', to: ['p1'], distanceM: 39, ttlMs: 5000 });
|
|
1403
|
+
assert.equal(mine().until, 7000);
|
|
1404
|
+
setLabel(h, 'corner', 'Mill', { style: 'goal', to: ['p1'], distanceM: 38 });
|
|
1405
|
+
assert.equal(mine().until, null);
|
|
1406
|
+
// Cleared like any label.
|
|
1407
|
+
setLabel(h, 'corner', null, { to: ['p1'] });
|
|
1408
|
+
assert.equal(h.labelsMe.get('p1').has('corner'), false);
|
|
1409
|
+
});
|
|
1410
|
+
|
|
1411
|
+
|
|
1412
|
+
await test('yourGames: private rows from the existing read, latched and resent to a fresh client', async () => {
|
|
1413
|
+
const p = platformHub({ read: (input) => input.userIds ? { players: {
|
|
1414
|
+
101: { avatar: 1, hearts: ['race'], recent: [{ deckId: 'race-deck', place: 'race', score: 12, at: new Date().toISOString() }], records: [] },
|
|
1415
|
+
102: { avatar: 1, hearts: [], recent: [], records: [] },
|
|
1416
|
+
} } : { boards: { race: { toDeckId: 'race-deck', unit: 'ms' } } } });
|
|
1417
|
+
const s = session({ hub: p.hub });
|
|
1418
|
+
const json = structuredClone(castleJson);
|
|
1419
|
+
json.hub.yourGames = true;
|
|
1420
|
+
const { h, world } = boot(s, {}, json);
|
|
1421
|
+
for (const { playerId } of PLAYERS) hello(h, s, playerId);
|
|
1422
|
+
h.place(world, []);
|
|
1423
|
+
await flush();
|
|
1424
|
+
h.step(world, []);
|
|
1425
|
+
const mine = () => s.sent.filter(([, msg]) => msg.k === 'hub-yours');
|
|
1426
|
+
assert.equal(mine().length, 1);
|
|
1427
|
+
assert.equal(mine()[0][0], 'p1');
|
|
1428
|
+
assert.equal(mine()[0][1].rows[0].door, 'race');
|
|
1429
|
+
assert.equal(mine()[0][1].rows[0].line, 'Last 12 ms');
|
|
1430
|
+
assert.ok(Number.isFinite(mine()[0][1].rows[0].lastAt));
|
|
1431
|
+
h.step(world, []);
|
|
1432
|
+
assert.equal(mine().length, 1);
|
|
1433
|
+
hello(h, s, 'p1', { again: true });
|
|
1434
|
+
h.step(world, []);
|
|
1435
|
+
assert.equal(mine().length, 1, 'avatar hello keeps latch');
|
|
1436
|
+
hello(h, s, 'p1');
|
|
1437
|
+
h.step(world, []);
|
|
1438
|
+
assert.equal(mine().length, 2, 'fresh client gets private rows again');
|
|
1439
|
+
assert.equal(p.calls.filter(([k]) => k === 'read').length, 2, 'only the normal player and board reads');
|
|
1440
|
+
});
|
|
1441
|
+
|
|
1442
|
+
await test('yourGames: closed event gates cannot crowd playable doors out of the five rows', async () => {
|
|
1443
|
+
const actors = globalThis.__hubTestActors;
|
|
1444
|
+
const ids = ['gate0', 'gate1', 'gate2', 'gate3', 'gate4', 'play0', 'play1', 'play2', 'play3', 'play4', 'open-gate'];
|
|
1445
|
+
globalThis.__hubTestActors = [actors[0], ...ids.map((id) => ({
|
|
1446
|
+
id: `${id}-actor`,
|
|
1447
|
+
components: { HubDoor: { id, to: `deck:${id}`, title: id }, Transform: { x: 5, y: 0, z: 5 } },
|
|
1448
|
+
}))];
|
|
1449
|
+
try {
|
|
1450
|
+
const p = platformHub({ read: (input) => input.userIds ? { players: {
|
|
1451
|
+
101: { hearts: ids.slice(0, 8), recent: ids.slice(8).map((id) => ({ deckId: id, place: 'main', score: 2, at: new Date().toISOString() })), records: [] },
|
|
1452
|
+
} } : { boards: Object.fromEntries(ids.map((id) => [id, {
|
|
1453
|
+
toDeckId: id, unit: 'points', ...(id.startsWith('gate') || id === 'open-gate' ? { event: { open: id === 'open-gate' } } : {}),
|
|
1454
|
+
}])) } });
|
|
1455
|
+
const s = session({ hub: p.hub });
|
|
1456
|
+
const json = structuredClone(castleJson);
|
|
1457
|
+
json.hub.yourGames = true;
|
|
1458
|
+
const { h, world } = boot(s, {}, json);
|
|
1459
|
+
hello(h, s, 'p1');
|
|
1460
|
+
h.place(world, []);
|
|
1461
|
+
await flush();
|
|
1462
|
+
h.step(world, []);
|
|
1463
|
+
const listed = h.join().hubDoors;
|
|
1464
|
+
assert.deepEqual(listed.map((d) => d.id), ids.slice(5), 'Doors list excludes closed gates and keeps an open gate');
|
|
1465
|
+
const rows = s.sent.find(([id, msg]) => id === 'p1' && msg.k === 'hub-yours')[1].rows;
|
|
1466
|
+
assert.deepEqual(rows.map((r) => r.door), ids.slice(5, 10), 'cap applies after excluding five closed hearted gates');
|
|
1467
|
+
assert.ok(rows.every((r) => listed.some((d) => d.id === r.door)));
|
|
1468
|
+
} finally {
|
|
1469
|
+
globalThis.__hubTestActors = actors;
|
|
1470
|
+
}
|
|
1471
|
+
});
|
|
1472
|
+
|
|
1473
|
+
await test('sixteen avatars (v1.51): a place takes 0-15 from the hello and from ghost, and anything else as before', async () => {
|
|
1474
|
+
const { AVATARS } = await import('../code/server/hub.js');
|
|
1475
|
+
// The client's count is held to this one in test-avatar.mjs.
|
|
1476
|
+
// What a v1.51 client draws a player as: `hubAv2` where it names them, else `hubAv`.
|
|
1477
|
+
const wornBy = (h, playerId) => {
|
|
1478
|
+
const snapshot = h.join();
|
|
1479
|
+
return snapshot.hubAv2?.[playerId] ?? snapshot.hubAv[playerId];
|
|
1480
|
+
};
|
|
1481
|
+
assert.equal(AVATARS, 16);
|
|
1482
|
+
// The dev serve: the hello is all there is.
|
|
1483
|
+
{
|
|
1484
|
+
const s = session();
|
|
1485
|
+
const { h } = boot(s);
|
|
1486
|
+
for (const [said, worn] of [[4, 4], [9, 9], [15, 15], [0, 0], [3, 3], [16, 0], [255, 0], [-1, 0], [9.5, 0], ['9', 0], [null, 0]]) {
|
|
1487
|
+
hello(h, s, 'p1', { avatar: said });
|
|
1488
|
+
assert.equal(wornBy(h, 'p1'), worn, `hello ${JSON.stringify(said)}`);
|
|
1489
|
+
}
|
|
1490
|
+
// `hubAv` names a stand-in from the first four, `hubAv2` what is worn (test-avatar-wire.mjs).
|
|
1491
|
+
hello(h, s, 'p2', { avatar: 12 });
|
|
1492
|
+
assert.deepEqual(h.join().hubAv, { p1: 0, p2: 0 });
|
|
1493
|
+
assert.deepEqual(h.join().hubAv2, { p2: 12 });
|
|
1494
|
+
}
|
|
1495
|
+
// With ghost: its word replaces the hello's, a new character included; one past the kit's is not taken.
|
|
1496
|
+
for (const [ghost, said, worn] of [[9, 1, 9], [15, 15, 15], [16, 2, 2], [-1, 3, 3], [4.5, 1, 1]]) {
|
|
1497
|
+
const p = platformHub({ read: (input) => (input.userIds ? { players: { 101: { avatar: ghost, records: [], recent: [] } }, boards: {} } : { players: {}, boards: {} }) });
|
|
1498
|
+
const s = session({ hub: p.hub });
|
|
1499
|
+
const { h, world } = boot(s);
|
|
1500
|
+
hello(h, s, 'p1', { avatar: said });
|
|
1501
|
+
h.place(world);
|
|
1502
|
+
await flush();
|
|
1503
|
+
h.place(world);
|
|
1504
|
+
assert.equal(wornBy(h, 'p1'), worn, `ghost ${ghost}, hello ${said}`);
|
|
1505
|
+
// A pick after the read wins, a new character as any other.
|
|
1506
|
+
hello(h, s, 'p1', { avatar: 7 });
|
|
1507
|
+
assert.equal(wornBy(h, 'p1'), 7);
|
|
1508
|
+
}
|
|
1509
|
+
});
|
|
1510
|
+
|
|
1511
|
+
await test('private goal coordinates stay out of shared snapshots and blocked recipients', async () => {
|
|
1512
|
+
const p = platformHub();
|
|
1513
|
+
p.hub.hiddenPair = (a, b) => new Set([a, b]).has('p2') && new Set([a, b]).has('p3');
|
|
1514
|
+
const s = session({ hub: p.hub });
|
|
1515
|
+
const { h, world, ctx } = boot(s);
|
|
1516
|
+
assert.equal(ctx().goalPositions, true);
|
|
1517
|
+
for (const { playerId } of PLAYERS) hello(h, s, playerId);
|
|
1518
|
+
h.place(world); await flush(); h.place(world);
|
|
1519
|
+
const at = { x: 81.25, y: 1.2, z: -53.75 };
|
|
1520
|
+
ctx().label('race-door', 'bo', { style: 'goal', to: ['p1', 'p3'], about: 'p2', at });
|
|
1521
|
+
at.x = 99; // The stored wire point must not alias the caller's object.
|
|
1522
|
+
h.step(world);
|
|
1523
|
+
const own = s.sent.filter(([id, data]) => id === 'p1' && data.k === 'hub-labels').at(-1)?.[1].labels;
|
|
1524
|
+
assert.deepEqual(own['race-door'].at, { x: 81.25, y: 1.2, z: -53.75 });
|
|
1525
|
+
assert.ok(!JSON.stringify(s.sent.filter(([id]) => id === 'p3')).includes('81.25'));
|
|
1526
|
+
assert.ok(!JSON.stringify(h.join()).includes('81.25'), 'shared join has no private coordinates');
|
|
1527
|
+
assert.equal(Object.keys(h.join().spawned).length, 0, 'no spawned tracking actor');
|
|
1528
|
+
assert.equal(world.bodies.size, 0, 'no shared kinematic marker body');
|
|
1529
|
+
for (const bad of [{x:NaN,y:0,z:0}, {x:201,y:0,z:0}, {x:0,y:81,z:0}, {x:0,z:0}]) {
|
|
1530
|
+
ctx().label('race-door', 'bo', {style:'goal',to:['p1'],at:bad});
|
|
1531
|
+
h.step(world);
|
|
1532
|
+
const row=s.sent.filter(([id,data])=>id==='p1'&&data.k==='hub-labels').at(-1)?.[1].labels;
|
|
1533
|
+
assert.ok(!row['race-door'].at, 'invalid coordinates ignored');
|
|
1534
|
+
}
|
|
1535
|
+
ctx().label('race-door', 'bo', {style:'goal',at:{x:81.25,y:1.2,z:-53.75}});
|
|
1536
|
+
assert.ok(!JSON.stringify(h.join()).includes('81.25'), 'unscoped sign ignores coordinates');
|
|
1537
|
+
});
|
|
1538
|
+
|
|
1539
|
+
|
|
1540
|
+
|
|
1541
|
+
|
|
1542
|
+
await test('door telemetry follows real arrival/result/end and authenticated quit', async () => {
|
|
1543
|
+
const events = [], p = platformHub();
|
|
1544
|
+
p.hub.track = (id, event) => { events.push([id, event]); return Promise.resolve({ recorded: true }); };
|
|
1545
|
+
const s = session({ hub: p.hub, place: 'race' });
|
|
1546
|
+
const { h, world, ctx } = boot(s);
|
|
1547
|
+
hello(h, s, 'p1');
|
|
1548
|
+
h.place(world); await flush(); h.place(world);
|
|
1549
|
+
assert.equal(events.filter(([, e]) => e.kind === 28).length, 1);
|
|
1550
|
+
world.timeMs = 7000;
|
|
1551
|
+
assert.equal(ctx().result('p1', { outcome: 'win', score: 100 }), true);
|
|
1552
|
+
ctx().end(['p1']);
|
|
1553
|
+
assert.deepEqual(events.filter(([, e]) => e.kind === 29).map(([, e]) => [e.value, e.result]), [[7, 1]]);
|
|
1554
|
+
hello(h, s, 'p2'); h.place(world); await flush(); h.place(world);
|
|
1555
|
+
h.message(s.session, { playerId: 'p2' }, { k: 'hub-door-quit' });
|
|
1556
|
+
assert.equal(events.at(-1)[1].result, 2);
|
|
1557
|
+
h.message(s.session, { playerId: 'stranger' }, { k: 'hub-door-error', result: 2 });
|
|
1558
|
+
assert.equal(events.at(-1)[1].kind, 29);
|
|
1559
|
+
});
|
|
1560
|
+
|
|
1561
|
+
|
|
1562
|
+
|
|
1563
|
+
await test('authored visit results/end do not finish an interrupted competitive round', async () => {
|
|
1564
|
+
const events = [], p = platformHub();
|
|
1565
|
+
p.hub.track = (id, event) => { events.push([id, event]); return Promise.resolve({ recorded: true }); };
|
|
1566
|
+
const json = structuredClone(castleJson); json.hub.places.race.analyticsRounds = 'authored';
|
|
1567
|
+
const s = session({ hub: p.hub, place: 'race' });
|
|
1568
|
+
const { h, world, ctx } = boot(s, {}, json);
|
|
1569
|
+
hello(h,s,'p1'); h.place(world); await flush(); h.place(world);
|
|
1570
|
+
assert.equal(events.length,0,'no automatic arrival round in authored mode');
|
|
1571
|
+
ctx().track('p1','round_start',{value:1});
|
|
1572
|
+
assert.equal(ctx().result('p1',{outcome:'win',score:100}),true);
|
|
1573
|
+
ctx().end(['p1']);
|
|
1574
|
+
assert.equal(events.filter(([,e])=>e.kind===29).length,0,'visit result/end cannot claim round completion');
|
|
1575
|
+
world.players.delete('p1'); s.session.players = s.session.players.filter(p=>p.playerId!=='p1'); h.place(world);
|
|
1576
|
+
assert.deepEqual(events.filter(([,e])=>e.kind===29).map(([,e])=>e.result),[3],'disconnect closes interrupted round');
|
|
1577
|
+
});
|
|
835
1578
|
console.log(`hub ops: ${n} tests passed`);
|
|
1579
|
+
|
|
1580
|
+
// Opt-in exists after actual layer construction, before authored hooks run.
|
|
1581
|
+
{
|
|
1582
|
+
const s = session();
|
|
1583
|
+
const plain = boot(s);
|
|
1584
|
+
assert.equal(plain.ctx().firstVisit, undefined);
|
|
1585
|
+
assert.equal(plain.ctx().firstVisitArrived, undefined);
|
|
1586
|
+
const enabled = boot(session(), {}, { ...castleJson, hub: { ...castleJson.hub, firstVisit: { live: ['home', 'door'] } } });
|
|
1587
|
+
assert.deepEqual(enabled.ctx().firstVisit, { live: ['home', 'door'] });
|
|
1588
|
+
assert.equal(typeof enabled.ctx().firstVisitArrived, 'function');
|
|
1589
|
+
assert.equal(enabled.ctx().firstVisitArrived('unknown', 2), false);
|
|
1590
|
+
assert(Object.isFrozen(enabled.ctx().firstVisit.live));
|
|
1591
|
+
}
|