@adatechnology/game-stories 0.2.8 → 0.3.1

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.
@@ -3367,6 +3367,7 @@ var GameStories = (() => {
3367
3367
  }
3368
3368
 
3369
3369
  // ../game-contracts/dist/index.js
3370
+ var DEFAULT_COST_ALLOCATION_BYTES = 1024 * 1024;
3370
3371
  var MISSING_BITS = {
3371
3372
  head: 1,
3372
3373
  armL: 2,
@@ -3379,6 +3380,54 @@ var GameStories = (() => {
3379
3380
  legRBroken: 256,
3380
3381
  jaw: 512
3381
3382
  };
3383
+ var DEFERRED_QUEUE_ID = {
3384
+ DESTRUCTION_EVENTS: "destruction.events",
3385
+ BREACH_PAINT: "floorplan.breach-paint",
3386
+ AUDIO_VOICES: "audio.voices",
3387
+ VEHICLE_CREASE: "vehicles.crease"
3388
+ };
3389
+ var DEFERRED_PRIORITY = {
3390
+ [DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS]: { priority: 300, phase: "present" },
3391
+ [DEFERRED_QUEUE_ID.BREACH_PAINT]: { priority: 250, phase: "present" },
3392
+ [DEFERRED_QUEUE_ID.AUDIO_VOICES]: { priority: 200, phase: "idle", reserveMs: 1 },
3393
+ [DEFERRED_QUEUE_ID.VEHICLE_CREASE]: { priority: 100, phase: "idle" }
3394
+ };
3395
+ var SURFACE_IDS = ["concrete", "asphalt", "wood", "tile", "dirt", "grass", "gravel", "sand", "metal", "water", "glass", "carpet"];
3396
+ var GAIT_IDS = ["walk", "run"];
3397
+ var LANDING_IDS = ["light", "heavy"];
3398
+ var BODY_SOUND_IDS = [
3399
+ "jump",
3400
+ "cloth_rustle",
3401
+ "body_fall",
3402
+ "fall_damage",
3403
+ "player_hurt",
3404
+ "player_breath_run",
3405
+ "player_death",
3406
+ "bite",
3407
+ "grab",
3408
+ "punch_swing",
3409
+ "punch_hit_body",
3410
+ "punch_hit_face",
3411
+ "punch_hit_object",
3412
+ "kick_swing",
3413
+ "kick_hit",
3414
+ "kick_hit_object",
3415
+ "shove_two_hands",
3416
+ "knife_swing",
3417
+ "knife_stab",
3418
+ "knife_slash",
3419
+ "knife_hit_object",
3420
+ "blunt_swing",
3421
+ "blunt_hit",
3422
+ "blunt_hit_object",
3423
+ "axe_swing",
3424
+ "axe_chop",
3425
+ "axe_hit_object"
3426
+ ];
3427
+ var footstepSoundId = (surface, gait) => `footstep_${surface}_${gait}`;
3428
+ var FOOTSTEP_SOUND_IDS = SURFACE_IDS.flatMap((surface) => GAIT_IDS.map((gait) => footstepSoundId(surface, gait)));
3429
+ var LAND_SOUND_IDS = SURFACE_IDS.flatMap((surface) => LANDING_IDS.map((landing) => `land_${surface}_${landing}`));
3430
+ var BODY_FOLEY_IDS = [...FOOTSTEP_SOUND_IDS, ...LAND_SOUND_IDS, ...BODY_SOUND_IDS];
3382
3431
 
3383
3432
  // ../game-characters/dist/index.js
3384
3433
  var __defProp2 = Object.defineProperty;
@@ -4687,6 +4736,7 @@ var GameStories = (() => {
4687
4736
  const seed = options.seed ?? 1;
4688
4737
  const locale = options.locale ?? "pt-BR";
4689
4738
  const names = options.names ?? getNamePools(locale);
4739
+ const ruleset = options.ruleset ?? SHEET_RULESET;
4690
4740
  const stories = options.stories ?? [];
4691
4741
  const castRandom = createRng((seed ^ 2654435769) >>> 0);
4692
4742
  const casting = castStories({ stories, ...options.people ? { people: options.people } : {}, names, random: castRandom, ...options.life?.nomadBase ? { defaultBase: options.life.nomadBase } : {} });
@@ -4715,7 +4765,7 @@ var GameStories = (() => {
4715
4765
  let made = sheets.get(id);
4716
4766
  if (!made) {
4717
4767
  const p = person(id);
4718
- made = drawSheet(createRng((seed ^ hashId(id)) >>> 0), { ...p?.profession ? { profession: p.profession } : {}, ...p?.personality ? { personality: p.personality } : {} });
4768
+ made = drawSheet(createRng((seed ^ hashId(id)) >>> 0), { ruleset, ...p?.profession ? { profession: p.profession } : {}, ...p?.personality ? { personality: p.personality } : {} });
4719
4769
  sheets.set(id, made);
4720
4770
  }
4721
4771
  return made;
@@ -4931,11 +4981,14 @@ var GameStories = (() => {
4931
4981
  var storiesBenchTextOf = (locale) => TEXT[locale] ?? PT_BR;
4932
4982
 
4933
4983
  // src/bench/module.ts
4984
+ var defaultProfessionName = (professionId, language) => getProfession(professionId)?.name[language === "en" ? "en" : "pt-BR"];
4934
4985
  var STORIES_AREA_ID = "stories_area";
4935
4986
  var MAX_DAYS = 365;
4936
4987
  var actionControl = (id) => `act_${id.toLowerCase().replace(/[^a-z0-9]+/g, "_")}`;
4937
4988
  function createStoriesTestModule(options = {}) {
4938
4989
  const locale = options.locale ?? "pt-BR";
4990
+ const ruleset = options.ruleset ?? SHEET_RULESET;
4991
+ const names = options.names ?? getNamePools(locale);
4939
4992
  const text = storiesBenchTextOf(locale);
4940
4993
  let content2 = options.content ?? STORIES_EXAMPLE[locale === "en" ? "en" : "pt-BR"];
4941
4994
  const settings = { seed: options.seed ?? 1, day: Math.min(30, content2.days ?? 90), life: true, infection: false, person: "" };
@@ -4944,6 +4997,8 @@ var GameStories = (() => {
4944
4997
  const worldOptions = (seed, withLife, infection, acts) => {
4945
4998
  const life = withLife && content2.life ? { ...content2.life, numbers: { ...content2.life.numbers, infection } } : void 0;
4946
4999
  return {
5000
+ names,
5001
+ ruleset,
4947
5002
  stories: content2.stories,
4948
5003
  ...content2.people ? { people: content2.people } : {},
4949
5004
  seed,
@@ -4982,7 +5037,7 @@ var GameStories = (() => {
4982
5037
  { label: text.sheet.state, value: state ? text.states[state.state] : "" },
4983
5038
  { label: text.sheet.base, value: state ? groupName(state.base) : "" },
4984
5039
  ...person.age !== void 0 ? [{ label: text.sheet.age, value: String(person.age) }] : [],
4985
- { label: text.sheet.profession, value: getProfession(sheet.profession)?.name[locale === "en" ? "en" : "pt-BR"] ?? sheet.profession },
5040
+ { label: text.sheet.profession, value: (options.professionName ?? defaultProfessionName)(sheet.profession, locale === "en" ? "en" : "pt-BR") ?? sheet.profession },
4986
5041
  { label: text.sheet.pool, value: String(sheet.pool()) },
4987
5042
  ...Object.entries(derived).map(([key, value]) => ({ label: text.derived[key] ?? key, value: String(Math.round(value * 100) / 100) }))
4988
5043
  ],
@@ -5065,8 +5120,8 @@ var GameStories = (() => {
5065
5120
  id: "stories_casting",
5066
5121
  name: text.scenarios.casting,
5067
5122
  run: ({ expect }) => {
5068
- const names = (seed) => run(seed, 0, false, false, {}).people().map((p) => p.name).join(",");
5069
- const drawn = new Set([1, 2, 3, 4, 5].map(names));
5123
+ const names2 = (seed) => run(seed, 0, false, false, {}).people().map((p) => p.name).join(",");
5124
+ const drawn = new Set([1, 2, 3, 4, 5].map(names2));
5070
5125
  expect(drawn.size > 1, "five seeds do not all cast the same names", { casts: drawn.size });
5071
5126
  }
5072
5127
  },
@@ -5093,11 +5148,11 @@ var GameStories = (() => {
5093
5148
  id: "stories_point_buy",
5094
5149
  name: text.scenarios.point_buy,
5095
5150
  run: ({ expect }) => {
5096
- const nurse = createSheet({ profession: "nurse" });
5151
+ const nurse = createSheet({ ruleset, profession: "nurse" });
5097
5152
  expect(nurse.pool() === 12, "a nurse starts with 14 \u2212 2 = 12 points", { pool: nurse.pool() });
5098
- const spent = createSheet({ profession: "nurse", attributes: { agility: 8 }, traits: ["athlete", "smoker"] });
5153
+ const spent = createSheet({ ruleset, profession: "nurse", attributes: { agility: 8 }, traits: ["athlete", "smoker"] });
5099
5154
  expect(spent.pool() === 6 && spent.valid(), "agility 8 (\u22125), athlete (\u22124), smoker (+3): 6 left", { pool: spent.pool() });
5100
- const clash = createSheet({ traits: ["athlete", "asthmatic"] });
5155
+ const clash = createSheet({ ruleset, traits: ["athlete", "asthmatic"] });
5101
5156
  expect(!clash.valid(), "athlete and asthmatic exclude each other");
5102
5157
  }
5103
5158
  },