@adatechnology/game-player 0.6.4 → 0.7.0
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/README.md +24 -1
- package/dist/chunk-HYJIZT2V.js +52 -0
- package/dist/chunk-HYJIZT2V.js.map +1 -0
- package/dist/{chunk-RUFQCNZH.js → chunk-TFDLGOOE.js} +20 -53
- package/dist/chunk-TFDLGOOE.js.map +1 -0
- package/dist/hud.d.ts +127 -0
- package/dist/hud.js +370 -0
- package/dist/hud.js.map +1 -0
- package/dist/index.d.ts +23 -6
- package/dist/index.global.js +115 -38
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +65 -37
- package/dist/index.js.map +1 -1
- package/dist/{testing-CD4p4NR5.d.ts → player-BRl5ea2y.d.ts} +15 -20
- package/dist/testing.d.ts +22 -2
- package/dist/testing.js +2 -1
- package/package.json +8 -3
- package/dist/chunk-RUFQCNZH.js.map +0 -1
package/dist/hud.js
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import {
|
|
2
|
+
playerTextOf
|
|
3
|
+
} from "./chunk-HYJIZT2V.js";
|
|
4
|
+
|
|
5
|
+
// src/hud/hud-style.ts
|
|
6
|
+
var PLAYER_HUD_CSS = `
|
|
7
|
+
.gp-hud{position:absolute;inset:0;pointer-events:none;font:12px/1.35 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;color:#e8eaee;overflow:hidden;z-index:10}
|
|
8
|
+
.gp-hud *{box-sizing:border-box}
|
|
9
|
+
.gp-hud-pill{background:rgba(10,12,16,.72);padding:4px 12px;border-radius:6px;font-size:14px;font-weight:600}
|
|
10
|
+
.gp-hud-pill small{font-weight:400;opacity:.8;margin-left:8px}
|
|
11
|
+
.gp-hud-title{position:absolute;top:8px;left:8px;display:none}
|
|
12
|
+
.gp-hud-message{position:absolute;top:8px;left:50%;transform:translateX(-50%);max-width:60vw;text-align:center;color:#ffd23f;text-shadow:0 1px 2px #000;font-size:14px;font-weight:600;display:none}
|
|
13
|
+
.gp-hud-vitals{position:absolute;left:8px;bottom:8px;width:210px;background:rgba(10,12,16,.72);border-radius:6px;padding:6px 8px;display:flex;flex-direction:column;gap:4px}
|
|
14
|
+
.gp-hud-row{display:grid;grid-template-columns:62px 1fr 30px;align-items:center;gap:6px}
|
|
15
|
+
.gp-hud-row span:first-child{color:#9aa3b2}
|
|
16
|
+
.gp-hud-row output{text-align:right;font-variant-numeric:tabular-nums}
|
|
17
|
+
.gp-hud-bar{height:7px;background:#2a2e36;border-radius:4px;overflow:hidden}
|
|
18
|
+
.gp-hud-bar i{display:block;height:100%;width:0;background:#4fc3f7}
|
|
19
|
+
.gp-hud-bar.hp i{background:#66bb6a}.gp-hud-bar.warn i{background:#ffb300}.gp-hud-bar.bad i{background:#ef5350}
|
|
20
|
+
.gp-hud-status{display:flex;flex-wrap:wrap;gap:4px}
|
|
21
|
+
.gp-hud-status:empty{display:none}
|
|
22
|
+
.gp-hud-tag{border-radius:4px;padding:0 6px;background:#2a2e36}
|
|
23
|
+
.gp-hud-tag.bad{background:rgba(183,28,28,.9);color:#fff}.gp-hud-tag.warn{background:rgba(120,90,10,.9);color:#fff}
|
|
24
|
+
.gp-hud-weapon{position:absolute;right:8px;bottom:8px;display:none}
|
|
25
|
+
.gp-hud-cross{position:absolute;left:50%;top:50%;width:18px;height:18px;margin:-9px 0 0 -9px;display:none}
|
|
26
|
+
.gp-hud-cross:before,.gp-hud-cross:after{content:"";position:absolute;background:#fff;opacity:.85;box-shadow:0 0 2px #000}
|
|
27
|
+
.gp-hud-cross:before{left:8px;top:0;width:2px;height:18px}.gp-hud-cross:after{top:8px;left:0;height:2px;width:18px}
|
|
28
|
+
.gp-hud-cross i{position:absolute;left:6px;top:6px;width:6px;height:6px;background:#0b0c0e;border-radius:50%;z-index:1}
|
|
29
|
+
.gp-death{position:absolute;inset:0;display:none;align-items:flex-end;justify-content:center;padding-bottom:12vh;background:linear-gradient(transparent 45%,rgba(0,0,0,.55));font:13px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;color:#e8eaee;z-index:20}
|
|
30
|
+
.gp-death.open{display:flex}
|
|
31
|
+
.gp-death-panel{min-width:min(320px,90vw);max-width:90vw;background:rgba(12,14,19,.92);border:1px solid #2c313b;border-radius:8px;padding:18px 22px;text-align:center;box-shadow:0 4px 18px rgba(0,0,0,.5)}
|
|
32
|
+
.gp-death-panel h2{margin:0 0 6px;font-size:22px;color:#ef5350}
|
|
33
|
+
.gp-death-panel p{margin:2px 0;color:#9aa3b2}
|
|
34
|
+
.gp-death-actions{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;margin-top:14px}
|
|
35
|
+
.gp-death-actions button{background:#232831;border:1px solid #3a404c;color:#e8eaee;border-radius:5px;padding:6px 14px;cursor:pointer;font:inherit}
|
|
36
|
+
.gp-death-actions button:hover,.gp-death-actions button:focus-visible{background:#2d3440;border-color:#ffd23f}
|
|
37
|
+
.gp-death-actions button:disabled{opacity:.5;cursor:default}
|
|
38
|
+
.gp-death-actions kbd{background:#2a2e36;border:1px solid #4a505c;border-radius:3px;padding:0 4px;font:inherit;font-weight:700;margin-left:6px}
|
|
39
|
+
`;
|
|
40
|
+
var STYLE_ID = "gp-hud-style";
|
|
41
|
+
function ensurePlayerHudStyle() {
|
|
42
|
+
if (document.getElementById(STYLE_ID)) return;
|
|
43
|
+
const style = document.createElement("style");
|
|
44
|
+
style.id = STYLE_ID;
|
|
45
|
+
style.textContent = PLAYER_HUD_CSS;
|
|
46
|
+
document.head.appendChild(style);
|
|
47
|
+
}
|
|
48
|
+
function positionContainer(container) {
|
|
49
|
+
const position = getComputedStyle(container).position;
|
|
50
|
+
if (position && position !== "static") return () => void 0;
|
|
51
|
+
const before = container.style.position;
|
|
52
|
+
container.style.position = "relative";
|
|
53
|
+
return () => {
|
|
54
|
+
if (container.style.position === "relative") container.style.position = before;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/hud/hud-text.ts
|
|
59
|
+
var PT_BR = {
|
|
60
|
+
health: "Vida",
|
|
61
|
+
stamina: "F\xF4lego",
|
|
62
|
+
bleeding: "Sangrando",
|
|
63
|
+
wounds: "Ferimentos",
|
|
64
|
+
infected: "Infectado",
|
|
65
|
+
stageMalaise: "mal-estar",
|
|
66
|
+
stageFever: "febre",
|
|
67
|
+
stageDelirium: "del\xEDrio",
|
|
68
|
+
woundScratch: "arranh\xE3o",
|
|
69
|
+
woundLaceration: "corte",
|
|
70
|
+
woundBite: "mordida",
|
|
71
|
+
died: "Voc\xEA morreu",
|
|
72
|
+
survived: "Sobreviveu {time}",
|
|
73
|
+
restart: "Reiniciar cena",
|
|
74
|
+
backToStart: "Voltar ao in\xEDcio"
|
|
75
|
+
};
|
|
76
|
+
var EN = {
|
|
77
|
+
health: "Health",
|
|
78
|
+
stamina: "Stamina",
|
|
79
|
+
bleeding: "Bleeding",
|
|
80
|
+
wounds: "Wounds",
|
|
81
|
+
infected: "Infected",
|
|
82
|
+
stageMalaise: "malaise",
|
|
83
|
+
stageFever: "fever",
|
|
84
|
+
stageDelirium: "delirium",
|
|
85
|
+
woundScratch: "scratch",
|
|
86
|
+
woundLaceration: "laceration",
|
|
87
|
+
woundBite: "bite",
|
|
88
|
+
died: "You died",
|
|
89
|
+
survived: "Survived {time}",
|
|
90
|
+
restart: "Restart scene",
|
|
91
|
+
backToStart: "Back to the start"
|
|
92
|
+
};
|
|
93
|
+
var PLAYER_HUD_TEXT = { en: EN, "pt-BR": PT_BR };
|
|
94
|
+
var playerHudTextOf = (locale = "pt-BR") => locale.toLowerCase().startsWith("en") ? EN : PT_BR;
|
|
95
|
+
var WOUND_KEY = { scratch: "woundScratch", laceration: "woundLaceration", bite: "woundBite" };
|
|
96
|
+
var STAGE_KEY = { malaise: "stageMalaise", fever: "stageFever", delirium: "stageDelirium" };
|
|
97
|
+
var woundTextOf = (text, kind) => {
|
|
98
|
+
const key = WOUND_KEY[kind];
|
|
99
|
+
return key ? text[key] : kind;
|
|
100
|
+
};
|
|
101
|
+
var stageTextOf = (text, stage) => {
|
|
102
|
+
const key = STAGE_KEY[stage];
|
|
103
|
+
return key ? text[key] : "";
|
|
104
|
+
};
|
|
105
|
+
var formatSurvived = (seconds) => {
|
|
106
|
+
const whole = Math.max(0, Math.floor(seconds));
|
|
107
|
+
const hours = Math.floor(whole / 3600);
|
|
108
|
+
const minutes = Math.floor(whole % 3600 / 60);
|
|
109
|
+
const rest = String(whole % 60).padStart(2, "0");
|
|
110
|
+
return hours > 0 ? `${hours}:${String(minutes).padStart(2, "0")}:${rest}` : `${minutes}:${rest}`;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// src/hud/player-hud.ts
|
|
114
|
+
var LOW_SHARE = 0.25;
|
|
115
|
+
var WARN_SHARE = 0.5;
|
|
116
|
+
var MS_PER_SECOND = 1e3;
|
|
117
|
+
var element = (tag, className, text) => {
|
|
118
|
+
const node = document.createElement(tag);
|
|
119
|
+
if (className) node.className = className;
|
|
120
|
+
if (text !== void 0) node.textContent = text;
|
|
121
|
+
return node;
|
|
122
|
+
};
|
|
123
|
+
function createGauge(label, tone) {
|
|
124
|
+
const row = element("div", "gp-hud-row");
|
|
125
|
+
const bar = element("div", tone === "hp" ? "gp-hud-bar hp" : "gp-hud-bar");
|
|
126
|
+
const fill = element("i");
|
|
127
|
+
const value = element("output");
|
|
128
|
+
bar.appendChild(fill);
|
|
129
|
+
row.append(element("span", void 0, label), bar, value);
|
|
130
|
+
let lastValue = Number.NaN;
|
|
131
|
+
let lastPercent = Number.NaN;
|
|
132
|
+
return {
|
|
133
|
+
row,
|
|
134
|
+
set(current, max) {
|
|
135
|
+
const share = max > 0 ? Math.max(0, Math.min(1, current / max)) : 0;
|
|
136
|
+
const shownValue = Math.max(0, Math.round(current));
|
|
137
|
+
const percent = Math.round(share * 100);
|
|
138
|
+
if (shownValue === lastValue && percent === lastPercent) return;
|
|
139
|
+
lastValue = shownValue;
|
|
140
|
+
lastPercent = percent;
|
|
141
|
+
fill.style.width = `${percent}%`;
|
|
142
|
+
value.textContent = String(shownValue);
|
|
143
|
+
if (tone === "hp") bar.className = share <= LOW_SHARE ? "gp-hud-bar bad" : share <= WARN_SHARE ? "gp-hud-bar warn" : "gp-hud-bar hp";
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function statusTags(view, text) {
|
|
148
|
+
const tags = [];
|
|
149
|
+
if (view.bleeding) tags.push({ label: text.bleeding, tone: "bad" });
|
|
150
|
+
if (view.infection !== "none") tags.push({ label: `${text.infected} \xB7 ${stageTextOf(text, view.infection)}`, tone: "warn" });
|
|
151
|
+
if (view.wounds.length > 0) {
|
|
152
|
+
const counts = /* @__PURE__ */ new Map();
|
|
153
|
+
for (const kind of view.wounds) counts.set(kind, (counts.get(kind) ?? 0) + 1);
|
|
154
|
+
const list = [...counts].map(([kind, count]) => count > 1 ? `${count}\xD7 ${woundTextOf(text, kind)}` : woundTextOf(text, kind)).join(", ");
|
|
155
|
+
tags.push({ label: `${text.wounds}: ${list}`, tone: "" });
|
|
156
|
+
}
|
|
157
|
+
return tags;
|
|
158
|
+
}
|
|
159
|
+
function createPlayerHud({ container, locale = "pt-BR", title }) {
|
|
160
|
+
const text = playerHudTextOf(locale);
|
|
161
|
+
ensurePlayerHudStyle();
|
|
162
|
+
const restorePosition = positionContainer(container);
|
|
163
|
+
const root = element("div", "gp-hud");
|
|
164
|
+
root.dataset.hud = "player";
|
|
165
|
+
const titleBox = element("div", "gp-hud-pill gp-hud-title");
|
|
166
|
+
const messageBox = element("div", "gp-hud-message");
|
|
167
|
+
const vitals = element("div", "gp-hud-vitals");
|
|
168
|
+
const health = createGauge(text.health, "hp");
|
|
169
|
+
const stamina = createGauge(text.stamina, "stamina");
|
|
170
|
+
const status = element("div", "gp-hud-status");
|
|
171
|
+
vitals.append(health.row, stamina.row, status);
|
|
172
|
+
const weaponBox = element("div", "gp-hud-pill gp-hud-weapon");
|
|
173
|
+
const cross = element("div", "gp-hud-cross");
|
|
174
|
+
cross.appendChild(element("i"));
|
|
175
|
+
root.append(titleBox, messageBox, vitals, weaponBox, cross);
|
|
176
|
+
container.appendChild(root);
|
|
177
|
+
let lastBleeding = null;
|
|
178
|
+
let lastInfection = "";
|
|
179
|
+
let lastWounds = null;
|
|
180
|
+
let lastWoundCount = -1;
|
|
181
|
+
let lastAlive = null;
|
|
182
|
+
let lastView = null;
|
|
183
|
+
let messageTimer = null;
|
|
184
|
+
const setTitle = (next) => {
|
|
185
|
+
titleBox.textContent = next ?? "";
|
|
186
|
+
titleBox.style.display = next ? "block" : "none";
|
|
187
|
+
};
|
|
188
|
+
setTitle(title ?? null);
|
|
189
|
+
return {
|
|
190
|
+
update(view) {
|
|
191
|
+
if (view.alive !== lastAlive) {
|
|
192
|
+
lastAlive = view.alive;
|
|
193
|
+
vitals.style.display = view.alive ? "flex" : "none";
|
|
194
|
+
}
|
|
195
|
+
health.set(view.health, view.maxHealth);
|
|
196
|
+
stamina.set(view.stamina, view.maxStamina);
|
|
197
|
+
if (view.bleeding === lastBleeding && view.infection === lastInfection && view.wounds === lastWounds && view.wounds.length === lastWoundCount) return;
|
|
198
|
+
lastBleeding = view.bleeding;
|
|
199
|
+
lastInfection = view.infection;
|
|
200
|
+
lastWounds = view.wounds;
|
|
201
|
+
lastWoundCount = view.wounds.length;
|
|
202
|
+
const tags = statusTags(view, text);
|
|
203
|
+
status.replaceChildren(...tags.map((tag) => element("span", tag.tone ? `gp-hud-tag ${tag.tone}` : "gp-hud-tag", tag.label)));
|
|
204
|
+
},
|
|
205
|
+
setTitle,
|
|
206
|
+
setWeapon(weapon) {
|
|
207
|
+
weaponBox.replaceChildren();
|
|
208
|
+
weaponBox.style.display = weapon ? "block" : "none";
|
|
209
|
+
if (!weapon) return;
|
|
210
|
+
weaponBox.append(document.createTextNode(weapon.name));
|
|
211
|
+
if (weapon.ammo) weaponBox.append(element("small", void 0, weapon.ammo));
|
|
212
|
+
},
|
|
213
|
+
setView(view) {
|
|
214
|
+
if (view === lastView) return;
|
|
215
|
+
lastView = view;
|
|
216
|
+
cross.style.display = view === "first" ? "block" : "none";
|
|
217
|
+
},
|
|
218
|
+
message(line, seconds) {
|
|
219
|
+
messageBox.textContent = line;
|
|
220
|
+
messageBox.style.display = "block";
|
|
221
|
+
if (messageTimer) clearTimeout(messageTimer);
|
|
222
|
+
messageTimer = setTimeout(() => {
|
|
223
|
+
messageTimer = null;
|
|
224
|
+
messageBox.style.display = "none";
|
|
225
|
+
}, seconds * MS_PER_SECOND);
|
|
226
|
+
},
|
|
227
|
+
dispose() {
|
|
228
|
+
if (messageTimer) clearTimeout(messageTimer);
|
|
229
|
+
root.remove();
|
|
230
|
+
restorePosition();
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// src/hud/death-screen.ts
|
|
236
|
+
var DEATH_SCREEN_DELAY_SECONDS = 1.5;
|
|
237
|
+
var RESTART_KEY = "KeyR";
|
|
238
|
+
var nextHeadingId = 0;
|
|
239
|
+
function createDeathScreen({ container, locale = "pt-BR", delaySeconds = DEATH_SCREEN_DELAY_SECONDS, onRestart, onBackToStart, returnFocus }) {
|
|
240
|
+
const text = playerHudTextOf(locale);
|
|
241
|
+
ensurePlayerHudStyle();
|
|
242
|
+
const restorePosition = positionContainer(container);
|
|
243
|
+
const root = document.createElement("div");
|
|
244
|
+
root.className = "gp-death";
|
|
245
|
+
root.setAttribute("role", "dialog");
|
|
246
|
+
root.setAttribute("aria-modal", "true");
|
|
247
|
+
const panel = document.createElement("div");
|
|
248
|
+
panel.className = "gp-death-panel";
|
|
249
|
+
const heading = document.createElement("h2");
|
|
250
|
+
heading.id = `gp-death-title-${nextHeadingId++}`;
|
|
251
|
+
heading.textContent = text.died;
|
|
252
|
+
root.setAttribute("aria-labelledby", heading.id);
|
|
253
|
+
const cause = document.createElement("p");
|
|
254
|
+
const survived = document.createElement("p");
|
|
255
|
+
const actions = document.createElement("div");
|
|
256
|
+
actions.className = "gp-death-actions";
|
|
257
|
+
const button = (label, key) => {
|
|
258
|
+
const node = document.createElement("button");
|
|
259
|
+
node.type = "button";
|
|
260
|
+
node.append(document.createTextNode(label));
|
|
261
|
+
if (key) {
|
|
262
|
+
const hint = document.createElement("kbd");
|
|
263
|
+
hint.textContent = key;
|
|
264
|
+
node.appendChild(hint);
|
|
265
|
+
}
|
|
266
|
+
actions.appendChild(node);
|
|
267
|
+
return node;
|
|
268
|
+
};
|
|
269
|
+
const restartButton = button(text.restart, "R");
|
|
270
|
+
const backButton = button(text.backToStart, null);
|
|
271
|
+
panel.append(heading, cause, survived, actions);
|
|
272
|
+
root.appendChild(panel);
|
|
273
|
+
container.appendChild(root);
|
|
274
|
+
let isOpen = false;
|
|
275
|
+
let isSpent = false;
|
|
276
|
+
let focusBefore = null;
|
|
277
|
+
const setEnabled = (enabled) => {
|
|
278
|
+
restartButton.disabled = !enabled;
|
|
279
|
+
backButton.disabled = !enabled;
|
|
280
|
+
};
|
|
281
|
+
const choose = (hook) => {
|
|
282
|
+
if (!isOpen || isSpent) return;
|
|
283
|
+
isSpent = true;
|
|
284
|
+
setEnabled(false);
|
|
285
|
+
try {
|
|
286
|
+
hook();
|
|
287
|
+
} catch (error) {
|
|
288
|
+
isSpent = false;
|
|
289
|
+
setEnabled(true);
|
|
290
|
+
throw error;
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
restartButton.onclick = () => choose(onRestart);
|
|
294
|
+
backButton.onclick = () => choose(onBackToStart);
|
|
295
|
+
const onKeyDown = (event) => {
|
|
296
|
+
if (!isOpen || event.code !== RESTART_KEY) return;
|
|
297
|
+
event.preventDefault();
|
|
298
|
+
choose(onRestart);
|
|
299
|
+
};
|
|
300
|
+
window.addEventListener("keydown", onKeyDown);
|
|
301
|
+
const open = (state) => {
|
|
302
|
+
isOpen = true;
|
|
303
|
+
isSpent = false;
|
|
304
|
+
restartButton.disabled = false;
|
|
305
|
+
backButton.disabled = false;
|
|
306
|
+
cause.textContent = state.cause ? playerTextOf(state.cause, locale) : "";
|
|
307
|
+
cause.style.display = state.cause ? "block" : "none";
|
|
308
|
+
survived.textContent = text.survived.replace("{time}", formatSurvived(state.survivedSeconds));
|
|
309
|
+
root.classList.add("open");
|
|
310
|
+
if (document.pointerLockElement) document.exitPointerLock();
|
|
311
|
+
focusBefore = document.activeElement;
|
|
312
|
+
restartButton.focus();
|
|
313
|
+
};
|
|
314
|
+
const close = () => {
|
|
315
|
+
isOpen = false;
|
|
316
|
+
if (root.contains(document.activeElement) && document.activeElement instanceof HTMLElement) document.activeElement.blur();
|
|
317
|
+
root.classList.remove("open");
|
|
318
|
+
const target = returnFocus ?? (focusBefore instanceof HTMLElement && focusBefore.isConnected && focusBefore !== document.body ? focusBefore : null);
|
|
319
|
+
focusBefore = null;
|
|
320
|
+
target?.focus({ preventScroll: true });
|
|
321
|
+
};
|
|
322
|
+
return {
|
|
323
|
+
update(state) {
|
|
324
|
+
if (state.alive) {
|
|
325
|
+
if (isOpen) close();
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
if (!isOpen && state.deathTime >= delaySeconds) open(state);
|
|
329
|
+
},
|
|
330
|
+
get isOpen() {
|
|
331
|
+
return isOpen;
|
|
332
|
+
},
|
|
333
|
+
dispose() {
|
|
334
|
+
window.removeEventListener("keydown", onKeyDown);
|
|
335
|
+
root.remove();
|
|
336
|
+
restorePosition();
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// src/hud/hud-view.ts
|
|
342
|
+
var playerHudViewOf = (player) => writePlayerHudView(player, createPlayerHudView());
|
|
343
|
+
var createPlayerHudView = () => ({ alive: true, health: 0, maxHealth: 0, stamina: 0, maxStamina: 0, bleeding: false, wounds: [], infection: "none" });
|
|
344
|
+
function writePlayerHudView(player, view) {
|
|
345
|
+
const { state, derived } = player;
|
|
346
|
+
view.alive = state.alive;
|
|
347
|
+
view.health = state.health;
|
|
348
|
+
view.maxHealth = derived.maxHealth;
|
|
349
|
+
view.stamina = state.stamina;
|
|
350
|
+
view.maxStamina = derived.maxStamina;
|
|
351
|
+
view.bleeding = state.bleeding > 0;
|
|
352
|
+
view.wounds = state.wounds;
|
|
353
|
+
view.infection = state.infected ? player.stage() : "none";
|
|
354
|
+
return view;
|
|
355
|
+
}
|
|
356
|
+
export {
|
|
357
|
+
DEATH_SCREEN_DELAY_SECONDS,
|
|
358
|
+
PLAYER_HUD_CSS,
|
|
359
|
+
PLAYER_HUD_TEXT,
|
|
360
|
+
createDeathScreen,
|
|
361
|
+
createPlayerHud,
|
|
362
|
+
createPlayerHudView,
|
|
363
|
+
formatSurvived,
|
|
364
|
+
playerHudTextOf,
|
|
365
|
+
playerHudViewOf,
|
|
366
|
+
stageTextOf,
|
|
367
|
+
woundTextOf,
|
|
368
|
+
writePlayerHudView
|
|
369
|
+
};
|
|
370
|
+
//# sourceMappingURL=hud.js.map
|
package/dist/hud.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hud/hud-style.ts","../src/hud/hud-text.ts","../src/hud/player-hud.ts","../src/hud/death-screen.ts","../src/hud/hud-view.ts"],"sourcesContent":["// The death panel sits in the lower third: the death camera keeps the body at the centre of the view.\n// The same tokens as the test room's HUD (panel rgba(10,12,16,.72), accent #ffd23f, bars #2a2e36 / #66bb6a / #ffb300 / #ef5350 / #4fc3f7), so a game and its room read alike.\nexport const PLAYER_HUD_CSS = `\n.gp-hud{position:absolute;inset:0;pointer-events:none;font:12px/1.35 system-ui,-apple-system,\"Segoe UI\",Roboto,sans-serif;color:#e8eaee;overflow:hidden;z-index:10}\n.gp-hud *{box-sizing:border-box}\n.gp-hud-pill{background:rgba(10,12,16,.72);padding:4px 12px;border-radius:6px;font-size:14px;font-weight:600}\n.gp-hud-pill small{font-weight:400;opacity:.8;margin-left:8px}\n.gp-hud-title{position:absolute;top:8px;left:8px;display:none}\n.gp-hud-message{position:absolute;top:8px;left:50%;transform:translateX(-50%);max-width:60vw;text-align:center;color:#ffd23f;text-shadow:0 1px 2px #000;font-size:14px;font-weight:600;display:none}\n.gp-hud-vitals{position:absolute;left:8px;bottom:8px;width:210px;background:rgba(10,12,16,.72);border-radius:6px;padding:6px 8px;display:flex;flex-direction:column;gap:4px}\n.gp-hud-row{display:grid;grid-template-columns:62px 1fr 30px;align-items:center;gap:6px}\n.gp-hud-row span:first-child{color:#9aa3b2}\n.gp-hud-row output{text-align:right;font-variant-numeric:tabular-nums}\n.gp-hud-bar{height:7px;background:#2a2e36;border-radius:4px;overflow:hidden}\n.gp-hud-bar i{display:block;height:100%;width:0;background:#4fc3f7}\n.gp-hud-bar.hp i{background:#66bb6a}.gp-hud-bar.warn i{background:#ffb300}.gp-hud-bar.bad i{background:#ef5350}\n.gp-hud-status{display:flex;flex-wrap:wrap;gap:4px}\n.gp-hud-status:empty{display:none}\n.gp-hud-tag{border-radius:4px;padding:0 6px;background:#2a2e36}\n.gp-hud-tag.bad{background:rgba(183,28,28,.9);color:#fff}.gp-hud-tag.warn{background:rgba(120,90,10,.9);color:#fff}\n.gp-hud-weapon{position:absolute;right:8px;bottom:8px;display:none}\n.gp-hud-cross{position:absolute;left:50%;top:50%;width:18px;height:18px;margin:-9px 0 0 -9px;display:none}\n.gp-hud-cross:before,.gp-hud-cross:after{content:\"\";position:absolute;background:#fff;opacity:.85;box-shadow:0 0 2px #000}\n.gp-hud-cross:before{left:8px;top:0;width:2px;height:18px}.gp-hud-cross:after{top:8px;left:0;height:2px;width:18px}\n.gp-hud-cross i{position:absolute;left:6px;top:6px;width:6px;height:6px;background:#0b0c0e;border-radius:50%;z-index:1}\n.gp-death{position:absolute;inset:0;display:none;align-items:flex-end;justify-content:center;padding-bottom:12vh;background:linear-gradient(transparent 45%,rgba(0,0,0,.55));font:13px/1.4 system-ui,-apple-system,\"Segoe UI\",Roboto,sans-serif;color:#e8eaee;z-index:20}\n.gp-death.open{display:flex}\n.gp-death-panel{min-width:min(320px,90vw);max-width:90vw;background:rgba(12,14,19,.92);border:1px solid #2c313b;border-radius:8px;padding:18px 22px;text-align:center;box-shadow:0 4px 18px rgba(0,0,0,.5)}\n.gp-death-panel h2{margin:0 0 6px;font-size:22px;color:#ef5350}\n.gp-death-panel p{margin:2px 0;color:#9aa3b2}\n.gp-death-actions{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;margin-top:14px}\n.gp-death-actions button{background:#232831;border:1px solid #3a404c;color:#e8eaee;border-radius:5px;padding:6px 14px;cursor:pointer;font:inherit}\n.gp-death-actions button:hover,.gp-death-actions button:focus-visible{background:#2d3440;border-color:#ffd23f}\n.gp-death-actions button:disabled{opacity:.5;cursor:default}\n.gp-death-actions kbd{background:#2a2e36;border:1px solid #4a505c;border-radius:3px;padding:0 4px;font:inherit;font-weight:700;margin-left:6px}\n`\n\nconst STYLE_ID = 'gp-hud-style'\n\n/** Puts the HUD's style in the document once (the HUD and the death screen share it). */\nexport function ensurePlayerHudStyle(): void {\n if (document.getElementById(STYLE_ID)) return\n const style = document.createElement('style')\n style.id = STYLE_ID\n style.textContent = PLAYER_HUD_CSS\n document.head.appendChild(style)\n}\n\n/** Makes `container` the positioning box of an overlay laid over it; the answer puts back what it changed. */\nexport function positionContainer(container: HTMLElement): () => void {\n const position = getComputedStyle(container).position\n if (position && position !== 'static') return () => undefined\n const before = container.style.position\n container.style.position = 'relative'\n return () => {\n if (container.style.position === 'relative') container.style.position = before\n }\n}\n","/** The words of the player's HUD and of the death screen, in a locale. */\nexport type PlayerHudText = {\n readonly health: string\n readonly stamina: string\n readonly bleeding: string\n readonly wounds: string\n readonly infected: string\n readonly stageMalaise: string\n readonly stageFever: string\n readonly stageDelirium: string\n readonly woundScratch: string\n readonly woundLaceration: string\n readonly woundBite: string\n readonly died: string\n readonly survived: string\n readonly restart: string\n readonly backToStart: string\n}\n\nconst PT_BR: PlayerHudText = {\n health: 'Vida',\n stamina: 'Fôlego',\n bleeding: 'Sangrando',\n wounds: 'Ferimentos',\n infected: 'Infectado',\n stageMalaise: 'mal-estar',\n stageFever: 'febre',\n stageDelirium: 'delírio',\n woundScratch: 'arranhão',\n woundLaceration: 'corte',\n woundBite: 'mordida',\n died: 'Você morreu',\n survived: 'Sobreviveu {time}',\n restart: 'Reiniciar cena',\n backToStart: 'Voltar ao início',\n}\n\nconst EN: PlayerHudText = {\n health: 'Health',\n stamina: 'Stamina',\n bleeding: 'Bleeding',\n wounds: 'Wounds',\n infected: 'Infected',\n stageMalaise: 'malaise',\n stageFever: 'fever',\n stageDelirium: 'delirium',\n woundScratch: 'scratch',\n woundLaceration: 'laceration',\n woundBite: 'bite',\n died: 'You died',\n survived: 'Survived {time}',\n restart: 'Restart scene',\n backToStart: 'Back to the start',\n}\n\nexport const PLAYER_HUD_TEXT: Readonly<Record<'en' | 'pt-BR', PlayerHudText>> = { en: EN, 'pt-BR': PT_BR }\n\n/** The HUD's words for a locale (`pt-BR` or `en`, the language part is enough; anything else is `pt-BR`). */\nexport const playerHudTextOf = (locale = 'pt-BR'): PlayerHudText => (locale.toLowerCase().startsWith('en') ? EN : PT_BR)\n\nconst WOUND_KEY: Readonly<Record<string, keyof PlayerHudText>> = { scratch: 'woundScratch', laceration: 'woundLaceration', bite: 'woundBite' }\nconst STAGE_KEY: Readonly<Record<string, keyof PlayerHudText>> = { malaise: 'stageMalaise', fever: 'stageFever', delirium: 'stageDelirium' }\n\n/** A wound kind in words; a kind the table does not know (a game's own) comes back as it is. */\nexport const woundTextOf = (text: PlayerHudText, kind: string): string => {\n const key = WOUND_KEY[kind]\n return key ? text[key] : kind\n}\n\n/** An infection stage in words (`none` gives an empty text). */\nexport const stageTextOf = (text: PlayerHudText, stage: string): string => {\n const key = STAGE_KEY[stage]\n return key ? text[key] : ''\n}\n\n/** Seconds as `m:ss` (or `h:mm:ss` past the hour). */\nexport const formatSurvived = (seconds: number): string => {\n const whole = Math.max(0, Math.floor(seconds))\n const hours = Math.floor(whole / 3600)\n const minutes = Math.floor((whole % 3600) / 60)\n const rest = String(whole % 60).padStart(2, '0')\n return hours > 0 ? `${hours}:${String(minutes).padStart(2, '0')}:${rest}` : `${minutes}:${rest}`\n}\n","import { ensurePlayerHudStyle, positionContainer } from './hud-style'\nimport { playerHudTextOf, stageTextOf, woundTextOf } from './hud-text'\nimport type { PlayerHudText } from './hud-text'\nimport type { PlayerHudView } from './hud-view'\n\n/** The weapon in the hand: its name and, for a gun, the rounds as the game writes them (`12 / 48`). */\nexport type PlayerHudWeapon = { readonly name: string; readonly ammo?: string }\n\nexport type PlayerHudOptions = {\n /** The box the HUD is laid over (the game's canvas box). */\n readonly container: HTMLElement\n /** `pt-BR` (default) or `en`. */\n readonly locale?: string\n /** A name shown at the top left (the level, the scenario); absent, nothing there. */\n readonly title?: string\n}\n\nexport type PlayerHud = {\n /** The body's numbers now (call it every frame; it writes the DOM only when a shown value changes). */\n update(view: PlayerHudView): void\n setTitle(title: string | null): void\n /** The weapon in the hand, or null when the hand is empty. */\n setWeapon(weapon: PlayerHudWeapon | null): void\n /** The crosshair is drawn in the first person only (the third person aims with the body). */\n setView(view: 'first' | 'third'): void\n /** A line at the top centre for `seconds` (the body's `message` events, in `playerTextOf` words). */\n message(text: string, seconds: number): void\n dispose(): void\n}\n\nconst LOW_SHARE = 0.25\nconst WARN_SHARE = 0.5\nconst MS_PER_SECOND = 1000\n\nconst element = <K extends keyof HTMLElementTagNameMap>(tag: K, className?: string, text?: string): HTMLElementTagNameMap[K] => {\n const node = document.createElement(tag)\n if (className) node.className = className\n if (text !== undefined) node.textContent = text\n return node\n}\n\ntype Gauge = { readonly row: HTMLElement; set(value: number, max: number): void }\n\nfunction createGauge(label: string, tone: 'hp' | 'stamina'): Gauge {\n const row = element('div', 'gp-hud-row')\n const bar = element('div', tone === 'hp' ? 'gp-hud-bar hp' : 'gp-hud-bar')\n const fill = element('i')\n const value = element('output')\n bar.appendChild(fill)\n row.append(element('span', undefined, label), bar, value)\n let lastValue = Number.NaN\n let lastPercent = Number.NaN\n return {\n row,\n set(current, max) {\n const share = max > 0 ? Math.max(0, Math.min(1, current / max)) : 0\n const shownValue = Math.max(0, Math.round(current))\n const percent = Math.round(share * 100)\n if (shownValue === lastValue && percent === lastPercent) return\n lastValue = shownValue\n lastPercent = percent\n fill.style.width = `${percent}%`\n value.textContent = String(shownValue)\n if (tone === 'hp') bar.className = share <= LOW_SHARE ? 'gp-hud-bar bad' : share <= WARN_SHARE ? 'gp-hud-bar warn' : 'gp-hud-bar hp'\n },\n }\n}\n\nfunction statusTags(view: PlayerHudView, text: PlayerHudText): Array<{ readonly label: string; readonly tone: 'bad' | 'warn' | '' }> {\n const tags: Array<{ label: string; tone: 'bad' | 'warn' | '' }> = []\n if (view.bleeding) tags.push({ label: text.bleeding, tone: 'bad' })\n if (view.infection !== 'none') tags.push({ label: `${text.infected} · ${stageTextOf(text, view.infection)}`, tone: 'warn' })\n if (view.wounds.length > 0) {\n const counts = new Map<string, number>()\n for (const kind of view.wounds) counts.set(kind, (counts.get(kind) ?? 0) + 1)\n const list = [...counts].map(([kind, count]) => (count > 1 ? `${count}× ${woundTextOf(text, kind)}` : woundTextOf(text, kind))).join(', ')\n tags.push({ label: `${text.wounds}: ${list}`, tone: '' })\n }\n return tags\n}\n\n/**\n * The player's HUD over the game's view (DOM, no three.js): the health and stamina bars with the bleeding, the infection and the wounds under them at the bottom left, the\n * weapon and its rounds at the bottom right, a name at the top left, the body's messages at the top centre and the crosshair in the first person. Small boxes at the edges:\n * the view stays clear, and nothing takes the mouse.\n */\nexport function createPlayerHud({ container, locale = 'pt-BR', title }: PlayerHudOptions): PlayerHud {\n const text = playerHudTextOf(locale)\n ensurePlayerHudStyle()\n const restorePosition = positionContainer(container)\n const root = element('div', 'gp-hud')\n root.dataset.hud = 'player'\n const titleBox = element('div', 'gp-hud-pill gp-hud-title')\n const messageBox = element('div', 'gp-hud-message')\n const vitals = element('div', 'gp-hud-vitals')\n const health = createGauge(text.health, 'hp')\n const stamina = createGauge(text.stamina, 'stamina')\n const status = element('div', 'gp-hud-status')\n vitals.append(health.row, stamina.row, status)\n const weaponBox = element('div', 'gp-hud-pill gp-hud-weapon')\n const cross = element('div', 'gp-hud-cross')\n cross.appendChild(element('i'))\n root.append(titleBox, messageBox, vitals, weaponBox, cross)\n container.appendChild(root)\n\n // the status line is rebuilt only when one of these scalars moves: the frame allocates nothing\n let lastBleeding: boolean | null = null\n let lastInfection = ''\n let lastWounds: readonly string[] | null = null\n let lastWoundCount = -1\n let lastAlive: boolean | null = null\n let lastView: 'first' | 'third' | null = null\n let messageTimer: ReturnType<typeof setTimeout> | null = null\n const setTitle = (next: string | null): void => {\n titleBox.textContent = next ?? ''\n titleBox.style.display = next ? 'block' : 'none'\n }\n setTitle(title ?? null)\n\n return {\n update(view) {\n if (view.alive !== lastAlive) {\n lastAlive = view.alive\n vitals.style.display = view.alive ? 'flex' : 'none'\n }\n health.set(view.health, view.maxHealth)\n stamina.set(view.stamina, view.maxStamina)\n if (view.bleeding === lastBleeding && view.infection === lastInfection && view.wounds === lastWounds && view.wounds.length === lastWoundCount) return\n lastBleeding = view.bleeding\n lastInfection = view.infection\n lastWounds = view.wounds\n lastWoundCount = view.wounds.length\n const tags = statusTags(view, text)\n status.replaceChildren(...tags.map((tag) => element('span', tag.tone ? `gp-hud-tag ${tag.tone}` : 'gp-hud-tag', tag.label)))\n },\n setTitle,\n setWeapon(weapon) {\n weaponBox.replaceChildren()\n weaponBox.style.display = weapon ? 'block' : 'none'\n if (!weapon) return\n weaponBox.append(document.createTextNode(weapon.name))\n if (weapon.ammo) weaponBox.append(element('small', undefined, weapon.ammo))\n },\n setView(view) {\n if (view === lastView) return\n lastView = view\n cross.style.display = view === 'first' ? 'block' : 'none'\n },\n message(line, seconds) {\n messageBox.textContent = line\n messageBox.style.display = 'block'\n if (messageTimer) clearTimeout(messageTimer)\n messageTimer = setTimeout(() => {\n messageTimer = null\n messageBox.style.display = 'none'\n }, seconds * MS_PER_SECOND)\n },\n dispose() {\n if (messageTimer) clearTimeout(messageTimer)\n root.remove()\n restorePosition()\n },\n }\n}\n","import { playerTextOf } from '../locales'\nimport { ensurePlayerHudStyle, positionContainer } from './hud-style'\nimport { formatSurvived, playerHudTextOf } from './hud-text'\n\nexport type DeathScreenOptions = {\n readonly container: HTMLElement\n /** `pt-BR` (default) or `en`. */\n readonly locale?: string\n /** Seconds after the death before the panel opens: the death camera settles on the body first. Default 1.5. */\n readonly delaySeconds?: number\n /** Rebuilds the scene from its seed. Enter and R press it too. */\n readonly onRestart: () => void\n /** Puts the body back at the start with the world as it is. */\n readonly onBackToStart: () => void\n /** What takes the focus back when the panel shuts (the game's canvas); absent, what had it before the panel opened. */\n readonly returnFocus?: HTMLElement\n}\n\n/** The body as the death screen reads it: `game-player`'s `state.alive`, `state.deathTime` and `state.cause`, and the seconds the game ran before the death. */\nexport type DeathScreenState = {\n readonly alive: boolean\n /** Seconds since the death. */\n readonly deathTime: number\n /** The cause id (`killed`, `bled_out`...), shown in `playerTextOf` words. */\n readonly cause?: string\n readonly survivedSeconds: number\n}\n\nexport type DeathScreen = {\n /** Call it every frame: it opens once the body has been dead `delaySeconds`, and closes when the body is alive again. */\n update(state: DeathScreenState): void\n readonly isOpen: boolean\n dispose(): void\n}\n\nexport const DEATH_SCREEN_DELAY_SECONDS = 1.5\nconst RESTART_KEY = 'KeyR'\nlet nextHeadingId = 0\n\n/**\n * The death screen (DOM, no three.js): a panel in the lower third (the death camera keeps the body at the centre) with \"you died\", the cause, the time survived and two buttons,\n * restart the scene and back to the start. It opens once the death camera has settled, frees the mouse from the pointer lock and focuses the restart button (Enter presses the focused\n * button, R restarts from anywhere), calls each hook once until the body lives again, and gives the focus back when it shuts.\n */\nexport function createDeathScreen({ container, locale = 'pt-BR', delaySeconds = DEATH_SCREEN_DELAY_SECONDS, onRestart, onBackToStart, returnFocus }: DeathScreenOptions): DeathScreen {\n const text = playerHudTextOf(locale)\n ensurePlayerHudStyle()\n const restorePosition = positionContainer(container)\n const root = document.createElement('div')\n root.className = 'gp-death'\n root.setAttribute('role', 'dialog')\n root.setAttribute('aria-modal', 'true')\n const panel = document.createElement('div')\n panel.className = 'gp-death-panel'\n const heading = document.createElement('h2')\n heading.id = `gp-death-title-${nextHeadingId++}`\n heading.textContent = text.died\n root.setAttribute('aria-labelledby', heading.id)\n const cause = document.createElement('p')\n const survived = document.createElement('p')\n const actions = document.createElement('div')\n actions.className = 'gp-death-actions'\n const button = (label: string, key: string | null): HTMLButtonElement => {\n const node = document.createElement('button')\n node.type = 'button'\n node.append(document.createTextNode(label))\n if (key) {\n const hint = document.createElement('kbd')\n hint.textContent = key\n node.appendChild(hint)\n }\n actions.appendChild(node)\n return node\n }\n const restartButton = button(text.restart, 'R')\n const backButton = button(text.backToStart, null)\n panel.append(heading, cause, survived, actions)\n root.appendChild(panel)\n container.appendChild(root)\n\n let isOpen = false\n let isSpent = false\n let focusBefore: Element | null = null\n const setEnabled = (enabled: boolean): void => {\n restartButton.disabled = !enabled\n backButton.disabled = !enabled\n }\n const choose = (hook: () => void): void => {\n if (!isOpen || isSpent) return\n isSpent = true\n setEnabled(false)\n try {\n hook()\n } catch (error) {\n isSpent = false\n setEnabled(true)\n throw error\n }\n }\n restartButton.onclick = () => choose(onRestart)\n backButton.onclick = () => choose(onBackToStart)\n // Enter is left to the focused button (the browser presses it): only R is caught here, and it restarts from anywhere, a focused button included\n const onKeyDown = (event: KeyboardEvent): void => {\n if (!isOpen || event.code !== RESTART_KEY) return\n event.preventDefault()\n choose(onRestart)\n }\n window.addEventListener('keydown', onKeyDown)\n\n const open = (state: DeathScreenState): void => {\n isOpen = true\n isSpent = false\n restartButton.disabled = false\n backButton.disabled = false\n cause.textContent = state.cause ? playerTextOf(state.cause, locale) : ''\n cause.style.display = state.cause ? 'block' : 'none'\n survived.textContent = text.survived.replace('{time}', formatSurvived(state.survivedSeconds))\n root.classList.add('open')\n if (document.pointerLockElement) document.exitPointerLock()\n focusBefore = document.activeElement\n restartButton.focus()\n }\n const close = (): void => {\n isOpen = false\n if (root.contains(document.activeElement) && document.activeElement instanceof HTMLElement) document.activeElement.blur()\n root.classList.remove('open')\n const target = returnFocus ?? (focusBefore instanceof HTMLElement && focusBefore.isConnected && focusBefore !== document.body ? focusBefore : null)\n focusBefore = null\n target?.focus({ preventScroll: true })\n }\n\n return {\n update(state) {\n if (state.alive) {\n if (isOpen) close()\n return\n }\n if (!isOpen && state.deathTime >= delaySeconds) open(state)\n },\n get isOpen() {\n return isOpen\n },\n dispose() {\n window.removeEventListener('keydown', onKeyDown)\n root.remove()\n restorePosition()\n },\n }\n}\n","import type { Player } from '../player'\n\n/** An infection stage as `Player.stage()` answers it. */\nexport type InfectionStage = ReturnType<Player['stage']>\n\n/** What the HUD shows of a body, read from its state: plain numbers, so a game with its own body fills it too. */\nexport type PlayerHudView = {\n readonly alive: boolean\n readonly health: number\n readonly maxHealth: number\n readonly stamina: number\n readonly maxStamina: number\n readonly bleeding: boolean\n /** The open wounds by kind, oldest first (`scratch`, `laceration`, `bite`, or a game's own kinds). */\n readonly wounds: readonly string[]\n readonly infection: InfectionStage\n}\n\n/** The HUD's view of a `game-player` body now, as a new object (a frame loop refills one with `writePlayerHudView`). */\nexport const playerHudViewOf = (player: Pick<Player, 'state' | 'derived' | 'stage'>): PlayerHudView => writePlayerHudView(player, createPlayerHudView())\n\n/** A view the host keeps and refills every frame (`writePlayerHudView`), so the frame allocates nothing. */\nexport type MutablePlayerHudView = { -readonly [K in keyof PlayerHudView]: PlayerHudView[K] }\n\n/** An empty view to refill. */\nexport const createPlayerHudView = (): MutablePlayerHudView => ({ alive: true, health: 0, maxHealth: 0, stamina: 0, maxStamina: 0, bleeding: false, wounds: [], infection: 'none' })\n\n/** Writes the body's numbers now into `view` (no allocation) and answers it. */\nexport function writePlayerHudView(player: Pick<Player, 'state' | 'derived' | 'stage'>, view: MutablePlayerHudView): MutablePlayerHudView {\n const { state, derived } = player\n view.alive = state.alive\n view.health = state.health\n view.maxHealth = derived.maxHealth\n view.stamina = state.stamina\n view.maxStamina = derived.maxStamina\n view.bleeding = state.bleeding > 0\n view.wounds = state.wounds\n view.infection = state.infected ? player.stage() : 'none'\n return view\n}\n"],"mappings":";;;;;AAEO,IAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmC9B,IAAM,WAAW;AAGV,SAAS,uBAA6B;AAC3C,MAAI,SAAS,eAAe,QAAQ,EAAG;AACvC,QAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,QAAM,KAAK;AACX,QAAM,cAAc;AACpB,WAAS,KAAK,YAAY,KAAK;AACjC;AAGO,SAAS,kBAAkB,WAAoC;AACpE,QAAM,WAAW,iBAAiB,SAAS,EAAE;AAC7C,MAAI,YAAY,aAAa,SAAU,QAAO,MAAM;AACpD,QAAM,SAAS,UAAU,MAAM;AAC/B,YAAU,MAAM,WAAW;AAC3B,SAAO,MAAM;AACX,QAAI,UAAU,MAAM,aAAa,WAAY,WAAU,MAAM,WAAW;AAAA,EAC1E;AACF;;;ACtCA,IAAM,QAAuB;AAAA,EAC3B,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,aAAa;AACf;AAEA,IAAM,KAAoB;AAAA,EACxB,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,cAAc;AAAA,EACd,iBAAiB;AAAA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;AAAA,IACL,OAAO,OAAO;AACZ,UAAI,MAAM,OAAO;AACf,YAAI,OAAQ,OAAM;AAClB;AAAA,MACF;AACA,UAAI,CAAC,UAAU,MAAM,aAAa,aAAc,MAAK,KAAK;AAAA,IAC5D;AAAA,IACA,IAAI,SAAS;AACX,aAAO;AAAA,IACT;AAAA,IACA,UAAU;AACR,aAAO,oBAAoB,WAAW,SAAS;AAC/C,WAAK,OAAO;AACZ,sBAAgB;AAAA,IAClB;AAAA,EACF;AACF;;;ACjIO,IAAM,kBAAkB,CAAC,WAAuE,mBAAmB,QAAQ,oBAAoB,CAAC;AAMhJ,IAAM,sBAAsB,OAA6B,EAAE,OAAO,MAAM,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,YAAY,GAAG,UAAU,OAAO,QAAQ,CAAC,GAAG,WAAW,OAAO;AAG3K,SAAS,mBAAmB,QAAqD,MAAkD;AACxI,QAAM,EAAE,OAAO,QAAQ,IAAI;AAC3B,OAAK,QAAQ,MAAM;AACnB,OAAK,SAAS,MAAM;AACpB,OAAK,YAAY,QAAQ;AACzB,OAAK,UAAU,MAAM;AACrB,OAAK,aAAa,QAAQ;AAC1B,OAAK,WAAW,MAAM,WAAW;AACjC,OAAK,SAAS,MAAM;AACpB,OAAK,YAAY,MAAM,WAAW,OAAO,MAAM,IAAI;AACnD,SAAO;AACT;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { P as PlayerMessageId, K as KnownDeathCause } from './
|
|
2
|
-
export { A as AttributeId, a as Attributes, D as DeathCause, b as Derived, c as DerivedFormulas, d as DerivedId, I as InfectionRule, L as LinearFormula, M as MeleeItem, e as PLAYER_DEFAULTS, f as Player, g as PlayerAction, h as
|
|
1
|
+
import { P as PlayerMessageId, K as KnownDeathCause } from './player-BRl5ea2y.js';
|
|
2
|
+
export { A as AttributeId, a as Attributes, D as DeathCause, b as Derived, c as DerivedFormulas, d as DerivedId, I as InfectionRule, L as LinearFormula, M as MeleeItem, e as PLAYER_DEFAULTS, f as Player, g as PlayerAction, h as PlayerCollider, i as PlayerCrowd, j as PlayerEvent, k as PlayerEventMap, l as PlayerEventName, m as PlayerInput, n as PlayerNumbers, o as PlayerOptions, p as PlayerSave, q as PlayerSoundId, r as PlayerState, s as PlayerWorld, W as WoundRule, t as WoundTable, u as createPlayer, v as deriveVitals, w as drawWound } from './player-BRl5ea2y.js';
|
|
3
3
|
import { SurfaceId } from '@adatechnology/game-contracts';
|
|
4
|
+
export { PlayerTestModule, PlayerTestModuleOptions, createPlayerTestModule } from './testing.js';
|
|
4
5
|
|
|
5
6
|
/** Deterministic mulberry32 generator; returns floats in [0, 1). */
|
|
6
7
|
declare function createRng(seed: number): () => number;
|
|
@@ -121,9 +122,11 @@ declare const playerTextOf: (id: string, locale?: string) => string;
|
|
|
121
122
|
/**
|
|
122
123
|
* Opening and closing a hinged or sliding leaf by hand (a house door, a wardrobe or fridge door, a drawer, a car door, a hood): the hand reaches the handle, the leaf
|
|
123
124
|
* follows the hand at a speed set by its mass, stops where something is in its way, and a locked leaf only rattles.
|
|
125
|
+
* The player does not follow the leaf: when the handle leaves arm reach a leaf that goes away is shoved on (`push`) and one that comes toward the body is let go (`release`),
|
|
126
|
+
* and either one finishes its swing on its own.
|
|
124
127
|
* Engine-agnostic: the host says how open the leaf is (0 closed, 1 open) and answers whether it can go to a new opening; this says how far it goes each step.
|
|
125
128
|
*/
|
|
126
|
-
type DoorUsePhase = 'idle' | 'reach' | 'swing' | 'release' | 'rattle';
|
|
129
|
+
type DoorUsePhase = 'idle' | 'reach' | 'swing' | 'push' | 'release' | 'rattle';
|
|
127
130
|
type DoorUseBlock = 'locked' | 'obstacle' | null;
|
|
128
131
|
/** Every number of the use; a game overrides what it wants (`createDoorUse(rules)`). */
|
|
129
132
|
interface DoorUseRules {
|
|
@@ -136,6 +139,8 @@ interface DoorUseRules {
|
|
|
136
139
|
readonly min: number;
|
|
137
140
|
readonly max: number;
|
|
138
141
|
};
|
|
142
|
+
/** The shove of a leaf that goes away once the handle is out of reach, seconds. */
|
|
143
|
+
readonly pushSeconds: number;
|
|
139
144
|
/** The hand letting go and coming back, seconds. */
|
|
140
145
|
readonly releaseSeconds: number;
|
|
141
146
|
/** How long a locked leaf is shaken before the hand gives up, seconds. */
|
|
@@ -146,6 +151,10 @@ interface DoorUseRules {
|
|
|
146
151
|
readonly endTolerance: number;
|
|
147
152
|
}
|
|
148
153
|
declare const DOOR_USE_DEFAULTS: DoorUseRules;
|
|
154
|
+
/** The body's shoulder, metres over the feet (the avatar's door pose is drawn for it). */
|
|
155
|
+
declare const DOOR_SHOULDER_HEIGHT = 1.42;
|
|
156
|
+
/** The farthest a handle is from the shoulder joint for the palm to stay on it (measured on the body in both views: the palm is 0.06 m off up to 0.5, 0.11 at 0.55, 0.24 at 0.65). */
|
|
157
|
+
declare const DOOR_ARM_REACH = 0.55;
|
|
149
158
|
type DoorUseTarget = {
|
|
150
159
|
/** How open the leaf is now, 0 closed to 1 open. */
|
|
151
160
|
readonly opening: number;
|
|
@@ -167,6 +176,10 @@ type DoorUseStep = {
|
|
|
167
176
|
};
|
|
168
177
|
/** Seconds of a full swing for a leaf of this mass. */
|
|
169
178
|
declare const swingSecondsFor: (massKg: number, rules?: DoorUseRules) => number;
|
|
179
|
+
type DoorUseHand = {
|
|
180
|
+
readonly reaches: () => boolean;
|
|
181
|
+
readonly pull: boolean;
|
|
182
|
+
};
|
|
170
183
|
interface DoorUse {
|
|
171
184
|
readonly phase: DoorUsePhase;
|
|
172
185
|
/** Where the leaf is going: 1 opening, 0 closing. */
|
|
@@ -178,11 +191,15 @@ interface DoorUse {
|
|
|
178
191
|
* Answers the goal (1 open, 0 closed), or null when the leaf is locked (it rattles instead).
|
|
179
192
|
*/
|
|
180
193
|
begin(target: DoorUseTarget): 0 | 1 | null;
|
|
181
|
-
/**
|
|
182
|
-
|
|
194
|
+
/**
|
|
195
|
+
* Advances the use; `isFree(from, to)` answers whether the leaf can go from one opening to the other (nothing in the way of its sweep). `hand` says whether the handle is still
|
|
196
|
+
* within arm reach after the step and whether the leaf comes toward the body (`pull`): once the handle is out of reach the swing hands over to `push` (a leaf going away is shoved
|
|
197
|
+
* on) or `release` (a leaf coming toward the body is let go) and the leaf finishes on its own. Without `hand` the hand never lets go.
|
|
198
|
+
*/
|
|
199
|
+
step(dt: number, isFree: (from: number, to: number) => boolean, hand?: DoorUseHand): DoorUseStep;
|
|
183
200
|
/** Lets go at once. */
|
|
184
201
|
cancel(): void;
|
|
185
202
|
}
|
|
186
203
|
declare function createDoorUse(rules?: Partial<DoorUseRules>): DoorUse;
|
|
187
204
|
|
|
188
|
-
export { DOOR_USE_DEFAULTS, type DoorUse, type DoorUseBlock, type DoorUsePhase, type DoorUseRules, type DoorUseStep, type DoorUseTarget, type DragMark, FURNITURE_PUSH_DEFAULTS, type FurniturePush, type FurniturePushBlock, type FurniturePushInput, type FurniturePushLoad, type FurniturePushPhase, type FurniturePushRules, type FurniturePushStep, type FurniturePushTarget, KnownDeathCause, PLAYER_TEXT, PlayerMessageId, type PlayerText, canPush, createDoorUse, createFurniturePush, createRng, dragMarkFor, frictionFor, gripSecondsFor, playerTextOf, pushAccelerationFor, pushSpeedFor, slipsOnTop, swingSecondsFor };
|
|
205
|
+
export { DOOR_ARM_REACH, DOOR_SHOULDER_HEIGHT, DOOR_USE_DEFAULTS, type DoorUse, type DoorUseBlock, type DoorUseHand, type DoorUsePhase, type DoorUseRules, type DoorUseStep, type DoorUseTarget, type DragMark, FURNITURE_PUSH_DEFAULTS, type FurniturePush, type FurniturePushBlock, type FurniturePushInput, type FurniturePushLoad, type FurniturePushPhase, type FurniturePushRules, type FurniturePushStep, type FurniturePushTarget, KnownDeathCause, PLAYER_TEXT, PlayerMessageId, type PlayerText, canPush, createDoorUse, createFurniturePush, createRng, dragMarkFor, frictionFor, gripSecondsFor, playerTextOf, pushAccelerationFor, pushSpeedFor, slipsOnTop, swingSecondsFor };
|