@adatechnology/game-items 0.1.10 → 0.2.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 +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.global.js +8 -0
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ const { contents, leftover } = placeFinds(stacks, slots, items)
|
|
|
70
70
|
| `advanceAge`, `moveToStorage`, `storageMultiplier`, `freshness`, `shelfRatio`, `chargeLevel`, `failsToStart` | aging and decay |
|
|
71
71
|
| `blockChance`, `wearBlocked`, `repairPiece`, `pieceBlock` | layered clothing protection |
|
|
72
72
|
| `maxLoadKg`, `carriedKg`, `loadState`, `bagOption`, `canTake` | carry weight and slots |
|
|
73
|
-
| `resolveUse` | what using an item does, as data |
|
|
73
|
+
| `resolveUse` | what using an item does, as data; with `UseContext.seal` a sealed item (`ItemDef.seal`, a `SealSpec` of game-contracts) still closed, holed or leaking is not eaten (`blocked`) |
|
|
74
74
|
| `canCraft`, `craft` | recipes |
|
|
75
75
|
| `createFindsProvider`, `rollByCategory`, `rollExplicitPool`, `spawnData`, `depletionFactor`, `placeFinds`, `toLootTables` | finds |
|
|
76
76
|
| `itemsFromArsenal` | the arsenal as items |
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BodySlot, DeepPartial } from '@adatechnology/game-contracts';
|
|
1
|
+
import { BodySlot, SealSpec, DeepPartial, SealState, SealBlock } from '@adatechnology/game-contracts';
|
|
2
2
|
export { BodySlot } from '@adatechnology/game-contracts';
|
|
3
3
|
import { ItemDef as ItemDef$1, rng, ItemStack, SlotSpec, LootTables } from '@adatechnology/game-interactables';
|
|
4
4
|
export { ItemDef as BaseItemDef } from '@adatechnology/game-interactables';
|
|
@@ -180,6 +180,8 @@ interface ItemDef extends ItemDef$1 {
|
|
|
180
180
|
chance: number;
|
|
181
181
|
};
|
|
182
182
|
/** Key of the 3D model in `game-items-three`; without it a simple shape from `shape` is drawn. */
|
|
183
|
+
/** A sealed container (a food tin, a drink can): what opens it and whether a breach spoils it. The kinds of a content pack give it (`game-items-goods`). */
|
|
184
|
+
seal?: SealSpec;
|
|
183
185
|
model?: string;
|
|
184
186
|
}
|
|
185
187
|
/** A bundle of content: items plus the categories, places and containers they rely on. */
|
|
@@ -492,6 +494,8 @@ interface UseContext {
|
|
|
492
494
|
freshness?: Freshness;
|
|
493
495
|
/** The food was cooked: it keeps only `cookedPoisonFactor` of its poison chance. */
|
|
494
496
|
isCooked?: boolean;
|
|
497
|
+
/** State of a sealed item (`ItemDef.seal`): opened, holed, leaking. Given, a closed or spoiled container is not eaten (`UseResult.blocked`). */
|
|
498
|
+
seal?: SealState;
|
|
495
499
|
}
|
|
496
500
|
interface NutritionResult {
|
|
497
501
|
satiety: number;
|
|
@@ -508,6 +512,8 @@ interface UseResult {
|
|
|
508
512
|
consumes: boolean;
|
|
509
513
|
/** Only for `consume_nutrition`. */
|
|
510
514
|
nutrition?: NutritionResult;
|
|
515
|
+
/** Why it cannot be eaten or drunk now: still `sealed`, or spoiled by a hole (`breached`) or a leak (`leaked`). Only with `UseContext.seal`. */
|
|
516
|
+
blocked?: SealBlock;
|
|
511
517
|
}
|
|
512
518
|
/**
|
|
513
519
|
* What using `item` does, as data: the host applies it (the player, the needs, the world). Pure. The first effect that lists the item wins, then the first
|
package/dist/index.global.js
CHANGED
|
@@ -61,6 +61,12 @@ var GameItems = (() => {
|
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
// ../game-contracts/dist/index.js
|
|
64
|
+
var sealBlock = (seal, state) => {
|
|
65
|
+
if (seal.spoilsWhenBreached && state.breached) return "breached";
|
|
66
|
+
if (seal.spoilsWhenBreached && state.leaked) return "leaked";
|
|
67
|
+
if (!state.opened) return "sealed";
|
|
68
|
+
return void 0;
|
|
69
|
+
};
|
|
64
70
|
var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
65
71
|
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
66
72
|
var deepMerge = (base, patch) => {
|
|
@@ -440,6 +446,8 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
|
|
|
440
446
|
const base = { useId: def.id, effect: def.effect, params: def.params ?? {}, consumes: def.consumes };
|
|
441
447
|
if (def.effect !== "consume_nutrition") return base;
|
|
442
448
|
const nutrition = nutritionOf(item, context, rules);
|
|
449
|
+
const blocked = item.seal && context.seal ? sealBlock(item.seal, context.seal) : void 0;
|
|
450
|
+
if (blocked) return { ...base, consumes: false, nutrition: { ...nutrition, isEdible: false }, blocked };
|
|
443
451
|
return { ...base, consumes: def.consumes && nutrition.isEdible, nutrition };
|
|
444
452
|
};
|
|
445
453
|
|