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
|
@@ -0,0 +1,664 @@
|
|
|
1
|
+
// Tests over a town's labels kept near and apart (contract v1.43, the deck's
|
|
2
|
+
// `hub.labels: "near"`; code/client/labelsNear.js): a sign only near the
|
|
3
|
+
// player, no two world labels overlapping, three at most, and none of it
|
|
4
|
+
// flickering at an edge. `npm run check` runs this.
|
|
5
|
+
|
|
6
|
+
import assert from 'node:assert/strict';
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import { goalAt, chromeItem, CLEAR_PX, HIDE_MS, labelBox, makeNear, MAX, near, nearCandidates, nearFor, SIGN_FAR_M, SIGN_NEAR_M, STICK_M } from '../code/client/labelsNear.js';
|
|
9
|
+
import { fakeDom } from './fixtures/fake-dom.mjs';
|
|
10
|
+
import { readManifest } from '../code/server/manifest.js';
|
|
11
|
+
|
|
12
|
+
const VIEW = { w: 412, h: 870 };
|
|
13
|
+
const touching = (a, b) => a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom;
|
|
14
|
+
let passed = 0;
|
|
15
|
+
function test(name, fn) {
|
|
16
|
+
fn();
|
|
17
|
+
passed += 1;
|
|
18
|
+
}
|
|
19
|
+
// A label 100 x 26 hanging over (x, y).
|
|
20
|
+
const box = (x, y, w = 100, h = 26) => labelBox(x, y, { w, h }, false, VIEW);
|
|
21
|
+
const sign = (id, d, x, y, more = {}) => ({ id, kind: 'sign', d, mine: false, box: box(x, y), ...more });
|
|
22
|
+
const plate = (id, d, x, y, more = {}) => ({ id, kind: 'plate', pick: true, d, mine: false, box: box(x, y), ...more });
|
|
23
|
+
const line = (id, d, x, y, more = {}) => ({ id, kind: 'speech', pick: true, d, mine: false, box: box(x, y, 240, 60), ...more });
|
|
24
|
+
// The same items every 16 ms from `from` for `ms`; the last frame's answer.
|
|
25
|
+
function hold(s, items, from, ms) {
|
|
26
|
+
let out = null;
|
|
27
|
+
for (let t = from; t <= from + ms; t += 16) {
|
|
28
|
+
out = near(s, typeof items === 'function' ? items(t) : items, VIEW, t);
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
const ids = (shown) => [...shown.keys()].sort();
|
|
33
|
+
|
|
34
|
+
test('a sign is drawn only near the player', () => {
|
|
35
|
+
let s = makeNear();
|
|
36
|
+
assert.equal(near(s, [sign('arch', SIGN_NEAR_M + 0.1, 200, 300)], VIEW, 1000).size, 0, 'a step short of near: not drawn');
|
|
37
|
+
assert.deepEqual(ids(near(s, [sign('arch', SIGN_NEAR_M - 0.1, 200, 300)], VIEW, 1016)), ['arch']);
|
|
38
|
+
// The owner's view: six signs 34 to 59 m off from a district's middle. None.
|
|
39
|
+
s = makeNear();
|
|
40
|
+
const far = [34.5, 39.2, 48.5, 50.7, 58.5, 59.3].map((d, i) => sign(`s${i}`, d, 60 + i * 60, 240));
|
|
41
|
+
assert.equal(hold(s, far, 0, 1000).size, 0);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('a sign once drawn is kept to the far line, thinning, and nothing is drawn at it', () => {
|
|
45
|
+
const s = makeNear();
|
|
46
|
+
hold(s, [sign('arch', 11, 200, 300)], 0, 400);
|
|
47
|
+
assert.equal(near(s, [sign('arch', 12.9, 200, 300)], VIEW, 416).get('arch'), 1, 'past near, still whole');
|
|
48
|
+
const thin = near(s, [sign('arch', 13.5, 200, 300)], VIEW, 432).get('arch');
|
|
49
|
+
assert.ok(thin > 0.4 && thin < 0.6, `thinning toward the far line (${thin})`);
|
|
50
|
+
assert.equal(near(s, [sign('arch', SIGN_FAR_M, 200, 300)], VIEW, 448).size, 0, 'nothing at the far line');
|
|
51
|
+
assert.equal(near(s, [sign('arch', SIGN_FAR_M + 0.1, 200, 300)], VIEW, 464).size, 0);
|
|
52
|
+
// Walking the line between near and far: on once, never off and on.
|
|
53
|
+
const t = makeNear();
|
|
54
|
+
let flips = 0;
|
|
55
|
+
let was = false;
|
|
56
|
+
for (let i = 0; i < 200; i += 1) {
|
|
57
|
+
const on = near(t, [sign('arch', 12.5 + (i % 2 ? 0.8 : -0.8), 200, 300)], VIEW, i * 16).has('arch');
|
|
58
|
+
flips += on === was ? 0 : 1;
|
|
59
|
+
was = on;
|
|
60
|
+
}
|
|
61
|
+
assert.equal(flips, 1);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('it fades in over a quarter second', () => {
|
|
65
|
+
const s = makeNear();
|
|
66
|
+
near(s, [], VIEW, 1000);
|
|
67
|
+
const a = near(s, [sign('arch', 5, 200, 300)], VIEW, 1016).get('arch');
|
|
68
|
+
assert.ok(a > 0 && a < 0.2);
|
|
69
|
+
assert.equal(hold(s, [sign('arch', 5, 200, 300)], 1032, 300).get('arch'), 1);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test('the plate stood by, then the NPC line, then signs by how near', () => {
|
|
73
|
+
// All four on one spot: only the plate.
|
|
74
|
+
let s = makeNear();
|
|
75
|
+
assert.deepEqual(ids(hold(s, [sign('far', 9, 200, 300), sign('near', 4, 200, 300), line('npc', 6, 200, 300), plate('pad', 2, 200, 300)], 0, 400)), ['pad']);
|
|
76
|
+
// Without the plate: the line. Without both: the nearer sign.
|
|
77
|
+
s = makeNear();
|
|
78
|
+
assert.deepEqual(ids(hold(s, [sign('far', 9, 200, 300), sign('near', 4, 200, 300), line('npc', 6, 200, 300)], 0, 400)), ['npc']);
|
|
79
|
+
s = makeNear();
|
|
80
|
+
assert.deepEqual(ids(hold(s, [sign('far', 9, 200, 300), sign('near', 4, 200, 300)], 0, 400)), ['near']);
|
|
81
|
+
// Equally near, one said to this player alone: theirs.
|
|
82
|
+
s = makeNear();
|
|
83
|
+
assert.deepEqual(ids(hold(s, [sign('all', 6, 200, 300), sign('me', 6, 200, 300, { mine: true })], 0, 400)), ['me']);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('no two overlap; one that touches neither is drawn too', () => {
|
|
87
|
+
const s = makeNear();
|
|
88
|
+
// The owner's arrangement from Sunny Side, brought near: "Sunny Side" on
|
|
89
|
+
// "Hollow End", "Arcade" behind "The Stadium" on "The Kettle - inn".
|
|
90
|
+
const items = [sign('sunny', 5, 206, 250), sign('hollow', 9, 206, 256), sign('arcade', 11, 330, 252), sign('stadium', 8, 368, 254), sign('inn', 7, 345, 266)];
|
|
91
|
+
const shown = hold(s, items, 0, 600);
|
|
92
|
+
assert.deepEqual(ids(shown), ['inn', 'sunny']);
|
|
93
|
+
const boxes = items.filter((i) => shown.has(i.id)).map((i) => i.box);
|
|
94
|
+
assert.ok(boxes[0].right <= boxes[1].left || boxes[1].right <= boxes[0].left);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test(`at most ${MAX} at once`, () => {
|
|
98
|
+
const s = makeNear();
|
|
99
|
+
const four = [sign('a', 4, 60, 100), sign('b', 5, 60, 300), sign('c', 6, 60, 500), sign('d', 7, 60, 700)];
|
|
100
|
+
assert.deepEqual(ids(hold(s, four, 0, 600)), ['a', 'b', 'c']);
|
|
101
|
+
// With a plate and a line up, one sign.
|
|
102
|
+
const t = makeNear();
|
|
103
|
+
assert.deepEqual(ids(hold(t, [...four, plate('pad', 1, 300, 100), line('npc', 3, 280, 400)], 0, 600)), ['a', 'npc', 'pad']);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('never more than three and never two overlapping, fading ones counted', () => {
|
|
107
|
+
// Signs swept across each other and in and out of reach.
|
|
108
|
+
const s = makeNear();
|
|
109
|
+
for (let t = 0; t < 12000; t += 33) {
|
|
110
|
+
const k = t / 1000;
|
|
111
|
+
const items = [0, 1, 2, 3, 4, 5].map((i) => sign(`s${i}`, 9 + 6 * Math.sin(k * (0.4 + i * 0.13) + i), 206 + 150 * Math.sin(k * (0.7 + i * 0.21) + i * 2), 300 + 120 * Math.cos(k * (0.5 + i * 0.17) + i)));
|
|
112
|
+
const shown = near(s, items, VIEW, t);
|
|
113
|
+
assert.ok(shown.size <= MAX, `${shown.size} drawn at ${t}`);
|
|
114
|
+
const drawn = items.filter((i) => shown.get(i.id) > 0);
|
|
115
|
+
for (const a of drawn) {
|
|
116
|
+
assert.ok(a.d < SIGN_FAR_M, `drawn at ${a.d} m`);
|
|
117
|
+
for (const b of drawn) {
|
|
118
|
+
assert.ok(a === b || a.box.right <= b.box.left || b.box.right <= a.box.left || a.box.bottom <= b.box.top || b.box.bottom <= a.box.top, `overlap at ${t}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test('two equally near do not swap', () => {
|
|
125
|
+
const s = makeNear();
|
|
126
|
+
let swaps = 0;
|
|
127
|
+
let was = null;
|
|
128
|
+
for (let i = 0; i < 300; i += 1) {
|
|
129
|
+
const wobble = (i % 2 ? 1 : -1) * (STICK_M / 2 - 0.05);
|
|
130
|
+
const shown = near(s, [sign('a', 8 + wobble, 200, 300), sign('b', 8 - wobble, 200, 300)], VIEW, i * 16);
|
|
131
|
+
const on = ids(shown).filter((id) => shown.get(id) === 1 || ids(shown).length === 1)[0] ?? was;
|
|
132
|
+
swaps += was !== null && on !== was ? 1 : 0;
|
|
133
|
+
was = on;
|
|
134
|
+
}
|
|
135
|
+
assert.equal(swaps, 0);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test('one taken down for another comes back only clear of it, and not at once', () => {
|
|
139
|
+
const s = makeNear();
|
|
140
|
+
// `b` slides over `a` and back off: touching at 100 px apart.
|
|
141
|
+
const at = (gap) => [sign('a', 5, 150, 300), sign('b', 8, 150 + gap, 300)];
|
|
142
|
+
assert.deepEqual(ids(hold(s, at(140), 0, 400)), ['a', 'b']);
|
|
143
|
+
assert.deepEqual(ids(near(s, at(99), VIEW, 416)), ['a'], 'touching: gone at once, not faded over the other');
|
|
144
|
+
// Clear by a pixel straight away: still down (too soon, and not clear enough).
|
|
145
|
+
assert.deepEqual(ids(near(s, at(101), VIEW, 432)), ['a']);
|
|
146
|
+
assert.deepEqual(ids(hold(s, at(100 + CLEAR_PX - 1), 448, HIDE_MS + 200)), ['a'], 'not clear enough, however long');
|
|
147
|
+
assert.deepEqual(ids(hold(s, at(100 + CLEAR_PX + 1), 416 + HIDE_MS - 200, 100)), ['a'], 'clear enough, too soon');
|
|
148
|
+
assert.deepEqual(ids(hold(s, at(100 + CLEAR_PX + 1), 416 + HIDE_MS + 16, 300)), ['a', 'b']);
|
|
149
|
+
// A camera turning back and forth across the touching point: down once.
|
|
150
|
+
const t = makeNear();
|
|
151
|
+
hold(t, at(140), 0, 400);
|
|
152
|
+
let flips = 0;
|
|
153
|
+
let was = true;
|
|
154
|
+
for (let i = 0; i < 120; i += 1) {
|
|
155
|
+
const on = near(t, at(i % 2 ? 98 : 103), VIEW, 416 + i * 16).has('b');
|
|
156
|
+
flips += on === was ? 0 : 1;
|
|
157
|
+
was = on;
|
|
158
|
+
}
|
|
159
|
+
assert.equal(flips, 1);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test('one waiting to come back keeps its place: the next down the order does not flash up in it', () => {
|
|
163
|
+
const s = makeNear();
|
|
164
|
+
// Three signs drawn and a fourth, farther, waiting on the cap.
|
|
165
|
+
const base = (third) => [sign('a', 4, 60, 100), sign('b', 5, 60, 300), sign('c', 6, third, 500), sign('d', 9, 300, 700)];
|
|
166
|
+
assert.deepEqual(ids(hold(s, base(60), 0, 600)), ['a', 'b', 'c']);
|
|
167
|
+
// A bubble passes over `c` for a moment: `c` goes, and `d` does not come up
|
|
168
|
+
// for it; `c` is back once its time down is over, having changed twice.
|
|
169
|
+
const bubble = line('npc', 3, 60, 520);
|
|
170
|
+
let seen = new Set();
|
|
171
|
+
for (let t = 616; t < 616 + 400; t += 16) {
|
|
172
|
+
for (const id of near(s, [...base(60), bubble], VIEW, t).keys()) seen.add(id);
|
|
173
|
+
}
|
|
174
|
+
assert.equal(seen.has('d'), false);
|
|
175
|
+
seen = new Set();
|
|
176
|
+
for (let t = 1016; t < 616 + HIDE_MS; t += 16) {
|
|
177
|
+
for (const id of near(s, base(60), VIEW, t).keys()) seen.add(id);
|
|
178
|
+
}
|
|
179
|
+
assert.deepEqual([...seen].sort(), ['a', 'b'], 'the place is kept while it waits');
|
|
180
|
+
assert.deepEqual(ids(hold(s, base(60), 616 + HIDE_MS + 16, 400)), ['a', 'b', 'c']);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
test('a label goes and comes at most once in any two seconds, whatever crosses it', () => {
|
|
184
|
+
const s = makeNear();
|
|
185
|
+
const changes = [];
|
|
186
|
+
let was = false;
|
|
187
|
+
for (let t = 0; t < 20000; t += 16) {
|
|
188
|
+
// A bubble sweeping back and forth over the sign, across it every 0.6 s.
|
|
189
|
+
const x = 200 + 420 * Math.sin(t / 190);
|
|
190
|
+
const on = near(s, [sign('arch', 6, 200, 300), line('npc', 3, x, 310)], VIEW, t).get('arch') > 0;
|
|
191
|
+
if (on !== was) changes.push(t);
|
|
192
|
+
was = on;
|
|
193
|
+
}
|
|
194
|
+
assert.ok(changes.length >= 4, 'it does go and come');
|
|
195
|
+
for (let i = 2; i < changes.length; i += 1) {
|
|
196
|
+
assert.ok(changes[i] - changes[i - 2] >= 2000, `three changes inside ${changes[i] - changes[i - 2]} ms`);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test('a plate or a line the attention rule passed over only finishes fading', () => {
|
|
201
|
+
const s = makeNear();
|
|
202
|
+
hold(s, [plate('pad', 2, 200, 300)], 0, 400);
|
|
203
|
+
const fading = near(s, [plate('pad', 5, 200, 300, { pick: false })], VIEW, 416);
|
|
204
|
+
assert.ok(fading.get('pad') > 0 && fading.get('pad') < 1);
|
|
205
|
+
assert.equal(hold(s, [plate('pad', 5, 200, 300, { pick: false })], 432, 400).size, 0);
|
|
206
|
+
// Never drawn, never picked: nothing.
|
|
207
|
+
assert.equal(near(makeNear(), [plate('other', 3, 200, 300, { pick: false })], VIEW, 0).size, 0);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
test('behind the camera or off the view: not drawn and not counted', () => {
|
|
211
|
+
const s = makeNear();
|
|
212
|
+
const items = [sign('behind', 3, 0, 0, { box: null }), sign('off', 4, -400, 300), sign('a', 5, 60, 100), sign('b', 6, 60, 300), sign('c', 7, 60, 500)];
|
|
213
|
+
assert.deepEqual(ids(hold(s, items, 0, 400)), ['a', 'b', 'c']);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
test('an NPC line is boxed where the chrome keeps it on screen', () => {
|
|
217
|
+
assert.deepEqual(labelBox(10, 200, { w: 200, h: 60 }, true, VIEW), { left: 6, right: 206, top: 140, bottom: 200 });
|
|
218
|
+
assert.deepEqual(labelBox(10, 200, { w: 200, h: 60 }, false, VIEW), { left: -90, right: 110, top: 140, bottom: 200 });
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
test('the key: "near" or left out, the deck\'s alone, and not in the manifest', () => {
|
|
222
|
+
const deck = (hub) => ({ hub: { contract: 1, title: 'Town', ...hub } });
|
|
223
|
+
const has = () => true;
|
|
224
|
+
const without = readManifest(deck({}), has);
|
|
225
|
+
const withKey = readManifest(deck({ labels: 'near' }), has);
|
|
226
|
+
assert.deepEqual(withKey.errors, []);
|
|
227
|
+
assert.deepEqual(withKey.manifest, without.manifest, 'the server manifest is the same with the key and without');
|
|
228
|
+
for (const bad of [true, false, 'far', 14, { near: 14 }, null]) {
|
|
229
|
+
assert.match(readManifest(deck({ labels: bad }), has).errors.join(), /hub\.labels must be "near"/);
|
|
230
|
+
}
|
|
231
|
+
const place = readManifest(deck({ places: { arena: { title: 'Arena', scene: 'scenes/arena.scene', labels: 'near' } } }), has);
|
|
232
|
+
assert.match(place.errors.join('\n'), /hub\.places\.arena\.labels is not part/);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
// --- the state is one visit's ----------------------------------------------
|
|
236
|
+
|
|
237
|
+
// A visit as the hub system names it at its one call site.
|
|
238
|
+
const visit = (over = {}) => ({ scene: 'scenes/main.scene', data: DATA, net: NET, place: PLACE, ...over });
|
|
239
|
+
const DATA = { actors: [] };
|
|
240
|
+
const NET = { id: 'connection 1' };
|
|
241
|
+
const PLACE = { id: 'main' };
|
|
242
|
+
// The reviewer's probe: an arch taken down for a nearer sign is held down;
|
|
243
|
+
// then the arch alone. In the same visit it stays down for its two seconds.
|
|
244
|
+
function suppressed(holder) {
|
|
245
|
+
const s = nearFor(holder, visit());
|
|
246
|
+
hold(s, [sign('arch', 6, 200, 300), sign('other', 9, 200, 600)], 0, 400);
|
|
247
|
+
const down = near(s, [sign('arch', 6, 200, 300), sign('inn', 3, 200, 300)], VIEW, 416);
|
|
248
|
+
assert.deepEqual(ids(down), ['inn']);
|
|
249
|
+
assert.equal(near(nearFor(holder, visit()), [sign('arch', 6, 200, 300)], VIEW, 432).has('arch'), false, 'the same visit: still held down');
|
|
250
|
+
assert.equal(nearFor(holder, visit()), s, 'the same visit keeps its state');
|
|
251
|
+
return s;
|
|
252
|
+
}
|
|
253
|
+
const alone = (holder, scope) => near(nearFor(holder, scope), [sign('arch', 6, 200, 300)], VIEW, 448);
|
|
254
|
+
|
|
255
|
+
for (const [path, scope] of [
|
|
256
|
+
['another scene (the hub system\'s enterScene: the scene key changes)', () => visit({ scene: 'scenes/arena.scene' })],
|
|
257
|
+
['the same scene loaded again (the engine\'s reset: scene.data is a new object)', () => visit({ data: { actors: [] } })],
|
|
258
|
+
['a reconnect (a new connection object)', () => visit({ net: { id: 'connection 2' } })],
|
|
259
|
+
['the hub\'s state cleared and the place told again (Hub.clear(), then a new hubPlace)', () => visit({ place: { id: 'main' } })],
|
|
260
|
+
['the hub\'s state cleared and no place yet (Hub.clear())', () => visit({ place: null })],
|
|
261
|
+
]) {
|
|
262
|
+
test(`a new visit starts the rule again: ${path}`, () => {
|
|
263
|
+
const holder = {};
|
|
264
|
+
const old = suppressed(holder);
|
|
265
|
+
const shown = alone(holder, scope());
|
|
266
|
+
assert.equal(shown.has('arch'), true, 'not held down by the visit before');
|
|
267
|
+
assert.notEqual(holder.state, old);
|
|
268
|
+
assert.equal(holder.state.downAt.size, 0);
|
|
269
|
+
assert.deepEqual([...holder.state.reach], ['arch']);
|
|
270
|
+
assert.ok(shown.get('arch') > 0 && shown.get('arch') < 1 || shown.get('arch') === 1);
|
|
271
|
+
// Nothing of the old visit's reach or opacity either.
|
|
272
|
+
const fresh = {};
|
|
273
|
+
hold(nearFor(fresh, visit()), [sign('far', 13, 200, 300, { d: 11 })], 0, 400);
|
|
274
|
+
assert.equal(near(nearFor(fresh, visit()), [sign('far', 13, 200, 300)], VIEW, 416).has('far'), true, 'in the same visit a sign in reach is kept to the far line');
|
|
275
|
+
assert.equal(near(nearFor(fresh, scope()), [sign('far', 13, 200, 300)], VIEW, 432).has('far'), false, 'a new visit has no reach: 13 m is not near');
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
test('the hub system names the visit by all four at its one call site, and holds no other state', () => {
|
|
280
|
+
const src = fs.readFileSync(new URL('../code/systems/hub.js', import.meta.url), 'utf8');
|
|
281
|
+
assert.match(src, /nearFor\(\(this\.nearHeld \?\?= \{\}\), \{ scene: sceneKeyOf\(scene\), data: scene\.data, net: scene\.multiplayer\?\.net \?\? null, place: Hub\.hub\.place \}\)/);
|
|
282
|
+
assert.equal(src.includes('makeNear'), false, 'only nearFor makes the state');
|
|
283
|
+
assert.equal(src.split('nearFor(').length - 1, 1);
|
|
284
|
+
assert.equal(src.split('near(state, items, view, now)').length - 1, 1);
|
|
285
|
+
// What each path changes, as the code has it: the engine gives every load new data,
|
|
286
|
+
// and clearing the hub's state drops the place.
|
|
287
|
+
const state = fs.readFileSync(new URL('../code/client/state.js', import.meta.url), 'utf8');
|
|
288
|
+
assert.match(state, /export function clear\(\) \{\n {2}hub\.place = null;/);
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
// --- every box drawn in a frame, at any opacity -----------------------------
|
|
292
|
+
|
|
293
|
+
test('two outgoing labels whose boxes coincide: one is gone at once', () => {
|
|
294
|
+
const s = makeNear();
|
|
295
|
+
// Two signs drawn apart...
|
|
296
|
+
hold(s, [sign('a', 5, 100, 300), sign('b', 6, 300, 300)], 0, 400);
|
|
297
|
+
// ...then both out of reach's order (a plate takes over) and on one spot.
|
|
298
|
+
const shown = near(s, [sign('a', 5, 200, 500, { box: null }), sign('b', 6, 200, 500, { box: null }), plate('pad', 1, 200, 200)], VIEW, 416);
|
|
299
|
+
assert.deepEqual(ids(shown), ['pad'], 'no box: nothing to fade');
|
|
300
|
+
const t = makeNear();
|
|
301
|
+
hold(t, [plate('p1', 2, 100, 300), line('l1', 5, 280, 600)], 0, 400);
|
|
302
|
+
// Both passed over by the attention rule this frame, their boxes now one on
|
|
303
|
+
// the other; a new plate is picked elsewhere.
|
|
304
|
+
const out = near(t, [plate('p1', 2, 200, 500, { pick: false }), line('l1', 5, 200, 500, { pick: false }), plate('p2', 1, 200, 200)], VIEW, 416);
|
|
305
|
+
assert.deepEqual(ids(out), ['p1', 'p2'], 'the plate fades, the line under it is gone at once');
|
|
306
|
+
assert.ok(out.get('p1') < 1);
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
test('an outgoing label under a chosen one is gone at once; clear of it, it fades', () => {
|
|
310
|
+
const s = makeNear();
|
|
311
|
+
hold(s, [plate('old', 2, 200, 300)], 0, 400);
|
|
312
|
+
assert.deepEqual(ids(near(s, [plate('old', 3, 200, 300, { pick: false }), plate('new', 1, 210, 305)], VIEW, 416)), ['new']);
|
|
313
|
+
const t = makeNear();
|
|
314
|
+
hold(t, [plate('old', 2, 200, 300)], 0, 400);
|
|
315
|
+
assert.deepEqual(ids(near(t, [plate('old', 3, 200, 300, { pick: false }), plate('new', 1, 200, 600)], VIEW, 416)), ['new', 'old']);
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
test('property: no two labels returned in a frame touch, whatever their opacity; three at most, fading ones counted', () => {
|
|
319
|
+
// A small seeded generator: the same sequences on every run.
|
|
320
|
+
let seed = 20261005;
|
|
321
|
+
const rnd = () => ((seed = (seed * 1664525 + 1013904223) >>> 0) / 4294967296);
|
|
322
|
+
const pickOf = (list) => list[Math.floor(rnd() * list.length)];
|
|
323
|
+
let frames = 0;
|
|
324
|
+
let most = 0;
|
|
325
|
+
let faded = 0;
|
|
326
|
+
for (let run = 0; run < 300; run += 1) {
|
|
327
|
+
const s = makeNear();
|
|
328
|
+
const n = 2 + Math.floor(rnd() * 9);
|
|
329
|
+
const labels = Array.from({ length: n }, (_, i) => ({
|
|
330
|
+
id: `l${i}`,
|
|
331
|
+
kind: pickOf(['plate', 'plate', 'speech', 'sign', 'sign', 'sign']),
|
|
332
|
+
x: rnd() * VIEW.w,
|
|
333
|
+
y: 100 + rnd() * 600,
|
|
334
|
+
d: rnd() * 16,
|
|
335
|
+
w: 60 + rnd() * 200,
|
|
336
|
+
h: pickOf([26, 26, 44, 62]),
|
|
337
|
+
mine: rnd() < 0.3,
|
|
338
|
+
}));
|
|
339
|
+
let t = Math.floor(rnd() * 1000);
|
|
340
|
+
let plateNow = null;
|
|
341
|
+
let lineNow = null;
|
|
342
|
+
for (let f = 0; f < 120; f += 1) {
|
|
343
|
+
t += pickOf([8, 16, 16, 33, 50, 120, 400]);
|
|
344
|
+
// Labels drift, jump, leave the view, lose their point, change distance.
|
|
345
|
+
for (const l of labels) {
|
|
346
|
+
const jump = rnd() < 0.04;
|
|
347
|
+
l.x += jump ? (rnd() - 0.5) * 400 : (rnd() - 0.5) * 30;
|
|
348
|
+
l.y += jump ? (rnd() - 0.5) * 400 : (rnd() - 0.5) * 30;
|
|
349
|
+
l.d = Math.max(0, l.d + (rnd() - 0.5) * (jump ? 8 : 1));
|
|
350
|
+
l.gone = rnd() < 0.03;
|
|
351
|
+
}
|
|
352
|
+
// The attention rule's picks move about too.
|
|
353
|
+
if (rnd() < 0.15) plateNow = pickOf([null, ...labels.filter((l) => l.kind === 'plate').map((l) => l.id)]);
|
|
354
|
+
if (rnd() < 0.15) lineNow = pickOf([null, ...labels.filter((l) => l.kind === 'speech').map((l) => l.id)]);
|
|
355
|
+
const present = labels.filter(() => rnd() > 0.05);
|
|
356
|
+
const items = present.map((l) => ({
|
|
357
|
+
id: l.id,
|
|
358
|
+
kind: l.kind,
|
|
359
|
+
pick: l.kind === 'sign' ? false : l.id === (l.kind === 'plate' ? plateNow : lineNow),
|
|
360
|
+
d: l.d,
|
|
361
|
+
mine: l.mine,
|
|
362
|
+
box: l.gone ? null : labelBox(l.x, l.y, { w: l.w, h: l.h }, l.kind === 'speech', VIEW, rnd() < 0.2 ? { left: 60, right: 350, top: 12, bottom: 130 } : null),
|
|
363
|
+
}));
|
|
364
|
+
const shown = near(s, items, VIEW, t);
|
|
365
|
+
frames += 1;
|
|
366
|
+
const drawn = items.filter((i) => shown.has(i.id));
|
|
367
|
+
assert.equal(drawn.length, shown.size, 'only labels given this frame are returned');
|
|
368
|
+
assert.ok(shown.size <= MAX, `${shown.size} returned (run ${run}, frame ${f})`);
|
|
369
|
+
assert.ok(s.chosen.size <= MAX);
|
|
370
|
+
most = Math.max(most, shown.size);
|
|
371
|
+
for (const a of drawn) {
|
|
372
|
+
assert.ok(shown.get(a.id) > 0 && shown.get(a.id) <= 1);
|
|
373
|
+
assert.ok(a.box, 'a label with no point is never returned');
|
|
374
|
+
assert.ok(a.kind !== 'sign' || a.d < SIGN_FAR_M, `a sign returned at ${a.d} m`);
|
|
375
|
+
faded += s.chosen.has(a.id) ? 0 : 1;
|
|
376
|
+
for (const b of drawn) {
|
|
377
|
+
assert.ok(a === b || !touching(a.box, b.box), `run ${run}, frame ${f}: ${a.id} (${shown.get(a.id)}) touches ${b.id} (${shown.get(b.id)})`);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
assert.equal(frames, 36000);
|
|
383
|
+
assert.equal(most, MAX, 'the cap is reached');
|
|
384
|
+
assert.ok(faded > 500, `fading labels were among those returned (${faded})`);
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
// --- one box: the rule judges it and the chrome draws in it ------------------
|
|
388
|
+
//
|
|
389
|
+
// The real chrome over a stand-in DOM whose layout follows a node's words and
|
|
390
|
+
// styles: a plate is one line; a line of speech wraps at its `maxWidth`, and
|
|
391
|
+
// one with no width of its own also at the room to its right.
|
|
392
|
+
|
|
393
|
+
const PHONE = { viewW: 360, viewH: 740 };
|
|
394
|
+
function layout(node) {
|
|
395
|
+
if (node.styles.padding !== '4px 10px') {
|
|
396
|
+
return undefined;
|
|
397
|
+
}
|
|
398
|
+
const chars = node.textContent.length;
|
|
399
|
+
if (node.styles.fontSize !== '13px') {
|
|
400
|
+
return { w: chars * 7 + 20, h: 26 };
|
|
401
|
+
}
|
|
402
|
+
const most = Math.floor(PHONE.viewW * 0.62);
|
|
403
|
+
const room = node.styles.width === 'max-content' ? Infinity : Math.max(40, PHONE.viewW - (parseFloat(node.styles.left) || 0));
|
|
404
|
+
const w = Math.min(chars * 6 + 20, most, room);
|
|
405
|
+
return { w, h: Math.ceil((chars * 6) / (w - 20)) * 17 + 8 };
|
|
406
|
+
}
|
|
407
|
+
const dom = fakeDom(PHONE, layout);
|
|
408
|
+
const { makeChrome } = await import('../code/client/chrome.js');
|
|
409
|
+
const chrome = makeChrome({ onBack() {}, onAvatar() {}, avatarCount: 4 });
|
|
410
|
+
const root = dom.body.children[0];
|
|
411
|
+
const hudNode = root.children.find((c) => c.styles.textShadow?.includes('rgba(0,0,0,0.95)'));
|
|
412
|
+
const labelLayer = root.children[root.children.indexOf(hudNode) + 3];
|
|
413
|
+
const view = { w: PHONE.viewW, h: PHONE.viewH };
|
|
414
|
+
hudNode.rect = { left: 60, right: 300, top: 12, bottom: 124 };
|
|
415
|
+
dom.made.find(node => node.dataset.hub === 'hud-prompt').rect = { left: 72, right: 288, top: 660, bottom: 686, width: 216, height: 26 };
|
|
416
|
+
// One frame as the hub system draws it under the key (`nearLabels`): the HUD,
|
|
417
|
+
// each label's box from `labelBox`, the rule, `chromeItem` to `setLabels`,
|
|
418
|
+
// and the frame's flush. `wanted` is `{ id, kind, npc, text, d, x, y }`, (x, y)
|
|
419
|
+
// the label's point on the screen. Returns what the rule judged and where
|
|
420
|
+
// the chrome left each node.
|
|
421
|
+
function frame(s, hudOn, wanted, t) {
|
|
422
|
+
chrome.setHudClear(hudOn);
|
|
423
|
+
chrome.setHud({ title: 'Lantern Run', big: '12.3', text: 'find the lantern and bring it home' }, null);
|
|
424
|
+
const hud = chrome.hudClearBox();
|
|
425
|
+
const items = wanted.map((w) => {
|
|
426
|
+
const speech = w.kind === 'speech';
|
|
427
|
+
return { id: w.id, kind: w.kind ?? 'sign', pick: w.pick ?? true, d: w.d, mine: false, box: labelBox(w.x, w.y, chrome.measureLabel(w.text, speech, w.npc === true), w.npc === true, view, hud) };
|
|
428
|
+
});
|
|
429
|
+
const shown = near(s, items, view, t);
|
|
430
|
+
chrome.setLabels(wanted.filter((w) => shown.has(w.id)).map((w) => chromeItem(w.id, w.text, w.kind === 'speech', w.npc === true, items.find((i) => i.id === w.id).box, shown.get(w.id))));
|
|
431
|
+
chrome.flushHudClear();
|
|
432
|
+
const left = labelLayer.children.map((node) => {
|
|
433
|
+
const bottom = parseFloat(node.styles.top);
|
|
434
|
+
const cx = parseFloat(node.styles.left);
|
|
435
|
+
const { w, h } = layout(node);
|
|
436
|
+
return { text: node.textContent, left: cx - w / 2, right: cx + w / 2, top: bottom - h, bottom };
|
|
437
|
+
});
|
|
438
|
+
return { hud, items, shown, left };
|
|
439
|
+
}
|
|
440
|
+
// After a frame: every node lies exactly in the box the rule judged for a
|
|
441
|
+
// label it chose (tolerance 0), one node a label, and no two touch.
|
|
442
|
+
function held(g, where) {
|
|
443
|
+
assert.equal(g.left.length, g.shown.size, `${where}: one node for each label chosen`);
|
|
444
|
+
const judged = g.items.filter((i) => g.shown.has(i.id)).map((i) => i.box);
|
|
445
|
+
for (const a of g.left) {
|
|
446
|
+
assert.ok(judged.some((j) => j.left === a.left && j.right === a.right && j.top === a.top && j.bottom === a.bottom), `${where}: "${a.text}" drawn at ${JSON.stringify([a.left, a.top, a.right, a.bottom])}, judged ${JSON.stringify(judged.map((j) => [j.left, j.top, j.right, j.bottom]))}`);
|
|
447
|
+
for (const b of g.left) {
|
|
448
|
+
assert.ok(a === b || !touching(a, b), `${where}: "${a.text}" on "${b.text}"`);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
const clearAll = () => chrome.setLabels([]);
|
|
453
|
+
|
|
454
|
+
test('a clear HUD: two signs apart on the screen, both moved under the HUD onto one spot -- one is drawn', () => {
|
|
455
|
+
const two = [
|
|
456
|
+
{ id: 'near', text: 'Start here', d: 4, x: 180, y: 60 },
|
|
457
|
+
{ id: 'far', text: 'The well', d: 9, x: 180, y: 100 },
|
|
458
|
+
];
|
|
459
|
+
// As projected they do not touch...
|
|
460
|
+
assert.equal(touching(labelBox(180, 60, { w: 90, h: 26 }, false, view), labelBox(180, 100, { w: 76, h: 26 }, false, view)), false);
|
|
461
|
+
const f = frame(makeNear(), true, two, 1000);
|
|
462
|
+
assert.deepEqual(f.hud, { left: 60, right: 300, top: 12, bottom: 124 });
|
|
463
|
+
// ...but both end at 130 px (6 under the HUD): the rule saw that, and drew the nearer.
|
|
464
|
+
assert.deepEqual(f.items.map((i) => i.box.top), [130, 130]);
|
|
465
|
+
assert.deepEqual(ids(f.shown), ['near']);
|
|
466
|
+
assert.deepEqual(f.left.map((l) => [l.text, l.top]), [['Start here', 130]]);
|
|
467
|
+
held(f, 'two signs under the HUD');
|
|
468
|
+
clearAll();
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
test('a clear HUD: a sign moved down onto the plate below it is not drawn; sliding through, nothing ever touches', () => {
|
|
472
|
+
const f = frame(makeNear(), true, [{ id: 'pad', kind: 'plate', text: 'Tag · needs 4', d: 2, x: 180, y: 160 }, { id: 'arch', text: 'The Stadium', d: 8, x: 180, y: 70 }], 2000);
|
|
473
|
+
assert.deepEqual(ids(f.shown), ['pad']);
|
|
474
|
+
held(f, 'sign onto plate');
|
|
475
|
+
const t = makeNear();
|
|
476
|
+
for (let i = 0; i < 80; i += 1) {
|
|
477
|
+
held(frame(t, true, [{ id: 'a', text: 'Start here', d: 4, x: 150, y: 20 + i * 2 }, { id: 'b', text: 'The well', d: 6, x: 200, y: 180 - i }, { id: 'c', text: 'Gate', d: 9, x: 320, y: 60 + i }], 3000 + i * 33), `slide ${i}`);
|
|
478
|
+
}
|
|
479
|
+
clearAll();
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
test('no clear HUD: no box to move from under, and labels are drawn where they are projected', () => {
|
|
483
|
+
const f = frame(makeNear(), false, [{ id: 'near', text: 'Start here', d: 4, x: 180, y: 60 }, { id: 'far', text: 'The well', d: 9, x: 180, y: 100 }], 5000);
|
|
484
|
+
assert.equal(f.hud, null);
|
|
485
|
+
assert.deepEqual(ids(f.shown), ['far', 'near']);
|
|
486
|
+
assert.deepEqual(f.left.map((l) => l.bottom).sort((a, b) => a - b), [60, 100]);
|
|
487
|
+
held(f, 'no HUD');
|
|
488
|
+
clearAll();
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
const LONG = 'Rowan, the greeter: Here we are: Lantern Lot. Step on the glowing pad and the door opens.';
|
|
492
|
+
const SHORT = 'Rowan, the greeter: Hello!';
|
|
493
|
+
|
|
494
|
+
test('an NPC reply that shrinks by the screen edge is drawn where its new words were judged', () => {
|
|
495
|
+
// The review's case. The long reply is kept on screen by its own width; the
|
|
496
|
+
// short one, by its own: the chrome's old way kept it by the width of the
|
|
497
|
+
// node as it still was (the long one), further in than the rule judged.
|
|
498
|
+
for (const hudOn of [true, false]) {
|
|
499
|
+
const s = makeNear();
|
|
500
|
+
const npc = (text) => ({ id: 'greeter', kind: 'speech', npc: true, text, d: 5, x: 352, y: hudOn ? 90 : 300 });
|
|
501
|
+
const sign = { id: 'arch', text: 'The Stadium', d: 8, x: 110, y: hudOn ? 100 : 296 };
|
|
502
|
+
for (let i = 0; i < 20; i += 1) {
|
|
503
|
+
held(frame(s, hudOn, [npc(LONG), sign], 1000 + i * 33), `long ${i}`);
|
|
504
|
+
}
|
|
505
|
+
for (let i = 0; i < 20; i += 1) {
|
|
506
|
+
const g = frame(s, hudOn, [npc(SHORT), sign], 2000 + i * 33);
|
|
507
|
+
held(g, `short ${i}`);
|
|
508
|
+
const line = g.left.find((l) => l.text === SHORT);
|
|
509
|
+
assert.equal(line.right, PHONE.viewW - 6, 'kept on screen by its own width, not the long reply\'s');
|
|
510
|
+
}
|
|
511
|
+
const last = frame(s, hudOn, [npc(SHORT), sign], 3000 + HIDE_MS);
|
|
512
|
+
held(last, 'settled');
|
|
513
|
+
assert.deepEqual(ids(last.shown), ['arch', 'greeter'], 'apart once the reply is short: both drawn');
|
|
514
|
+
clearAll();
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
test('an NPC reply that grows by the screen edge takes the sign it now covers down, the same frame', () => {
|
|
519
|
+
const s = makeNear();
|
|
520
|
+
const npc = (text) => ({ id: 'greeter', kind: 'speech', npc: true, text, d: 5, x: 352, y: 300 });
|
|
521
|
+
const sign = { id: 'arch', text: 'The Stadium', d: 8, x: 110, y: 296 };
|
|
522
|
+
let g = null;
|
|
523
|
+
for (let i = 0; i < 20; i += 1) {
|
|
524
|
+
g = frame(s, false, [npc(SHORT), sign], 1000 + i * 33);
|
|
525
|
+
held(g, `short ${i}`);
|
|
526
|
+
}
|
|
527
|
+
assert.deepEqual(ids(g.shown), ['arch', 'greeter']);
|
|
528
|
+
for (let i = 0; i < 20; i += 1) {
|
|
529
|
+
g = frame(s, false, [npc(LONG), sign], 2000 + i * 33);
|
|
530
|
+
held(g, `long ${i}`);
|
|
531
|
+
assert.deepEqual(ids(g.shown), ['greeter']);
|
|
532
|
+
}
|
|
533
|
+
clearAll();
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
test('at each edge of the screen: an NPC line kept on it either side, a sign and a plate left to run off it', () => {
|
|
537
|
+
for (const hudOn of [true, false]) {
|
|
538
|
+
for (const [x, y] of [[-60, 300], [4, 300], [356, 300], [430, 300], [180, 8], [180, 760], [-60, 20], [430, 20]]) {
|
|
539
|
+
for (const one of [
|
|
540
|
+
{ id: 'npc', kind: 'speech', npc: true, text: LONG, d: 5 },
|
|
541
|
+
{ id: 'npc', kind: 'speech', npc: true, text: SHORT, d: 5 },
|
|
542
|
+
{ id: 'said', kind: 'speech', npc: false, text: LONG, d: 5 },
|
|
543
|
+
{ id: 'arch', kind: 'sign', text: 'The Stadium', d: 8 },
|
|
544
|
+
{ id: 'pad', kind: 'plate', text: 'Wishwell · step on to play', d: 2 },
|
|
545
|
+
]) {
|
|
546
|
+
const g = frame(makeNear(), hudOn, [{ ...one, x, y }], 1000);
|
|
547
|
+
held(g, `${one.id} at ${x},${y}`);
|
|
548
|
+
if (one.npc && g.left.length) {
|
|
549
|
+
assert.ok(g.left[0].left >= 6 && g.left[0].right <= PHONE.viewW - 6, 'an NPC line is whole on the screen sideways');
|
|
550
|
+
}
|
|
551
|
+
clearAll();
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
test('words and styles changing every frame for 60 frames: each frame is drawn as judged, and nothing touches', () => {
|
|
558
|
+
let seed = 914;
|
|
559
|
+
const rnd = () => ((seed = (seed * 1664525 + 1013904223) >>> 0) / 4294967296);
|
|
560
|
+
const words = (n) => 'x'.repeat(n).replace(/x/g, (_, i) => 'abcdefghij '[(i * 7 + n) % 11]).trim() || 'a';
|
|
561
|
+
let drawn = 0;
|
|
562
|
+
for (let run = 0; run < 12; run += 1) {
|
|
563
|
+
const s = makeNear();
|
|
564
|
+
const hudOn = run % 2 === 0;
|
|
565
|
+
for (let i = 0; i < 60; i += 1) {
|
|
566
|
+
const wanted = [
|
|
567
|
+
// An NPC whose reply is another length every frame, by the right edge and by the left.
|
|
568
|
+
{ id: 'npc', kind: 'speech', npc: true, text: words(4 + Math.floor(rnd() * 90)), d: 5, x: run % 4 < 2 ? 340 + rnd() * 30 : -10 + rnd() * 30, y: 80 + rnd() * 300 },
|
|
569
|
+
// A label that is a plate one frame and a line of speech the next.
|
|
570
|
+
i % 3 === 0
|
|
571
|
+
? { id: 'board', kind: 'speech', npc: false, text: words(10 + Math.floor(rnd() * 60)), d: 3, x: 100 + rnd() * 200, y: 100 + rnd() * 400 }
|
|
572
|
+
: { id: 'board', kind: 'plate', text: words(3 + Math.floor(rnd() * 30)), d: 3, x: 100 + rnd() * 200, y: 100 + rnd() * 400 },
|
|
573
|
+
{ id: 'arch', kind: 'sign', text: words(3 + Math.floor(rnd() * 20)), d: 8, x: rnd() * 360, y: 60 + rnd() * 300 },
|
|
574
|
+
{ id: 'inn', kind: 'sign', text: words(3 + Math.floor(rnd() * 20)), d: 9, x: rnd() * 360, y: 60 + rnd() * 300 },
|
|
575
|
+
];
|
|
576
|
+
const g = frame(s, hudOn, wanted, 1000 + i * 33);
|
|
577
|
+
held(g, `run ${run} frame ${i}`);
|
|
578
|
+
drawn += g.left.length;
|
|
579
|
+
}
|
|
580
|
+
clearAll();
|
|
581
|
+
}
|
|
582
|
+
assert.ok(drawn > 700, `labels were drawn (${drawn})`);
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
test('the chrome draws a world label from its box alone: no width read, no move after', () => {
|
|
586
|
+
const s = makeNear();
|
|
587
|
+
frame(s, true, [{ id: 'greeter', kind: 'speech', npc: true, text: LONG, d: 5, x: 352, y: 90 }], 1000);
|
|
588
|
+
const before = dom.log.length;
|
|
589
|
+
frame(s, true, [{ id: 'greeter', kind: 'speech', npc: true, text: SHORT, d: 5, x: 352, y: 90 }], 1033);
|
|
590
|
+
const node = labelLayer.children[0];
|
|
591
|
+
const writes = dom.log.slice(before).filter((l) => l.startsWith(`${node.id} `));
|
|
592
|
+
assert.equal(writes.some((l) => l.endsWith(' read')), false, 'the node is never measured to place it');
|
|
593
|
+
assert.equal(writes.filter((l) => l.includes('style.top=')).length, 1, 'placed once: the flush does not move it');
|
|
594
|
+
clearAll();
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
test('private goal position projects independently of a hidden actor Transform', () => {
|
|
598
|
+
const hidden = { x: 0, y: -9998.8, z: 0 };
|
|
599
|
+
const at = { x: 30, y: 1.2, z: 40 };
|
|
600
|
+
assert.deepEqual(goalAt({style:'goal',at}, hidden), at);
|
|
601
|
+
assert.deepEqual(goalAt({style:'goal',at}, undefined), at);
|
|
602
|
+
assert.strictEqual(goalAt({style:'tag',at}, hidden), hidden);
|
|
603
|
+
assert.strictEqual(goalAt({style:'goal',at:{x:NaN,y:1,z:0}}, hidden), hidden);
|
|
604
|
+
assert.strictEqual(goalAt({style:'goal'}, hidden), hidden);
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
test('v1.131 prompt clearance happens before near-label selection', () => {
|
|
610
|
+
const hud = { left: 120, right: 724, top: 12, bottom: 80 };
|
|
611
|
+
const prompt = { left: 260, right: 584, top: 310, bottom: 336 };
|
|
612
|
+
const view = { w: 844, h: 390 };
|
|
613
|
+
const placed = labelBox(422, 330, { w: 100, h: 26 }, false, view, hud, prompt);
|
|
614
|
+
assert.equal(placed.bottom, 304);
|
|
615
|
+
assert.equal(touching(placed, prompt), false);
|
|
616
|
+
assert.equal(touching(placed, hud), false);
|
|
617
|
+
assert.equal(labelBox(422, 330, { w: 100, h: 300 }, false, view, hud, prompt), null, 'oversized label cannot cover either band');
|
|
618
|
+
});
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
// Cache only a conservative distance shortlist; compare every rendered frame
|
|
622
|
+
// with the original unthrottled selection, including camera-only changes.
|
|
623
|
+
for (const scenario of ['camera turn', 'overlap', 'distance boundary', 'teleport', 'source change']) {
|
|
624
|
+
test(`${scenario}: cached candidates equal fresh selection each frame`, () => {
|
|
625
|
+
const fresh = makeNear(), cached = makeNear(), holder = {}, scope = {};
|
|
626
|
+
let placed = Array.from({ length: 6 }, (_, i) => ({ id: `sign${i}`, at: { x: i + 2, y: 0, z: 0 }, label: { style: 'sign', text: `Sign ${i}` }, always: true }));
|
|
627
|
+
placed.push({ id: 'edge', at: { x: 15.1, y: 0, z: 0 }, label: { style: 'sign', text: 'Edge' }, always: true });
|
|
628
|
+
if (scenario === 'distance boundary') {placed.at(-1).at.x = 12.2;}
|
|
629
|
+
const position = { x: 0, y: 0, z: 0 };
|
|
630
|
+
let first;
|
|
631
|
+
for (let frame = 0; frame < 12; frame += 1) {
|
|
632
|
+
if (scenario === 'distance boundary') {position.x = frame * 0.11;}
|
|
633
|
+
if (scenario === 'teleport' && frame === 2) {position.x = 10;}
|
|
634
|
+
if (scenario === 'source change' && frame === 2) {placed = [...placed, { id: 'new', at: { x: 1, y: 0, z: 0 }, label: { style: 'sign', text: 'New' }, always: true }];}
|
|
635
|
+
const ids = nearCandidates(holder, placed, position, 1000 + frame * 16, scope);
|
|
636
|
+
if (frame === 0) {first = ids;}
|
|
637
|
+
if (frame === 2 && ['camera turn', 'overlap'].includes(scenario)) {assert.strictEqual(ids, first, 'camera changes reuse distance candidates');}
|
|
638
|
+
const project = (entry, index) => {
|
|
639
|
+
if (scenario === 'camera turn' && (frame < 2 ? index > 0 : index === 0)) {return null;}
|
|
640
|
+
return box(scenario === 'overlap' && frame >= 2 ? 200 : 60 + index * 110, 300);
|
|
641
|
+
};
|
|
642
|
+
const items = placed.map((entry, index) => ({ id: entry.id, kind: 'sign', d: Math.abs(entry.at.x - position.x), box: project(entry, index) }));
|
|
643
|
+
const shortlisted = items.map((item) => ids.has(item.id) ? item : { ...item, d: Infinity, box: null });
|
|
644
|
+
assert.deepEqual(near(cached, shortlisted, VIEW, 1000 + frame * 16), near(fresh, items, VIEW, 1000 + frame * 16), `frame ${frame}`);
|
|
645
|
+
if (scenario === 'camera turn' && frame === 2) {assert(!cached.chosen.has('sign0') && cached.chosen.size > 0, 'turn reveals a different sign immediately');}
|
|
646
|
+
if (scenario === 'distance boundary' && frame === 2) {assert(cached.reach.has('edge'), 'reach updates between candidate refreshes');}
|
|
647
|
+
if (scenario === 'overlap' && frame >= 2) {assert(cached.chosen.size <= 1, 'collisions run between candidate refreshes');}
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
test('candidate refreshes cover arrival, movement, source changes and cadence', () => {
|
|
653
|
+
const holder = {}, scope = {}, position = { x: 0, y: 0, z: 0 };
|
|
654
|
+
const placed = [{ id: 'a', at: { x: 2, y: 0, z: 0 }, label: {}, always: true }];
|
|
655
|
+
const initial = nearCandidates(holder, placed, position, 1000, scope);
|
|
656
|
+
assert.strictEqual(nearCandidates(holder, placed, { ...position, x: 0.5 }, 1099, scope), initial);
|
|
657
|
+
const moved = nearCandidates(holder, placed, { ...position, x: 0.51 }, 1099, scope);
|
|
658
|
+
assert.notStrictEqual(moved, initial);
|
|
659
|
+
const arrived = nearCandidates(holder, placed, position, 1100, {});
|
|
660
|
+
assert.notStrictEqual(arrived, moved);
|
|
661
|
+
assert.notStrictEqual(nearCandidates(holder, placed, position, 1200, scope), arrived);
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
console.log(`hub-game labels: ${passed} tests passed`);
|