@adatechnology/game-player 0.4.0 → 0.5.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/dist/chunk-FRZ6ISLA.js +1068 -0
- package/dist/chunk-FRZ6ISLA.js.map +1 -0
- package/dist/index.d.ts +4 -410
- package/dist/index.global.js +170 -17
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +10 -1015
- package/dist/index.js.map +1 -1
- package/dist/testing-CD4p4NR5.d.ts +430 -0
- package/dist/testing.d.ts +2 -0
- package/dist/testing.js +7 -0
- package/dist/testing.js.map +1 -0
- package/package.json +6 -2
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
import { BlowId, BodyFoleyId, SurfaceId, TestableModule } from '@adatechnology/game-contracts';
|
|
2
|
+
|
|
3
|
+
var numbers = {
|
|
4
|
+
hurtFlash: 0.4,
|
|
5
|
+
hurtVolume: 0.8,
|
|
6
|
+
biteDamage: 25,
|
|
7
|
+
biteFlash: 0.8,
|
|
8
|
+
biteVolume: 1.2,
|
|
9
|
+
burnPerSecond: 3,
|
|
10
|
+
bleedPerSecond: 0.15,
|
|
11
|
+
grabSeconds: 3,
|
|
12
|
+
grabVolume: 1,
|
|
13
|
+
grabFollow: 12,
|
|
14
|
+
grabOffset: 0.55,
|
|
15
|
+
grabPushCost: 6,
|
|
16
|
+
grabPushMinStamina: 5,
|
|
17
|
+
grabPushVolume: 1.5,
|
|
18
|
+
grabPushes: 6,
|
|
19
|
+
grabPushStun: 1.2,
|
|
20
|
+
grabPushSpeed: 3,
|
|
21
|
+
grabKnifeChance: 0.7,
|
|
22
|
+
grabKnifeRegion: 0,
|
|
23
|
+
grabKnifeDamage: 22,
|
|
24
|
+
grabKnifeDistance: 0.5,
|
|
25
|
+
grabKnifeCut: 0.7,
|
|
26
|
+
drownDamage: 30,
|
|
27
|
+
drownFlash: 0.8,
|
|
28
|
+
noJawDamage: 8,
|
|
29
|
+
grabAttackCooldown: 2,
|
|
30
|
+
vaultSeconds: 0.7,
|
|
31
|
+
vaultCost: 15,
|
|
32
|
+
vaultHeight: 1.9,
|
|
33
|
+
vaultScanFrom: 0.3,
|
|
34
|
+
vaultScanTo: 1,
|
|
35
|
+
vaultScanStep: 0.1,
|
|
36
|
+
vaultLandFrom: 0.4,
|
|
37
|
+
vaultLandTo: 1.4,
|
|
38
|
+
vaultClearance: 0.3,
|
|
39
|
+
vaultCheckHeight: 0.4,
|
|
40
|
+
vaultNoise: 6,
|
|
41
|
+
vaultStartVolume: 0.8,
|
|
42
|
+
vaultLandVolume: 1,
|
|
43
|
+
crouchSpeed: 1,
|
|
44
|
+
walkFactor: 1.35,
|
|
45
|
+
aimSpeedCap: 1.4,
|
|
46
|
+
waterSpeed: 0.55,
|
|
47
|
+
runMinStamina: 1,
|
|
48
|
+
runDrain: 12,
|
|
49
|
+
regenMoving: 4,
|
|
50
|
+
regenStill: 8,
|
|
51
|
+
acceleration: 10,
|
|
52
|
+
radius: 0.3,
|
|
53
|
+
blockHeight: 0.4,
|
|
54
|
+
pushApartRadius: 0.55,
|
|
55
|
+
pushApartHeight: 1.2,
|
|
56
|
+
hipFollow: 10,
|
|
57
|
+
hipMinSpeed: 0.3,
|
|
58
|
+
hipLimit: 0.9,
|
|
59
|
+
backwardsBelow: -0.1,
|
|
60
|
+
cadenceBase: 0.5,
|
|
61
|
+
cadencePerSpeed: 0.3,
|
|
62
|
+
cadenceMinSpeed: 0.05,
|
|
63
|
+
turnFollow: 12,
|
|
64
|
+
stepEvery: 0.75,
|
|
65
|
+
stepMinSpeed: 0.3,
|
|
66
|
+
stepNoiseRun: 8,
|
|
67
|
+
stepNoiseWalk: 3,
|
|
68
|
+
stepNoiseCrouch: 1,
|
|
69
|
+
stepNoiseWater: 2,
|
|
70
|
+
stepVolumeRun: 0.6,
|
|
71
|
+
stepVolumeWalk: 0.3,
|
|
72
|
+
shoveCost: 10,
|
|
73
|
+
shoveVolume: 1.2,
|
|
74
|
+
shoveRange: 1.6,
|
|
75
|
+
shoveCone: 0.3,
|
|
76
|
+
shoveStun: 0.9,
|
|
77
|
+
shoveSpeed: 2.5,
|
|
78
|
+
meleeMinStamina: 5,
|
|
79
|
+
meleeCostLight: 5,
|
|
80
|
+
meleeCostHeavy: 12,
|
|
81
|
+
meleeHeavyKg: 1.5,
|
|
82
|
+
meleeVolume: 0.6,
|
|
83
|
+
meleeRangeBase: 0.9,
|
|
84
|
+
meleeCone: 0.5,
|
|
85
|
+
meleeHeadChance: 0.35,
|
|
86
|
+
meleeArmChance: 0.5,
|
|
87
|
+
meleeStrengthPerPoint: 0.06,
|
|
88
|
+
meleeStrengthBase: 5,
|
|
89
|
+
meleeCritToCut: 60,
|
|
90
|
+
panicGain: 1.2,
|
|
91
|
+
panicDecay: 3,
|
|
92
|
+
panicMax: 100,
|
|
93
|
+
panicSpreadAt: 0.6,
|
|
94
|
+
panicSpread: 1.4,
|
|
95
|
+
moveSpread: 0.4
|
|
96
|
+
};
|
|
97
|
+
var defaults = {
|
|
98
|
+
numbers: numbers};
|
|
99
|
+
|
|
100
|
+
type AttributeId = 'strength' | 'vigor' | 'agility' | 'perception' | 'intellect' | 'presence';
|
|
101
|
+
type Attributes = Readonly<Record<AttributeId, number>>;
|
|
102
|
+
/** `(base + Σ coefficient × attribute) / divide`, summed left to right in the order given (the game's own order, so the floats match). */
|
|
103
|
+
type LinearFormula = {
|
|
104
|
+
readonly base: number;
|
|
105
|
+
readonly terms: readonly (readonly [AttributeId, number])[];
|
|
106
|
+
readonly divide?: number;
|
|
107
|
+
};
|
|
108
|
+
type DerivedId = 'maxHealth' | 'maxStamina' | 'runSpeed' | 'walkSpeed' | 'footstepNoise' | 'composure';
|
|
109
|
+
type DerivedFormulas = Readonly<Record<DerivedId, LinearFormula>>;
|
|
110
|
+
type Derived = Readonly<Record<DerivedId, number>>;
|
|
111
|
+
/** A wound kind: its share of the hits (drawn in the listed order, the last one takes the rest), its infection chance and whether it bleeds. */
|
|
112
|
+
type WoundRule = {
|
|
113
|
+
readonly share: number;
|
|
114
|
+
readonly infectionChance: number;
|
|
115
|
+
readonly bleeds: boolean;
|
|
116
|
+
};
|
|
117
|
+
type WoundTable = Readonly<Record<string, WoundRule>>;
|
|
118
|
+
/** An individual infection that runs on its own clock and kills at `deathSeconds`. Off by default: a normal world has none. */
|
|
119
|
+
type InfectionRule = {
|
|
120
|
+
readonly feverSeconds: number;
|
|
121
|
+
readonly deliriumSeconds: number;
|
|
122
|
+
readonly deathSeconds: number;
|
|
123
|
+
/** Seconds after death the body turns (`turned` event). */
|
|
124
|
+
readonly reanimateSeconds: number;
|
|
125
|
+
/** With fever, every this many seconds there is a `feverNoiseChance` of a cough: noise of `feverNoiseRadius` m. */
|
|
126
|
+
readonly feverNoiseEvery: number;
|
|
127
|
+
readonly feverNoiseChance: number;
|
|
128
|
+
readonly feverNoiseRadius: number;
|
|
129
|
+
readonly feverNoiseVolume: number;
|
|
130
|
+
readonly feverSpeed: number;
|
|
131
|
+
readonly feverSpread: number;
|
|
132
|
+
/** Infection chance per wound kind; a kind left out uses the wound table's `infectionChance`. */
|
|
133
|
+
readonly chances?: Readonly<Record<string, number>>;
|
|
134
|
+
};
|
|
135
|
+
type PlayerNumbers = typeof defaults.numbers;
|
|
136
|
+
/** What is in the hand for melee (the fist when absent): damage, critical (0..60 turns into a cut), reach in metres, noise radius, mass. */
|
|
137
|
+
type MeleeItem = {
|
|
138
|
+
readonly damage: number;
|
|
139
|
+
readonly crit?: number;
|
|
140
|
+
readonly reach?: number;
|
|
141
|
+
readonly noise?: number;
|
|
142
|
+
readonly kg?: number;
|
|
143
|
+
/** How it strikes, for its sound (`game-contracts`' `BlowId`). Default: `punch` for the bare fist, `blade` when it cuts (`crit`), else `blunt`. */
|
|
144
|
+
readonly blow?: BlowId;
|
|
145
|
+
};
|
|
146
|
+
/** One frame of input. Held keys are booleans; the `pressed` ones are true only on the frame the key went down. */
|
|
147
|
+
type PlayerInput = {
|
|
148
|
+
/** -1 back, 0, 1 forward. */
|
|
149
|
+
readonly forward?: number;
|
|
150
|
+
/** -1 left, 0, 1 right. */
|
|
151
|
+
readonly right?: number;
|
|
152
|
+
readonly run?: boolean;
|
|
153
|
+
/** Aiming down the sights: speed is capped and the body turns with the view at once. */
|
|
154
|
+
readonly aim?: boolean;
|
|
155
|
+
/** The trigger is held or the weapon is cooling: the body turns with the view at once. */
|
|
156
|
+
readonly firing?: boolean;
|
|
157
|
+
/** Where the view looks (radians, the camera's yaw: forward is `(-sin, -cos)`). */
|
|
158
|
+
readonly yaw?: number;
|
|
159
|
+
/** Held: dress the bleeding wound. */
|
|
160
|
+
readonly bandage?: boolean;
|
|
161
|
+
readonly pressed?: Readonly<Partial<Record<PlayerAction, boolean>>>;
|
|
162
|
+
/** The melee item in hand. */
|
|
163
|
+
readonly melee?: MeleeItem;
|
|
164
|
+
/**
|
|
165
|
+
* A foot of the body the host draws touched the ground this frame (its walk cycle, `HostEvent` `footfall`). From the first one on, the footsteps (their
|
|
166
|
+
* noise and their sound) follow the host's feet instead of the player's own stride timer, so the step is heard at the frame the foot is seen down.
|
|
167
|
+
*/
|
|
168
|
+
readonly footfall?: boolean;
|
|
169
|
+
/** What is under the feet this frame (a surface id or a material id), when the host knows better than `world.surfaceAt`. */
|
|
170
|
+
readonly surface?: string;
|
|
171
|
+
};
|
|
172
|
+
type PlayerAction = 'crouch' | 'push' | 'knife' | 'vault' | 'throw';
|
|
173
|
+
/**
|
|
174
|
+
* The crowd the player touches (a horde, any crowd): read by index, written through a few verbs. `game-crowd` implements it; a game with its own
|
|
175
|
+
* agents writes a small adapter. Only agents that are `active` (close and simulated every frame) are pushed, counted for panic or hit.
|
|
176
|
+
*/
|
|
177
|
+
interface PlayerCrowd {
|
|
178
|
+
count(): number;
|
|
179
|
+
active(i: number): boolean;
|
|
180
|
+
x(i: number): number;
|
|
181
|
+
z(i: number): number;
|
|
182
|
+
y(i: number): number;
|
|
183
|
+
floor(i: number): number;
|
|
184
|
+
chasing(i: number): boolean;
|
|
185
|
+
/** On the ground: crawling or stunned. A melee blow on it always goes to the head. */
|
|
186
|
+
down(i: number): boolean;
|
|
187
|
+
/** How much it adds to panic (default 1). */
|
|
188
|
+
panicWeight?(i: number): number;
|
|
189
|
+
/** The grabbing agent is glued to the player's body: move by `k` of the way to (x, z), stop, and face (lookX, lookZ). */
|
|
190
|
+
hold(i: number, x: number, z: number, k: number, lookX: number, lookZ: number): void;
|
|
191
|
+
stun(i: number, seconds: number, vx: number, vz: number): void;
|
|
192
|
+
/** Back to chasing, with the attack cooling for `cooldown` seconds. */
|
|
193
|
+
chase(i: number, cooldown: number): void;
|
|
194
|
+
damage(i: number, hit: {
|
|
195
|
+
region: number;
|
|
196
|
+
amount: number;
|
|
197
|
+
distance: number;
|
|
198
|
+
cut: number;
|
|
199
|
+
}): void;
|
|
200
|
+
}
|
|
201
|
+
/** What the player asks of the world. Everything is optional: the default is an open, dry field. */
|
|
202
|
+
interface PlayerWorld {
|
|
203
|
+
/** Occupancy code of the cell at (x, z): -1 outside, 0 free, 1 solid, 2 low wall that can be vaulted, 3 open door, others solid. */
|
|
204
|
+
cellKind?(x: number, z: number): number;
|
|
205
|
+
solidAt?(x: number, z: number, y: number): boolean;
|
|
206
|
+
/** Blocks the player's body at (x, z). Default `solidAt(x, z, blockHeight)` (a roof or a floor plan passes its own). */
|
|
207
|
+
blocked?(x: number, z: number): boolean;
|
|
208
|
+
inWater?(x: number, z: number): boolean;
|
|
209
|
+
/** What is under the feet at (x, z): a surface id (`concrete`, `gravel`...) or a material id (`wood_hard`, `turf`). Default `concrete`. */
|
|
210
|
+
surfaceAt?(x: number, z: number): string | undefined;
|
|
211
|
+
/** Something else drives the player this frame (a car seat, a chair, a ladder): skip moving. */
|
|
212
|
+
busy?(dt: number): boolean;
|
|
213
|
+
/** Low walls can be vaulted here (the game says no on a roof or an upper floor). Default: only on the ground floor. */
|
|
214
|
+
canVault?(): boolean;
|
|
215
|
+
/** After the move (stairs change the floor and the height). */
|
|
216
|
+
afterMove?(player: PlayerState): void;
|
|
217
|
+
crowd?: PlayerCrowd;
|
|
218
|
+
}
|
|
219
|
+
type PlayerState = {
|
|
220
|
+
x: number;
|
|
221
|
+
z: number;
|
|
222
|
+
y: number;
|
|
223
|
+
vx: number;
|
|
224
|
+
vz: number;
|
|
225
|
+
/** The body's yaw (the view's yaw + π, smoothed). */
|
|
226
|
+
yaw: number;
|
|
227
|
+
floor: number;
|
|
228
|
+
alive: boolean;
|
|
229
|
+
turned: boolean;
|
|
230
|
+
health: number;
|
|
231
|
+
stamina: number;
|
|
232
|
+
crouch: boolean;
|
|
233
|
+
running: boolean;
|
|
234
|
+
stepTimer: number;
|
|
235
|
+
phase: number;
|
|
236
|
+
hip: number;
|
|
237
|
+
grabbedBy: number;
|
|
238
|
+
grabTimer: number;
|
|
239
|
+
grabPushes: number;
|
|
240
|
+
grabNoJaw: boolean;
|
|
241
|
+
grabDrown: boolean;
|
|
242
|
+
infected: boolean;
|
|
243
|
+
infectionTime: number;
|
|
244
|
+
infectionSource: string;
|
|
245
|
+
wounds: string[];
|
|
246
|
+
bleeding: number;
|
|
247
|
+
blind: number;
|
|
248
|
+
screamBoost: number;
|
|
249
|
+
panic: number;
|
|
250
|
+
hurtFlash: number;
|
|
251
|
+
deathTime: number;
|
|
252
|
+
cause: string;
|
|
253
|
+
downTimer: number;
|
|
254
|
+
burnTimer: number;
|
|
255
|
+
scentTimer: number;
|
|
256
|
+
vaultTimer: number;
|
|
257
|
+
vault: [number, number, number, number] | null;
|
|
258
|
+
};
|
|
259
|
+
type PlayerSoundId = 'step' | 'flesh';
|
|
260
|
+
type PlayerMessageId = 'grabbed' | 'grabbed_drown' | 'bitten' | 'bandaged' | 'knife_head' | 'knife_miss' | 'pushed_off' | 'drowning' | 'no_jaw' | 'stood_up';
|
|
261
|
+
type KnownDeathCause = 'infected' | 'killed' | 'bitten_to_death' | 'infection' | 'bled_out' | 'hunger_thirst' | 'drowned' | 'burned';
|
|
262
|
+
/** Why the player died: the rule's own causes, or any id the host passes to `die`. */
|
|
263
|
+
type DeathCause = KnownDeathCause | (string & {});
|
|
264
|
+
type PlayerEventMap = {
|
|
265
|
+
noise: {
|
|
266
|
+
x: number;
|
|
267
|
+
z: number;
|
|
268
|
+
radius: number;
|
|
269
|
+
};
|
|
270
|
+
/**
|
|
271
|
+
* `sound` is the team's class (`step` or `flesh`, what the game played); `ids` are the body sounds of `game-contracts` to play together (the swing and the hit of
|
|
272
|
+
* a blow, a footstep on its surface), which `game-audio`'s `BODY_FOLEY_BANK` answers. `surface` is set for footsteps and landings.
|
|
273
|
+
*/
|
|
274
|
+
sound: {
|
|
275
|
+
sound: PlayerSoundId;
|
|
276
|
+
ids: readonly BodyFoleyId[];
|
|
277
|
+
/** Seconds after now each of `ids` starts (the hit of a blow lands at the swing's loudest point); left out, all now. */
|
|
278
|
+
at?: readonly number[];
|
|
279
|
+
volume: number;
|
|
280
|
+
position: [number, number, number];
|
|
281
|
+
surface?: SurfaceId;
|
|
282
|
+
};
|
|
283
|
+
step: {
|
|
284
|
+
x: number;
|
|
285
|
+
z: number;
|
|
286
|
+
yaw: number;
|
|
287
|
+
};
|
|
288
|
+
message: {
|
|
289
|
+
id: PlayerMessageId | DeathCause;
|
|
290
|
+
seconds: number;
|
|
291
|
+
};
|
|
292
|
+
hurt: {
|
|
293
|
+
amount: number;
|
|
294
|
+
wound: string;
|
|
295
|
+
};
|
|
296
|
+
infected: {
|
|
297
|
+
source: string;
|
|
298
|
+
};
|
|
299
|
+
stage: {
|
|
300
|
+
stage: 'fever' | 'delirium';
|
|
301
|
+
};
|
|
302
|
+
died: {
|
|
303
|
+
cause: DeathCause;
|
|
304
|
+
};
|
|
305
|
+
turned: {
|
|
306
|
+
x: number;
|
|
307
|
+
z: number;
|
|
308
|
+
floor: number;
|
|
309
|
+
};
|
|
310
|
+
grabbed: {
|
|
311
|
+
by: number;
|
|
312
|
+
noJaw: boolean;
|
|
313
|
+
drown: boolean;
|
|
314
|
+
};
|
|
315
|
+
released: {
|
|
316
|
+
by: number;
|
|
317
|
+
how: 'push' | 'knife' | 'bite' | 'scratch' | 'free';
|
|
318
|
+
};
|
|
319
|
+
vault: {
|
|
320
|
+
from: [number, number];
|
|
321
|
+
to: [number, number];
|
|
322
|
+
};
|
|
323
|
+
shove: {
|
|
324
|
+
targets: number[];
|
|
325
|
+
};
|
|
326
|
+
melee: {
|
|
327
|
+
target: number;
|
|
328
|
+
region: number;
|
|
329
|
+
damage: number;
|
|
330
|
+
distance: number;
|
|
331
|
+
cut: number;
|
|
332
|
+
};
|
|
333
|
+
throw: Record<string, never>;
|
|
334
|
+
};
|
|
335
|
+
type PlayerEventName = keyof PlayerEventMap;
|
|
336
|
+
type PlayerEvent<K extends PlayerEventName = PlayerEventName> = PlayerEventMap[K];
|
|
337
|
+
type PlayerSave = {
|
|
338
|
+
readonly state: PlayerState;
|
|
339
|
+
readonly attributes: Attributes;
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
declare const PLAYER_DEFAULTS: {
|
|
343
|
+
readonly sources: Readonly<Record<string, string>>;
|
|
344
|
+
readonly attributes: Attributes;
|
|
345
|
+
readonly derived: DerivedFormulas;
|
|
346
|
+
readonly wounds: WoundTable;
|
|
347
|
+
readonly infection: InfectionRule;
|
|
348
|
+
readonly numbers: PlayerNumbers;
|
|
349
|
+
readonly fist: MeleeItem;
|
|
350
|
+
};
|
|
351
|
+
type PlayerOptions = {
|
|
352
|
+
/** The random stream (the game passes its single stream). Default `createRng(seed)`. */
|
|
353
|
+
readonly random?: () => number;
|
|
354
|
+
readonly seed?: number;
|
|
355
|
+
/** The sheet: every attribute 5 by default. */
|
|
356
|
+
readonly attributes?: Partial<Attributes>;
|
|
357
|
+
readonly derived?: Partial<DerivedFormulas>;
|
|
358
|
+
readonly wounds?: WoundTable;
|
|
359
|
+
/** An individual infection (`true` uses the defaults; an object patches them). Off by default: the normal world comes first. */
|
|
360
|
+
readonly infection?: boolean | Partial<InfectionRule>;
|
|
361
|
+
readonly numbers?: Partial<PlayerNumbers>;
|
|
362
|
+
readonly fist?: MeleeItem;
|
|
363
|
+
readonly position?: {
|
|
364
|
+
readonly x?: number;
|
|
365
|
+
readonly z?: number;
|
|
366
|
+
readonly yaw?: number;
|
|
367
|
+
};
|
|
368
|
+
readonly world?: PlayerWorld;
|
|
369
|
+
};
|
|
370
|
+
type Player = {
|
|
371
|
+
readonly state: PlayerState;
|
|
372
|
+
readonly attributes: Attributes;
|
|
373
|
+
readonly derived: Derived;
|
|
374
|
+
readonly numbers: PlayerNumbers;
|
|
375
|
+
readonly infection: InfectionRule | null;
|
|
376
|
+
update(dt: number, input?: PlayerInput, world?: PlayerWorld): void;
|
|
377
|
+
/** A hit that opens a wound (drawn from the wound table) and may infect. `by` is the agent that hit, if any. */
|
|
378
|
+
hurt(amount: number, by?: number): void;
|
|
379
|
+
/** A bite: damage, bleeding, a bite wound and (with an infection rule) the infection. */
|
|
380
|
+
bite(by?: number): void;
|
|
381
|
+
grab(by: number, noJaw?: boolean, drown?: boolean): void;
|
|
382
|
+
release(): void;
|
|
383
|
+
knock(seconds: number): void;
|
|
384
|
+
infect(source: string): void;
|
|
385
|
+
/** Kills the player with a cause (the host's deaths: a fall, a fire). */
|
|
386
|
+
die(cause: DeathCause): void;
|
|
387
|
+
/** Infection stage: `none`, `malaise`, `fever`, `delirium`. */
|
|
388
|
+
stage(): 'none' | 'malaise' | 'fever' | 'delirium';
|
|
389
|
+
/** Seconds the infection has left, or null. */
|
|
390
|
+
timeLeft(): number | null;
|
|
391
|
+
/** What the player's state does to aim spread (panic, fever, moving); the weapon multiplies its own spread by it. */
|
|
392
|
+
spreadFactor(): number;
|
|
393
|
+
/** The agents in front (nearest first) within `range` m and a cone of `cosMin`, as `[distance, index]`. */
|
|
394
|
+
front(range: number, cosMin: number, yaw: number, crowd?: PlayerCrowd): [number, number][];
|
|
395
|
+
on<K extends PlayerEventName>(event: K, listener: (event: PlayerEventMap[K]) => void): () => void;
|
|
396
|
+
save(): PlayerSave;
|
|
397
|
+
load(save: PlayerSave): void;
|
|
398
|
+
/** The world `update` uses when it is given none. */
|
|
399
|
+
setWorld(world: PlayerWorld): void;
|
|
400
|
+
};
|
|
401
|
+
/** The derived values of a sheet (the game's `DERIV`). */
|
|
402
|
+
declare const deriveVitals: (attributes: Attributes, formulas?: DerivedFormulas) => Derived;
|
|
403
|
+
/** Which wound a hit opens: one draw, the kinds in the listed order, the last one takes the rest (the game's `FERIDA` draw). */
|
|
404
|
+
declare const drawWound: (wounds: WoundTable, random: () => number) => string;
|
|
405
|
+
/**
|
|
406
|
+
* 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
|
|
407
|
+
* arguments instead of globals. The draws on `random` happen in the game's order (wound kind, infection, the fever cough, the knife when grabbed,
|
|
408
|
+
* the melee region), so a game that passes its own stream keeps its sequence.
|
|
409
|
+
*/
|
|
410
|
+
declare function createPlayer(options?: PlayerOptions): Player;
|
|
411
|
+
|
|
412
|
+
type PlayerTestModuleOptions = PlayerOptions & {
|
|
413
|
+
readonly locale?: string;
|
|
414
|
+
};
|
|
415
|
+
/** What the scenarios use of the context the test room passes. */
|
|
416
|
+
interface PlayerScenarioLike {
|
|
417
|
+
expect(condition: boolean, label: string, data?: Record<string, unknown>): void;
|
|
418
|
+
}
|
|
419
|
+
type PlayerTestModule = TestableModule<PlayerScenarioLike> & {
|
|
420
|
+
/** The player in use (replaced when the bench changes the sheet, the seed or the infection). */
|
|
421
|
+
readonly player: Player;
|
|
422
|
+
};
|
|
423
|
+
/**
|
|
424
|
+
* 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
|
|
425
|
+
* decides walking or running, so stamina, footsteps and their noise follow the viewer. The bench hurts, bites, grabs and knocks the player down,
|
|
426
|
+
* switches the individual infection (off by default: a normal world) and sets the sheet. Footsteps and flesh sounds go to `host.audio`.
|
|
427
|
+
*/
|
|
428
|
+
declare function createPlayerTestModule(options?: PlayerTestModuleOptions): PlayerTestModule;
|
|
429
|
+
|
|
430
|
+
export { type AttributeId as A, type DeathCause as D, type InfectionRule as I, type KnownDeathCause as K, type LinearFormula as L, type MeleeItem as M, type PlayerMessageId as P, type WoundRule as W, type Attributes as a, type Derived as b, type DerivedFormulas as c, type DerivedId as d, PLAYER_DEFAULTS as e, type Player as f, type PlayerAction as g, type PlayerCrowd as h, type PlayerEvent as i, type PlayerEventMap as j, type PlayerEventName as k, type PlayerInput as l, type PlayerNumbers as m, type PlayerOptions as n, type PlayerSave as o, type PlayerSoundId as p, type PlayerState as q, type PlayerTestModule as r, type PlayerTestModuleOptions as s, type PlayerWorld as t, type WoundTable as u, createPlayer as v, createPlayerTestModule as w, deriveVitals as x, drawWound as y };
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adatechnology/game-player",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Pure, seeded player body for games: vitals from an attribute sheet, stamina, wounds and bleeding, an optional individual infection, being grabbed and breaking free, knock-downs, low-wall vaults, footstep noise, panic, shove and melee against any crowd. A literal port of the team game's player. Knows nothing about any game.",
|
|
6
6
|
"keywords": [
|
|
@@ -32,13 +32,17 @@
|
|
|
32
32
|
"types": "./dist/index.d.ts",
|
|
33
33
|
"import": "./dist/index.js"
|
|
34
34
|
},
|
|
35
|
+
"./testing": {
|
|
36
|
+
"types": "./dist/testing.d.ts",
|
|
37
|
+
"import": "./dist/testing.js"
|
|
38
|
+
},
|
|
35
39
|
"./global": "./dist/index.global.js"
|
|
36
40
|
},
|
|
37
41
|
"files": [
|
|
38
42
|
"dist"
|
|
39
43
|
],
|
|
40
44
|
"dependencies": {
|
|
41
|
-
"@adatechnology/game-contracts": "^0.
|
|
45
|
+
"@adatechnology/game-contracts": "^0.22.0"
|
|
42
46
|
},
|
|
43
47
|
"devDependencies": {
|
|
44
48
|
"@types/node": "^22.10.7",
|