| 1 | import { ItemCategory } from "./itemCategories.js"; |
| 2 | import { MaterialTier, GatherMaterialId } from "./materialTiers.js"; |
| 3 | import { StatusEffectType } from "../statusEffects/rules.js"; |
| 4 | |
| 5 | const DEFAULT_STACK = 99; |
| 6 | |
| 7 | /** Default spark charges on a fresh tinderbox. */ |
| 8 | export const TINDERBOX_MAX_CHARGES = 20; |
| 9 | |
| 10 | /** |
| 11 | * Reserved numeric IDs for gathering, crafting, and cooking content (9–25). |
| 12 | * Metal ores/bars/pickaxes above bronze live in metalItems.js (35+). |
| 13 | * IDs 11 / 12 / 25 are cotton fibre / yarn / cloth (see clothItems.js). |
| 14 | * Burnt venison uses 280; ash tiers live in woodItems.js (281+). |
| 15 | */ |
| 16 | export const CraftingItemId = Object.freeze({ |
| 17 | tinderbox: 10, |
| 18 | copperOre: 13, |
| 19 | bronzeBar: 14, |
| 20 | /** Uncooked Venison */ |
| 21 | rawMeat: 15, |
| 22 | /** Cooked Venison */ |
| 23 | cookedMeat: 16, |
| 24 | leather: 17, |
| 25 | arrowTip: 18, |
| 26 | arrow: 19, |
| 27 | bronzeAxe: 20, |
| 28 | bronzePickaxe: 21, |
| 29 | tinOre: 53, |
| 30 | burntMeat: 280 |
| 31 | }); |
| 32 | |
| 33 | /** Magenta cookable base; tinted per cook state. */ |
| 34 | const VENISON_COOK_COLORS = Object.freeze({ |
| 35 | raw: Object.freeze({ r: 0.72, g: 0.28, b: 0.32 }), |
| 36 | cooked: Object.freeze({ r: 0.55, g: 0.32, b: 0.18 }), |
| 37 | burnt: Object.freeze({ r: 0.18, g: 0.14, b: 0.12 }) |
| 38 | }); |
| 39 | |
| 40 | /** |
| 41 | * Fresh tinderbox instance payload (charges, not potion fill 1–5). |
| 42 | * @param {number} [charges] |
| 43 | */ |
| 44 | export function tinderboxItemInstance (charges = TINDERBOX_MAX_CHARGES) |
| 45 | { |
| 46 | return Object.freeze({ |
| 47 | kind: "tinderbox", |
| 48 | charges: Math.max(0, Math.min(TINDERBOX_MAX_CHARGES, charges | 0 || TINDERBOX_MAX_CHARGES)) |
| 49 | }); |
| 50 | } |
| 51 | |
| 52 | function stub (itemId, key, displayName, category, extra = {}) |
| 53 | { |
| 54 | return Object.freeze({ |
| 55 | itemId, |
| 56 | key, |
| 57 | displayName, |
| 58 | description: extra.description ?? "An unfinished good awaiting a proper name.", |
| 59 | seedValue: extra.seedValue ?? 1, |
| 60 | stackable: extra.stackable ?? true, |
| 61 | maxStackSize: extra.maxStackSize ?? DEFAULT_STACK, |
| 62 | uniqueInstance: false, |
| 63 | category, |
| 64 | stub: true, |
| 65 | iconKey: extra.iconKey ?? "paper", |
| 66 | ...extra |
| 67 | }); |
| 68 | } |
| 69 | |
| 70 | /** Minimal defs so recipes and the craft UI can resolve names/icons before art exists. */ |
| 71 | export const CRAFTING_ITEM_STUBS = Object.freeze({ |
| 72 | [CraftingItemId.tinderbox]: Object.freeze({ |
| 73 | itemId: CraftingItemId.tinderbox, |
| 74 | key: "tinderbox", |
| 75 | displayName: "Tinderbox", |
| 76 | description: "A flint and steel kit for coaxing sparks onto dry wood.", |
| 77 | seedValue: 8, |
| 78 | stackable: false, |
| 79 | maxStackSize: 1, |
| 80 | uniqueInstance: true, |
| 81 | category: ItemCategory.tool, |
| 82 | iconKey: "tinderbox", |
| 83 | defaultState: "tinderbox", |
| 84 | /** Show tinderbox-equip while lighting a ground log (not worn gear). */ |
| 85 | gatherEquipSprite: true, |
| 86 | npcShopAllowed: true, |
| 87 | defaultInstance: tinderboxItemInstance() |
| 88 | }), |
| 89 | [CraftingItemId.copperOre]: Object.freeze({ |
| 90 | itemId: CraftingItemId.copperOre, |
| 91 | key: "copper-ore", |
| 92 | displayName: "Copper ore", |
| 93 | description: "Reddish copper ore. Smelt with tin at a furnace into bronze bars.", |
| 94 | seedValue: 5, |
| 95 | stackable: true, |
| 96 | maxStackSize: DEFAULT_STACK, |
| 97 | uniqueInstance: false, |
| 98 | category: ItemCategory.ingredient, |
| 99 | iconKey: "metal", |
| 100 | defaultState: "ore", |
| 101 | tier: GatherMaterialId.copper, |
| 102 | tintFromTier: true |
| 103 | }), |
| 104 | [CraftingItemId.tinOre]: Object.freeze({ |
| 105 | itemId: CraftingItemId.tinOre, |
| 106 | key: "tin-ore", |
| 107 | displayName: "Tin ore", |
| 108 | description: "Pale tin ore. Smelt with copper at a furnace into bronze bars.", |
| 109 | seedValue: 5, |
| 110 | stackable: true, |
| 111 | maxStackSize: DEFAULT_STACK, |
| 112 | uniqueInstance: false, |
| 113 | category: ItemCategory.ingredient, |
| 114 | iconKey: "metal", |
| 115 | defaultState: "ore", |
| 116 | tier: GatherMaterialId.tin, |
| 117 | tintFromTier: true |
| 118 | }), |
| 119 | [CraftingItemId.bronzeBar]: Object.freeze({ |
| 120 | itemId: CraftingItemId.bronzeBar, |
| 121 | key: "bronze-bar", |
| 122 | displayName: "Bronze bar", |
| 123 | description: "A solid bronze bar, ready for the anvil.", |
| 124 | seedValue: 4, |
| 125 | stackable: true, |
| 126 | maxStackSize: DEFAULT_STACK, |
| 127 | uniqueInstance: false, |
| 128 | category: ItemCategory.intermediate, |
| 129 | iconKey: "metal", |
| 130 | defaultState: "bar", |
| 131 | tier: MaterialTier.bronze, |
| 132 | tintFromTier: true |
| 133 | }), |
| 134 | [CraftingItemId.rawMeat]: Object.freeze({ |
| 135 | itemId: CraftingItemId.rawMeat, |
| 136 | key: "uncooked-venison", |
| 137 | displayName: "Uncooked Venison", |
| 138 | description: "Fresh deer meat. Cook at an oven or campfire.", |
| 139 | seedValue: 3, |
| 140 | stackable: true, |
| 141 | maxStackSize: DEFAULT_STACK, |
| 142 | uniqueInstance: false, |
| 143 | category: ItemCategory.ingredient, |
| 144 | iconKey: "meat", |
| 145 | defaultState: "raw", |
| 146 | cookable: true, |
| 147 | cookState: "raw", |
| 148 | burntItemId: CraftingItemId.burntMeat, |
| 149 | tint: VENISON_COOK_COLORS.raw |
| 150 | }), |
| 151 | [CraftingItemId.cookedMeat]: Object.freeze({ |
| 152 | itemId: CraftingItemId.cookedMeat, |
| 153 | key: "cooked-venison", |
| 154 | displayName: "Cooked Venison", |
| 155 | description: "Roasted deer meat, still warm from the fire.", |
| 156 | seedValue: 4, |
| 157 | stackable: true, |
| 158 | maxStackSize: DEFAULT_STACK, |
| 159 | uniqueInstance: false, |
| 160 | category: ItemCategory.food, |
| 161 | iconKey: "meat", |
| 162 | defaultState: "cooked", |
| 163 | cookable: true, |
| 164 | cookState: "cooked", |
| 165 | tint: VENISON_COOK_COLORS.cooked, |
| 166 | healing: 5, |
| 167 | eatStatusEffect: Object.freeze({ |
| 168 | type: StatusEffectType.healthRegen, |
| 169 | amountPerSecond: 1, |
| 170 | durationMs: 5_000 |
| 171 | }) |
| 172 | }), |
| 173 | [CraftingItemId.burntMeat]: Object.freeze({ |
| 174 | itemId: CraftingItemId.burntMeat, |
| 175 | key: "burnt-venison", |
| 176 | displayName: "Burnt Venison", |
| 177 | description: "Charred beyond saving — little more than a bitter lump.", |
| 178 | seedValue: 1, |
| 179 | stackable: true, |
| 180 | maxStackSize: DEFAULT_STACK, |
| 181 | uniqueInstance: false, |
| 182 | category: ItemCategory.food, |
| 183 | iconKey: "meat", |
| 184 | defaultState: "burnt", |
| 185 | cookable: true, |
| 186 | cookState: "burnt", |
| 187 | tint: VENISON_COOK_COLORS.burnt |
| 188 | }) |
| 189 | }); |