castle-web-cli 0.4.236 → 0.4.238
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/api.d.ts +2 -0
- package/dist/bundle.d.ts +24 -0
- package/dist/bundle.js +447 -4
- package/dist/bundleLatin1.d.ts +6 -0
- package/dist/bundleLatin1.js +333 -0
- package/dist/castle-host/host.d.ts +10 -1
- package/dist/castle-host/host.js +78 -9
- package/dist/castleJson.d.ts +20 -0
- package/dist/castleJson.js +40 -0
- package/dist/deckExports.d.ts +35 -0
- package/dist/deckExports.js +365 -0
- package/dist/importCheckHook.d.ts +1 -0
- package/dist/importCheckHook.js +1 -1
- package/dist/index.js +5 -0
- package/dist/init.js +2 -1
- package/dist/save-deck.js +18 -13
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +47 -0
- package/kits/base/sdk/castle.d.ts +3 -1
- package/kits/base/sdk/castle.js +1 -0
- package/kits/base/sdk/commands.d.ts +25 -1
- package/kits/base/sdk/commands.js +29 -1
- package/kits/base/sdk/hub.d.ts +17 -0
- package/kits/base/sdk/hub.js +33 -9
- package/kits/base/sdk/localCache.d.ts +27 -0
- package/kits/base/sdk/localCache.js +115 -0
- package/kits/base/sdk/localCacheStore.d.ts +15 -0
- package/kits/base/sdk/localCacheStore.js +358 -0
- package/kits/base/sdk/transport.d.ts +1 -0
- package/kits/base/sdk/transport.js +4 -5
- package/kits/hub-game/CLAUDE.md +22 -2
- package/kits/hub-game/castle.json +4 -1
- package/kits/hub-game/code/client/act.js +66 -91
- package/kits/hub-game/code/client/actCore.js +134 -0
- package/kits/hub-game/code/client/car.js +35 -0
- package/kits/hub-game/code/client/chrome.js +207 -381
- package/kits/hub-game/code/client/crowdNames.js +2 -2
- package/kits/hub-game/code/client/emoteWheel.js +109 -0
- package/kits/hub-game/code/client/hats.js +2 -0
- package/kits/hub-game/code/client/hookLayer.js +99 -48
- package/kits/hub-game/code/client/hostGo.js +77 -0
- package/kits/hub-game/code/client/hubControls.js +125 -0
- package/kits/hub-game/code/client/hubEntry.js +187 -0
- package/kits/hub-game/code/client/hudSurface.js +148 -0
- package/kits/hub-game/code/client/hudTree.js +96 -0
- package/kits/hub-game/code/client/idle.js +59 -13
- package/kits/hub-game/code/client/invites.js +13 -4
- package/kits/hub-game/code/client/menuIcons.js +8 -0
- package/kits/hub-game/code/client/noTrips.js +38 -0
- package/kits/hub-game/code/client/qualityEntry.js +6 -1
- package/kits/hub-game/code/client/rehello.js +3 -1
- package/kits/hub-game/code/client/riders.js +26 -0
- package/kits/hub-game/code/client/role.js +79 -0
- package/kits/hub-game/code/client/safeLayout.js +32 -3
- package/kits/hub-game/code/client/sound.js +10 -3
- package/kits/hub-game/code/client/soundscape.js +2 -2
- package/kits/hub-game/code/client/soundscapeAmbience.js +38 -8
- package/kits/hub-game/code/client/soundscapeBaked.js +24 -5
- package/kits/hub-game/code/client/soundscapeCues.js +2 -1
- package/kits/hub-game/code/client/state.js +19 -0
- package/kits/hub-game/code/client/stuck.js +2 -1
- package/kits/hub-game/code/client/talkSurface.js +178 -0
- package/kits/hub-game/code/client/talkTree.js +238 -0
- package/kits/hub-game/code/client/tiers.js +8 -5
- package/kits/hub-game/code/client/uiDom.js +600 -0
- package/kits/hub-game/code/client/uiTree.js +359 -0
- package/kits/hub-game/code/client/vehicle.js +154 -0
- package/kits/hub-game/code/client/wear.js +27 -5
- package/kits/hub-game/code/client/worldLabels.js +3 -2
- package/kits/hub-game/code/client/yours.js +10 -3
- package/kits/hub-game/code/server/actors.js +4 -3
- package/kits/hub-game/code/server/analytics.js +56 -6
- package/kits/hub-game/code/server/decor.js +56 -16
- package/kits/hub-game/code/server/hub.js +258 -46
- package/kits/hub-game/code/server/idle.js +118 -5
- package/kits/hub-game/code/server/manifest.js +46 -4
- package/kits/hub-game/code/server/npcs.js +4 -2
- package/kits/hub-game/code/server/players.js +3 -0
- package/kits/hub-game/code/server/role.js +142 -0
- package/kits/hub-game/code/server/standing.js +6 -4
- package/kits/hub-game/code/server/vehicle.js +126 -0
- package/kits/hub-game/code/shared/car.js +52 -0
- package/kits/hub-game/code/shared/deckFlags.js +34 -0
- package/kits/hub-game/code/shared/deviceClass.js +39 -0
- package/kits/hub-game/code/shared/expression.js +9 -0
- package/kits/hub-game/code/systems/hub.js +300 -85
- package/kits/hub-game/docs/analytics.md +11 -2
- package/kits/hub-game/docs/contract.md +353 -14
- package/kits/hub-game/docs/vehicle-preset.md +132 -0
- package/kits/hub-game/models/hats/baker-cap.pxmodel +89 -0
- package/kits/hub-game/models/hats/chef-toque.pxmodel +60 -0
- package/kits/hub-game/models/hats/delivery-cap.pxmodel +105 -0
- package/kits/hub-game/models/hats/fire-helmet.pxmodel +87 -0
- package/kits/hub-game/models/hats/hard-hat.pxmodel +71 -0
- package/kits/hub-game/models/hats/nurse-cap.pxmodel +61 -0
- package/kits/hub-game/models/hats/police-cap.pxmodel +105 -0
- package/kits/hub-game/models/hats/teacher-beret.pxmodel +52 -0
- package/kits/hub-game/models/role/square/top-apron.pxmodel +109 -0
- package/kits/hub-game/models/role/square/top-cardigan.pxmodel +141 -0
- package/kits/hub-game/models/role/square/top-coat.pxmodel +157 -0
- package/kits/hub-game/models/role/square/top-scrubs.pxmodel +93 -0
- package/kits/hub-game/models/role/square/top-tabard.pxmodel +109 -0
- package/kits/hub-game/models/role/square/top-vest.pxmodel +109 -0
- package/kits/hub-game/models/role/tool-bag.pxmodel +75 -0
- package/kits/hub-game/models/role/tool-bell.pxmodel +71 -0
- package/kits/hub-game/models/role/tool-hose.pxmodel +60 -0
- package/kits/hub-game/models/role/tool-parcel.pxmodel +61 -0
- package/kits/hub-game/models/role/tool-torch.pxmodel +55 -0
- package/kits/hub-game/models/role/tool-tray.pxmodel +75 -0
- package/kits/hub-game/models/role/top-apron.pxmodel +70 -0
- package/kits/hub-game/models/role/top-cardigan.pxmodel +102 -0
- package/kits/hub-game/models/role/top-coat.pxmodel +79 -0
- package/kits/hub-game/models/role/top-scrubs.pxmodel +54 -0
- package/kits/hub-game/models/role/top-tabard.pxmodel +70 -0
- package/kits/hub-game/models/role/top-vest.pxmodel +70 -0
- package/kits/hub-game/package-lock.json +1 -1
- package/kits/hub-game/package.json +1 -1
- package/kits/hub-game/scripts/check.mjs +7 -4
- package/kits/hub-game/scripts/fixtures/car-vectors.json +279 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +2 -1
- package/kits/hub-game/scripts/fixtures/hud-surface.json +670 -0
- package/kits/hub-game/scripts/fixtures/talk-surface.json +3930 -0
- package/kits/hub-game/scripts/gen-hats.mjs +46 -2
- package/kits/hub-game/scripts/gen-role.mjs +80 -0
- package/kits/hub-game/scripts/test-act-core.mjs +167 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +34 -0
- package/kits/hub-game/scripts/test-actors.mjs +48 -0
- package/kits/hub-game/scripts/test-analytics.mjs +99 -5
- package/kits/hub-game/scripts/test-apply-deck.mjs +122 -0
- package/kits/hub-game/scripts/test-back-visibility.mjs +3 -1
- package/kits/hub-game/scripts/test-ballot.mjs +2 -0
- package/kits/hub-game/scripts/test-car.mjs +43 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +2 -1
- package/kits/hub-game/scripts/test-decor.mjs +77 -0
- package/kits/hub-game/scripts/test-device-class.mjs +83 -0
- package/kits/hub-game/scripts/test-emote-wheel.mjs +374 -0
- package/kits/hub-game/scripts/test-hats.mjs +5 -4
- package/kits/hub-game/scripts/test-host-go.mjs +265 -0
- package/kits/hub-game/scripts/test-hub-controls.mjs +108 -0
- package/kits/hub-game/scripts/test-hub-entry.mjs +531 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +75 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +85 -0
- package/kits/hub-game/scripts/test-hud-clear.mjs +12 -2
- package/kits/hub-game/scripts/test-hud-rate.mjs +6 -2
- package/kits/hub-game/scripts/test-hud-surface.mjs +272 -0
- package/kits/hub-game/scripts/test-idle.mjs +347 -1
- package/kits/hub-game/scripts/test-interest-cells.mjs +8 -1
- package/kits/hub-game/scripts/test-invites-client.mjs +42 -1
- package/kits/hub-game/scripts/test-manifest.mjs +30 -0
- package/kits/hub-game/scripts/test-no-trips.mjs +42 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
- package/kits/hub-game/scripts/test-quality.mjs +13 -0
- package/kits/hub-game/scripts/test-rehello.mjs +258 -3
- package/kits/hub-game/scripts/test-resume-pose-server.mjs +203 -0
- package/kits/hub-game/scripts/test-resync.mjs +183 -0
- package/kits/hub-game/scripts/test-role-client.mjs +421 -0
- package/kits/hub-game/scripts/test-role.mjs +350 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +50 -1
- package/kits/hub-game/scripts/test-soundscape.mjs +124 -7
- package/kits/hub-game/scripts/test-standing.mjs +15 -1
- package/kits/hub-game/scripts/test-talk-surface.mjs +296 -0
- package/kits/hub-game/scripts/test-tiers.mjs +13 -0
- package/kits/hub-game/scripts/test-ui-dom-dom.mjs +96 -0
- package/kits/hub-game/scripts/test-ui-tree.mjs +711 -0
- package/kits/hub-game/scripts/test-vehicle-client.mjs +159 -0
- package/kits/hub-game/scripts/test-vehicle.mjs +135 -0
- package/kits/hub-game/scripts/test-yours.mjs +33 -0
- package/kits/hub-game/tools/hubScene/export.mjs +613 -0
- package/kits/hub-game/tools/hubScene/hubdata.mjs +921 -0
- package/kits/hub-game/tools/hubScene/merge-root.mjs +39 -0
- package/kits/hub-game/tools/hubScene/nodeworld.mjs +227 -0
- package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +798 -0
- package/kits/hub-game/tools/hubScene/test/fixture.json +637 -0
- package/kits/hub-game/tools/hubScene/test/paint-export.mjs +40 -0
- package/kits/hub-game/tools/hubScene/test/upload.test.mjs +655 -0
- package/kits/hub-game/tools/hubScene/upload.mjs +636 -0
- package/kits/hub-game/tools/hubScene/validate-manifest.mjs +291 -0
- package/kits/multiplayer-3d/castle.json +4 -4
- package/kits/multiplayer-3d/code/client/resumeGate.js +30 -2
- package/kits/multiplayer-3d/code/client/steer.js +3 -1
- package/kits/multiplayer-3d/code/systems/multiplayer.js +30 -2
- package/kits/multiplayer-3d/package-lock.json +1 -1
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +74 -2
- package/kits/physics-3d/CLAUDE.md +1 -1
- package/kits/physics-3d/behaviors/Player.jsx +37 -27
- package/kits/physics-3d/castle.json +2 -2
- package/kits/physics-3d/docs/engine-geometry-memory.md +23 -0
- package/kits/physics-3d/engine3d/memoryprofile.js +17 -0
- package/kits/physics-3d/engine3d/playerRun.js +6 -1
- package/kits/physics-3d/engine3d/pxmodel.js +6 -1
- package/kits/physics-3d/engine3d/world3d.js +6 -3
- package/kits/physics-3d/package.json +1 -1
- package/kits/physics-3d/play/behaviors/Player.js +40 -28
- package/kits/physics-3d/scripts/test-memory-profile.mjs +237 -0
- package/kits/physics-3d/systems/physics3d.js +5 -2
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/messages.js +5 -0
- package/kits/real-time/code/server/session.js +28 -1
- package/kits/real-time/package-lock.json +1 -1
- package/package.json +5 -4
- package/vendor/three/LICENSE +21 -0
- package/vendor/three/build/three.core.js +58773 -0
- package/vendor/three/build/three.module.js +18251 -0
- package/vendor/three/examples/jsm/controls/OrbitControls.js +1860 -0
- package/vendor/three/examples/jsm/controls/TransformControls.js +1918 -0
- package/vendor/three/examples/jsm/exporters/GLTFExporter.js +3595 -0
- package/vendor/three/examples/jsm/geometries/RoundedBoxGeometry.js +216 -0
- package/vendor/three/examples/jsm/math/MeshSurfaceSampler.js +315 -0
- package/vendor/three/examples/jsm/postprocessing/EffectComposer.js +363 -0
- package/vendor/three/examples/jsm/postprocessing/MaskPass.js +195 -0
- package/vendor/three/examples/jsm/postprocessing/OutputPass.js +139 -0
- package/vendor/three/examples/jsm/postprocessing/Pass.js +191 -0
- package/vendor/three/examples/jsm/postprocessing/RenderPass.js +183 -0
- package/vendor/three/examples/jsm/postprocessing/ShaderPass.js +135 -0
- package/vendor/three/examples/jsm/shaders/CopyShader.js +52 -0
- package/vendor/three/examples/jsm/shaders/OutputShader.js +103 -0
- package/vendor/three/examples/jsm/utils/BufferGeometryUtils.js +1435 -0
- package/vendor/three/package.json +134 -0
|
@@ -140,12 +140,12 @@ export function layoutCrowdNames(state, candidates, { now, view, obstacles = []
|
|
|
140
140
|
const limit = tiny ? 0 : dense ? 2 : 1;
|
|
141
141
|
let used = 0;
|
|
142
142
|
for (const candidate of group) {
|
|
143
|
-
const blocked = obstacles.some((box) => touches(candidate.box, box));
|
|
143
|
+
const blocked = obstacles.some((box) => box.rolePlayerId !== candidate.id && touches(candidate.box, box));
|
|
144
144
|
const conflicts = chosenBoxes.some((box) => touches(candidate.box, box));
|
|
145
145
|
let allowed = used < limit && !blocked && !conflicts;
|
|
146
146
|
let waiting = false;
|
|
147
147
|
if (allowed && state.suppressed.has(candidate.id)) {
|
|
148
|
-
const separated = !obstacles.some((box) => touches(candidate.box, box, RESTORE_PX)) &&
|
|
148
|
+
const separated = !obstacles.some((box) => box.rolePlayerId !== candidate.id && touches(candidate.box, box, RESTORE_PX)) &&
|
|
149
149
|
!chosenBoxes.some((box) => touches(candidate.box, box, RESTORE_PX));
|
|
150
150
|
if (!separated) {
|
|
151
151
|
state.clearSince.delete(candidate.id);
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// v1.158: a ring (or compact grid) of basics, then paged place/original emotes.
|
|
2
|
+
import { panelPlacement } from './safeLayout.js';
|
|
3
|
+
|
|
4
|
+
export function makeEmoteWheel({ root, el, view, bands, trigger, pick, close }) {
|
|
5
|
+
const sheet = el('div', { position: 'absolute', display: 'none', width: '240px', boxSizing: 'border-box', padding: '4px', borderRadius: '24px', background: 'rgba(20,16,12,0.94)', color: '#fff', pointerEvents: 'auto', overflowY: 'auto', overscrollBehavior: 'contain', touchAction: 'pan-y', zIndex: '4' }, root);
|
|
6
|
+
const probe = el('div', { position: 'absolute', visibility: 'hidden', pointerEvents: 'none', paddingTop: 'env(safe-area-inset-top)', paddingRight: 'env(safe-area-inset-right)', paddingBottom: 'env(safe-area-inset-bottom)', paddingLeft: 'env(safe-area-inset-left)' }, root);
|
|
7
|
+
sheet.setAttribute('role', 'dialog');
|
|
8
|
+
sheet.setAttribute('aria-label', 'Emotes');
|
|
9
|
+
const controller = new AbortController();
|
|
10
|
+
const { signal } = controller;
|
|
11
|
+
let choices, page = 0, opened = false, drawn = '', resizeFrame = null;
|
|
12
|
+
const button = (parent, text, label, action) => {
|
|
13
|
+
const node = el('button', { boxSizing: 'border-box', minWidth: '44px', minHeight: '44px', border: '1px solid rgba(255,255,255,0.35)', borderRadius: '16px', background: 'rgba(255,255,255,0.08)', color: '#fff', font: '600 12px system-ui, sans-serif', cursor: 'pointer', padding: '2px', touchAction: 'manipulation' }, parent);
|
|
14
|
+
node.type = 'button';
|
|
15
|
+
node.textContent = text;
|
|
16
|
+
node.setAttribute('aria-label', label);
|
|
17
|
+
node.addEventListener('click', action);
|
|
18
|
+
return node;
|
|
19
|
+
};
|
|
20
|
+
const slot = (parent, [id, emoji, label], ground = false) => {
|
|
21
|
+
const node = button(parent, '', label, () => { close(); pick(id, ground); });
|
|
22
|
+
el('span', { display: 'block', fontSize: '22px', lineHeight: '24px' }, node).textContent = emoji;
|
|
23
|
+
el('span', { display: 'block', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', lineHeight: '14px' }, node).textContent = label;
|
|
24
|
+
node.dataset.emote = id;
|
|
25
|
+
return node;
|
|
26
|
+
};
|
|
27
|
+
function layout() {
|
|
28
|
+
const v = { ...view() };
|
|
29
|
+
const css = globalThis.getComputedStyle?.(probe);
|
|
30
|
+
v.insets = Object.fromEntries(['top', 'right', 'bottom', 'left'].map((side) => [side, Math.max(v.insets[side], Number.parseFloat(css?.[`padding${side[0].toUpperCase()}${side.slice(1)}`]) || 0)]));
|
|
31
|
+
const obstacles = bands();
|
|
32
|
+
const place = (height, top) => panelPlacement({ left: (v.w - 240) / 2, right: (v.w + 240) / 2, top: (v.h - height) / 2, bottom: (v.h + height) / 2 }, v, { top, bottom: 12, left: 12, right: 12 }, obstacles, 240);
|
|
33
|
+
let placed = place(284, 64);
|
|
34
|
+
const ring = placed.h >= 284 && placed.w >= 240;
|
|
35
|
+
if (!ring) {
|
|
36
|
+
placed = place(148, 64);
|
|
37
|
+
if (placed.h < 148) {
|
|
38
|
+
// Actual HUD bands still reserve their space when the blanket top
|
|
39
|
+
// margin is reduced to the ordinary safe edge.
|
|
40
|
+
const compact = place(148, 12);
|
|
41
|
+
if (compact.h > placed.h) { placed = compact; }
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const columns = ring ? 3 : 4;
|
|
45
|
+
const rows = ring ? 2 : Math.max(1, Math.min(2, Math.floor((placed.h - 52) / 48)));
|
|
46
|
+
return { placed, ring, columns, bodyHeight: ring ? 232 : (page ? rows : 2) * 48, pageSize: Math.min(6, columns * rows) };
|
|
47
|
+
}
|
|
48
|
+
function draw() {
|
|
49
|
+
if (!opened) { return; }
|
|
50
|
+
const { placed, ring, columns, bodyHeight, pageSize } = layout();
|
|
51
|
+
if (page) { page = Math.min(page, Math.ceil(choices.more.length / pageSize)); }
|
|
52
|
+
// Safe-layout notifications can follow our own DOM changes. Leave an
|
|
53
|
+
// unchanged drawing alone so those notifications settle.
|
|
54
|
+
const key = JSON.stringify([placed, ring, columns, bodyHeight, pageSize, page, choices]);
|
|
55
|
+
if (key === drawn) { return; }
|
|
56
|
+
drawn = key;
|
|
57
|
+
sheet.replaceChildren();
|
|
58
|
+
Object.assign(sheet.style, { width: `${placed.w}px`, left: `${placed.x}px`, top: `${placed.y}px`, height: `${bodyHeight + 52}px`, maxHeight: `${placed.h}px` });
|
|
59
|
+
const body = el('div', { position: 'relative', height: `${bodyHeight}px` }, sheet);
|
|
60
|
+
if (page === 0 && ring) {
|
|
61
|
+
choices.basics.forEach((entry, i) => {
|
|
62
|
+
const angle = i * Math.PI / 4 - Math.PI / 2;
|
|
63
|
+
const node = slot(body, entry, entry[0] === 'sit');
|
|
64
|
+
Object.assign(node.style, { position: 'absolute', width: '56px', height: '48px', left: `${88 + Math.cos(angle) * 86}px`, top: `${92 + Math.sin(angle) * 86}px` });
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
const entries = page ? choices.more.slice((page - 1) * pageSize, page * pageSize) : choices.basics;
|
|
68
|
+
const count = page ? columns : 4;
|
|
69
|
+
const width = (placed.w - 8 - (count - 1) * 6) / count;
|
|
70
|
+
entries.forEach((entry, i) => {
|
|
71
|
+
const node = slot(body, entry, !page && entry[0] === 'sit');
|
|
72
|
+
Object.assign(node.style, { position: 'absolute', width: `${width}px`, height: ring ? '48px' : '44px', left: `${i % count * (width + 6)}px`, top: `${Math.floor(i / count) * (ring ? 54 : 48) + (ring ? 62 : 0)}px` });
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
const nav = el('div', { display: 'flex', height: '44px', justifyContent: 'space-between', gap: '6px' }, sheet);
|
|
76
|
+
button(nav, page ? 'Basics' : 'More', page ? 'Basic emotes' : 'More emotes', () => { page = page ? 0 : 1; draw(); });
|
|
77
|
+
if (page && choices.more.length > pageSize) {
|
|
78
|
+
button(nav, 'Next', 'Next emotes', () => { page = page % Math.ceil(choices.more.length / pageSize) + 1; draw(); });
|
|
79
|
+
}
|
|
80
|
+
button(nav, 'Close', 'Close emotes', close);
|
|
81
|
+
sheet.querySelector?.('button')?.focus();
|
|
82
|
+
}
|
|
83
|
+
sheet.addEventListener('pointerdown', (event) => event.stopPropagation());
|
|
84
|
+
sheet.addEventListener('keydown', (event) => event.stopPropagation());
|
|
85
|
+
globalThis.addEventListener?.('pointerdown', (event) => {
|
|
86
|
+
if (opened && !sheet.contains(event.target) && event.target !== trigger) { close(); }
|
|
87
|
+
}, { capture: true, signal });
|
|
88
|
+
globalThis.addEventListener?.('keydown', (event) => {
|
|
89
|
+
if (opened && event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); close(); }
|
|
90
|
+
}, { capture: true, signal });
|
|
91
|
+
const resized = () => {
|
|
92
|
+
if (!opened || resizeFrame !== null) { return; }
|
|
93
|
+
resizeFrame = requestAnimationFrame(() => { resizeFrame = null; draw(); });
|
|
94
|
+
};
|
|
95
|
+
globalThis.addEventListener?.('resize', resized, { signal });
|
|
96
|
+
globalThis.addEventListener?.('orientationchange', resized, { signal });
|
|
97
|
+
return {
|
|
98
|
+
node: sheet,
|
|
99
|
+
// Chrome calls this again after its safe-layout cache refreshes.
|
|
100
|
+
layout: draw,
|
|
101
|
+
set(value) { choices = value; page = 0; if (opened) { draw(); } },
|
|
102
|
+
open(value) {
|
|
103
|
+
opened = value;
|
|
104
|
+
sheet.style.display = value ? 'block' : 'none';
|
|
105
|
+
if (value) { page = 0; drawn = ''; draw(); }
|
|
106
|
+
},
|
|
107
|
+
dispose() { opened = false; cancelAnimationFrame(resizeFrame); controller.abort(); sheet.remove(); probe.remove(); },
|
|
108
|
+
};
|
|
109
|
+
}
|
|
@@ -10,6 +10,8 @@ export const HAT_SETS = {
|
|
|
10
10
|
hollow: ['bat-clip', 'witch', 'lantern', 'crooked-top'],
|
|
11
11
|
sunny: ['straw', 'flower-crown', 'beekeeper', 'sunflower'],
|
|
12
12
|
harbour: ['sailor', 'souwester', 'captain', 'lighthouse'],
|
|
13
|
+
services: ['police-cap', 'nurse-cap', 'fire-helmet', 'chef-toque'],
|
|
14
|
+
neighbourhood: ['delivery-cap', 'teacher-beret', 'hard-hat', 'baker-cap'],
|
|
13
15
|
};
|
|
14
16
|
|
|
15
17
|
export const HATS = Object.values(HAT_SETS).flat();
|
|
@@ -11,7 +11,7 @@ import * as AvatarCap from './avatarCap.js';
|
|
|
11
11
|
import { mergeDictionary } from './interestCap.js';
|
|
12
12
|
import * as Cabinets from './cabinets.js';
|
|
13
13
|
import { firstJoinFor } from './firstJoin.js';
|
|
14
|
-
import { deck, earnedNow, hub, localArrival, mergeHidden, receiveParty, wearingNow } from './state.js';
|
|
14
|
+
import { deck, earnedNow, hub, localArrival, mergeHidden, receiveParty, rolesNow, wearingNow } from './state.js';
|
|
15
15
|
import { clearShot, receiveShot } from './shot.js';
|
|
16
16
|
import * as Ballot from './ballot.js';
|
|
17
17
|
import * as Rehello from './rehello.js';
|
|
@@ -23,6 +23,8 @@ import { setFpsTelemetry } from './fpsTelemetry.js';
|
|
|
23
23
|
import { setLoadTelemetry } from './loadTelemetry.js';
|
|
24
24
|
import { readQuality } from '../shared/quality.js';
|
|
25
25
|
import { noteQualityInteraction } from './quality.js';
|
|
26
|
+
import { parseCar, vehicleOf } from '../shared/car.js';
|
|
27
|
+
import { pinRiders } from './riders.js';
|
|
26
28
|
import { readDanceIdle } from '../shared/danceIdle.js';
|
|
27
29
|
|
|
28
30
|
// Root-anchored: the deck's own castle.json once this kit is imported.
|
|
@@ -39,52 +41,65 @@ if (deck.build && kitBuild?.source === 'builtin' && typeof kitBuild.version ===
|
|
|
39
41
|
...(typeof kitBuild.digest === 'string' ? { hubGameBuiltinDigest: kitBuild.digest } : {}) });
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
else { delete deck.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
deck.
|
|
69
|
-
|
|
70
|
-
if (
|
|
71
|
-
deck.
|
|
72
|
-
}
|
|
73
|
-
deck.
|
|
74
|
-
deck.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
44
|
+
// What the deck's `hub` block asks of the client, into `deck` (state.js).
|
|
45
|
+
// The page applies its own castle.json's block once, below; a host with no
|
|
46
|
+
// castle.json to glob (the native hub) applies the scene manifest's `deck`
|
|
47
|
+
// block instead (shared/deckFlags.js), and may apply a newer one later: every
|
|
48
|
+
// key is set or cleared each time, as from a fresh page.
|
|
49
|
+
export function applyDeck(hubBlock) {
|
|
50
|
+
const block = hubBlock && typeof hubBlock === 'object' && !Array.isArray(hubBlock) ? hubBlock : {};
|
|
51
|
+
if (block.pongTimeoutMs > 0) { deck.pongTimeoutMs = block.pongTimeoutMs; }
|
|
52
|
+
else { delete deck.pongTimeoutMs; }
|
|
53
|
+
deck.invite = (block.places?.main?.invite ?? block.invite) === true;
|
|
54
|
+
deck.defaultEnvironment = block.defaultEnvironment !== false;
|
|
55
|
+
deck.tiers = block.tiers === true;
|
|
56
|
+
if (block.highOnly === true && deck.tiers) { deck.highOnly = true; }
|
|
57
|
+
else { delete deck.highOnly; }
|
|
58
|
+
if (block.quality !== undefined && deck.tiers) { deck.quality = readQuality(block.quality, true, []); }
|
|
59
|
+
else { delete deck.quality; }
|
|
60
|
+
if (block.safeInsets === true) { deck.safeInsets = true; }
|
|
61
|
+
else { delete deck.safeInsets; }
|
|
62
|
+
if (block.weakestTier === true) { deck.weakestTier = true; }
|
|
63
|
+
else { delete deck.weakestTier; }
|
|
64
|
+
if (block.weakestLookBake === true) { deck.weakestLookBake = true; }
|
|
65
|
+
else { delete deck.weakestLookBake; }
|
|
66
|
+
if (block.mergeFarAvatars === true) { deck.mergeFarAvatars = true; }
|
|
67
|
+
else { delete deck.mergeFarAvatars; }
|
|
68
|
+
if (block.lowActorDistance === true) { deck.lowActorDistance = true; }
|
|
69
|
+
else { delete deck.lowActorDistance; }
|
|
70
|
+
if (block.lowActorBudget === true) { deck.lowActorBudget = true; }
|
|
71
|
+
else { delete deck.lowActorBudget; }
|
|
72
|
+
if (block.companionIdle === true) { deck.companionIdle = true; }
|
|
73
|
+
else { delete deck.companionIdle; }
|
|
74
|
+
if (block.act === true) {deck.act = true;}
|
|
75
|
+
else {delete deck.act;}
|
|
76
|
+
deck.cues = block.cues === true;
|
|
77
|
+
deck.playCards = block.playCards === true;
|
|
78
|
+
deck.yourGames = block.yourGames === true;
|
|
79
|
+
if (block.avatarColors === true) {
|
|
80
|
+
deck.avatarColors = true;
|
|
81
|
+
} else {
|
|
82
|
+
delete deck.avatarColors;
|
|
83
|
+
}
|
|
84
|
+
deck.stuck = block.stuck === true;
|
|
85
|
+
deck.labels = block.labels === 'near';
|
|
86
|
+
// `hub.soundscape`: true, or an object with optional ground, ambience and UI.
|
|
87
|
+
const soundscape = block.soundscape;
|
|
88
|
+
deck.soundscape = soundscape === true || (soundscape && typeof soundscape === 'object' && !Array.isArray(soundscape)) ? {
|
|
89
|
+
babble: soundscape.babble !== false,
|
|
90
|
+
steps: soundscape.steps && typeof soundscape.steps === 'object' && !Array.isArray(soundscape.steps) ? soundscape.steps : soundscape.steps !== false,
|
|
91
|
+
...(typeof soundscape.zones === 'string' ? { zones: soundscape.zones } : {}),
|
|
92
|
+
...(soundscape.ambience && typeof soundscape.ambience === 'object' && !Array.isArray(soundscape.ambience) ? { ambience: soundscape.ambience } : {}),
|
|
93
|
+
...(Object.hasOwn(soundscape, 'ui') && typeof soundscape.ui === 'boolean' ? { ui: soundscape.ui } : {}),
|
|
94
|
+
...(Object.hasOwn(soundscape, 'cues') && typeof soundscape.cues === 'boolean' ? { cues: soundscape.cues } : {}),
|
|
95
|
+
} : null;
|
|
96
|
+
if (deck.soundscape?.cues === true) {
|
|
97
|
+
hub.cueEvents = Array.isArray(hub.cueEvents) ? hub.cueEvents : [];
|
|
98
|
+
} else {
|
|
99
|
+
hub.cueEvents = null;
|
|
100
|
+
}
|
|
87
101
|
}
|
|
102
|
+
applyDeck(castleJson?.hub);
|
|
88
103
|
|
|
89
104
|
let files = null;
|
|
90
105
|
// The scene and multiplayer system of the newest snapshot, for a message that
|
|
@@ -178,7 +193,14 @@ function wearMap(value) {
|
|
|
178
193
|
return new Map(Object.entries(value && typeof value === 'object' ? value : {}));
|
|
179
194
|
}
|
|
180
195
|
|
|
181
|
-
|
|
196
|
+
const hooks = {
|
|
197
|
+
beforeReport(scene, local) {
|
|
198
|
+
if (Object.keys(hub.cars).length) {pinRiders(scene, local, hub.cars);}
|
|
199
|
+
},
|
|
200
|
+
report(scene, local, system) {
|
|
201
|
+
const mine = vehicleOf(hub.cars, system.net?.selfId?.());
|
|
202
|
+
if (!mine || mine.driver) {system.report(scene, local);}
|
|
203
|
+
},
|
|
182
204
|
// Travel retains these hooks: decode offers from any opted-in destination.
|
|
183
205
|
unpack: unpackFrame,
|
|
184
206
|
// A place whose NPCs have minds (`hub.npcs`, contract §13) is joined like any
|
|
@@ -216,6 +238,9 @@ export default {
|
|
|
216
238
|
hub.companion = { c: sanitise(msg.c), n: msg.n, ...(hub.companion?.stamps !== undefined ? { stamps: hub.companion.stamps } : {}) };
|
|
217
239
|
}
|
|
218
240
|
break;
|
|
241
|
+
case 'hub-emotes-for':
|
|
242
|
+
if ((!hub.place || hub.place.idle?.expression) && Array.isArray(msg.ids)) { hub.roleEmotes = msg.ids.filter((id) => typeof id === 'string'); }
|
|
243
|
+
break;
|
|
219
244
|
case 'hub-menu':
|
|
220
245
|
if ((!hub.place || hub.place.menu === true) && Number.isSafeInteger(msg.n) && msg.n >= 0 &&
|
|
221
246
|
(!hub.menu || msg.n > hub.menu.n)) {
|
|
@@ -340,6 +365,10 @@ export default {
|
|
|
340
365
|
hub.wearMe = wearMap(msg.hubWear);
|
|
341
366
|
setWearing();
|
|
342
367
|
break;
|
|
368
|
+
case 'hub-role':
|
|
369
|
+
hub.roleMe = wearMap(msg.hubRole);
|
|
370
|
+
hub.roles = rolesNow();
|
|
371
|
+
break;
|
|
343
372
|
case 'hub-earned':
|
|
344
373
|
// v1.53: earned items of players in a hidden pair this player may see.
|
|
345
374
|
hub.earnedMe = wearMap(msg.hubEarned);
|
|
@@ -413,7 +442,7 @@ export default {
|
|
|
413
442
|
// corrected position has reached Transform. A later WORLD is equivalent
|
|
414
443
|
// on reconnect; the initial WORLD cannot qualify before hub-arrived.
|
|
415
444
|
if (!hub.arrivalPlaced && hub.arrivedFacing !== null && (
|
|
416
|
-
msg.k === 'w' ||
|
|
445
|
+
(msg.k === 'w' && msg.again !== 1) ||
|
|
417
446
|
// Match multiplayer's clamp acceptance exactly. `packPlayer` puts 1/0
|
|
418
447
|
// on the wire, while older composed fixtures may still carry true.
|
|
419
448
|
(msg.ps ?? []).some((row) => row?.[0] === system?.net?.selfId?.() && Boolean(row[5]))
|
|
@@ -431,6 +460,7 @@ export default {
|
|
|
431
460
|
hub.askClose?.();
|
|
432
461
|
delete hub.ask;
|
|
433
462
|
}
|
|
463
|
+
if (!msg.hubPlace.idle?.expression || (hub.place && hub.place.id !== msg.hubPlace.id)) { hub.roleEmotes = []; }
|
|
434
464
|
hub.place = msg.hubPlace;
|
|
435
465
|
if (hub.place.anonymousEntry !== true) {
|
|
436
466
|
delete hub.guests;
|
|
@@ -543,6 +573,14 @@ export default {
|
|
|
543
573
|
hub.tryAll = new Map();
|
|
544
574
|
setWearing();
|
|
545
575
|
}
|
|
576
|
+
// v1.157: snapshots clear only the shared block, as hubTry does.
|
|
577
|
+
if (msg.hubRole && typeof msg.hubRole === 'object') {
|
|
578
|
+
hub.roleAll = wearMap(msg.hubRole);
|
|
579
|
+
hub.roles = rolesNow();
|
|
580
|
+
} else if (msg.hubPlace && hub.roleAll.size > 0) {
|
|
581
|
+
hub.roleAll = new Map();
|
|
582
|
+
hub.roles = rolesNow();
|
|
583
|
+
}
|
|
546
584
|
if ('hud' in msg) {
|
|
547
585
|
hub.hud = msg.hud ?? null;
|
|
548
586
|
}
|
|
@@ -584,6 +622,13 @@ export default {
|
|
|
584
622
|
if (msg.hubKept && typeof msg.hubKept === 'object') {
|
|
585
623
|
hub.keptFor = new Map(Object.entries(msg.hubKept));
|
|
586
624
|
}
|
|
625
|
+
if (msg.hubCars && typeof msg.hubCars === 'object') {
|
|
626
|
+
hub.cars = Object.fromEntries(Object.entries(msg.hubCars).slice(0, 24).flatMap(([id, spec]) => {
|
|
627
|
+
const car = parseCar(spec);
|
|
628
|
+
return car ? [[id, { ...car, riders: Object.fromEntries(Object.entries(spec.riders ?? {}).filter(([seat, rider]) => Number.isInteger(Number(seat)) && Number(seat) > 0 && Number(seat) < car.seats.length && typeof rider === 'string')) }]] : [];
|
|
629
|
+
}));
|
|
630
|
+
}
|
|
631
|
+
else if (msg.hubPlace) {hub.cars = {};}
|
|
587
632
|
// v1.6: only a place that turns idle play on sends these.
|
|
588
633
|
if (msg.hubEmotes && typeof msg.hubEmotes === 'object') {
|
|
589
634
|
hub.emotes = msg.hubEmotes;
|
|
@@ -626,3 +671,9 @@ export default {
|
|
|
626
671
|
clearShot();
|
|
627
672
|
},
|
|
628
673
|
};
|
|
674
|
+
// `hookLayer.applyDeck` for a host that imports this layer itself (the native
|
|
675
|
+
// hub's kit bundle). Not enumerable, so composing the layers (real-time
|
|
676
|
+
// gameHooks.js) never copies it into the hooks a system calls.
|
|
677
|
+
Object.defineProperty(hooks, 'applyDeck', { value: applyDeck });
|
|
678
|
+
|
|
679
|
+
export default hooks;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// A host's Go (SDK `Hub.onGo`, contract v1.155): the host asks this place to
|
|
2
|
+
// take the player through one of its doors, e.g. a trip begun outside this
|
|
3
|
+
// page that hands back to the Town. The kit answers it like a fired pad: the
|
|
4
|
+
// same `goHub` trip (Hub.go, the door beat, the cover).
|
|
5
|
+
//
|
|
6
|
+
// Only one waits, the latest. It is taken once the place is settled (the
|
|
7
|
+
// first hello on this connection, placed, not held, not ending, the Doors
|
|
8
|
+
// list known) with no trip under way, and let go after HOST_GO_WAIT_MS, when
|
|
9
|
+
// a trip starts first, or when the door is not one of this place's listed
|
|
10
|
+
// doors -- which a cabinet (a classic deck) never is: the host plays those
|
|
11
|
+
// itself and never sends a Go for one. Nothing is persisted.
|
|
12
|
+
|
|
13
|
+
export const HOST_GO_WAIT_MS = 60000;
|
|
14
|
+
|
|
15
|
+
export function makeHostGo({ warn = (text) => console.warn(text) } = {}) {
|
|
16
|
+
let pending = null;
|
|
17
|
+
const drop = (why) => {
|
|
18
|
+
warn(`[hub-host-go] dropped a Go to ${JSON.stringify(pending.doorId)}: ${why}`);
|
|
19
|
+
pending = null;
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
// A Go from the host. One that arrives during a trip is not queued
|
|
23
|
+
// behind it: the player is already going somewhere.
|
|
24
|
+
offer(go, { at, tripping }) {
|
|
25
|
+
if (!go || typeof go.doorId !== 'string' || !go.doorId) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (tripping) {
|
|
29
|
+
warn(`[hub-host-go] ignored a Go to ${JSON.stringify(go.doorId)}: a trip is under way`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
pending = {
|
|
33
|
+
doorId: go.doorId,
|
|
34
|
+
owner: typeof go.owner === 'string' ? go.owner : null,
|
|
35
|
+
title: typeof go.title === 'string' ? go.title : null,
|
|
36
|
+
party: Number.isInteger(go.party) && go.party > 0 ? go.party : 1,
|
|
37
|
+
at,
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
// Each frame: the trip to take now as a `hub-go` message for `goHub`, or
|
|
41
|
+
// null. `doors` is the place's Doors list (`hubDoors`: { id, title }).
|
|
42
|
+
take({ now, settled, tripping, result, doors }) {
|
|
43
|
+
if (!pending) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
if (now - pending.at > HOST_GO_WAIT_MS) {
|
|
47
|
+
drop('too old');
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
if (tripping) {
|
|
51
|
+
drop('a trip started first');
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
if (!settled || result) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const row = (doors ?? []).find((d) => d?.id === pending.doorId);
|
|
58
|
+
if (!row) {
|
|
59
|
+
drop('no such door here');
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const { doorId, owner, title, party } = pending;
|
|
63
|
+
pending = null;
|
|
64
|
+
return {
|
|
65
|
+
k: 'hub-go',
|
|
66
|
+
door: doorId,
|
|
67
|
+
key: null,
|
|
68
|
+
place: null,
|
|
69
|
+
scene: null,
|
|
70
|
+
title: title ?? row.title ?? doorId,
|
|
71
|
+
party,
|
|
72
|
+
...(owner ? { owner } : {}),
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
pending: () => (pending ? { ...pending } : null),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// The decisions behind the People list and the Back control, as plain
|
|
2
|
+
// functions of their inputs: the hub system (`systems/hub.js`) runs them on
|
|
3
|
+
// the web, and a native host runs the same ones over its own state.
|
|
4
|
+
|
|
5
|
+
// An action from the People list (`together.rows`): the pointer on someone
|
|
6
|
+
// here (Find), an invitation into the party (Invite), or Join -- beside a
|
|
7
|
+
// party member or a friend in this layer (the place moves this player), into
|
|
8
|
+
// the layer of this place a friend is in (a jump), or to the door of the game
|
|
9
|
+
// a friend is inside. Report is `reportPerson`.
|
|
10
|
+
// net the connection (`send`)
|
|
11
|
+
// person a row: { playerId, userId, username, door, owner }
|
|
12
|
+
// action the row action's id
|
|
13
|
+
// together `makeTogether()` (Find)
|
|
14
|
+
// say(text) a toast
|
|
15
|
+
// jump(net, msg) a paced jump message (`HubSystem.sendJump`)
|
|
16
|
+
// jumpTo(friend) a jump into a friend's layer by `Hub.jump` ({ userId, username })
|
|
17
|
+
// doors the town's doors (`hub.doors`), for a title
|
|
18
|
+
// Returns whether it acted on anything.
|
|
19
|
+
export function personAction(net, person, action, { together, say, jump, jumpTo, doors = [] }) {
|
|
20
|
+
if (!net || !person) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
if (action === 'find' && person.playerId) {
|
|
24
|
+
together.find(person.playerId);
|
|
25
|
+
} else if (action === 'invite' && person.playerId) {
|
|
26
|
+
net.send({ k: 'hub-party', op: 'invite', player: person.playerId });
|
|
27
|
+
say(`Invited ${person.username ?? 'them'} to your party`);
|
|
28
|
+
} else if (action === 'goto' && person.playerId) {
|
|
29
|
+
jump(net, { k: 'hub-goto', player: person.playerId });
|
|
30
|
+
} else if (action === 'door' && person.door && person.owner) {
|
|
31
|
+
// A friend at home: the place sends this player through their House
|
|
32
|
+
// door with the owner (`hub-go` carrying `owner`), ending the visit here
|
|
33
|
+
// as any door's trip does. A host that predates the owner acquires this
|
|
34
|
+
// player's own House, as the pad would have.
|
|
35
|
+
jump(net, { k: 'hub-house-visit', door: person.door, owner: person.owner });
|
|
36
|
+
say(`Going to ${person.username ?? 'your friend'}'s House`);
|
|
37
|
+
} else if (action === 'door' && person.door) {
|
|
38
|
+
jump(net, { k: 'hub-door-jump', door: person.door });
|
|
39
|
+
// A friend inside the game is said to be; someone standing at the door
|
|
40
|
+
// is simply gone to.
|
|
41
|
+
if (person.playerId === null) {
|
|
42
|
+
const title = doors.find((d) => d.id === person.door)?.title ?? 'that game';
|
|
43
|
+
say(`${person.username ?? 'Your friend'} is inside ${title}`);
|
|
44
|
+
}
|
|
45
|
+
} else if (action === 'jump' && person.userId) {
|
|
46
|
+
jumpTo({ userId: person.userId, username: person.username });
|
|
47
|
+
} else {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Reports a player to Castle (`Hub.report`), one at a time. `gate` holds
|
|
54
|
+
// `{ reporting, reportOff }`: a host that answers it is not available, or does
|
|
55
|
+
// not know the call, is asked no more. Returns the report's promise, or null
|
|
56
|
+
// when nothing was sent.
|
|
57
|
+
export function reportPerson(person, { report, gate, say }) {
|
|
58
|
+
if (gate.reporting || !person?.userId || typeof report !== 'function') {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
gate.reporting = true;
|
|
62
|
+
return Promise.resolve(report(person.userId))
|
|
63
|
+
.then((answer) => {
|
|
64
|
+
if (answer?.status === 'ok') {
|
|
65
|
+
say('Reported. Thanks.');
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
gate.reportOff = true;
|
|
69
|
+
say("Reporting isn't available here.");
|
|
70
|
+
})
|
|
71
|
+
.catch((err) => {
|
|
72
|
+
if (err?.code === 'UNKNOWN_COMMAND' || err?.code === 'CASTLE_HOST_UNAVAILABLE') {
|
|
73
|
+
gate.reportOff = true;
|
|
74
|
+
}
|
|
75
|
+
say("That report didn't go through. Try again later.");
|
|
76
|
+
})
|
|
77
|
+
.finally(() => {
|
|
78
|
+
gate.reporting = false;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Whether the kit's Back control shows, and its words. A place that reports
|
|
83
|
+
// results is a game: it always has Back. A place that does not (a town) has
|
|
84
|
+
// Back only when it was reached through a door. Behind a host trail
|
|
85
|
+
// (`hubDepth > 0`) the host draws Back, except where the kit must
|
|
86
|
+
// (`kitBackNeeded`: old Android landscape hosts draw Exit deck instead).
|
|
87
|
+
// away a classic deck's away phase: the cover is down, Back is the only control
|
|
88
|
+
// idle no trip in progress
|
|
89
|
+
// pendingEnd a place's end still settling (null when none)
|
|
90
|
+
// hostTrail reached by a hub trip (`hubDepth > 0`)
|
|
91
|
+
// place the place's manifest, or null
|
|
92
|
+
// ticket the latest return ticket, or undefined
|
|
93
|
+
// kitBack `kitBackNeeded()`
|
|
94
|
+
export function backControl({ away, idle, pendingEnd, hostTrail, place, ticket, kitBack }) {
|
|
95
|
+
const inGame = Boolean(place?.result);
|
|
96
|
+
return {
|
|
97
|
+
show: Boolean((away || (idle && pendingEnd === null)) && (hostTrail ? place !== null && kitBack : inGame || Boolean(ticket))),
|
|
98
|
+
label: ticket?.title ?? (hostTrail && kitBack ? 'Back' : 'Again'),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// What a user's Back (the kit's control or the host's) does: it first closes
|
|
103
|
+
// the action overflow, then the place menu; in a game it quits the door
|
|
104
|
+
// (`hub-door-quit`) and goes back; anywhere else it goes back.
|
|
105
|
+
// Returns 'overflow' | 'menu' | 'quit' | 'back'.
|
|
106
|
+
export function backPress({ overflowOpen, menuOpen, inGame }) {
|
|
107
|
+
if (overflowOpen) {
|
|
108
|
+
return 'overflow';
|
|
109
|
+
}
|
|
110
|
+
if (menuOpen) {
|
|
111
|
+
return 'menu';
|
|
112
|
+
}
|
|
113
|
+
return inGame ? 'quit' : 'back';
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Which way back goes once the ticket is taken: through the host
|
|
117
|
+
// (`Hub.back`) for a hub trip's ticket, or with no ticket behind a host trail;
|
|
118
|
+
// a fresh or rejoined instance with no ticket; else the ticket's own place.
|
|
119
|
+
// Returns 'host' | 'instance' | 'ticket'.
|
|
120
|
+
export function backRoute({ ticket, hubDepth }) {
|
|
121
|
+
if (ticket?.hub || (!ticket && hubDepth > 0)) {
|
|
122
|
+
return 'host';
|
|
123
|
+
}
|
|
124
|
+
return ticket ? 'ticket' : 'instance';
|
|
125
|
+
}
|