@adatechnology/game-items-goods 0.4.7 → 0.6.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/index.js CHANGED
@@ -13790,6 +13790,12 @@ var kinds_default = [
13790
13790
  impact: {
13791
13791
  response: "dent",
13792
13792
  pushImpulse: true
13793
+ },
13794
+ use: {
13795
+ clip: "use_hygiene",
13796
+ sounds: [
13797
+ "scrub"
13798
+ ]
13793
13799
  }
13794
13800
  }
13795
13801
  }
@@ -17639,6 +17645,22 @@ var use_effects_default = [
17639
17645
  items: [
17640
17646
  "alcohol_70",
17641
17647
  "povidone_iodine"
17648
+ ],
17649
+ params: {
17650
+ clip: "apply_dressing"
17651
+ }
17652
+ },
17653
+ {
17654
+ id: "wash",
17655
+ effect: "wash",
17656
+ consumes: false,
17657
+ items: [
17658
+ "soap",
17659
+ "shampoo",
17660
+ "toothpaste",
17661
+ "toothbrush",
17662
+ "deodorant",
17663
+ "towel"
17642
17664
  ]
17643
17665
  },
17644
17666
  {
@@ -17660,7 +17682,44 @@ var use_effects_default = [
17660
17682
  consumes: false,
17661
17683
  items: [
17662
17684
  "flashlight"
17663
- ]
17685
+ ],
17686
+ params: {
17687
+ clip: "toggle_flashlight"
17688
+ }
17689
+ },
17690
+ {
17691
+ id: "ignite",
17692
+ effect: "ignite",
17693
+ consumes: false,
17694
+ items: [
17695
+ "lighter"
17696
+ ],
17697
+ params: {
17698
+ clip: "light_lighter"
17699
+ }
17700
+ },
17701
+ {
17702
+ id: "radio_call",
17703
+ effect: "radio_call",
17704
+ consumes: false,
17705
+ items: [
17706
+ "portable_radio",
17707
+ "walkie_talkies"
17708
+ ],
17709
+ params: {
17710
+ clip: "use_radio"
17711
+ }
17712
+ },
17713
+ {
17714
+ id: "turn_key",
17715
+ effect: "turn_key",
17716
+ consumes: false,
17717
+ category: [
17718
+ "keys"
17719
+ ],
17720
+ params: {
17721
+ clip: "turn_key"
17722
+ }
17664
17723
  },
17665
17724
  {
17666
17725
  id: "swap_bag",
@@ -19006,6 +19065,34 @@ var pt_BR_default = {
19006
19065
  var GOODS_STRINGS = { en: en_default, "pt-BR": pt_BR_default };
19007
19066
  var pickGoodsLocale = (locale) => locale?.toLowerCase().startsWith("pt") ? "pt-BR" : "en";
19008
19067
  var goodsText = (key, locale) => GOODS_STRINGS[pickGoodsLocale(locale)][key] ?? key;
19068
+
19069
+ // src/item-use.ts
19070
+ import { resolveEntry } from "@adatechnology/game-contracts";
19071
+ import { LIQUIDS } from "@adatechnology/game-fluids";
19072
+ import { resolveUse } from "@adatechnology/game-items";
19073
+ var drinkHydrationOf = (item, liquids = LIQUIDS) => {
19074
+ const fluid = item.fluid;
19075
+ const drink = fluid ? liquids.find((liquid) => liquid.id === fluid.liquid)?.drink : void 0;
19076
+ if (!fluid || !drink) return void 0;
19077
+ const doses = item.durability?.kind === "doses" ? Math.max(1, item.durability.amount ?? 1) : 1;
19078
+ return drink.thirst * fluid.liters / doses;
19079
+ };
19080
+ var createGoodsItemUse = (options = {}) => {
19081
+ const kinds = options.kinds ?? createGoodsKinds();
19082
+ const effects = options.effects ?? GOODS_USE_EFFECTS;
19083
+ const liquids = options.liquids ?? LIQUIDS;
19084
+ return (item) => {
19085
+ if (item.kind === void 0 || !kinds.has(item.kind)) return void 0;
19086
+ const result = resolveUse(item, effects);
19087
+ const { clip: effectClip, ...params } = result?.params ?? {};
19088
+ const clip = typeof effectClip === "string" ? effectClip : resolveEntry(kinds, item).use?.clip;
19089
+ if (clip === void 0) return void 0;
19090
+ if (!result) return { clip, consumes: false };
19091
+ const nutrition = result.nutrition ? { satiety: result.nutrition.satiety, hydration: drinkHydrationOf(item, liquids) ?? result.nutrition.hydration } : {};
19092
+ return { clip, consumes: result.consumes, effect: { id: result.effect, ...Object.keys(params).length > 0 ? { params } : {}, ...nutrition } };
19093
+ };
19094
+ };
19095
+ var goodsItemUse = createGoodsItemUse();
19009
19096
  export {
19010
19097
  BODY_SLOTS,
19011
19098
  DENSITY_KG_PER_LITRE,
@@ -19031,9 +19118,12 @@ export {
19031
19118
  POOL_PLACES,
19032
19119
  checkGoodsItems,
19033
19120
  createGoodsFindsProvider,
19121
+ createGoodsItemUse,
19034
19122
  createGoodsItems,
19035
19123
  createGoodsKinds,
19036
19124
  createItemContracts,
19125
+ drinkHydrationOf,
19126
+ goodsItemUse,
19037
19127
  goodsPack,
19038
19128
  goodsText,
19039
19129
  lootCategoriesOf,