castle-web-cli 0.4.232 → 0.4.233
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/castle-host/host.d.ts +1 -0
- package/dist/castle-host/host.js +51 -3
- package/dist/castleJson.d.ts +4 -2
- package/dist/castleJson.js +2 -0
- package/dist/check.d.ts +3 -1
- package/dist/check.js +11 -1
- package/dist/devSessionStorage.js +47 -1
- 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 +5 -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 +5 -0
- package/dist/save-deck.js +37 -4
- package/dist/serve.js +3 -0
- package/dist/shell/assets/{index-D2tWM896.js → index-BjOxR-lW.js} +4 -4
- 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/kits/base/castle.json +1 -1
- package/kits/base/package-lock.json +1 -1
- package/kits/base/sdk/README.md +79 -2
- package/kits/base/sdk/avatar.d.ts +6 -2
- package/kits/base/sdk/avatar.js +12 -4
- package/kits/base/sdk/castle.d.ts +1 -1
- package/kits/base/sdk/commands.d.ts +14 -0
- package/kits/base/sdk/hub.d.ts +6 -2
- package/kits/base/sdk/hub.js +13 -0
- package/kits/base/sdk/multiplayer.js +17 -1
- package/kits/base/sdk/save.js +2 -1
- package/kits/base/sdk/server/hub.d.ts +87 -0
- package/kits/base/sdk/server/hub.js +70 -0
- package/kits/base/sdk/server/platformHandle.d.ts +31 -1
- package/kits/base/sdk/server/storage.d.ts +13 -0
- package/kits/base/sdk/server/storage.js +46 -0
- package/kits/base/sdk/server/wrapper.d.ts +36 -5
- package/kits/base/sdk/server/wrapper.js +83 -8
- package/kits/hub-game/CLAUDE.md +329 -11
- 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/code/client/actorBudget.js +47 -0
- package/kits/hub-game/code/client/attention.js +11 -2
- package/kits/hub-game/code/client/avatar.js +309 -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 +251 -0
- package/kits/hub-game/code/client/ballot.js +467 -0
- package/kits/hub-game/code/client/build.js +22 -0
- package/kits/hub-game/code/client/chrome.js +1144 -50
- 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/decor.js +509 -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/grab.js +339 -20
- package/kits/hub-game/code/client/hookLayer.js +299 -13
- package/kits/hub-game/code/client/idle.js +163 -22
- package/kits/hub-game/code/client/interestCap.js +81 -0
- package/kits/hub-game/code/client/keys.js +36 -0
- package/kits/hub-game/code/client/labelsNear.js +205 -0
- package/kits/hub-game/code/client/menuIcons.js +34 -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/rehello.js +167 -0
- package/kits/hub-game/code/client/shot.js +92 -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 +109 -1
- package/kits/hub-game/code/client/stuck.js +259 -0
- package/kits/hub-game/code/client/talk.js +538 -47
- package/kits/hub-game/code/client/tiers.js +516 -27
- package/kits/hub-game/code/client/toastBand.js +37 -0
- package/kits/hub-game/code/client/together.js +32 -0
- package/kits/hub-game/code/client/visibility.js +43 -0
- package/kits/hub-game/code/client/wear.js +461 -170
- package/kits/hub-game/code/client/yours.js +199 -0
- package/kits/hub-game/code/companionSpec.js +45 -0
- package/kits/hub-game/code/privateText.js +7 -0
- package/kits/hub-game/code/server/actions.js +133 -0
- package/kits/hub-game/code/server/actors.js +9 -1
- 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 +82 -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/earned.js +461 -0
- package/kits/hub-game/code/server/friendBests.js +166 -0
- package/kits/hub-game/code/server/friendsAmong.js +232 -0
- package/kits/hub-game/code/server/history.js +5 -0
- package/kits/hub-game/code/server/hub.js +1254 -50
- package/kits/hub-game/code/server/idle.js +30 -11
- package/kits/hub-game/code/server/index.js +2 -2
- package/kits/hub-game/code/server/labels.js +28 -2
- package/kits/hub-game/code/server/manifest.js +378 -7
- package/kits/hub-game/code/server/menu.js +133 -0
- package/kits/hub-game/code/server/npcs.js +830 -80
- package/kits/hub-game/code/server/party.js +2 -2
- package/kits/hub-game/code/server/players.js +22 -0
- package/kits/hub-game/code/server/shot.js +110 -0
- package/kits/hub-game/code/server/standing.js +124 -0
- package/kits/hub-game/code/server/vis.js +113 -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/cues.js +9 -0
- package/kits/hub-game/code/shared/decor.js +41 -0
- package/kits/hub-game/code/shared/shot.js +19 -0
- package/kits/hub-game/code/shared/spin.js +57 -0
- package/kits/hub-game/code/systems/hub.js +845 -95
- package/kits/hub-game/docs/content-pack.md +1 -1
- package/kits/hub-game/docs/contract.md +2244 -61
- package/kits/hub-game/docs/home-pieces.md +64 -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 +2 -0
- package/kits/hub-game/package.json +2 -1
- package/kits/hub-game/scripts/check.mjs +78 -11
- package/kits/hub-game/scripts/companion-follower-wire.json +1 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +121 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless.json +293 -0
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +23 -0
- package/kits/hub-game/scripts/fixtures/fake-dom.mjs +107 -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/soundscape-wave-analysis.mjs +125 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +488 -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 +19 -17
- package/kits/hub-game/scripts/test-ask-client.mjs +358 -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 +753 -0
- package/kits/hub-game/scripts/test-avatar.mjs +540 -7
- package/kits/hub-game/scripts/test-ballot.mjs +1001 -0
- package/kits/hub-game/scripts/test-build.mjs +31 -0
- package/kits/hub-game/scripts/test-cells.mjs +71 -0
- package/kits/hub-game/scripts/test-chat.mjs +662 -0
- package/kits/hub-game/scripts/test-classic.mjs +2 -0
- package/kits/hub-game/scripts/test-companion-chat.mjs +198 -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-decor-client.mjs +303 -0
- package/kits/hub-game/scripts/test-decor.mjs +457 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +459 -0
- package/kits/hub-game/scripts/test-earned.mjs +1194 -0
- package/kits/hub-game/scripts/test-emote-bubble.mjs +110 -0
- package/kits/hub-game/scripts/test-friend-bests.mjs +435 -0
- package/kits/hub-game/scripts/test-grab-orbit.mjs +918 -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-hub-leaving.mjs +203 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +439 -2
- package/kits/hub-game/scripts/test-hub-trip.mjs +716 -2
- package/kits/hub-game/scripts/test-hud-clear.mjs +328 -4
- package/kits/hub-game/scripts/test-idle.mjs +361 -1
- package/kits/hub-game/scripts/test-interest-cap.mjs +36 -0
- package/kits/hub-game/scripts/test-interest-cells.mjs +493 -0
- package/kits/hub-game/scripts/test-interest-client.mjs +118 -0
- package/kits/hub-game/scripts/test-keys.mjs +46 -1
- package/kits/hub-game/scripts/test-labels.mjs +596 -0
- package/kits/hub-game/scripts/test-manifest.mjs +207 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +480 -0
- package/kits/hub-game/scripts/test-menu.mjs +296 -0
- package/kits/hub-game/scripts/test-npcs.mjs +1718 -12
- package/kits/hub-game/scripts/test-object-entry.mjs +76 -0
- package/kits/hub-game/scripts/test-pack.mjs +7 -0
- package/kits/hub-game/scripts/test-picker.mjs +314 -0
- package/kits/hub-game/scripts/test-rehello.mjs +1039 -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-shot.mjs +756 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +5432 -0
- package/kits/hub-game/scripts/test-spin.mjs +314 -0
- package/kits/hub-game/scripts/test-standing.mjs +416 -0
- package/kits/hub-game/scripts/test-stuck.mjs +1903 -0
- package/kits/hub-game/scripts/test-tier-cells.mjs +706 -0
- package/kits/hub-game/scripts/test-tiers-render.mjs +339 -0
- package/kits/hub-game/scripts/test-tiers.mjs +477 -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 +343 -0
- package/kits/hub-game/scripts/test-visibility.mjs +134 -0
- package/kits/hub-game/scripts/test-yours-chrome.mjs +166 -0
- package/kits/hub-game/scripts/test-yours.mjs +372 -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/nameTags.js +59 -4
- 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 +74 -4
- package/kits/multiplayer-3d/package.json +2 -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-own-name-tag.mjs +247 -0
- package/kits/physics-2d/CLAUDE.md +9 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +253 -1
- 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/scripts/test-skip-unchanged.mjs +326 -1
- package/kits/physics-3d/CLAUDE.md +1169 -30
- package/kits/physics-3d/behaviors/Player.jsx +629 -72
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/pxmodel-format.md +8 -0
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +69 -13
- package/kits/physics-3d/engine3d/actornode.js +86 -0
- package/kits/physics-3d/engine3d/animationBudget.js +23 -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 +96 -0
- package/kits/physics-3d/engine3d/gait.js +118 -0
- package/kits/physics-3d/engine3d/kithooks.js +47 -0
- package/kits/physics-3d/engine3d/look.js +507 -48
- package/kits/physics-3d/engine3d/lookbake.js +208 -0
- package/kits/physics-3d/engine3d/materialpresets.js +2 -0
- package/kits/physics-3d/engine3d/motion.js +39 -10
- package/kits/physics-3d/engine3d/nearshadows.js +37 -19
- package/kits/physics-3d/engine3d/optimize.js +9 -5
- package/kits/physics-3d/engine3d/orbitinput.js +487 -9
- package/kits/physics-3d/engine3d/orbitlens.js +48 -0
- package/kits/physics-3d/engine3d/ownmodel.js +213 -0
- package/kits/physics-3d/engine3d/pxmodel.js +42 -11
- package/kits/physics-3d/engine3d/shadowfade.js +882 -0
- package/kits/physics-3d/engine3d/sky.js +547 -0
- package/kits/physics-3d/engine3d/skylife.js +306 -0
- 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 +796 -69
- package/kits/physics-3d/main.jsx +5 -0
- package/kits/physics-3d/package.json +1 -1
- package/kits/physics-3d/scripts/look-baseline.mjs +155 -0
- package/kits/physics-3d/scripts/test-camera-orbit.mjs +2563 -80
- package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +1 -1
- package/kits/physics-3d/scripts/test-frame-cap-bob.mjs +435 -0
- package/kits/physics-3d/scripts/test-frame-cap.mjs +452 -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 +3 -0
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1920 -0
- package/kits/physics-3d/scripts/test-orbit-shift-lock.mjs +545 -0
- package/kits/physics-3d/scripts/test-orbit-shot.mjs +583 -0
- package/kits/physics-3d/scripts/test-orbit-view.mjs +230 -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-static-actors.mjs +8 -1
- package/kits/physics-3d/scripts/test-static-scenery.mjs +2171 -0
- package/kits/physics-3d/scripts/test-steady-hover.mjs +2 -0
- package/kits/physics-3d/scripts/test-view-range.mjs +260 -0
- package/kits/physics-3d/systems/physics3d.js +383 -6
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/server/gameHooks.js +7 -0
- package/kits/real-time/code/server/session.js +97 -19
- package/package.json +2 -2
- package/dist/shell/assets/index-Cf61cNfT.css +0 -1
|
@@ -190,6 +190,15 @@ function fakeDom(view) {
|
|
|
190
190
|
append(...kids) {
|
|
191
191
|
kids.forEach((kid) => self.appendChild(kid));
|
|
192
192
|
},
|
|
193
|
+
insertBefore(child, before) {
|
|
194
|
+
if (child.parent) {
|
|
195
|
+
child.parent.children = child.parent.children.filter((c) => c !== child);
|
|
196
|
+
}
|
|
197
|
+
child.parent = self;
|
|
198
|
+
const at = self.children.indexOf(before);
|
|
199
|
+
self.children.splice(at < 0 ? self.children.length : at, 0, child);
|
|
200
|
+
return child;
|
|
201
|
+
},
|
|
193
202
|
remove() {
|
|
194
203
|
if (self.parent) {
|
|
195
204
|
self.parent.children = self.parent.children.filter((c) => c !== self);
|
|
@@ -250,12 +259,73 @@ function rig(view = PHONE) {
|
|
|
250
259
|
const root = dom.body.children[0];
|
|
251
260
|
const hud = root.children.find((c) => c.styles.maxWidth === '70vw');
|
|
252
261
|
const [hudTitle, hudBig, hudText] = hud.children;
|
|
253
|
-
|
|
254
|
-
const pointers =
|
|
262
|
+
// v1.38: the pointers' layer is under the labels' (a speech bubble is read over a chip).
|
|
263
|
+
const pointers = root.children[root.children.indexOf(hud) + 1];
|
|
264
|
+
const labels = root.children[root.children.indexOf(hud) + 2];
|
|
255
265
|
const cabinet = dom.made.find((c) => c.dataset.hub === 'cabinet');
|
|
256
266
|
return { ...dom, chrome, root, hud, hudTitle, hudBig, hudText, labels, pointers, cabinet };
|
|
257
267
|
}
|
|
258
268
|
|
|
269
|
+
test('v1.52: the cover line is smaller, centred and phone-wrappable, and absent without text', () => {
|
|
270
|
+
const r = rig();
|
|
271
|
+
const cover = r.root.children[0];
|
|
272
|
+
const [title] = cover.children;
|
|
273
|
+
r.chrome.setCover(1, 'Town');
|
|
274
|
+
assert.equal(title.textContent, 'Town');
|
|
275
|
+
assert.equal(cover.children.length, 1, 'no second line until a place asks');
|
|
276
|
+
assert.equal(cover.styles.flexDirection, undefined, 'original cover layout');
|
|
277
|
+
r.chrome.setCover(1, 'Town', 'Your lantern will be waiting by the well');
|
|
278
|
+
const line = cover.children[1];
|
|
279
|
+
assert.equal(line.textContent, 'Your lantern will be waiting by the well');
|
|
280
|
+
assert.equal(line.styles.display, 'block');
|
|
281
|
+
assert.ok(parseFloat(line.styles.fontSize) < parseFloat(title.styles.fontSize));
|
|
282
|
+
assert.equal(line.styles.textAlign, 'center');
|
|
283
|
+
assert.equal(line.styles.overflowWrap, 'anywhere');
|
|
284
|
+
assert.equal(line.styles.width, 'min(84vw, 420px)');
|
|
285
|
+
assert.equal(line.styles.fontFamily, undefined, 'both lines inherit the chrome font');
|
|
286
|
+
r.chrome.setCover(0);
|
|
287
|
+
assert.equal(line.textContent, '');
|
|
288
|
+
assert.equal(line.styles.display, 'none');
|
|
289
|
+
r.chrome.setCover(1, 'Another place');
|
|
290
|
+
assert.equal(line.styles.display, 'none', 'no old line on the next cover');
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
test('v1.52: leaving toasts wrap a 120-character unbroken line and restore the ordinary toast styles', () => {
|
|
294
|
+
for (const view of [PHONE, SIDEWAYS, { viewW: 1280, viewH: 800 }]) {
|
|
295
|
+
const r = rig(view);
|
|
296
|
+
const toast = r.root.children.find((c) => c.dataset.hub === 'toast');
|
|
297
|
+
r.chrome.setToast('Ordinary feedback');
|
|
298
|
+
const original = { ...toast.styles, display: 'none' };
|
|
299
|
+
assert.equal(toast.styles.width, 'max-content');
|
|
300
|
+
assert.equal(toast.styles.maxWidth, 'calc(100vw - 24px)');
|
|
301
|
+
assert.equal(toast.styles.textAlign, 'center');
|
|
302
|
+
r.log.length = 0;
|
|
303
|
+
r.chrome.setToast('Ordinary feedback');
|
|
304
|
+
assert.equal(r.log.some((entry) => entry.startsWith(`${toast.id} style.`)), false, 'an unchanged toast writes no styles');
|
|
305
|
+
const line = 'x'.repeat(120);
|
|
306
|
+
r.chrome.setToast(line, { wrap: true });
|
|
307
|
+
assert.equal(toast.textContent, line);
|
|
308
|
+
assert.equal(toast.styles.maxWidth, 'min(90vw, 480px)');
|
|
309
|
+
assert.equal(toast.styles.overflowWrap, 'anywhere');
|
|
310
|
+
assert.equal(toast.styles.textAlign, 'center');
|
|
311
|
+
r.chrome.setToast(`Back from Foot Race · ${line}`, { wrap: true });
|
|
312
|
+
assert.equal(toast.styles.maxWidth, 'min(90vw, 480px)');
|
|
313
|
+
r.chrome.setToast('Invited Ada to your party');
|
|
314
|
+
const reset = { maxWidth: original.maxWidth, overflowWrap: '', textAlign: original.textAlign };
|
|
315
|
+
assert.deepEqual(toast.styles, { ...original, ...reset, display: 'block' });
|
|
316
|
+
// Restore actual prior inline values, not just the current empty defaults.
|
|
317
|
+
const prior = { maxWidth: '240px', overflowWrap: 'normal', textAlign: 'left' };
|
|
318
|
+
Object.assign(toast.style, prior);
|
|
319
|
+
r.chrome.setToast(line, { wrap: true });
|
|
320
|
+
r.chrome.setToast('');
|
|
321
|
+
assert.deepEqual(toast.styles, { ...original, ...prior });
|
|
322
|
+
// Even a wrap option on an empty toast must restore the old styles.
|
|
323
|
+
r.chrome.setToast(line, { wrap: true });
|
|
324
|
+
r.chrome.setToast('', { wrap: true });
|
|
325
|
+
assert.deepEqual(toast.styles, { ...original, ...prior });
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
|
|
259
329
|
const SPEC = { title: 'Lantern Run', big: '12.3', text: 'find the lantern and bring it home' };
|
|
260
330
|
const LABELS = [
|
|
261
331
|
{ id: 'sign', x: 180, y: 90, text: 'Start here', speech: false, npc: false, opacity: 1 },
|
|
@@ -308,9 +378,11 @@ test('never told: the HUD, labels and pointers are styled and placed as today',
|
|
|
308
378
|
assert.deepEqual(styleOf(r.hudTitle), TODAY.title);
|
|
309
379
|
assert.deepEqual(styleOf(r.hudBig), TODAY.big);
|
|
310
380
|
assert.deepEqual(styleOf(r.hudText), TODAY.text);
|
|
311
|
-
// Each label is where it was asked to be, under the HUD or not
|
|
381
|
+
// Each label is where it was asked to be, under the HUD or not -- except
|
|
382
|
+
// an emote's emoji, which is drawn just under the HUD's box (106 px, an 8 px
|
|
383
|
+
// gap, its own height to its anchored bottom: `emoteBubble.js`).
|
|
312
384
|
const top = Object.fromEntries(r.labels.children.map((c) => [c.textContent, c.styles.top]));
|
|
313
|
-
assert.deepEqual(top, { 'Start here': '90px', 'Take the lantern to the well.': '60px', IT: '80px', Well: '400px', '👋': '
|
|
385
|
+
assert.deepEqual(top, { 'Start here': '90px', 'Take the lantern to the well.': '60px', IT: '80px', Well: '400px', '👋': '138px' });
|
|
314
386
|
assert.deepEqual(r.pointers.children.map((c) => c.styles.top), ['84px', '95px', '500px']);
|
|
315
387
|
// Nothing of a clear HUD was written anywhere.
|
|
316
388
|
for (const node of [r.hud, r.hudBig, r.hudText]) {
|
|
@@ -386,6 +458,36 @@ test('asked, a phone on its side: two lines of text and a box no taller than its
|
|
|
386
458
|
assert.equal(r.hud.styles.overflow, 'hidden');
|
|
387
459
|
});
|
|
388
460
|
|
|
461
|
+
test('emote bubbles: sizes are read once per emoji, never between this frame\'s writes', () => {
|
|
462
|
+
const r = rig();
|
|
463
|
+
const heads = Array.from({ length: 30 }, (_, i) => ({ id: `e${i}`, x: 0, y: 0, text: i % 2 ? '👋' : '💃', emote: true, head: { left: 20 + i * 10, right: 50 + i * 10, top: 400, bottom: 430 }, lift: 0 }));
|
|
464
|
+
r.chrome.setLabels(heads);
|
|
465
|
+
const reads = (from) => r.log.slice(from).filter((line) => line.endsWith(' read'));
|
|
466
|
+
assert.equal(reads(0).length, 4, 'two emoji, each read once (width and height)');
|
|
467
|
+
for (let frame = 0; frame < 3; frame += 1) {
|
|
468
|
+
const from = r.log.length;
|
|
469
|
+
r.chrome.setLabels(heads.map((h) => ({ ...h, head: { ...h.head, top: h.head.top + frame } })));
|
|
470
|
+
assert.deepEqual(reads(from), [], 'no read in a later frame');
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
test('emote bubbles: one hidden for a head off the view is shown again on any later placement', () => {
|
|
475
|
+
const r = rig();
|
|
476
|
+
const off = { id: 'w', x: 0, y: 0, text: '👋', emote: true, head: { left: 400, right: 440, top: 300, bottom: 330 }, lift: 0 };
|
|
477
|
+
r.chrome.setLabels([off]);
|
|
478
|
+
const node = r.labels.children.find((c) => c.textContent === '👋');
|
|
479
|
+
assert.equal(node.styles.visibility, 'hidden');
|
|
480
|
+
// Its head back in the view.
|
|
481
|
+
r.chrome.setLabels([{ ...off, head: { left: 150, right: 190, top: 300, bottom: 330 } }]);
|
|
482
|
+
assert.equal(node.styles.visibility, '');
|
|
483
|
+
r.chrome.setLabels([off]);
|
|
484
|
+
assert.equal(node.styles.visibility, 'hidden');
|
|
485
|
+
// No head this frame (the old point): shown again.
|
|
486
|
+
r.chrome.setLabels([{ id: 'w', x: 180, y: 400, text: '👋', emote: true }]);
|
|
487
|
+
assert.equal(node.styles.visibility, '');
|
|
488
|
+
assert.equal(node.styles.left, '180px');
|
|
489
|
+
});
|
|
490
|
+
|
|
389
491
|
test('asked: labels, speech, marks, emotes, pointers and the ribbon over the HUD go just under it', () => {
|
|
390
492
|
const r = rig();
|
|
391
493
|
r.hud.rect = { left: 90, right: 270, top: 12, bottom: 106 };
|
|
@@ -673,4 +775,226 @@ test('asked, then not, with no HUD drawn: put back at once, and written to as ne
|
|
|
673
775
|
n += 1;
|
|
674
776
|
}
|
|
675
777
|
|
|
778
|
+
// v1.34: pointers (friends, a place's goals) are under every panel and card:
|
|
779
|
+
// their layer is made with the labels', before anything that opens over the
|
|
780
|
+
// world, so a goal's arrow is never drawn on the NPC words being read.
|
|
781
|
+
{
|
|
782
|
+
const r = rig();
|
|
783
|
+
const order = r.root.children;
|
|
784
|
+
const at = order.indexOf(r.pointers);
|
|
785
|
+
// v1.38: and under the labels' layer, so an NPC's speech bubble is read over a chip.
|
|
786
|
+
assert.equal(at, order.indexOf(r.labels) - 1, 'the pointers layer is just under the labels layer');
|
|
787
|
+
const over = order.filter((c) => c.tag === 'button' || (c.styles.width ?? '').startsWith('min(') || c.styles.borderRadius);
|
|
788
|
+
// (Back and the toast are made before both layers, as they always were.)
|
|
789
|
+
const early = order.slice(0, at).filter((c) => over.includes(c));
|
|
790
|
+
assert.ok(early.length <= 3 && over.length - early.length >= 8, `made before the pointers: ${early.length} of ${over.length}`);
|
|
791
|
+
assert.ok(over.filter((c) => !early.includes(c)).every((c) => order.indexOf(c) > order.indexOf(r.labels)), 'everything that opens over the world is over the pointers and the labels');
|
|
792
|
+
assert.ok(order.filter((c, i) => i > at && (c.styles.width ?? '').startsWith('min(')).length >= 1, 'the talk panel among them');
|
|
793
|
+
n += 1;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
// v1.38: a chip at the screen's edge is kept beside the round buttons there
|
|
797
|
+
// (quick chat, emotes, grab), never under one: half its words were covered.
|
|
798
|
+
{
|
|
799
|
+
const r = rig();
|
|
800
|
+
const say = r.made.find((c) => c.attrs['aria-label'] === 'Quick chat');
|
|
801
|
+
r.chrome.setSay({ reactions: ['👋'], phrases: [] });
|
|
802
|
+
say.rect = { left: window.innerWidth - 72, right: window.innerWidth - 20, top: 600, bottom: 652 };
|
|
803
|
+
const chipOf = (text) => r.pointers.children.find((c) => c.children[1].textContent === text);
|
|
804
|
+
const edgeX = window.innerWidth - 4;
|
|
805
|
+
r.chrome.setPointers([
|
|
806
|
+
{ id: 'a', x: edgeX, y: 626, text: 'lantern', angle: 0 },
|
|
807
|
+
{ id: 'b', x: edgeX, y: 300, text: 'lantern b', angle: 0 },
|
|
808
|
+
{ id: 'c', x: edgeX - 40, y: 626, text: 'amy', angle: null },
|
|
809
|
+
]);
|
|
810
|
+
// (the stand-in layout measures a chip by its own text, none: 20 px wide)
|
|
811
|
+
const half = () => 10;
|
|
812
|
+
assert.equal(parseFloat(chipOf('lantern').styles.left), say.rect.left - 6 - half('lantern'), 'beside the button, not under it');
|
|
813
|
+
assert.equal(parseFloat(chipOf('lantern b').styles.left), window.innerWidth - half('lantern b') - 6, 'an edge chip clear of the button stays at the edge');
|
|
814
|
+
assert.equal(parseFloat(chipOf('amy').styles.left), Math.min(edgeX - 40, window.innerWidth - half('amy') - 6), 'a chip over a friend is not moved');
|
|
815
|
+
// A chip too wide to stand beside the button goes over it (under it with no room over).
|
|
816
|
+
const wide = chipOf('lantern');
|
|
817
|
+
wide.size = { w: 300, h: 20 };
|
|
818
|
+
r.chrome.setPointers([{ id: 'a', x: edgeX, y: 626, text: 'lantern', angle: 0 }]);
|
|
819
|
+
assert.equal(parseFloat(wide.styles.left), window.innerWidth - 150 - 6);
|
|
820
|
+
assert.equal(parseFloat(wide.styles.top), say.rect.top - 6 - 10, 'over the button');
|
|
821
|
+
say.rect = { ...say.rect, top: 10, bottom: 62 };
|
|
822
|
+
r.chrome.setPointers([{ id: 'a', x: edgeX, y: 30, text: 'lantern', angle: 0 }]);
|
|
823
|
+
assert.equal(parseFloat(wide.styles.top), 62 + 6 + 10, 'under it where there is no room over');
|
|
824
|
+
// With two buttons up, a move away from one never lands on the other.
|
|
825
|
+
const emote = r.made.find((c) => c.tag === 'button' && c.styles.right === '20px' && c.styles.width === '52px' && c !== say);
|
|
826
|
+
say.rect = { ...say.rect, top: 600, bottom: 652 };
|
|
827
|
+
emote.styles.display = 'block';
|
|
828
|
+
emote.style.display = 'block';
|
|
829
|
+
emote.rect = { left: say.rect.left, right: say.rect.right, top: 542, bottom: 594 };
|
|
830
|
+
r.chrome.setPointers([{ id: 'a', x: edgeX, y: 626, text: 'lantern', angle: 0 }]);
|
|
831
|
+
assert.equal(parseFloat(wide.styles.top), 542 - 6 - 10, 'over the whole column');
|
|
832
|
+
wide.size = undefined;
|
|
833
|
+
r.chrome.setPointers([{ id: 'a', x: edgeX, y: 626, text: 'lantern', angle: 0 }]);
|
|
834
|
+
assert.equal(parseFloat(wide.styles.left), say.rect.left - 6 - 10, 'a narrow chip goes left of the column');
|
|
835
|
+
emote.styles.display = 'none';
|
|
836
|
+
emote.style.display = 'none';
|
|
837
|
+
say.rect = { ...say.rect, top: 600, bottom: 652 };
|
|
838
|
+
// With the button hidden, the chip is at the edge as before.
|
|
839
|
+
r.chrome.setSay(null);
|
|
840
|
+
r.chrome.setPointers([{ id: 'a', x: edgeX, y: 626, text: 'lantern', angle: 0 }]);
|
|
841
|
+
assert.equal(parseFloat(chipOf('lantern').styles.left), window.innerWidth - half('lantern') - 6);
|
|
842
|
+
n += 1;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
// v1.35: the NPC talk panel. A reply is scrolled to its first word, the
|
|
846
|
+
// player's own line to the end of the log, and a player who has scrolled up to
|
|
847
|
+
// read is left where they are. The log has no layout here, so its numbers are
|
|
848
|
+
// set by hand: each line lies where the last one ended.
|
|
849
|
+
{
|
|
850
|
+
const r = rig();
|
|
851
|
+
const logNode = r.dom?.made?.find?.((c) => c.styles.maxHeight === '28vh') ?? r.made.find((c) => c.styles.maxHeight === '28vh' && c.styles.overflowY === 'auto');
|
|
852
|
+
assert.ok(logNode, 'the talk log');
|
|
853
|
+
Object.assign(logNode, { offsetTop: 40, clientHeight: 100, scrollTop: 0, scrollHeight: 0 });
|
|
854
|
+
// Adds a line `height` tall as the browser would lay it out.
|
|
855
|
+
const add = (who, height) => {
|
|
856
|
+
const before = logNode.children.length;
|
|
857
|
+
const top = 40 + logNode.scrollHeight;
|
|
858
|
+
const made = logNode.appendChild;
|
|
859
|
+
logNode.appendChild = (child) => {
|
|
860
|
+
child.offsetTop = top;
|
|
861
|
+
logNode.scrollHeight += height;
|
|
862
|
+
return made.call(logNode, child);
|
|
863
|
+
};
|
|
864
|
+
r.chrome.talkLine(who, 'words');
|
|
865
|
+
logNode.appendChild = made;
|
|
866
|
+
assert.equal(logNode.children.length, before + 1);
|
|
867
|
+
return top - 40;
|
|
868
|
+
};
|
|
869
|
+
r.chrome.openTalk('Mabel');
|
|
870
|
+
add('me', 30);
|
|
871
|
+
assert.equal(logNode.scrollTop, 30, 'my own line: the end of the log');
|
|
872
|
+
logNode.scrollTop = 0; // the browser stops at the end: 30 tall in 100
|
|
873
|
+
// A long reply: its first word at the top of what shows, not its last.
|
|
874
|
+
const reply = add('them', 400);
|
|
875
|
+
assert.equal(reply, 30);
|
|
876
|
+
assert.equal(logNode.scrollTop, 30, 'a long reply starts at the top of the view');
|
|
877
|
+
// The player reads to its end, then another reply: again from its start.
|
|
878
|
+
logNode.scrollTop = logNode.scrollHeight - logNode.clientHeight;
|
|
879
|
+
const next = add('them', 300);
|
|
880
|
+
assert.equal(logNode.scrollTop, next);
|
|
881
|
+
// Scrolled up to read something earlier: a reply does not move the view...
|
|
882
|
+
logNode.scrollTop = 10;
|
|
883
|
+
add('them', 200);
|
|
884
|
+
assert.equal(logNode.scrollTop, 10, 'a player who scrolled up is left there');
|
|
885
|
+
// ...and their own next line does.
|
|
886
|
+
add('me', 30);
|
|
887
|
+
assert.equal(logNode.scrollTop, logNode.scrollHeight);
|
|
888
|
+
n += 1;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
// v1.37: what to ask an NPC, as chips in the talk panel between the log and
|
|
892
|
+
// the field: none made until a place gives some, a tap hands back the
|
|
893
|
+
// question, an empty list or closing the panel takes them away.
|
|
894
|
+
{
|
|
895
|
+
const r = rig();
|
|
896
|
+
const panel = r.made.find((c) => (c.styles.width ?? '').startsWith('min(92vw'));
|
|
897
|
+
const kids = () => panel.children.length;
|
|
898
|
+
const before = kids();
|
|
899
|
+
r.chrome.openTalk('Mabel');
|
|
900
|
+
r.chrome.talkAsks([], null);
|
|
901
|
+
assert.equal(kids(), before, 'no chips row until there are chips');
|
|
902
|
+
const taps = [];
|
|
903
|
+
r.chrome.talkAsks(['What can I do here?', 'Where is the inn?', 'Who are you?', 'A fourth'], (ask) => taps.push(ask));
|
|
904
|
+
assert.equal(kids(), before + 1);
|
|
905
|
+
const row = panel.children.at(-2);
|
|
906
|
+
assert.equal(panel.children.at(-1).children.some((c) => c.tag === 'input'), true, 'the row sits just above the field');
|
|
907
|
+
assert.deepEqual([row.styles.display, row.children.map((c) => c.textContent)], ['flex', ['What can I do here?', 'Where is the inn?', 'Who are you?']]);
|
|
908
|
+
r.chrome.talkAsks([], null);
|
|
909
|
+
assert.equal(kids(), before, 'an empty list takes the row out again');
|
|
910
|
+
r.chrome.talkAsks(['Again?'], (ask) => taps.push(ask));
|
|
911
|
+
assert.equal(kids(), before + 1);
|
|
912
|
+
r.chrome.closeTalk();
|
|
913
|
+
assert.equal(kids(), before, 'closing the panel takes it out');
|
|
914
|
+
r.chrome.talkAsks(['Once more?'], (ask) => taps.push(ask));
|
|
915
|
+
r.chrome.openTalk('Rowan');
|
|
916
|
+
assert.equal(kids(), before, 'and the next conversation starts with the panel it always had');
|
|
917
|
+
n += 1;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
// --- a goal pointer's distance (v1.39) --------------------------------------
|
|
921
|
+
|
|
922
|
+
const { goalPointers, goalText, pointerAt } = await import('../code/client/together.js');
|
|
923
|
+
|
|
924
|
+
// A vector stand-in with identity camera matrices: x/y are NDC and z says
|
|
925
|
+
// whether a destination is in front. Exercise the real pointer projection.
|
|
926
|
+
class PointerVector {
|
|
927
|
+
clone() { return new PointerVector().set(this.x, this.y, this.z); }
|
|
928
|
+
set(x, y, z) { Object.assign(this, { x, y, z }); return this; }
|
|
929
|
+
applyMatrix4() { return this; }
|
|
930
|
+
project() { return this; }
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
test('v1.81: hints draw only on screen and hidden hints never consume the nearest-goal cap', () => {
|
|
934
|
+
const cam = { position: new PointerVector() };
|
|
935
|
+
const view = { w: 400, h: 800 };
|
|
936
|
+
const make = (id, d, at, edge) => ({ id, d, at, label: { text: id, ...(edge === undefined ? {} : { edge }) } });
|
|
937
|
+
const on = { x: 0, y: 0, z: -1 };
|
|
938
|
+
const off = { x: 2, y: 0, z: -1 };
|
|
939
|
+
const behind = { x: 0, y: 0, z: 1 };
|
|
940
|
+
const pointer = (g) => pointerAt(cam, view, g.at, `goal:${g.id}`, goalText(g.label, g.d, 6));
|
|
941
|
+
const visible = make('visible hint', 10, on, false);
|
|
942
|
+
const side = make('edge goal', 20, off);
|
|
943
|
+
const back = make('behind goal', 30, behind);
|
|
944
|
+
const hidden = [make('off hint', 1, off, false), make('behind hint', 2, behind, false)];
|
|
945
|
+
assert.deepEqual(goalPointers(hidden, 2, pointer), []);
|
|
946
|
+
assert.deepEqual(goalPointers([back, ...hidden, side, visible], 2, pointer), [pointer(visible), pointer(side)]);
|
|
947
|
+
assert.equal(pointer(visible).angle, null);
|
|
948
|
+
assert.equal(pointer(visible).text, 'visible hint · 10 m');
|
|
949
|
+
assert.notEqual(pointer(side).angle, null);
|
|
950
|
+
assert.deepEqual(goalPointers([...hidden, back, side], 2, pointer), [pointer(side), pointer(back)]);
|
|
951
|
+
assert.deepEqual(goalPointers([back, side, visible], 2, pointer), [pointer(visible), pointer(side)], 'absent-key selection is unchanged');
|
|
952
|
+
assert.deepEqual(goalPointers([make('near hint', 3, on, false)], 2, pointer)[0].text, 'near hint');
|
|
953
|
+
for (const edge of [true, null, 0, 'false']) {
|
|
954
|
+
const g = make('legacy', 10, behind, edge);
|
|
955
|
+
assert.deepEqual(goalPointers([g], 2, pointer), [pointer(g)]);
|
|
956
|
+
}
|
|
957
|
+
});
|
|
958
|
+
|
|
959
|
+
test("a goal pointer's words: the measured distance as before, the place's number, or none", () => {
|
|
960
|
+
const NEAR = 6;
|
|
961
|
+
// Without the option: the straight line to the actor, beyond 6 m, as it always was.
|
|
962
|
+
assert.equal(goalText({ text: 'Mill', style: 'goal' }, 22.4, NEAR), 'Mill · 22 m');
|
|
963
|
+
assert.equal(goalText({ text: 'Mill', style: 'goal' }, 6, NEAR), 'Mill');
|
|
964
|
+
assert.equal(goalText({ text: 'Mill', style: 'goal' }, 6.2, NEAR), 'Mill · 6 m');
|
|
965
|
+
// `distanceM`: that number, whatever the pointer's own actor is from the player.
|
|
966
|
+
assert.equal(goalText({ text: 'Mill', style: 'goal', distanceM: 84 }, 3, NEAR), 'Mill · 84 m', 'the corner is 3 m off, the walk 84');
|
|
967
|
+
assert.equal(goalText({ text: 'Mill', style: 'goal', distanceM: 84 }, 300, NEAR), 'Mill · 84 m');
|
|
968
|
+
assert.equal(goalText({ text: 'Mill', style: 'goal', distanceM: 4 }, 300, NEAR), 'Mill', 'nearly there: no number, as for a near actor');
|
|
969
|
+
assert.equal(goalText({ text: 'Mill', style: 'goal', distanceM: 0 }, 300, NEAR), 'Mill');
|
|
970
|
+
// `distance: false`: none, however far.
|
|
971
|
+
assert.equal(goalText({ text: 'Mill', style: 'goal', distance: false }, 300, NEAR), 'Mill');
|
|
972
|
+
assert.equal(goalText({ text: 'Mill', style: 'goal', distance: false, distanceM: 84 }, 300, NEAR), 'Mill');
|
|
973
|
+
// Anything else is not there: measured.
|
|
974
|
+
for (const junk of [{ distanceM: -1 }, { distanceM: NaN }, { distanceM: Infinity }, { distanceM: '40' }, { distanceM: null }, { distance: true }, { distance: 0 }]) {
|
|
975
|
+
assert.equal(goalText({ text: 'Mill', style: 'goal', ...junk }, 22.4, NEAR), 'Mill · 22 m', JSON.stringify(junk));
|
|
976
|
+
}
|
|
977
|
+
});
|
|
978
|
+
|
|
979
|
+
test('a new distance alone rewrites the chip\'s words: the same node, nothing else written', () => {
|
|
980
|
+
const r = rig();
|
|
981
|
+
const at = (text) => [{ id: 'goal:corner', x: 180, y: 300, text, angle: -1.57 }];
|
|
982
|
+
r.chrome.setPointers(at(goalText({ text: 'Mill', distanceM: 84 }, 3, 6)));
|
|
983
|
+
const chip = r.pointers.children[0];
|
|
984
|
+
const made = r.made.length;
|
|
985
|
+
r.log.length = 0;
|
|
986
|
+
// The place sends the label again a second later with one metre less.
|
|
987
|
+
r.chrome.setPointers(at(goalText({ text: 'Mill', distanceM: 83 }, 3, 6)));
|
|
988
|
+
assert.equal(r.pointers.children.length, 1);
|
|
989
|
+
assert.equal(r.pointers.children[0], chip, 'the same chip');
|
|
990
|
+
assert.equal(r.made.length, made, 'nothing built');
|
|
991
|
+
const words = chip.children[1];
|
|
992
|
+
assert.equal(words.textContent, 'Mill · 83 m');
|
|
993
|
+
assert.deepEqual(r.log.filter((line) => / text=| removed| emptied| \+/.test(line)), [`${words.id} text=Mill · 83 m`], 'one write of words: no node made, moved or taken away');
|
|
994
|
+
// The same number again: no words written at all.
|
|
995
|
+
r.log.length = 0;
|
|
996
|
+
r.chrome.setPointers(at('Mill · 83 m'));
|
|
997
|
+
assert.equal(r.log.some((line) => / text=/.test(line)), false);
|
|
998
|
+
});
|
|
999
|
+
|
|
676
1000
|
console.log(`hub-game hud-clear: ${n} tests passed`);
|