@adatechnology/game-player 0.12.3 → 0.13.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 CHANGED
@@ -50,14 +50,31 @@ player.grab(agentIndex) // 3 s to break free
50
50
  player.knock(1.5)
51
51
  ```
52
52
 
53
+ ## Hunger and thirst, and what items do to the body
54
+
55
+ Port of the team game's needs (G 57255-57344, `needs` in `data/defaults.json`): `hunger` and `thirst` on the body's state, 0 fed and quenched up to 100,
56
+ start at 20 and rise on the game clock (1 game hour is 50 s; hunger 2.5/h, 4/h running, thirst 4/h, times 1.1 − 0.02 × vigor). Past 90 either one costs
57
+ 0.2 health a second, and a body that dies of it dies of `hunger_thirst`. `createPlayer({ needs: false })` keeps them still; an object patches the rules.
58
+
59
+ `player.use(effect)` applies an item's effect as the catalogue resolved it (`ModuleItemUse.effect`, from `goodsItemUse` of game-items-goods): food and
60
+ drink take their own `satiety` and `hydration` off hunger and thirst (salted food makes you thirsty), `heal` gives back `params.amount` health up to the
61
+ most, `stop_bleeding` stops the bleeding, `clean_wound` cleans the last wound, `calm` takes the panic away; it answers how much each moved. The pure parts
62
+ are `advanceNeeds`, `nourish` and `applyItemEffect`; `createBodyVitals()` is the same body for a host without `createPlayer` (the test room uses it).
63
+
64
+ ```ts
65
+ const result = player.use({ id: 'consume_nutrition', satiety: 25, hydration: -5 }) // canned beans: { hunger: -25, thirst: +5, ... }
66
+ player.use(goodsItemUse(painkillers)!.effect!) // +15 health
67
+ ```
68
+
53
69
  ## HUD and death screen (`./hud`)
54
70
 
55
- `@adatechnology/game-player/hud` is the body's screen, in DOM and with no three.js, laid over the game's view: the health and stamina bars with the
71
+ `@adatechnology/game-player/hud` is the body's screen, in DOM and with no three.js, laid over the game's view: the health, stamina, hunger and thirst bars with the
56
72
  bleeding, the infection stage and the wounds under them (bottom left), the weapon in the hand and its rounds (bottom right, only when the hand holds
57
73
  one), a name at the top left, the body's `message` events at the top centre and the crosshair in the first person. Nothing in it takes the mouse.
58
74
  The death screen opens once the body has been dead `delaySeconds` (1.5 s: the death camera settles first), frees the pointer lock and shows the
59
75
  cause, the time survived and two buttons: restart the scene (also Enter or R) and back to the start. Each hook fires once until the body lives
60
- again. The words are `pt-BR` (default) and `en`.
76
+ again. The words are `pt-BR` (default) and `en`. A host with its own screen (the test room) mounts the body's box alone: `createVitalsPanel(locale)`,
77
+ its `element` inside an element of class `gp-hud`. Hunger and thirst grow amber past half and red once they cost health.
61
78
 
62
79
  ```ts
63
80
  import { createDeathScreen, createPlayerHud, playerHudViewOf } from '@adatechnology/game-player/hud'
@@ -100,6 +117,14 @@ the hip for a pistol, a sling on the back for a rifle) and, with none, drops it
100
117
  away or drops it. `drawBackOf(plan)` says what comes back to the hands when the interaction ends: what was put away, never what fell. `interactionHandsFor({ massKg, size })` says
101
118
  whether a thing goes in one hand (up to 4 kg and 0.7 m, `HANDS_DEFAULTS`). The hands and slot of each weapon come from `weaponHandsOf` of `@adatechnology/game-weapons`.
102
119
 
120
+ A second one-handed weapon (a pistol in each hand, owner 2026-11-27) is not thrown away when the holster is taken: it is tucked in the belt (`BELT_SLOT`, `SLOT_FALLBACKS`:
121
+ hip, then belt) and comes back after. Only a body with no place for it at all drops it.
122
+
123
+ Whether the hands lift a thing at all is `liftCheckFor({ massKg, size }, { maxKg })` (`LIFT_DEFAULTS`): the strength is the most lifted held against the body, and a bulky thing is
124
+ held away from it, so the back takes its weight times the lever (the horizontal multiplier of the NIOSH lifting equation, `closeReach / H`, H the spine to the middle of the
125
+ thing held its thinnest side out). `too_heavy` is over the strength; `too_bulky` is too wide for the arms (`maxSpan`) or too heavy that far out. A 45 kg sofa is `too_bulky`
126
+ (pushed or dragged, not picked up); a 16 kg gas bottle goes up.
127
+
103
128
  A long gun on its sling (owner, 2026-11-25) is not dropped: its slot is `sling` (`move: 'sling'`), it hangs on the body and stays there after the interaction until the player
104
129
  brings it back; with no sling worn it goes to the next slot that takes it (`SLOT_FALLBACKS`: the back). Every move is seen: `planTakeSequence(plan)` lays the steps (each weapon
105
130
  `stow`, `sling` or `drop`, the off hand first, then `reach`, `close`, `lift`; `HANDS_TIMING` in seconds), `planDrawSequence(moves)` the way back (`draw`), and
@@ -13,7 +13,20 @@ var defaults_default = {
13
13
  derived: "G 62005-62012 DERIV",
14
14
  wounds: "G 62016 FERIDA (Personagens 3.7): share of each wound kind, and its infection chance (used only when an infection rule is on)",
15
15
  infection: "G 62015 INFEC (the slice's accelerated clock: fever 30 s, delirium 70 s, death 120 s, reanimation 8 s after); G 68509 fever noise",
16
- numbers: "G 68427-68640 player, playerUpdate, frontZombies, shove, knife; G 68678-68681 the aim spread modifiers; G 65507 walkCad"
16
+ numbers: "G 68427-68640 player, playerUpdate, frontZombies, shove, knife; G 68678-68681 the aim spread modifiers; G 65507 walkCad",
17
+ needs: "G 57255 needs (fome 20, sede 20 at the start; 0 is fed, 100 starving), G 57271 useItem (food takes off its f, drink its s), G 57341-57344 (1 game hour = 50 s of the slice; hunger 2.5/h, 4/h running, thirst 4/h, times 1.1 - 0.02 x vigor; over 90 the body loses 0.2 health a second)"
18
+ },
19
+ needs: {
20
+ start: { hunger: 20, thirst: 20 },
21
+ max: 100,
22
+ gameHourSeconds: 50,
23
+ hungerPerHour: 2.5,
24
+ hungerRunningPerHour: 4,
25
+ thirstPerHour: 4,
26
+ vigorBase: 1.1,
27
+ vigorPerPoint: -0.02,
28
+ starvingAt: 90,
29
+ starvingDamagePerSecond: 0.2
17
30
  },
18
31
  attributes: { strength: 5, vigor: 5, agility: 5, perception: 5, intellect: 5, presence: 5 },
19
32
  derived: {
@@ -140,6 +153,26 @@ var defaults_default = {
140
153
  fist: { damage: 8, crit: 0, reach: 0.5, noise: 1 }
141
154
  };
142
155
 
156
+ // src/needs.ts
157
+ var NEEDS_DEFAULTS = defaults_default.needs;
158
+ var createNeedsState = (rules = NEEDS_DEFAULTS) => ({ hunger: rules.start.hunger, thirst: rules.start.thirst });
159
+ var clamp = (value, max) => value < 0 ? 0 : value > max ? max : value;
160
+ var needsHoursOf = (dt, vigor, rules = NEEDS_DEFAULTS) => Math.max(0, dt) / rules.gameHourSeconds * Math.max(0, rules.vigorBase + rules.vigorPerPoint * vigor);
161
+ var isStarving = (state, rules = NEEDS_DEFAULTS) => state.hunger > rules.starvingAt || state.thirst > rules.starvingAt;
162
+ function advanceNeeds(state, dt, body, rules = NEEDS_DEFAULTS) {
163
+ const hours = needsHoursOf(dt, body.vigor, rules);
164
+ state.hunger = clamp(state.hunger + (body.running ? rules.hungerRunningPerHour : rules.hungerPerHour) * hours, rules.max);
165
+ state.thirst = clamp(state.thirst + rules.thirstPerHour * hours, rules.max);
166
+ return isStarving(state, rules) ? rules.starvingDamagePerSecond * Math.max(0, dt) : 0;
167
+ }
168
+ function nourish(state, food, rules = NEEDS_DEFAULTS) {
169
+ const hunger = state.hunger;
170
+ const thirst = state.thirst;
171
+ state.hunger = clamp(hunger - (food.satiety ?? 0), rules.max);
172
+ state.thirst = clamp(thirst - (food.hydration ?? 0), rules.max);
173
+ return { hunger: state.hunger - hunger, thirst: state.thirst - thirst };
174
+ }
175
+
143
176
  // src/rng.ts
144
177
  function createRng(seed) {
145
178
  let state = seed >>> 0;
@@ -151,6 +184,66 @@ function createRng(seed) {
151
184
  };
152
185
  }
153
186
 
187
+ // src/vitals.ts
188
+ var NOTHING = { applied: false, health: 0, hunger: 0, thirst: 0, stoppedBleeding: false, calmed: false };
189
+ var numberOf = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
190
+ function applyItemEffect(body, effect, limits) {
191
+ switch (effect.id) {
192
+ case "consume_nutrition": {
193
+ const moved = nourish(body, { satiety: numberOf(effect.satiety), hydration: numberOf(effect.hydration) }, limits.needs ?? NEEDS_DEFAULTS);
194
+ return { ...NOTHING, applied: true, hunger: moved.hunger, thirst: moved.thirst };
195
+ }
196
+ case "heal": {
197
+ const before = body.health;
198
+ body.health = Math.min(limits.maxHealth, before + Math.max(0, numberOf(effect.params?.amount)));
199
+ return { ...NOTHING, applied: true, health: body.health - before };
200
+ }
201
+ case "stop_bleeding": {
202
+ const stopped = body.bleeding > 0;
203
+ body.bleeding = 0;
204
+ return { ...NOTHING, applied: true, stoppedBleeding: stopped };
205
+ }
206
+ case "clean_wound": {
207
+ const cleaned = body.wounds.pop();
208
+ return cleaned === void 0 ? NOTHING : { ...NOTHING, applied: true, cleaned };
209
+ }
210
+ case "calm": {
211
+ const calmed = body.panic > 0;
212
+ body.panic = 0;
213
+ return { ...NOTHING, applied: true, calmed };
214
+ }
215
+ default:
216
+ return NOTHING;
217
+ }
218
+ }
219
+ function createBodyVitals(options = {}) {
220
+ const maxHealth = options.maxHealth ?? 100;
221
+ const bleedPerSecond = options.bleedPerSecond ?? 0.15;
222
+ const vigor = options.vigor ?? 5;
223
+ const rules = { ...NEEDS_DEFAULTS, ...options.needs, start: { ...NEEDS_DEFAULTS.start, ...options.needs?.start } };
224
+ const fresh = () => ({ ...createNeedsState(rules), health: maxHealth, bleeding: 0, panic: 0, wounds: [], alive: true, cause: "" });
225
+ const state = fresh();
226
+ return {
227
+ state,
228
+ maxHealth,
229
+ rules,
230
+ update(dt, input = {}) {
231
+ if (!state.alive || dt <= 0) return;
232
+ state.health -= advanceNeeds(state, dt, { running: input.running ?? false, vigor }, rules);
233
+ if (state.bleeding > 0) state.health -= bleedPerSecond * dt;
234
+ if (state.health <= 0) {
235
+ state.health = 0;
236
+ state.alive = false;
237
+ state.cause = state.bleeding > 0 ? "bled_out" : "hunger_thirst";
238
+ }
239
+ },
240
+ apply: (effect) => state.alive ? applyItemEffect(state, effect, { maxHealth, needs: rules }) : NOTHING,
241
+ reset() {
242
+ Object.assign(state, fresh());
243
+ }
244
+ };
245
+ }
246
+
154
247
  // src/player.ts
155
248
  var PLAYER_DEFAULTS = defaults_default;
156
249
  var TAU_APPROX = 6.2832;
@@ -174,9 +267,9 @@ var drawWound = (wounds, random) => {
174
267
  }
175
268
  return kinds[kinds.length - 1];
176
269
  };
177
- var clamp = (v, a, b) => v < a ? a : v > b ? b : v;
270
+ var clamp2 = (v, a, b) => v < a ? a : v > b ? b : v;
178
271
  var lerp = (a, b, t) => a + (b - a) * t;
179
- var freshState = (derived, position) => ({
272
+ var freshState = (derived, position, needs) => ({
180
273
  x: position?.x ?? 0,
181
274
  z: position?.z ?? 0,
182
275
  y: 0,
@@ -188,6 +281,8 @@ var freshState = (derived, position) => ({
188
281
  turned: false,
189
282
  health: derived.maxHealth,
190
283
  stamina: derived.maxStamina,
284
+ hunger: needs?.start.hunger ?? 0,
285
+ thirst: needs?.start.thirst ?? 0,
191
286
  crouch: false,
192
287
  running: false,
193
288
  stepTimer: 0,
@@ -228,9 +323,10 @@ function createPlayer(options = {}) {
228
323
  const heightScale = heightMetres / numbers.heightMetres;
229
324
  const wounds = options.wounds ?? PLAYER_DEFAULTS.wounds;
230
325
  const infection = options.infection === void 0 || options.infection === false ? null : options.infection === true ? PLAYER_DEFAULTS.infection : { ...PLAYER_DEFAULTS.infection, ...options.infection };
326
+ const needs = options.needs === false ? null : options.needs === void 0 || options.needs === true ? NEEDS_DEFAULTS : { ...NEEDS_DEFAULTS, ...options.needs, start: { ...NEEDS_DEFAULTS.start, ...options.needs.start } };
231
327
  const fist = options.fist ?? PLAYER_DEFAULTS.fist;
232
328
  const listeners = /* @__PURE__ */ new Map();
233
- let P = freshState(derived, options.position);
329
+ let P = freshState(derived, options.position, needs);
234
330
  const feet = new Float64Array(3);
235
331
  let defaultWorld = options.world ?? {};
236
332
  let world = defaultWorld;
@@ -401,6 +497,7 @@ function createPlayer(options = {}) {
401
497
  message("bandaged", 2);
402
498
  }
403
499
  }
500
+ if (needs) P.health -= advanceNeeds(P, dt, { running: P.running, vigor: attributes.vigor }, needs);
404
501
  if (P.health <= 0) {
405
502
  die(P.infected ? "infected" : P.bleeding ? "bled_out" : "hunger_thirst");
406
503
  return;
@@ -560,7 +657,7 @@ function createPlayer(options = {}) {
560
657
  const lx = P.vx * cy - P.vz * sy;
561
658
  const lz = P.vx * sy + P.vz * cy;
562
659
  const back = lz < numbers.backwardsBelow ? -1 : 1;
563
- const hip = spd > numbers.hipMinSpeed ? clamp(Math.atan2(lx * back, lz * back), -numbers.hipLimit, numbers.hipLimit) : 0;
660
+ const hip = spd > numbers.hipMinSpeed ? clamp2(Math.atan2(lx * back, lz * back), -numbers.hipLimit, numbers.hipLimit) : 0;
564
661
  P.hip = P.hip + (hip - P.hip) * Math.min(1, dt * numbers.hipFollow);
565
662
  P.phase += dt * (spd < numbers.cadenceMinSpeed ? 0 : numbers.cadenceBase + numbers.cadencePerSpeed * spd) * back;
566
663
  }
@@ -595,7 +692,7 @@ function createPlayer(options = {}) {
595
692
  const n = crowd.count();
596
693
  for (let i = 0; i < n; i++) if (crowd.active(i) && crowd.chasing(i)) near += crowd.panicWeight?.(i) ?? 1;
597
694
  }
598
- P.panic = clamp(P.panic + (near * numbers.panicGain - (near ? 0 : numbers.panicDecay)) * dt, 0, numbers.panicMax);
695
+ P.panic = clamp2(P.panic + (near * numbers.panicGain - (near ? 0 : numbers.panicDecay)) * dt, 0, numbers.panicMax);
599
696
  };
600
697
  return {
601
698
  get state() {
@@ -610,6 +707,8 @@ function createPlayer(options = {}) {
610
707
  derived,
611
708
  numbers,
612
709
  infection,
710
+ needs,
711
+ use: (effect) => P.alive ? applyItemEffect(P, effect, { maxHealth: derived.maxHealth, ...needs ? { needs } : {} }) : { applied: false, health: 0, hunger: 0, thirst: 0, stoppedBleeding: false, calmed: false },
613
712
  update,
614
713
  hurt: (amount) => hurt(amount),
615
714
  bite: () => bite(),
@@ -642,6 +741,8 @@ function createPlayer(options = {}) {
642
741
  save: () => ({ state: structuredClone(P), attributes }),
643
742
  load(save) {
644
743
  P = structuredClone(save.state);
744
+ P.hunger ?? (P.hunger = needs?.start.hunger ?? 0);
745
+ P.thirst ?? (P.thirst = needs?.start.thirst ?? 0);
645
746
  world.controller?.teleport(P.x, P.y, P.z);
646
747
  },
647
748
  setWorld(next) {
@@ -1037,11 +1138,19 @@ function createPlayerTestModule(options = {}) {
1037
1138
  }
1038
1139
 
1039
1140
  export {
1141
+ NEEDS_DEFAULTS,
1142
+ createNeedsState,
1143
+ needsHoursOf,
1144
+ isStarving,
1145
+ advanceNeeds,
1146
+ nourish,
1040
1147
  createRng,
1148
+ applyItemEffect,
1149
+ createBodyVitals,
1041
1150
  PLAYER_DEFAULTS,
1042
1151
  deriveVitals,
1043
1152
  drawWound,
1044
1153
  createPlayer,
1045
1154
  createPlayerTestModule
1046
1155
  };
1047
- //# sourceMappingURL=chunk-EN2Z57NX.js.map
1156
+ //# sourceMappingURL=chunk-BQJMHKW5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/player.ts","../src/data/defaults.json","../src/needs.ts","../src/rng.ts","../src/vitals.ts","../src/bench/locale.ts","../src/bench/module.ts"],"sourcesContent":["import { SWING_LEAD_SECONDS, footstepSoundId, hitSoundId, landSoundId, surfaceOfMaterial, swingSoundId } from '@adatechnology/game-contracts'\nimport type { BlowId, BodyFoleyId, SurfaceId } from '@adatechnology/game-contracts'\n\nimport defaults from './data/defaults.json'\nimport { NEEDS_DEFAULTS, advanceNeeds } from './needs'\nimport type { NeedsRules } from './needs'\nimport { createRng } from './rng'\nimport { applyItemEffect } from './vitals'\nimport type { ItemEffect, ItemEffectResult } from './vitals'\nimport type {\n Attributes,\n DeathCause,\n Derived,\n DerivedFormulas,\n DerivedId,\n InfectionRule,\n LinearFormula,\n MeleeItem,\n PlayerAction,\n PlayerCrowd,\n PlayerEventMap,\n PlayerEventName,\n PlayerInput,\n PlayerMessageId,\n PlayerNumbers,\n PlayerSave,\n PlayerSoundId,\n PlayerState,\n PlayerWorld,\n WoundTable,\n} from './types'\n\nexport const PLAYER_DEFAULTS = defaults as unknown as {\n readonly sources: Readonly<Record<string, string>>\n readonly attributes: Attributes\n readonly derived: DerivedFormulas\n readonly wounds: WoundTable\n readonly infection: InfectionRule\n readonly numbers: PlayerNumbers\n readonly fist: MeleeItem\n}\n\nexport type PlayerOptions = {\n /** The random stream (the game passes its single stream). Default `createRng(seed)`. */\n readonly random?: () => number\n readonly seed?: number\n /** The sheet: every attribute 5 by default. */\n readonly attributes?: Partial<Attributes>\n readonly derived?: Partial<DerivedFormulas>\n readonly wounds?: WoundTable\n /** An individual infection (`true` uses the defaults; an object patches them). Off by default: the normal world comes first. */\n readonly infection?: boolean | Partial<InfectionRule>\n readonly numbers?: Partial<PlayerNumbers>\n /** Hunger and thirst (`NEEDS_DEFAULTS`, the team game's): an object patches them, `false` keeps them still. */\n readonly needs?: boolean | Partial<NeedsRules>\n readonly fist?: MeleeItem\n readonly position?: { readonly x?: number; readonly z?: number; readonly yaw?: number }\n /** Standing skull-top height in metres (default `numbers.heightMetres`, 1.80 m). Scales collider height and radius (Spec 012 R3/H5). */\n readonly heightMetres?: number\n readonly world?: PlayerWorld\n}\n\n/** Player capsule/cylinder collider dimensions in metres (follows standing vs crouched state and `heightMetres`). */\nexport type PlayerCollider = {\n readonly heightMetres: number\n readonly radiusMetres: number\n}\n\nexport type Player = {\n readonly state: PlayerState\n /** Declared standing height in metres. */\n readonly heightMetres: number\n /** Current collider height and radius in metres (adapts to crouch and `heightMetres`). */\n collider(): PlayerCollider\n readonly attributes: Attributes\n readonly derived: Derived\n readonly numbers: PlayerNumbers\n readonly infection: InfectionRule | null\n /** The hunger and thirst rules, or null when they are off. */\n readonly needs: NeedsRules | null\n /** An item used in the hand (`ModuleItemUse.effect`): food and drink feed, a painkiller heals, a dressing stops the bleeding. */\n use(effect: ItemEffect): ItemEffectResult\n update(dt: number, input?: PlayerInput, world?: PlayerWorld): void\n /** A hit that opens a wound (drawn from the wound table) and may infect. `by` is the agent that hit, if any. */\n hurt(amount: number, by?: number): void\n /** A bite: damage, bleeding, a bite wound and (with an infection rule) the infection. */\n bite(by?: number): void\n grab(by: number, noJaw?: boolean, drown?: boolean): void\n release(): void\n knock(seconds: number): void\n infect(source: string): void\n /** Kills the player with a cause (the host's deaths: a fall, a fire). */\n die(cause: DeathCause): void\n /** Infection stage: `none`, `malaise`, `fever`, `delirium`. */\n stage(): 'none' | 'malaise' | 'fever' | 'delirium'\n /** Seconds the infection has left, or null. */\n timeLeft(): number | null\n /** What the player's state does to aim spread (panic, fever, moving); the weapon multiplies its own spread by it. */\n spreadFactor(): number\n /** The agents in front (nearest first) within `range` m and a cone of `cosMin`, as `[distance, index]`. */\n front(range: number, cosMin: number, yaw: number, crowd?: PlayerCrowd): [number, number][]\n on<K extends PlayerEventName>(event: K, listener: (event: PlayerEventMap[K]) => void): () => void\n save(): PlayerSave\n load(save: PlayerSave): void\n /** The world `update` uses when it is given none. */\n setWorld(world: PlayerWorld): void\n}\n\nconst TAU_APPROX = 6.2832\n\nconst evaluate = (formula: LinearFormula, attributes: Attributes): number => {\n let value = formula.base\n for (const [attribute, coefficient] of formula.terms) value += coefficient * attributes[attribute]\n return formula.divide === undefined ? value : value / formula.divide\n}\n\n/** The derived values of a sheet (the game's `DERIV`). */\nexport const deriveVitals = (attributes: Attributes, formulas: DerivedFormulas = PLAYER_DEFAULTS.derived): Derived => {\n const out = {} as Record<DerivedId, number>\n for (const id of Object.keys(formulas) as DerivedId[]) out[id] = evaluate(formulas[id], attributes)\n return out\n}\n\n/** Which wound a hit opens: one draw, the kinds in the listed order, the last one takes the rest (the game's `FERIDA` draw). */\nexport const drawWound = (wounds: WoundTable, random: () => number): string => {\n const kinds = Object.keys(wounds)\n const draw = random()\n let acc = 0\n for (let k = 0; k < kinds.length - 1; k++) {\n acc += wounds[kinds[k]!]!.share\n if (draw < acc) return kinds[k]!\n }\n return kinds[kinds.length - 1]!\n}\n\nconst clamp = (v: number, a: number, b: number): number => (v < a ? a : v > b ? b : v)\nconst lerp = (a: number, b: number, t: number): number => a + (b - a) * t\n\nconst freshState = (derived: Derived, position: PlayerOptions['position'], needs: NeedsRules | null): PlayerState => ({\n x: position?.x ?? 0,\n z: position?.z ?? 0,\n y: 0,\n vx: 0,\n vz: 0,\n yaw: position?.yaw ?? 0,\n floor: 0,\n alive: true,\n turned: false,\n health: derived.maxHealth,\n stamina: derived.maxStamina,\n hunger: needs?.start.hunger ?? 0,\n thirst: needs?.start.thirst ?? 0,\n crouch: false,\n running: false,\n stepTimer: 0,\n phase: 0,\n hip: 0,\n grabbedBy: -1,\n grabTimer: 0,\n grabPushes: 0,\n grabNoJaw: false,\n grabDrown: false,\n infected: false,\n infectionTime: 0,\n infectionSource: '',\n wounds: [],\n bleeding: 0,\n blind: 0,\n screamBoost: 0,\n panic: 0,\n hurtFlash: 0,\n deathTime: 0,\n cause: '',\n downTimer: 0,\n burnTimer: 0,\n scentTimer: 0,\n vaultTimer: 0,\n vault: null,\n})\n\n/**\n * The player body: a literal port of the team game's `player` and `playerUpdate` (G 68427-68640) with the world, the crowd and the input as\n * arguments instead of globals. The draws on `random` happen in the game's order (wound kind, infection, the fever cough, the knife when grabbed,\n * the melee region), so a game that passes its own stream keeps its sequence.\n */\nexport function createPlayer(options: PlayerOptions = {}): Player {\n const random = options.random ?? createRng(options.seed ?? 1)\n const attributes: Attributes = { ...PLAYER_DEFAULTS.attributes, ...options.attributes }\n const formulas: DerivedFormulas = { ...PLAYER_DEFAULTS.derived, ...options.derived }\n const derived = deriveVitals(attributes, formulas)\n const numbers: PlayerNumbers = { ...PLAYER_DEFAULTS.numbers, ...options.numbers }\n const heightMetres = options.heightMetres ?? numbers.heightMetres\n if (!Number.isFinite(heightMetres) || heightMetres < 0.8 || heightMetres > 3.0) {\n throw new RangeError(`Player height ${String(heightMetres)} m is outside supported range [0.8, 3.0] m.`)\n }\n const heightScale = heightMetres / numbers.heightMetres\n const wounds = options.wounds ?? PLAYER_DEFAULTS.wounds\n const infection: InfectionRule | null =\n options.infection === undefined || options.infection === false ? null : options.infection === true ? PLAYER_DEFAULTS.infection : { ...PLAYER_DEFAULTS.infection, ...options.infection }\n const needs: NeedsRules | null =\n options.needs === false ? null : options.needs === undefined || options.needs === true ? NEEDS_DEFAULTS : { ...NEEDS_DEFAULTS, ...options.needs, start: { ...NEEDS_DEFAULTS.start, ...options.needs.start } }\n const fist = options.fist ?? PLAYER_DEFAULTS.fist\n const listeners = new Map<PlayerEventName, Set<(event: never) => void>>()\n let P = freshState(derived, options.position, needs)\n // the controller's feet, read every step it walks: a vault lifts the body over them\n const feet = new Float64Array(3)\n let defaultWorld: PlayerWorld = options.world ?? {}\n let world: PlayerWorld = defaultWorld\n\n const emit = <K extends PlayerEventName>(event: K, payload: PlayerEventMap[K]): void => {\n const set = listeners.get(event)\n if (set) for (const listener of set) (listener as (event: PlayerEventMap[K]) => void)(payload)\n }\n const sound = (id: PlayerSoundId, volume: number, ids: readonly BodyFoleyId[], surface?: SurfaceId, at?: readonly number[]): void =>\n emit('sound', { sound: id, ids, volume, position: [P.x, P.y, P.z], ...(surface ? { surface } : {}), ...(at ? { at } : {}) })\n // what is under the feet: the host's word this frame, else the world's, else concrete; water wins over everything\n let surfaceHint: string | undefined\n const surfaceHere = (): SurfaceId => (inWater(P.x, P.z) ? 'water' : surfaceOfMaterial(surfaceHint ?? world.surfaceAt?.(P.x, P.z)))\n // set by the first `footfall` the host sends: from then on its feet, not the stride timer, decide the footsteps\n let hostFeet = false\n const blowOf = (item: MeleeItem): BlowId => item.blow ?? (item === fist ? 'punch' : (item.crit ?? 0) > 0 ? 'blade' : 'blunt')\n const noise = (x: number, z: number, radius: number): void => emit('noise', { x, z, radius })\n const message = (id: PlayerMessageId | DeathCause, seconds: number): void => emit('message', { id, seconds })\n const inWater = (x: number, z: number): boolean => world.inWater?.(x, z) ?? false\n const solidAt = (x: number, z: number, y: number): boolean => world.solidAt?.(x, z, y) ?? false\n const cellKind = (x: number, z: number): number => world.cellKind?.(x, z) ?? 0\n const blocked = (x: number, z: number): boolean => (world.blocked ? world.blocked(x, z) : solidAt(x, z, numbers.blockHeight))\n const chanceOf = (kind: string): number => infection?.chances?.[kind] ?? wounds[kind]?.infectionChance ?? 0\n\n const die = (cause: DeathCause): void => {\n if (!P.alive) return\n P.alive = false\n P.cause = cause\n P.deathTime = 0\n P.grabbedBy = -1\n message(cause, 6)\n emit('died', { cause })\n }\n const infect = (source: string): void => {\n if (P.infected || !infection) return\n P.infected = true\n P.infectionTime = 0\n P.infectionSource = source\n emit('infected', { source })\n }\n const release = (how: PlayerEventMap['released']['how'] = 'free'): void => {\n const by = P.grabbedBy\n P.grabbedBy = -1\n if (by >= 0) emit('released', { by, how })\n }\n const hurt = (amount: number): void => {\n if (!P.alive) return\n P.health -= amount\n P.hurtFlash = numbers.hurtFlash\n sound('flesh', numbers.hurtVolume, ['player_hurt'])\n const kind = drawWound(wounds, random)\n P.wounds.push(kind)\n if (wounds[kind]?.bleeds) P.bleeding = 1\n emit('hurt', { amount, wound: kind })\n if (infection && !P.infected && random() < chanceOf(kind)) infect(kind)\n if (P.health <= 0) die(P.infected ? 'infected' : 'killed')\n }\n const bite = (): void => {\n P.health -= numbers.biteDamage\n P.hurtFlash = numbers.biteFlash\n P.bleeding = 1\n P.wounds.push('bite')\n sound('flesh', numbers.biteVolume, ['bite', 'player_hurt'])\n emit('hurt', { amount: numbers.biteDamage, wound: 'bite' })\n infect('bite')\n message('bitten', 5)\n if (P.health <= 0) die('bitten_to_death')\n }\n const grab = (by: number, noJaw = false, drown = false): void => {\n P.grabbedBy = by\n P.grabTimer = numbers.grabSeconds\n P.grabPushes = 0\n P.grabNoJaw = noJaw\n P.grabDrown = drown\n message(drown ? 'grabbed_drown' : 'grabbed', 3)\n sound('flesh', numbers.grabVolume, ['grab'])\n emit('grabbed', { by, noJaw, drown })\n }\n\n const front = (range: number, cosMin: number, yaw: number, crowd: PlayerCrowd | undefined = world.crowd): [number, number][] => {\n const out: [number, number][] = []\n if (!crowd) return out\n const fx = -Math.sin(yaw)\n const fz = -Math.cos(yaw)\n const n = crowd.count()\n for (let i = 0; i < n; i++) {\n if (!crowd.active(i) || crowd.floor(i) !== P.floor) continue\n const ex = crowd.x(i) - P.x\n const ez = crowd.z(i) - P.z\n const d = Math.hypot(ex, ez)\n if (d < range && (ex * fx + ez * fz) / (d || 1) > cosMin) out.push([d, i])\n }\n return out.sort((a, b) => a[0] - b[0])\n }\n\n const shove = (yaw: number): void => {\n sound('step', numbers.shoveVolume, ['shove_two_hands'])\n const crowd = world.crowd\n const targets: number[] = []\n for (const [d, i] of front(numbers.shoveRange, numbers.shoveCone, yaw)) {\n crowd!.stun(i, numbers.shoveStun, ((crowd!.x(i) - P.x) / d) * numbers.shoveSpeed, ((crowd!.z(i) - P.z) / d) * numbers.shoveSpeed)\n targets.push(i)\n }\n emit('shove', { targets })\n }\n\n const melee = (item: MeleeItem, yaw: number): void => {\n const t = front(numbers.meleeRangeBase + (item.reach ?? 0), numbers.meleeCone, yaw)[0]\n const blow = blowOf(item)\n const swing = swingSoundId(blow)\n if (!t) {\n sound('flesh', numbers.meleeVolume, swing ? [swing] : [])\n noise(P.x, P.z, item.noise || 1)\n return\n }\n const crowd = world.crowd!\n const i = t[1]\n // a blow to the head is x3 in melee; on the ground or crawling it is an execution\n const region = crowd.down(i) ? 0 : random() < numbers.meleeHeadChance ? 0 : random() < numbers.meleeArmChance ? 1 : 2 + Math.floor(random() * 2)\n const hit = hitSoundId(blow, region === 0 ? 'head' : 'body')\n if (swing) sound('flesh', numbers.meleeVolume, [swing, hit], undefined, [0, SWING_LEAD_SECONDS[blow]])\n else sound('flesh', numbers.meleeVolume, [hit])\n noise(P.x, P.z, item.noise || 1)\n const damage = item.damage * (1 + (attributes.strength - numbers.meleeStrengthBase) * numbers.meleeStrengthPerPoint)\n const cut = Math.min(1, (item.crit || 0) / numbers.meleeCritToCut)\n crowd.damage(i, { region, amount: damage, distance: t[0], cut })\n emit('melee', { target: i, region, damage, distance: t[0], cut })\n }\n\n const update = (dt: number, input: PlayerInput = {}, frameWorld?: PlayerWorld): void => {\n world = frameWorld ?? defaultWorld\n surfaceHint = input.surface\n if (!P.alive) {\n P.deathTime += dt\n if (P.infected && infection && !P.turned && P.deathTime >= infection.reanimateSeconds) {\n P.turned = true\n emit('turned', { x: P.x, z: P.z, floor: P.floor })\n }\n return\n }\n const pressed: Partial<Record<PlayerAction, boolean>> = { ...input.pressed }\n const wasPressed = (action: PlayerAction): boolean => {\n const v = pressed[action] === true\n pressed[action] = false\n return v\n }\n const viewYaw = input.yaw ?? 0\n const crowd = world.crowd\n P.screamBoost = Math.max(0, P.screamBoost - dt)\n P.blind = Math.max(0, P.blind - dt)\n P.hurtFlash = Math.max(0, P.hurtFlash - dt)\n // infection on its own clock\n if (P.infected && infection) {\n const before = P.infectionTime\n P.infectionTime += dt\n if (before <= infection.feverSeconds && P.infectionTime > infection.feverSeconds) emit('stage', { stage: 'fever' })\n if (before <= infection.deliriumSeconds && P.infectionTime > infection.deliriumSeconds) emit('stage', { stage: 'delirium' })\n const every = 1 / infection.feverNoiseEvery\n if (P.infectionTime > infection.feverSeconds && Math.floor(P.infectionTime * every) !== Math.floor((P.infectionTime - dt) * every) && random() < infection.feverNoiseChance) {\n noise(P.x, P.z, infection.feverNoiseRadius)\n sound('step', infection.feverNoiseVolume, ['cloth_rustle'])\n }\n if (P.infectionTime > infection.deathSeconds) {\n P.health = 0\n die('infection')\n return\n }\n }\n if (P.burnTimer > 0) {\n P.burnTimer -= dt\n P.health -= numbers.burnPerSecond * dt\n if (inWater(P.x, P.z)) P.burnTimer = 0\n }\n P.scentTimer = Math.max(0, P.scentTimer - dt)\n if (P.bleeding) {\n P.health -= dt * numbers.bleedPerSecond\n if (input.bandage && P.bleeding) {\n P.bleeding = 0\n message('bandaged', 2)\n }\n }\n if (needs) P.health -= advanceNeeds(P, dt, { running: P.running, vigor: attributes.vigor }, needs)\n if (P.health <= 0) {\n die(P.infected ? 'infected' : P.bleeding ? 'bled_out' : 'hunger_thirst')\n return\n }\n // grabbed: seconds to react\n if (P.grabbedBy >= 0) {\n const i = P.grabbedBy\n P.grabTimer -= dt\n if (crowd) {\n const k = 1 - Math.exp(-dt * numbers.grabFollow) // glued to the body without a jump\n crowd.hold(i, P.x - Math.sin(P.yaw) * numbers.grabOffset, P.z - Math.cos(P.yaw) * numbers.grabOffset, k, P.x, P.z)\n }\n if (wasPressed('push') && P.stamina > numbers.grabPushMinStamina) {\n P.grabPushes++\n P.stamina -= numbers.grabPushCost\n sound('step', numbers.grabPushVolume, ['shove_two_hands'])\n }\n if (wasPressed('knife')) {\n if (random() < numbers.grabKnifeChance) {\n crowd?.damage(i, { region: numbers.grabKnifeRegion, amount: numbers.grabKnifeDamage, distance: numbers.grabKnifeDistance, cut: numbers.grabKnifeCut })\n message('knife_head', 1.5)\n release('knife')\n return\n } else message('knife_miss', 1)\n }\n if (P.grabPushes >= numbers.grabPushes) {\n crowd?.stun(i, numbers.grabPushStun, -Math.sin(viewYaw) * numbers.grabPushSpeed, -Math.cos(viewYaw) * numbers.grabPushSpeed)\n release('push')\n message('pushed_off', 1.2)\n return\n }\n if (P.grabTimer <= 0) {\n if (P.grabDrown) {\n P.health -= numbers.drownDamage\n P.hurtFlash = numbers.drownFlash\n message('drowning', 2)\n if (P.health <= 0) {\n die('drowned')\n return\n }\n P.grabTimer = numbers.grabSeconds\n P.grabPushes = 0\n return\n }\n if (P.grabNoJaw) {\n hurt(numbers.noJawDamage)\n message('no_jaw', 2)\n } else bite()\n crowd?.chase(i, numbers.grabAttackCooldown)\n release(P.grabNoJaw ? 'scratch' : 'bite')\n }\n return\n }\n // knocked down\n if (P.downTimer > 0) {\n P.downTimer -= dt\n P.vx = P.vz = 0\n if (P.downTimer <= 0) message('stood_up', 0.8)\n return\n }\n if (world.busy?.(dt)) return\n // vaulting a low wall\n if (P.vaultTimer > 0 && P.vault) {\n P.vaultTimer -= dt\n const k = 1 - P.vaultTimer / numbers.vaultSeconds\n P.x = lerp(P.vault[0], P.vault[2], k)\n P.z = lerp(P.vault[1], P.vault[3], k)\n P.y = feet[1] + Math.sin(k * Math.PI) * numbers.vaultHeight\n if (P.vaultTimer <= 0) {\n P.y = feet[1]\n world.controller?.teleport(P.x, P.y, P.z)\n noise(P.x, P.z, numbers.vaultNoise)\n const surface = surfaceHere()\n sound('step', numbers.vaultLandVolume, [landSoundId(surface, 0)], surface)\n }\n return\n }\n if (wasPressed('vault') && P.stamina > numbers.vaultCost && (world.canVault?.() ?? !P.floor)) {\n const fx0 = -Math.sin(viewYaw)\n const fz0 = -Math.cos(viewYaw)\n for (let a = numbers.vaultScanFrom; a <= numbers.vaultScanTo; a += numbers.vaultScanStep) {\n const c = cellKind(P.x + fx0 * a, P.z + fz0 * a)\n if (c === 2) {\n for (let e = a + numbers.vaultLandFrom; e <= a + numbers.vaultLandTo; e += numbers.vaultScanStep) {\n const ex = P.x + fx0 * e\n const ez = P.z + fz0 * e\n if (!solidAt(ex, ez, numbers.vaultCheckHeight) && !solidAt(ex + fx0 * numbers.vaultClearance, ez + fz0 * numbers.vaultClearance, numbers.vaultCheckHeight)) {\n P.vault = [P.x, P.z, ex, ez]\n P.vaultTimer = numbers.vaultSeconds\n P.stamina -= numbers.vaultCost\n sound('step', numbers.vaultStartVolume, ['jump'])\n emit('vault', { from: [P.x, P.z], to: [ex, ez] })\n return\n }\n }\n break\n }\n if (c > 0 && c !== 3) break\n }\n }\n // movement\n const f = input.forward ?? 0\n const s = input.right ?? 0\n if (wasPressed('crouch')) P.crouch = !P.crouch\n const want = f || s\n P.running = !!(input.run && want && P.stamina > numbers.runMinStamina && !input.aim && !P.crouch)\n const fever = P.infected && infection !== null && P.infectionTime > infection.feverSeconds\n let sp = P.running ? derived.runSpeed : P.crouch ? numbers.crouchSpeed : derived.walkSpeed * numbers.walkFactor\n if (fever) sp *= infection!.feverSpeed\n if (input.aim) sp = Math.min(sp, numbers.aimSpeedCap)\n const wet = inWater(P.x, P.z)\n if (wet) sp *= numbers.waterSpeed\n if (P.running) P.stamina = Math.max(0, P.stamina - numbers.runDrain * dt)\n else P.stamina = Math.min(derived.maxStamina, P.stamina + (want ? numbers.regenMoving : numbers.regenStill) * dt)\n const fx = -Math.sin(viewYaw)\n const fz = -Math.cos(viewYaw)\n const mx = fx * f - fz * s\n const mz = fz * f + fx * s\n const ml = Math.hypot(mx, mz) || 1\n const tvx = want ? (mx / ml) * sp : 0\n const tvz = want ? (mz / ml) * sp : 0\n P.vx = lerp(P.vx, tvx, Math.min(1, dt * numbers.acceleration))\n P.vz = lerp(P.vz, tvz, Math.min(1, dt * numbers.acceleration))\n const controller = world.controller\n if (controller) {\n controller.move(P.vx, P.vz, dt)\n controller.read(feet)\n P.x = feet[0] ?? P.x\n P.y = feet[1] ?? P.y\n P.z = feet[2] ?? P.z\n } else {\n const r = numbers.radius * heightScale\n const nx = P.x + P.vx * dt\n const nz = P.z + P.vz * dt\n if (!blocked(nx + Math.sign(P.vx) * r, P.z)) P.x = nx\n if (!blocked(P.x, nz + Math.sign(P.vz) * r)) P.z = nz\n }\n world.afterMove?.(P)\n // the player does not walk through the crowd: agents pressed against the body push it out\n if (crowd) {\n const n = crowd.count()\n const rr = numbers.pushApartRadius\n for (let i = 0; i < n; i++) {\n if (!crowd.active(i) || Math.abs(crowd.y(i) - P.y) > numbers.pushApartHeight) continue\n const ex = P.x - crowd.x(i)\n const ez = P.z - crowd.z(i)\n const e2 = ex * ex + ez * ez\n if (e2 < rr * rr && e2 > 1e-5) {\n const e = Math.sqrt(e2)\n const k = ((rr - e) / e) * 0.5\n if (!solidAt(P.x + ex * k, P.z + ez * k, numbers.blockHeight)) {\n P.x += ex * k\n P.z += ez * k\n }\n }\n }\n }\n const spd = Math.hypot(P.vx, P.vz)\n // the legs follow the move even with the torso on the aim; walking backwards flips the stride\n {\n const cy = Math.cos(P.yaw)\n const sy = Math.sin(P.yaw)\n const lx = P.vx * cy - P.vz * sy\n const lz = P.vx * sy + P.vz * cy\n const back = lz < numbers.backwardsBelow ? -1 : 1\n const hip = spd > numbers.hipMinSpeed ? clamp(Math.atan2(lx * back, lz * back), -numbers.hipLimit, numbers.hipLimit) : 0\n P.hip = P.hip + (hip - P.hip) * Math.min(1, dt * numbers.hipFollow)\n P.phase += dt * (spd < numbers.cadenceMinSpeed ? 0 : numbers.cadenceBase + numbers.cadencePerSpeed * spd) * back\n }\n // the body follows the view (fast, no snap); aiming or firing, at once\n {\n const target = viewYaw + Math.PI\n let dy = target - P.yaw\n dy -= Math.round(dy / TAU_APPROX) * TAU_APPROX\n P.yaw += input.aim || input.firing ? dy : dy * Math.min(1, dt * numbers.turnFollow)\n }\n // footsteps make noise: walk 3 m, run 8 m, crouched 1 m (x the sheet's footstep noise, x2 in water)\n // the host's feet (`input.footfall`) once it sends them, else the stride timer\n if (input.footfall) hostFeet = true\n P.stepTimer -= dt * spd\n const stepNow = hostFeet ? input.footfall === true : P.stepTimer <= 0 && spd > numbers.stepMinSpeed\n if (stepNow) {\n P.stepTimer = numbers.stepEvery\n noise(P.x, P.z, (P.running ? numbers.stepNoiseRun : P.crouch ? numbers.stepNoiseCrouch : numbers.stepNoiseWalk) * derived.footstepNoise * (wet ? numbers.stepNoiseWater : 1))\n const surface = surfaceHere()\n sound('step', P.running ? numbers.stepVolumeRun : numbers.stepVolumeWalk, [footstepSoundId(surface, P.running ? 'run' : 'walk')], surface)\n emit('step', { x: P.x, z: P.z, yaw: P.yaw })\n }\n // shove and melee\n if (wasPressed('push') && P.stamina > numbers.shoveCost) {\n P.stamina -= numbers.shoveCost\n shove(viewYaw)\n }\n if (wasPressed('throw')) emit('throw', {})\n if (wasPressed('knife') && P.stamina > numbers.meleeMinStamina) {\n const item = input.melee ?? fist\n P.stamina -= (item.kg ?? 0) > numbers.meleeHeavyKg ? numbers.meleeCostHeavy : numbers.meleeCostLight\n melee(item, viewYaw)\n }\n // panic: chasing agents in sight nearby\n let near = 0\n if (crowd) {\n const n = crowd.count()\n for (let i = 0; i < n; i++) if (crowd.active(i) && crowd.chasing(i)) near += crowd.panicWeight?.(i) ?? 1\n }\n P.panic = clamp(P.panic + (near * numbers.panicGain - (near ? 0 : numbers.panicDecay)) * dt, 0, numbers.panicMax)\n }\n\n return {\n get state() {\n return P\n },\n heightMetres,\n collider: () => ({\n heightMetres: P.crouch ? heightMetres * numbers.crouchHeightRatio : heightMetres,\n radiusMetres: numbers.radius * heightScale,\n }),\n attributes,\n derived,\n numbers,\n infection,\n needs,\n use: (effect) => (P.alive ? applyItemEffect(P, effect, { maxHealth: derived.maxHealth, ...(needs ? { needs } : {}) }) : { applied: false, health: 0, hunger: 0, thirst: 0, stoppedBleeding: false, calmed: false }),\n update,\n hurt: (amount) => hurt(amount),\n bite: () => bite(),\n grab,\n release: () => release('free'),\n knock(seconds) {\n if (!P.alive) return\n P.downTimer = Math.max(P.downTimer, seconds)\n P.crouch = false\n },\n infect,\n die,\n stage() {\n if (!P.infected || !infection) return 'none'\n return P.infectionTime > infection.deliriumSeconds ? 'delirium' : P.infectionTime > infection.feverSeconds ? 'fever' : 'malaise'\n },\n timeLeft: () => (P.infected && infection ? Math.max(0, infection.deathSeconds - P.infectionTime) : null),\n spreadFactor() {\n const panic = P.panic > derived.composure * numbers.panicSpreadAt ? numbers.panicSpread : 1\n const fever = P.infected && infection && P.infectionTime > infection.feverSeconds ? infection.feverSpread : 1\n return panic * fever * (1 + Math.hypot(P.vx, P.vz) * numbers.moveSpread)\n },\n front,\n on(event, listener) {\n let set = listeners.get(event)\n if (!set) listeners.set(event, (set = new Set()))\n set.add(listener as (event: never) => void)\n return () => void set.delete(listener as (event: never) => void)\n },\n save: () => ({ state: structuredClone(P), attributes }),\n load(save) {\n P = structuredClone(save.state)\n // a save from before the needs: the body starts fed\n P.hunger ??= needs?.start.hunger ?? 0\n P.thirst ??= needs?.start.thirst ?? 0\n world.controller?.teleport(P.x, P.y, P.z)\n },\n setWorld(next) {\n defaultWorld = next\n },\n }\n}\n","{\n \"sources\": {\n \"game\": \"specs/001-migracao-entregas-dos-times/artefatos/2UG1Mhe9LqJkQKKVsJkTWR/jogo.js\",\n \"attributes\": \"G 62004 FICHA (Personagens 3.2: every attribute 5, no traits)\",\n \"derived\": \"G 62005-62012 DERIV\",\n \"wounds\": \"G 62016 FERIDA (Personagens 3.7): share of each wound kind, and its infection chance (used only when an infection rule is on)\",\n \"infection\": \"G 62015 INFEC (the slice's accelerated clock: fever 30 s, delirium 70 s, death 120 s, reanimation 8 s after); G 68509 fever noise\",\n \"numbers\": \"G 68427-68640 player, playerUpdate, frontZombies, shove, knife; G 68678-68681 the aim spread modifiers; G 65507 walkCad\",\n \"needs\": \"G 57255 needs (fome 20, sede 20 at the start; 0 is fed, 100 starving), G 57271 useItem (food takes off its f, drink its s), G 57341-57344 (1 game hour = 50 s of the slice; hunger 2.5/h, 4/h running, thirst 4/h, times 1.1 - 0.02 x vigor; over 90 the body loses 0.2 health a second)\"\n },\n \"needs\": {\n \"start\": { \"hunger\": 20, \"thirst\": 20 },\n \"max\": 100,\n \"gameHourSeconds\": 50,\n \"hungerPerHour\": 2.5,\n \"hungerRunningPerHour\": 4,\n \"thirstPerHour\": 4,\n \"vigorBase\": 1.1,\n \"vigorPerPoint\": -0.02,\n \"starvingAt\": 90,\n \"starvingDamagePerSecond\": 0.2\n },\n \"attributes\": { \"strength\": 5, \"vigor\": 5, \"agility\": 5, \"perception\": 5, \"intellect\": 5, \"presence\": 5 },\n \"derived\": {\n \"maxHealth\": { \"base\": 70, \"terms\": [[\"vigor\", 6]] },\n \"maxStamina\": { \"base\": 40, \"terms\": [[\"vigor\", 6], [\"agility\", 4]] },\n \"runSpeed\": { \"base\": 5.2, \"terms\": [[\"agility\", 0.12]] },\n \"walkSpeed\": { \"base\": 1.6, \"terms\": [] },\n \"footstepNoise\": { \"base\": 100, \"terms\": [[\"agility\", -4]], \"divide\": 100 },\n \"composure\": { \"base\": 20, \"terms\": [[\"vigor\", 3], [\"presence\", 4]] }\n },\n \"wounds\": {\n \"scratch\": { \"share\": 0.6, \"infectionChance\": 0.06, \"bleeds\": false },\n \"laceration\": { \"share\": 0.3, \"infectionChance\": 0.22, \"bleeds\": true },\n \"bite\": { \"share\": 0.1, \"infectionChance\": 1, \"bleeds\": true }\n },\n \"infection\": {\n \"feverSeconds\": 30,\n \"deliriumSeconds\": 70,\n \"deathSeconds\": 120,\n \"reanimateSeconds\": 8,\n \"feverNoiseEvery\": 2,\n \"feverNoiseChance\": 0.5,\n \"feverNoiseRadius\": 10,\n \"feverNoiseVolume\": 2,\n \"feverSpeed\": 0.85,\n \"feverSpread\": 1.5\n },\n \"numbers\": {\n \"hurtFlash\": 0.4,\n \"hurtVolume\": 0.8,\n \"biteDamage\": 25,\n \"biteFlash\": 0.8,\n \"biteVolume\": 1.2,\n \"burnPerSecond\": 3,\n \"bleedPerSecond\": 0.15,\n \"grabSeconds\": 3,\n \"grabVolume\": 1,\n \"grabFollow\": 12,\n \"grabOffset\": 0.55,\n \"grabPushCost\": 6,\n \"grabPushMinStamina\": 5,\n \"grabPushVolume\": 1.5,\n \"grabPushes\": 6,\n \"grabPushStun\": 1.2,\n \"grabPushSpeed\": 3,\n \"grabKnifeChance\": 0.7,\n \"grabKnifeRegion\": 0,\n \"grabKnifeDamage\": 22,\n \"grabKnifeDistance\": 0.5,\n \"grabKnifeCut\": 0.7,\n \"drownDamage\": 30,\n \"drownFlash\": 0.8,\n \"noJawDamage\": 8,\n \"grabAttackCooldown\": 2,\n \"vaultSeconds\": 0.7,\n \"vaultCost\": 15,\n \"vaultHeight\": 1.9,\n \"vaultScanFrom\": 0.3,\n \"vaultScanTo\": 1.0,\n \"vaultScanStep\": 0.1,\n \"vaultLandFrom\": 0.4,\n \"vaultLandTo\": 1.4,\n \"vaultClearance\": 0.3,\n \"vaultCheckHeight\": 0.4,\n \"vaultNoise\": 6,\n \"vaultStartVolume\": 0.8,\n \"vaultLandVolume\": 1,\n \"crouchSpeed\": 1.0,\n \"walkFactor\": 1.35,\n \"aimSpeedCap\": 1.4,\n \"waterSpeed\": 0.55,\n \"runMinStamina\": 1,\n \"runDrain\": 12,\n \"regenMoving\": 4,\n \"regenStill\": 8,\n \"acceleration\": 10,\n \"heightMetres\": 1.8,\n \"crouchHeightRatio\": 0.65,\n \"radius\": 0.3,\n \"blockHeight\": 0.4,\n \"pushApartRadius\": 0.55,\n \"pushApartHeight\": 1.2,\n \"hipFollow\": 10,\n \"hipMinSpeed\": 0.3,\n \"hipLimit\": 0.9,\n \"backwardsBelow\": -0.1,\n \"cadenceBase\": 0.5,\n \"cadencePerSpeed\": 0.3,\n \"cadenceMinSpeed\": 0.05,\n \"turnFollow\": 12,\n \"stepEvery\": 0.75,\n \"stepMinSpeed\": 0.3,\n \"stepNoiseRun\": 8,\n \"stepNoiseWalk\": 3,\n \"stepNoiseCrouch\": 1,\n \"stepNoiseWater\": 2,\n \"stepVolumeRun\": 0.6,\n \"stepVolumeWalk\": 0.3,\n \"shoveCost\": 10,\n \"shoveVolume\": 1.2,\n \"shoveRange\": 1.6,\n \"shoveCone\": 0.3,\n \"shoveStun\": 0.9,\n \"shoveSpeed\": 2.5,\n \"meleeMinStamina\": 5,\n \"meleeCostLight\": 5,\n \"meleeCostHeavy\": 12,\n \"meleeHeavyKg\": 1.5,\n \"meleeVolume\": 0.6,\n \"meleeRangeBase\": 0.9,\n \"meleeCone\": 0.5,\n \"meleeHeadChance\": 0.35,\n \"meleeArmChance\": 0.5,\n \"meleeStrengthPerPoint\": 0.06,\n \"meleeStrengthBase\": 5,\n \"meleeCritToCut\": 60,\n \"panicGain\": 1.2,\n \"panicDecay\": 3,\n \"panicMax\": 100,\n \"panicSpreadAt\": 0.6,\n \"panicSpread\": 1.4,\n \"moveSpread\": 0.4\n },\n \"fist\": { \"damage\": 8, \"crit\": 0, \"reach\": 0.5, \"noise\": 1 }\n}\n","/**\n * Hunger and thirst of a body (the team game's `needs`, G 57255-57344): two levels from 0 (fed, quenched) to `max` (starving, parched) that rise with the game's\n * clock, faster when running and slower for a stronger body, and fall by what the body eats and drinks (`satiety` and `hydration` of an item, the thirst a litre\n * of a liquid quenches). Past `starvingAt` either one costs health every second. Pure and allocation-free: the host keeps one `NeedsState` and passes it in.\n */\nimport defaults from './data/defaults.json'\n\nexport type NeedsRules = typeof defaults.needs\n\n/** The rules the team game shipped. */\nexport const NEEDS_DEFAULTS: NeedsRules = defaults.needs\n\n/** Where a body stands: `hunger` and `thirst`, 0 fed and quenched, `NeedsRules.max` starving. */\nexport interface NeedsState {\n hunger: number\n thirst: number\n}\n\n/** What the body ate or drank: points of hunger (`satiety`) and of thirst (`hydration`) it takes off; a negative number adds (salted fish makes you thirsty). */\nexport interface Nourishment {\n readonly satiety?: number\n readonly hydration?: number\n}\n\n/** A fresh body's needs (`rules.start`). */\nexport const createNeedsState = (rules: NeedsRules = NEEDS_DEFAULTS): NeedsState => ({ hunger: rules.start.hunger, thirst: rules.start.thirst })\n\nconst clamp = (value: number, max: number): number => (value < 0 ? 0 : value > max ? max : value)\n\n/** Game hours `dt` seconds are for a body of `vigor` (the vigor factor of the team game: 1.1 − 0.02 × vigor; never below zero). */\nexport const needsHoursOf = (dt: number, vigor: number, rules: NeedsRules = NEEDS_DEFAULTS): number =>\n (Math.max(0, dt) / rules.gameHourSeconds) * Math.max(0, rules.vigorBase + rules.vigorPerPoint * vigor)\n\n/** Either need is past `starvingAt`. */\nexport const isStarving = (state: NeedsState, rules: NeedsRules = NEEDS_DEFAULTS): boolean => state.hunger > rules.starvingAt || state.thirst > rules.starvingAt\n\n/** Moves `state` on by `dt` seconds and answers the health it costs in that time (0 unless the body is starving or parched). */\nexport function advanceNeeds(state: NeedsState, dt: number, body: { readonly running?: boolean; readonly vigor: number }, rules: NeedsRules = NEEDS_DEFAULTS): number {\n const hours = needsHoursOf(dt, body.vigor, rules)\n state.hunger = clamp(state.hunger + (body.running ? rules.hungerRunningPerHour : rules.hungerPerHour) * hours, rules.max)\n state.thirst = clamp(state.thirst + rules.thirstPerHour * hours, rules.max)\n return isStarving(state, rules) ? rules.starvingDamagePerSecond * Math.max(0, dt) : 0\n}\n\n/** Takes what was eaten or drunk off `state` (kept within 0 and `max`) and answers how much each level moved (negative: it went down). */\nexport function nourish(state: NeedsState, food: Nourishment, rules: NeedsRules = NEEDS_DEFAULTS): { hunger: number; thirst: number } {\n const hunger = state.hunger\n const thirst = state.thirst\n state.hunger = clamp(hunger - (food.satiety ?? 0), rules.max)\n state.thirst = clamp(thirst - (food.hydration ?? 0), rules.max)\n return { hunger: state.hunger - hunger, thirst: state.thirst - thirst }\n}\n","const FNV_OFFSET = 0x811c9dc5\nconst FNV_PRIME = 0x01000193\nconst MIX = 0x9e3779b1\n\n/** Deterministic mulberry32 generator; returns floats in [0, 1). */\nexport function createRng(seed: number): () => number {\n let state = seed >>> 0\n return () => {\n state = (state + 0x6d2b79f5) >>> 0\n let mixed = Math.imul(state ^ (state >>> 15), state | 1)\n mixed ^= mixed + Math.imul(mixed ^ (mixed >>> 7), mixed | 61)\n return ((mixed ^ (mixed >>> 14)) >>> 0) / 4294967296\n }\n}\n\n/** A seed for the stream called `name`: the same seed gives each name its own sequence, so lightning never shifts the schedule. */\nexport function streamSeed(seed: number, name: string): number {\n let hash = FNV_OFFSET\n for (let index = 0; index < name.length; index++) hash = Math.imul(hash ^ name.charCodeAt(index), FNV_PRIME) >>> 0\n return Math.imul((seed >>> 0) ^ hash, MIX) >>> 0\n}\n\nexport function createStream(seed: number, name: string): () => number {\n return createRng(streamSeed(seed, name))\n}\n\nexport function drawBetween(rng: () => number, range: readonly [min: number, max: number]): number {\n return range[0] + rng() * (range[1] - range[0])\n}\n","/**\n * What an item used in the hand does to the body (the team game's `useItem`, G 57269-57279): food and drink take their satiety and hydration off hunger and thirst,\n * a painkiller gives back health, a dressing stops the bleeding, alcohol or iodine cleans the last wound, a sedative takes the panic away. The effect comes as the\n * catalogue resolved it (`ModuleItemUse.effect` of game-contracts, from `resolveUse` of game-items), so the numbers are the item's own. `createBodyVitals` is the\n * same body for a host that has no `createPlayer` (a test room): health, bleeding, wounds, panic and the needs, on the same rules.\n */\nimport type { ModuleItemUse } from '@adatechnology/game-contracts'\n\nimport { NEEDS_DEFAULTS, advanceNeeds, createNeedsState, nourish } from './needs'\nimport type { NeedsRules, NeedsState } from './needs'\n\n/** The effect of an item as the catalogue gives it (`ModuleItemUse.effect`). */\nexport type ItemEffect = NonNullable<ModuleItemUse['effect']>\n\n/** The part of a body an item's effect changes: `createPlayer`'s state has it all, and so does `createBodyVitals`. */\nexport interface VitalsBody extends NeedsState {\n health: number\n bleeding: number\n panic: number\n wounds: string[]\n}\n\n/** What an effect did: `applied` false when it means nothing to the body (washing, a light) or found nothing to do (no wound to clean). */\nexport interface ItemEffectResult {\n readonly applied: boolean\n /** How much each moved (negative: down). */\n readonly health: number\n readonly hunger: number\n readonly thirst: number\n readonly stoppedBleeding: boolean\n /** The wound kind cleaned, if one was. */\n readonly cleaned?: string\n readonly calmed: boolean\n}\n\nconst NOTHING: ItemEffectResult = { applied: false, health: 0, hunger: 0, thirst: 0, stoppedBleeding: false, calmed: false }\n\nconst numberOf = (value: unknown): number => (typeof value === 'number' && Number.isFinite(value) ? value : 0)\n\n/** Applies an item's effect to `body` and answers what changed. `maxHealth` caps a heal. */\nexport function applyItemEffect(body: VitalsBody, effect: ItemEffect, limits: { readonly maxHealth: number; readonly needs?: NeedsRules }): ItemEffectResult {\n switch (effect.id) {\n case 'consume_nutrition': {\n const moved = nourish(body, { satiety: numberOf(effect.satiety), hydration: numberOf(effect.hydration) }, limits.needs ?? NEEDS_DEFAULTS)\n return { ...NOTHING, applied: true, hunger: moved.hunger, thirst: moved.thirst }\n }\n case 'heal': {\n const before = body.health\n body.health = Math.min(limits.maxHealth, before + Math.max(0, numberOf(effect.params?.amount)))\n return { ...NOTHING, applied: true, health: body.health - before }\n }\n case 'stop_bleeding': {\n const stopped = body.bleeding > 0\n body.bleeding = 0\n return { ...NOTHING, applied: true, stoppedBleeding: stopped }\n }\n case 'clean_wound': {\n const cleaned = body.wounds.pop()\n return cleaned === undefined ? NOTHING : { ...NOTHING, applied: true, cleaned }\n }\n case 'calm': {\n const calmed = body.panic > 0\n body.panic = 0\n return { ...NOTHING, applied: true, calmed }\n }\n default:\n return NOTHING\n }\n}\n\nexport interface BodyVitalsOptions {\n /** Health the body starts with and can be healed to. Default 100. */\n readonly maxHealth?: number\n /** Health lost per second while bleeding (`numbers.bleedPerSecond` of the player, 0.15). */\n readonly bleedPerSecond?: number\n /** Vigor of the body (the attribute, default 5): a stronger body gets hungry and thirsty slower. */\n readonly vigor?: number\n readonly needs?: Partial<NeedsRules>\n}\n\nexport interface BodyVitalsState extends VitalsBody {\n alive: boolean\n /** Why it died (`hunger_thirst`, `bled_out`), empty while alive. */\n cause: string\n}\n\n/** A body's vitals without the rest of the player: the needs on the game clock, the bleeding, and the item effects. */\nexport interface BodyVitals {\n readonly state: BodyVitalsState\n readonly maxHealth: number\n readonly rules: NeedsRules\n /** Moves the body on `dt` seconds of the game. */\n update(dt: number, input?: { readonly running?: boolean }): void\n apply(effect: ItemEffect): ItemEffectResult\n reset(): void\n}\n\nexport function createBodyVitals(options: BodyVitalsOptions = {}): BodyVitals {\n const maxHealth = options.maxHealth ?? 100\n const bleedPerSecond = options.bleedPerSecond ?? 0.15\n const vigor = options.vigor ?? 5\n const rules: NeedsRules = { ...NEEDS_DEFAULTS, ...options.needs, start: { ...NEEDS_DEFAULTS.start, ...options.needs?.start } }\n const fresh = (): BodyVitalsState => ({ ...createNeedsState(rules), health: maxHealth, bleeding: 0, panic: 0, wounds: [], alive: true, cause: '' })\n const state = fresh()\n return {\n state,\n maxHealth,\n rules,\n update(dt, input = {}) {\n if (!state.alive || dt <= 0) return\n state.health -= advanceNeeds(state, dt, { running: input.running ?? false, vigor }, rules)\n if (state.bleeding > 0) state.health -= bleedPerSecond * dt\n if (state.health <= 0) {\n state.health = 0\n state.alive = false\n state.cause = state.bleeding > 0 ? 'bled_out' : 'hunger_thirst'\n }\n },\n apply: (effect) => (state.alive ? applyItemEffect(state, effect, { maxHealth, needs: rules }) : NOTHING),\n reset() {\n Object.assign(state, fresh())\n },\n }\n}\n","export type PlayerBenchText = {\n readonly group: string\n readonly name: string\n readonly controls: Readonly<Record<'infection' | 'agility' | 'vigor' | 'seed' | 'hurt' | 'bite' | 'grab' | 'push' | 'knife' | 'bandage' | 'knock' | 'crouch' | 'reset', string>>\n readonly hints: Readonly<Record<'infection' | 'agility' | 'vigor' | 'seed' | 'grab' | 'push', string>>\n readonly metrics: Readonly<Record<'health' | 'stamina' | 'bleeding' | 'wounds' | 'stage' | 'time_left' | 'panic' | 'spread' | 'grab' | 'noise' | 'steps' | 'message', string>>\n readonly stages: Readonly<Record<'none' | 'malaise' | 'fever' | 'delirium' | 'dead', string>>\n readonly scenarios: Readonly<Record<'stamina' | 'bleed_bandage' | 'normal_world' | 'infection_kills' | 'grab_break_free' | 'determinism', string>>\n readonly yes: string\n readonly no: string\n}\n\nconst EN: PlayerBenchText = {\n group: 'Player',\n name: 'Player area',\n controls: {\n infection: 'Individual infection',\n agility: 'Agility',\n vigor: 'Vigor',\n seed: 'Seed',\n hurt: 'Take a hit (10)',\n bite: 'Bite',\n grab: 'Get grabbed',\n push: 'Push (E)',\n knife: 'Knife (F)',\n bandage: 'Bandage (B)',\n knock: 'Knocked down 1.5 s',\n crouch: 'Crouch (C)',\n reset: 'Start again',\n },\n hints: {\n infection: 'Off: a normal world, wounds never infect. On: the game rule (scratch 6%, laceration 22%, bite 100%; fever at 30 s, death at 120 s).',\n agility: 'The sheet: stamina, run speed and footstep noise come from it.',\n vigor: 'The sheet: health, stamina and composure come from it.',\n seed: 'The same seed gives the same wounds and the same knife rolls.',\n grab: 'Something grabs you from behind: 3 s to push it off (6 pushes) or to land the knife (70%).',\n push: 'Shoves what is in front, or pushes off what holds you.',\n },\n metrics: {\n health: 'Health',\n stamina: 'Stamina',\n bleeding: 'Bleeding',\n wounds: 'Wounds',\n stage: 'Infection',\n time_left: 'Time left',\n panic: 'Panic',\n spread: 'Aim spread x',\n grab: 'Grab timer',\n noise: 'Last noise',\n steps: 'Footsteps',\n message: 'Message',\n },\n stages: { none: 'None', malaise: 'Malaise', fever: 'Fever', delirium: 'Delirium', dead: 'Dead' },\n scenarios: {\n stamina: 'Running drains stamina and resting gives it back',\n bleed_bandage: 'A laceration bleeds until it is dressed',\n normal_world: 'In a normal world a bite hurts and bleeds but never infects',\n infection_kills: 'With the infection on, a bite brings fever and kills at its time',\n grab_break_free: 'Six pushes break a grab before the bite',\n determinism: 'The same seed gives the same wounds',\n },\n yes: 'yes',\n no: 'no',\n}\n\nconst PT_BR: PlayerBenchText = {\n group: 'Jogador',\n name: 'Área do jogador',\n controls: {\n infection: 'Infecção individual',\n agility: 'Agilidade',\n vigor: 'Vigor',\n seed: 'Semente',\n hurt: 'Levar um golpe (10)',\n bite: 'Mordida',\n grab: 'Ser agarrado',\n push: 'Empurrar (E)',\n knife: 'Faca (F)',\n bandage: 'Curativo (B)',\n knock: 'Derrubado 1,5 s',\n crouch: 'Agachar (C)',\n reset: 'Recomeçar',\n },\n hints: {\n infection: 'Desligada: mundo normal, ferida nunca infecta. Ligada: a regra do jogo (arranhão 6%, laceração 22%, mordida 100%; febre aos 30 s, morte aos 120 s).',\n agility: 'A ficha: fôlego, velocidade de corrida e ruído dos passos saem dela.',\n vigor: 'A ficha: vida, fôlego e compostura saem dela.',\n seed: 'A mesma semente dá as mesmas feridas e os mesmos golpes de faca.',\n grab: 'Algo te agarra por trás: 3 s para empurrar (6 empurrões) ou acertar a faca (70%).',\n push: 'Empurra o que está na frente, ou se solta do que te segura.',\n },\n metrics: {\n health: 'Vida',\n stamina: 'Fôlego',\n bleeding: 'Sangrando',\n wounds: 'Feridas',\n stage: 'Infecção',\n time_left: 'Tempo restante',\n panic: 'Pânico',\n spread: 'Dispersão x',\n grab: 'Agarrão',\n noise: 'Último ruído',\n steps: 'Passos',\n message: 'Mensagem',\n },\n stages: { none: 'Nenhuma', malaise: 'Mal-estar', fever: 'Febre', delirium: 'Delírio', dead: 'Morto' },\n scenarios: {\n stamina: 'Correr gasta fôlego e descansar devolve',\n bleed_bandage: 'Uma laceração sangra até o curativo',\n normal_world: 'No mundo normal a mordida machuca e sangra, mas não infecta',\n infection_kills: 'Com a infecção ligada, a mordida dá febre e mata no tempo dela',\n grab_break_free: 'Seis empurrões soltam o agarrão antes da mordida',\n determinism: 'A mesma semente dá as mesmas feridas',\n },\n yes: 'sim',\n no: 'não',\n}\n\nexport const playerBenchTextOf = (locale: string): PlayerBenchText => (locale.toLowerCase().startsWith('en') ? EN : PT_BR)\n","import type { BenchChange, GaitId, ModuleControl, ModuleHost, ModuleMetric, ModuleScenario, SurfaceId, TestableModule } from '@adatechnology/game-contracts'\n\nimport { playerTextOf } from '../locales'\nimport { createPlayer } from '../player'\nimport type { Player, PlayerOptions } from '../player'\nimport type { PlayerAction, PlayerCrowd, PlayerInput } from '../types'\nimport { playerBenchTextOf } from './locale'\n\nexport type PlayerTestModuleOptions = PlayerOptions & { readonly locale?: string }\n\n/** What the scenarios use of the context the test room passes. */\nexport interface PlayerScenarioLike {\n expect(condition: boolean, label: string, data?: Record<string, unknown>): void\n}\n\nexport type PlayerTestModule = TestableModule<PlayerScenarioLike> & {\n /** The player in use (replaced when the bench changes the sheet, the seed or the infection). */\n readonly player: Player\n}\n\ntype CameraLike = { position: { x: number; y: number; z: number }; rotation?: { y: number }; getWorldDirection?(target: unknown): { x: number; z: number } }\ntype ThreeLike = { Vector3?: new () => { x: number; y: number; z: number } }\n\nconst MOVING_SPEED = 0.2\n/** Metres per second above which a move of the view is a jump of the camera, not the body walking. */\nconst TELEPORT_SPEED = 10\nconst SPRINT_SPEED = 3.4\nconst FRAME = 1 / 30\n\n/**\n * One agent standing behind the player for the grab test: the bench has no crowd, so this is the hand that holds. It follows `hold`, takes\n * the shove and the knife, and leaves the count once it lets go.\n */\nconst createGrabber = () => {\n const agent = { x: 0, z: 0, on: false, stunned: 0, hits: 0 }\n const crowd: PlayerCrowd = {\n count: () => (agent.on ? 1 : 0),\n active: () => agent.on,\n x: () => agent.x,\n z: () => agent.z,\n y: () => 0,\n floor: () => 0,\n chasing: () => agent.on,\n down: () => agent.stunned > 0,\n hold(_i, x, z, k) {\n agent.x += (x - agent.x) * k\n agent.z += (z - agent.z) * k\n },\n stun(_i, seconds) {\n agent.stunned = seconds\n agent.on = false\n },\n chase() {\n agent.on = false\n },\n damage() {\n agent.hits += 1\n agent.on = false\n },\n }\n return { agent, crowd }\n}\n\n/**\n * The player area of a test room, against the generic contracts only. The room's camera is the player: where it walks, the player walks; its speed\n * decides walking or running, so stamina, footsteps and their noise follow the viewer. The bench hurts, bites, grabs and knocks the player down,\n * switches the individual infection (off by default: a normal world) and sets the sheet. Footsteps and flesh sounds go to `host.audio`.\n */\nexport function createPlayerTestModule(options: PlayerTestModuleOptions = {}): PlayerTestModule {\n const locale = options.locale ?? 'pt-BR'\n const text = playerBenchTextOf(locale)\n const { locale: _locale, ...playerOptions } = options\n void _locale\n const settings = { infection: options.infection === undefined ? false : options.infection !== false, agility: options.attributes?.agility ?? 5, vigor: options.attributes?.vigor ?? 5, seed: options.seed ?? 1 }\n let host: ModuleHost | null = null\n const grabber = createGrabber()\n let lastNoise = 0\n let steps = 0\n let lastMessage = ''\n let pending: Partial<Record<PlayerAction, boolean>> = {}\n let bandage = false\n let footfall = false\n let surface: SurfaceId | undefined\n let gait: GaitId | undefined\n let last: { x: number; z: number } | null = null\n const offs: (() => void)[] = []\n\n const build = (): Player => {\n for (const off of offs.splice(0)) off()\n const made = createPlayer({ ...playerOptions, seed: settings.seed, infection: settings.infection, attributes: { ...playerOptions.attributes, agility: settings.agility, vigor: settings.vigor } })\n offs.push(made.on('noise', (e) => void (lastNoise = e.radius)))\n offs.push(made.on('step', () => void (steps += 1)))\n offs.push(made.on('message', (e) => void (lastMessage = playerTextOf(e.id, locale))))\n // the body sounds of each event (a footstep on its surface, the swing and then the hit of a blow); the team's class only when it names none\n offs.push(\n made.on('sound', (e) => {\n if (e.ids.length === 0) return\n e.ids.forEach((id, index) => {\n const delay = e.at?.[index] ?? 0\n host?.audio?.play({ sound: id, volume: e.volume, position: e.position, urgent: true, ...(delay > 0 ? { delay } : {}) })\n })\n }),\n )\n offs.push(made.on('died', (e) => host?.log(`player died: ${e.cause}`, { cause: e.cause })))\n lastNoise = 0\n steps = 0\n lastMessage = ''\n return made\n }\n let player = build()\n\n const view = (): { x: number; z: number; yaw: number } | null => {\n const camera = host?.camera as CameraLike | undefined\n if (!camera?.position) return null\n const Vector3 = (host?.THREE as ThreeLike | undefined)?.Vector3\n if (camera.getWorldDirection && Vector3) {\n const look = camera.getWorldDirection(new Vector3())\n return { x: camera.position.x, z: camera.position.z, yaw: Math.atan2(-look.x, -look.z) }\n }\n return { x: camera.position.x, z: camera.position.z, yaw: camera.rotation?.y ?? 0 }\n }\n\n const frame = (dt: number): void => {\n const here = view()\n const raw = here && last && dt > 0 ? Math.hypot(here.x - last.x, here.z - last.z) / dt : 0\n // faster than anyone runs is the view put somewhere else (an area opening, a scripted look), not a walk: no footstep for it\n const speed = raw > TELEPORT_SPEED ? 0 : raw\n if (here) {\n player.state.x = here.x\n player.state.z = here.z\n }\n const input: PlayerInput = { forward: speed > MOVING_SPEED ? 1 : 0, run: gait ? gait === 'run' : speed > SPRINT_SPEED, yaw: here?.yaw ?? 0, bandage, pressed: pending, footfall, ...(surface ? { surface } : {}) }\n pending = {}\n footfall = false\n bandage = false\n player.update(dt, input, { crowd: grabber.crowd })\n if (here) {\n player.state.x = here.x\n player.state.z = here.z\n last = { x: here.x, z: here.z }\n }\n if (grabber.agent.stunned > 0) grabber.agent.stunned = Math.max(0, grabber.agent.stunned - dt)\n }\n\n const grab = (): void => {\n const P = player.state\n grabber.agent.on = true\n grabber.agent.x = P.x - Math.sin(P.yaw) * player.numbers.grabOffset\n grabber.agent.z = P.z - Math.cos(P.yaw) * player.numbers.grabOffset\n player.grab(0)\n }\n\n const onChange = (change: BenchChange): void => {\n if (change.kind === 'action') {\n const id = change.id\n if (id === 'hurt') player.hurt(10)\n else if (id === 'bite') player.bite()\n else if (id === 'grab') grab()\n else if (id === 'knock') player.knock(1.5)\n else if (id === 'bandage') bandage = true\n else if (id === 'push' || id === 'knife' || id === 'crouch') pending = { ...pending, [id]: true }\n else if (id === 'reset') player = build()\n return\n }\n if (change.kind !== 'control') return\n const { id, value } = change\n if (id === 'infection' && typeof value === 'boolean' && value !== settings.infection) settings.infection = value\n else if ((id === 'agility' || id === 'vigor' || id === 'seed') && typeof value === 'number' && value !== settings[id]) settings[id] = value\n else return\n player = build()\n }\n\n const controls = (): ModuleControl[] => [\n { kind: 'boolean', id: 'infection', name: text.controls.infection, hint: text.hints.infection, default: settings.infection },\n { kind: 'number', id: 'agility', name: text.controls.agility, hint: text.hints.agility, min: 1, max: 8, step: 1, default: settings.agility },\n { kind: 'number', id: 'vigor', name: text.controls.vigor, hint: text.hints.vigor, min: 1, max: 8, step: 1, default: settings.vigor },\n { kind: 'number', id: 'seed', name: text.controls.seed, hint: text.hints.seed, min: 1, max: 9999, step: 1, default: settings.seed },\n { kind: 'action', id: 'hurt', name: text.controls.hurt },\n { kind: 'action', id: 'bite', name: text.controls.bite },\n { kind: 'action', id: 'grab', name: text.controls.grab, hint: text.hints.grab },\n { kind: 'action', id: 'push', name: text.controls.push, hint: text.hints.push },\n { kind: 'action', id: 'knife', name: text.controls.knife },\n { kind: 'action', id: 'bandage', name: text.controls.bandage },\n { kind: 'action', id: 'knock', name: text.controls.knock },\n { kind: 'action', id: 'crouch', name: text.controls.crouch },\n { kind: 'action', id: 'reset', name: text.controls.reset },\n ]\n\n const stageName = (): string => (player.state.alive ? text.stages[player.stage()] : text.stages.dead)\n const metrics = (): ModuleMetric[] => [\n { id: 'health', name: text.metrics.health, digits: 1, max: player.derived.maxHealth, read: () => Math.max(0, player.state.health) },\n { id: 'stamina', name: text.metrics.stamina, digits: 1, max: player.derived.maxStamina, read: () => player.state.stamina },\n { id: 'bleeding', name: text.metrics.bleeding, read: () => (player.state.bleeding ? text.yes : text.no) },\n { id: 'wounds', name: text.metrics.wounds, digits: 0, read: () => player.state.wounds.length },\n { id: 'stage', name: text.metrics.stage, read: stageName },\n { id: 'time_left', name: text.metrics.time_left, unit: 's', digits: 0, read: () => player.timeLeft() ?? 0 },\n { id: 'panic', name: text.metrics.panic, digits: 1, read: () => player.state.panic },\n { id: 'spread', name: text.metrics.spread, digits: 2, read: () => player.spreadFactor() },\n { id: 'grab_timer', name: text.metrics.grab, unit: 's', digits: 1, read: () => (player.state.grabbedBy >= 0 ? player.state.grabTimer : 0) },\n { id: 'noise', name: text.metrics.noise, unit: 'm', digits: 1, read: () => lastNoise },\n { id: 'steps', name: text.metrics.steps, digits: 0, read: () => steps },\n { id: 'message', name: text.metrics.message, read: () => lastMessage },\n ]\n\n // each scenario runs its own player, so the bench's live one is not touched\n const fresh = (extra: PlayerOptions = {}): Player => createPlayer({ ...playerOptions, ...extra })\n const run = (made: Player, seconds: number, input: PlayerInput = {}, crowd?: PlayerCrowd): void => {\n for (let t = 0; t < seconds; t += FRAME) made.update(FRAME, input, crowd ? { crowd } : undefined)\n }\n const scenarios = (): Array<ModuleScenario<PlayerScenarioLike>> => [\n {\n id: 'player_stamina',\n name: text.scenarios.stamina,\n run: ({ expect }) => {\n const made = fresh({ seed: 1 })\n const full = made.state.stamina\n run(made, 4, { forward: 1, run: true })\n const tired = made.state.stamina\n expect(tired < full - 40, 'four seconds of running spend 48 of stamina', { full, tired })\n run(made, 3)\n expect(made.state.stamina > tired, 'standing still gives it back', { tired, rested: made.state.stamina })\n },\n },\n {\n id: 'player_bleed_bandage',\n name: text.scenarios.bleed_bandage,\n run: ({ expect }) => {\n const made = fresh({ seed: 1 })\n made.bite()\n const after = made.state.health\n run(made, 2)\n expect(made.state.bleeding === 1 && made.state.health < after, 'the wound bleeds', { health: made.state.health })\n run(made, FRAME, { bandage: true })\n const dressed = made.state.health\n run(made, 2)\n expect(made.state.bleeding === 0 && made.state.health === dressed, 'dressed, it stops', { health: made.state.health })\n },\n },\n {\n id: 'player_normal_world',\n name: text.scenarios.normal_world,\n run: ({ expect }) => {\n const made = fresh({ seed: 1, infection: false })\n made.bite()\n run(made, 10)\n expect(!made.state.infected && made.state.health < made.derived.maxHealth, 'bitten, hurt, not infected', { health: made.state.health })\n },\n },\n {\n id: 'player_infection_kills',\n name: text.scenarios.infection_kills,\n run: ({ expect }) => {\n const made = fresh({ seed: 1, infection: true })\n made.bite()\n run(made, FRAME, { bandage: true })\n run(made, 40)\n expect(made.stage() === 'fever', 'fever after 30 s', { stage: made.stage() })\n run(made, 90)\n expect(!made.state.alive && made.state.cause === 'infection', 'dead at 120 s', { cause: made.state.cause })\n },\n },\n {\n id: 'player_grab_break_free',\n name: text.scenarios.grab_break_free,\n run: ({ expect }) => {\n const made = fresh({ seed: 1 })\n const { agent, crowd } = createGrabber()\n agent.on = true\n made.grab(0)\n for (let push = 0; push < 6; push++) {\n made.update(FRAME, { pressed: { push: true } }, { crowd })\n made.update(FRAME, {}, { crowd })\n }\n expect(made.state.grabbedBy === -1 && made.state.wounds.length === 0, 'free, and no bite', { grabbedBy: made.state.grabbedBy })\n },\n },\n {\n id: 'player_determinism',\n name: text.scenarios.determinism,\n run: ({ expect }) => {\n const wounds = (seed: number): string => {\n const made = fresh({ seed })\n for (let k = 0; k < 12; k++) made.hurt(1)\n return made.state.wounds.join(',')\n }\n expect(wounds(4) === wounds(4), 'the same seed gives the same wounds')\n expect(wounds(4) !== wounds(5), 'another seed gives others')\n },\n },\n ]\n\n const module: PlayerTestModule = {\n id: 'player_area',\n name: text.name,\n ground: { surface: 'dirt' },\n group: text.group,\n get player() {\n return player\n },\n items: () => [],\n controls: () => controls(),\n metrics: () => metrics(),\n scenarios: () => scenarios(),\n attach(lent) {\n host = lent\n last = null\n const off = lent.bench?.onChange(onChange)\n const offFrame = lent.onFrame(frame)\n // the host's body puts its feet down: the footsteps follow it (and what it says is under them)\n const offFeet = lent.on((event) => {\n if (event.type !== 'footfall') return\n footfall = true\n surface = event.surface\n gait = event.gait\n })\n return () => {\n off?.()\n offFrame()\n offFeet()\n host = null\n }\n },\n }\n return module\n}\n"],"mappings":";;;;;AAAA,SAAS,oBAAoB,iBAAiB,YAAY,aAAa,mBAAmB,oBAAoB;;;ACA9G;AAAA,EACE,SAAW;AAAA,IACT,MAAQ;AA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AK,OAAO,SAAS,QAAQ;AACzC,YAAM,WAAW,KAAK,QAAQ,KAAK;AAEnC,YAAM,UAAU,KAAK,GAAG,CAAC,UAAU;AACjC,YAAI,MAAM,SAAS,WAAY;AAC/B,mBAAW;AACX,kBAAU,MAAM;AAChB,eAAO,MAAM;AAAA,MACf,CAAC;AACD,aAAO,MAAM;AACX,cAAM;AACN,iBAAS;AACT,gBAAQ;AACR,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":["clamp","id"]}
package/dist/hud.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { P as Player } from './player-B-CNsXV5.js';
1
+ import { P as Player } from './player-D2QiWWBg.js';
2
2
  import '@adatechnology/game-contracts';
3
3
 
4
4
  /** An infection stage as `Player.stage()` answers it. */
@@ -14,9 +14,22 @@ type PlayerHudView = {
14
14
  /** The open wounds by kind, oldest first (`scratch`, `laceration`, `bite`, or a game's own kinds). */
15
15
  readonly wounds: readonly string[];
16
16
  readonly infection: InfectionStage;
17
+ /** Hunger and thirst, 0 fed and quenched up to `needMax` (`advanceNeeds`); absent, the HUD shows no needs. */
18
+ readonly hunger?: number;
19
+ readonly thirst?: number;
20
+ readonly needMax?: number;
21
+ /** The level past which a need costs health (`NeedsRules.starvingAt`): the bar turns red there. */
22
+ readonly needStarving?: number;
17
23
  };
18
24
  /** The HUD's view of a `game-player` body now, as a new object (a frame loop refills one with `writePlayerHudView`). */
19
- declare const playerHudViewOf: (player: Pick<Player, "state" | "derived" | "stage">) => PlayerHudView;
25
+ /** The body the HUD reads: a `game-player` body, or one with the same fields (`needs` absent or null: no hunger and thirst bars). */
26
+ type PlayerHudSource = Pick<Player, 'state' | 'derived' | 'stage'> & {
27
+ readonly needs?: {
28
+ readonly max: number;
29
+ readonly starvingAt: number;
30
+ } | null;
31
+ };
32
+ declare const playerHudViewOf: (player: PlayerHudSource) => PlayerHudView;
20
33
  /** A view the host keeps and refills every frame (`writePlayerHudView`), so the frame allocates nothing. */
21
34
  type MutablePlayerHudView = {
22
35
  -readonly [K in keyof PlayerHudView]: PlayerHudView[K];
@@ -24,7 +37,7 @@ type MutablePlayerHudView = {
24
37
  /** An empty view to refill. */
25
38
  declare const createPlayerHudView: () => MutablePlayerHudView;
26
39
  /** Writes the body's numbers now into `view` (no allocation) and answers it. */
27
- declare function writePlayerHudView(player: Pick<Player, 'state' | 'derived' | 'stage'>, view: MutablePlayerHudView): MutablePlayerHudView;
40
+ declare function writePlayerHudView(player: PlayerHudSource, view: MutablePlayerHudView): MutablePlayerHudView;
28
41
 
29
42
  /** The weapon in the hand: its name and, for a gun, the rounds as the game writes them (`12 / 48`). */
30
43
  type PlayerHudWeapon = {
@@ -51,8 +64,16 @@ type PlayerHud = {
51
64
  message(text: string, seconds: number): void;
52
65
  dispose(): void;
53
66
  };
67
+ /** The body's box of the HUD on its own (health, stamina, hunger, thirst, and the bleeding, infection and wounds under them), for a host that lays out its own screen. */
68
+ type VitalsPanel = {
69
+ /** The box (class `gp-hud-vitals`: the bottom left of an element of class `gp-hud`, which gives it the font). */
70
+ readonly element: HTMLElement;
71
+ update(view: PlayerHudView): void;
72
+ };
73
+ /** The vitals box of `createPlayerHud`, alone: put `element` inside an element of class `gp-hud` (the style goes in the document once). */
74
+ declare function createVitalsPanel(locale?: string): VitalsPanel;
54
75
  /**
55
- * 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
76
+ * The player's HUD over the game's view (DOM, no three.js): the health, stamina, hunger and thirst bars with the bleeding, the infection and the wounds under them at the bottom left, the
56
77
  * 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:
57
78
  * the view stays clear, and nothing takes the mouse.
58
79
  */
@@ -98,6 +119,8 @@ declare function createDeathScreen({ container, locale, delaySeconds, onRestart,
98
119
  type PlayerHudText = {
99
120
  readonly health: string;
100
121
  readonly stamina: string;
122
+ readonly hunger: string;
123
+ readonly thirst: string;
101
124
  readonly bleeding: string;
102
125
  readonly wounds: string;
103
126
  readonly infected: string;
@@ -122,6 +145,6 @@ declare const stageTextOf: (text: PlayerHudText, stage: string) => string;
122
145
  /** Seconds as `m:ss` (or `h:mm:ss` past the hour). */
123
146
  declare const formatSurvived: (seconds: number) => string;
124
147
 
125
- declare 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";
148
+ declare 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.need i{background:#c8a165}.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";
126
149
 
127
- export { DEATH_SCREEN_DELAY_SECONDS, type DeathScreen, type DeathScreenOptions, type DeathScreenState, type InfectionStage, type MutablePlayerHudView, PLAYER_HUD_CSS, PLAYER_HUD_TEXT, type PlayerHud, type PlayerHudOptions, type PlayerHudText, type PlayerHudView, type PlayerHudWeapon, createDeathScreen, createPlayerHud, createPlayerHudView, formatSurvived, playerHudTextOf, playerHudViewOf, stageTextOf, woundTextOf, writePlayerHudView };
150
+ export { DEATH_SCREEN_DELAY_SECONDS, type DeathScreen, type DeathScreenOptions, type DeathScreenState, type InfectionStage, type MutablePlayerHudView, PLAYER_HUD_CSS, PLAYER_HUD_TEXT, type PlayerHud, type PlayerHudOptions, type PlayerHudSource, type PlayerHudText, type PlayerHudView, type PlayerHudWeapon, type VitalsPanel, createDeathScreen, createPlayerHud, createPlayerHudView, createVitalsPanel, formatSurvived, playerHudTextOf, playerHudViewOf, stageTextOf, woundTextOf, writePlayerHudView };