import { ItemCategory } from "./itemCategories.js"; import { MaterialTier, GatherMaterialId } from "./materialTiers.js"; import { StatusEffectType } from "../statusEffects/rules.js"; const DEFAULT_STACK = 99; /** Default spark charges on a fresh tinderbox. */ export const TINDERBOX_MAX_CHARGES = 20; /** * Reserved numeric IDs for gathering, crafting, and cooking content (9–25). * Metal ores/bars/pickaxes above bronze live in metalItems.js (35+). * IDs 11 / 12 / 25 are cotton fibre / yarn / cloth (see clothItems.js). * Burnt venison uses 280; ash tiers live in woodItems.js (281+). */ export const CraftingItemId = Object.freeze({ tinderbox: 10, copperOre: 13, bronzeBar: 14, /** Uncooked Venison */ rawMeat: 15, /** Cooked Venison */ cookedMeat: 16, leather: 17, arrowTip: 18, arrow: 19, bronzeAxe: 20, bronzePickaxe: 21, tinOre: 53, burntMeat: 280 }); /** Magenta cookable base; tinted per cook state. */ const VENISON_COOK_COLORS = Object.freeze({ raw: Object.freeze({ r: 0.72, g: 0.28, b: 0.32 }), cooked: Object.freeze({ r: 0.55, g: 0.32, b: 0.18 }), burnt: Object.freeze({ r: 0.18, g: 0.14, b: 0.12 }) }); /** * Fresh tinderbox instance payload (charges, not potion fill 1–5). * @param {number} [charges] */ export function tinderboxItemInstance (charges = TINDERBOX_MAX_CHARGES) { return Object.freeze({ kind: "tinderbox", charges: Math.max(0, Math.min(TINDERBOX_MAX_CHARGES, charges | 0 || TINDERBOX_MAX_CHARGES)) }); } function stub (itemId, key, displayName, category, extra = {}) { return Object.freeze({ itemId, key, displayName, description: extra.description ?? "An unfinished good awaiting a proper name.", seedValue: extra.seedValue ?? 1, stackable: extra.stackable ?? true, maxStackSize: extra.maxStackSize ?? DEFAULT_STACK, uniqueInstance: false, category, stub: true, iconKey: extra.iconKey ?? "paper", ...extra }); } /** Minimal defs so recipes and the craft UI can resolve names/icons before art exists. */ export const CRAFTING_ITEM_STUBS = Object.freeze({ [CraftingItemId.tinderbox]: Object.freeze({ itemId: CraftingItemId.tinderbox, key: "tinderbox", displayName: "Tinderbox", description: "A flint and steel kit for coaxing sparks onto dry wood.", seedValue: 8, stackable: false, maxStackSize: 1, uniqueInstance: true, category: ItemCategory.tool, iconKey: "tinderbox", defaultState: "tinderbox", /** Show tinderbox-equip while lighting a ground log (not worn gear). */ gatherEquipSprite: true, npcShopAllowed: true, defaultInstance: tinderboxItemInstance() }), [CraftingItemId.copperOre]: Object.freeze({ itemId: CraftingItemId.copperOre, key: "copper-ore", displayName: "Copper ore", description: "Reddish copper ore. Smelt with tin at a furnace into bronze bars.", seedValue: 5, stackable: true, maxStackSize: DEFAULT_STACK, uniqueInstance: false, category: ItemCategory.ingredient, iconKey: "metal", defaultState: "ore", tier: GatherMaterialId.copper, tintFromTier: true }), [CraftingItemId.tinOre]: Object.freeze({ itemId: CraftingItemId.tinOre, key: "tin-ore", displayName: "Tin ore", description: "Pale tin ore. Smelt with copper at a furnace into bronze bars.", seedValue: 5, stackable: true, maxStackSize: DEFAULT_STACK, uniqueInstance: false, category: ItemCategory.ingredient, iconKey: "metal", defaultState: "ore", tier: GatherMaterialId.tin, tintFromTier: true }), [CraftingItemId.bronzeBar]: Object.freeze({ itemId: CraftingItemId.bronzeBar, key: "bronze-bar", displayName: "Bronze bar", description: "A solid bronze bar, ready for the anvil.", seedValue: 4, stackable: true, maxStackSize: DEFAULT_STACK, uniqueInstance: false, category: ItemCategory.intermediate, iconKey: "metal", defaultState: "bar", tier: MaterialTier.bronze, tintFromTier: true }), [CraftingItemId.rawMeat]: Object.freeze({ itemId: CraftingItemId.rawMeat, key: "uncooked-venison", displayName: "Uncooked Venison", description: "Fresh deer meat. Cook at an oven or campfire.", seedValue: 3, stackable: true, maxStackSize: DEFAULT_STACK, uniqueInstance: false, category: ItemCategory.ingredient, iconKey: "meat", defaultState: "raw", cookable: true, cookState: "raw", burntItemId: CraftingItemId.burntMeat, tint: VENISON_COOK_COLORS.raw }), [CraftingItemId.cookedMeat]: Object.freeze({ itemId: CraftingItemId.cookedMeat, key: "cooked-venison", displayName: "Cooked Venison", description: "Roasted deer meat, still warm from the fire.", seedValue: 4, stackable: true, maxStackSize: DEFAULT_STACK, uniqueInstance: false, category: ItemCategory.food, iconKey: "meat", defaultState: "cooked", cookable: true, cookState: "cooked", tint: VENISON_COOK_COLORS.cooked, healing: 5, eatStatusEffect: Object.freeze({ type: StatusEffectType.healthRegen, amountPerSecond: 1, durationMs: 5_000 }) }), [CraftingItemId.burntMeat]: Object.freeze({ itemId: CraftingItemId.burntMeat, key: "burnt-venison", displayName: "Burnt Venison", description: "Charred beyond saving — little more than a bitter lump.", seedValue: 1, stackable: true, maxStackSize: DEFAULT_STACK, uniqueInstance: false, category: ItemCategory.food, iconKey: "meat", defaultState: "burnt", cookable: true, cookState: "burnt", tint: VENISON_COOK_COLORS.burnt }) });