@adatechnology/game-items-goods 0.4.6 → 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/index.d.ts +19 -2
- package/dist/index.global.js +769 -0
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
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
|
{
|
|
@@ -19006,6 +19028,34 @@ var pt_BR_default = {
|
|
|
19006
19028
|
var GOODS_STRINGS = { en: en_default, "pt-BR": pt_BR_default };
|
|
19007
19029
|
var pickGoodsLocale = (locale) => locale?.toLowerCase().startsWith("pt") ? "pt-BR" : "en";
|
|
19008
19030
|
var goodsText = (key, locale) => GOODS_STRINGS[pickGoodsLocale(locale)][key] ?? key;
|
|
19031
|
+
|
|
19032
|
+
// src/item-use.ts
|
|
19033
|
+
import { resolveEntry } from "@adatechnology/game-contracts";
|
|
19034
|
+
import { LIQUIDS } from "@adatechnology/game-fluids";
|
|
19035
|
+
import { resolveUse } from "@adatechnology/game-items";
|
|
19036
|
+
var drinkHydrationOf = (item, liquids = LIQUIDS) => {
|
|
19037
|
+
const fluid = item.fluid;
|
|
19038
|
+
const drink = fluid ? liquids.find((liquid) => liquid.id === fluid.liquid)?.drink : void 0;
|
|
19039
|
+
if (!fluid || !drink) return void 0;
|
|
19040
|
+
const doses = item.durability?.kind === "doses" ? Math.max(1, item.durability.amount ?? 1) : 1;
|
|
19041
|
+
return drink.thirst * fluid.liters / doses;
|
|
19042
|
+
};
|
|
19043
|
+
var createGoodsItemUse = (options = {}) => {
|
|
19044
|
+
const kinds = options.kinds ?? createGoodsKinds();
|
|
19045
|
+
const effects = options.effects ?? GOODS_USE_EFFECTS;
|
|
19046
|
+
const liquids = options.liquids ?? LIQUIDS;
|
|
19047
|
+
return (item) => {
|
|
19048
|
+
if (item.kind === void 0 || !kinds.has(item.kind)) return void 0;
|
|
19049
|
+
const result = resolveUse(item, effects);
|
|
19050
|
+
const { clip: effectClip, ...params } = result?.params ?? {};
|
|
19051
|
+
const clip = typeof effectClip === "string" ? effectClip : resolveEntry(kinds, item).use?.clip;
|
|
19052
|
+
if (clip === void 0) return void 0;
|
|
19053
|
+
if (!result) return { clip, consumes: false };
|
|
19054
|
+
const nutrition = result.nutrition ? { satiety: result.nutrition.satiety, hydration: drinkHydrationOf(item, liquids) ?? result.nutrition.hydration } : {};
|
|
19055
|
+
return { clip, consumes: result.consumes, effect: { id: result.effect, ...Object.keys(params).length > 0 ? { params } : {}, ...nutrition } };
|
|
19056
|
+
};
|
|
19057
|
+
};
|
|
19058
|
+
var goodsItemUse = createGoodsItemUse();
|
|
19009
19059
|
export {
|
|
19010
19060
|
BODY_SLOTS,
|
|
19011
19061
|
DENSITY_KG_PER_LITRE,
|
|
@@ -19031,9 +19081,12 @@ export {
|
|
|
19031
19081
|
POOL_PLACES,
|
|
19032
19082
|
checkGoodsItems,
|
|
19033
19083
|
createGoodsFindsProvider,
|
|
19084
|
+
createGoodsItemUse,
|
|
19034
19085
|
createGoodsItems,
|
|
19035
19086
|
createGoodsKinds,
|
|
19036
19087
|
createItemContracts,
|
|
19088
|
+
drinkHydrationOf,
|
|
19089
|
+
goodsItemUse,
|
|
19037
19090
|
goodsPack,
|
|
19038
19091
|
goodsText,
|
|
19039
19092
|
lootCategoriesOf,
|