| 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 = 6; |
| 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 | rawMutton: 506, |
| 32 | cookedMutton: 507, |
| 33 | burntMutton: 508, |
| 34 | rawGoat: 509, |
| 35 | cookedGoat: 510, |
| 36 | burntGoat: 511 |
| 37 | }); |
| 38 | |
| 39 | /** Magenta cookable base; tinted per cook state. */ |
| 40 | const VENISON_COOK_COLORS = Object.freeze({ |
| 41 | raw: Object.freeze({ r: 0.72, g: 0.28, b: 0.32 }), |
| 42 | cooked: Object.freeze({ r: 0.55, g: 0.32, b: 0.18 }), |
| 43 | burnt: Object.freeze({ r: 0.18, g: 0.14, b: 0.12 }) |
| 44 | }); |
| 45 | |
| 46 | const MUTTON_COOK_COLORS = Object.freeze({ |
| 47 | raw: Object.freeze({ r: 0.78, g: 0.36, b: 0.4 }), |
| 48 | cooked: Object.freeze({ r: 0.62, g: 0.36, b: 0.22 }), |
| 49 | burnt: Object.freeze({ r: 0.2, g: 0.15, b: 0.12 }) |
| 50 | }); |
| 51 | |
| 52 | const GOAT_COOK_COLORS = Object.freeze({ |
| 53 | raw: Object.freeze({ r: 0.68, g: 0.34, b: 0.38 }), |
| 54 | cooked: Object.freeze({ r: 0.5, g: 0.3, b: 0.2 }), |
| 55 | burnt: Object.freeze({ r: 0.16, g: 0.13, b: 0.11 }) |
| 56 | }); |
| 57 | |
| 58 | /** |
| 59 | * Fresh tinderbox instance payload (charges, not potion fill 1–5). |
| 60 | * @param {number} [charges] |
| 61 | */ |
| 62 | export function tinderboxItemInstance (charges = TINDERBOX_MAX_CHARGES) |
| 63 | { |
| 64 | return Object.freeze({ |
| 65 | kind: "tinderbox", |
| 66 | charges: Math.max(0, Math.min(TINDERBOX_MAX_CHARGES, charges | 0 || TINDERBOX_MAX_CHARGES)) |
| 67 | }); |
| 68 | } |
| 69 | |
| 70 | function stub (itemId, key, displayName, category, extra = {}) |
| 71 | { |
| 72 | return Object.freeze({ |
| 73 | itemId, |
| 74 | key, |
| 75 | displayName, |
| 76 | description: extra.description ?? "An unfinished good awaiting a proper name.", |
| 77 | seedValue: extra.seedValue ?? 1, |
| 78 | stackable: extra.stackable ?? true, |
| 79 | maxStackSize: extra.maxStackSize ?? DEFAULT_STACK, |
| 80 | uniqueInstance: false, |
| 81 | category, |
| 82 | stub: true, |
| 83 | iconKey: extra.iconKey ?? "paper", |
| 84 | ...extra |
| 85 | }); |
| 86 | } |
| 87 | |
| 88 | /** Minimal defs so recipes and the craft UI can resolve names/icons before art exists. */ |
| 89 | export const CRAFTING_ITEM_STUBS = Object.freeze({ |
| 90 | [CraftingItemId.tinderbox]: Object.freeze({ |
| 91 | itemId: CraftingItemId.tinderbox, |
| 92 | key: "tinderbox", |
| 93 | displayName: "Tinderbox", |
| 94 | description: "A flint and steel kit for coaxing sparks onto dry wood.", |
| 95 | seedValue: 8, |
| 96 | stackable: false, |
| 97 | maxStackSize: 1, |
| 98 | uniqueInstance: true, |
| 99 | category: ItemCategory.tool, |
| 100 | iconKey: "tinderbox", |
| 101 | defaultState: "tinderbox", |
| 102 | /** Sheet: 3×2 of 16px — frame index matches remaining uses (1…6). */ |
| 103 | frames: 6, |
| 104 | framesPerRow: 3, |
| 105 | maxCharges: TINDERBOX_MAX_CHARGES, |
| 106 | /** Show tinderbox-equip while lighting a ground log (not worn gear). */ |
| 107 | gatherEquipSprite: true, |
| 108 | npcShopAllowed: true, |
| 109 | defaultInstance: tinderboxItemInstance() |
| 110 | }), |
| 111 | [CraftingItemId.copperOre]: Object.freeze({ |
| 112 | itemId: CraftingItemId.copperOre, |
| 113 | key: "copper-ore", |
| 114 | displayName: "Copper ore", |
| 115 | description: "Reddish copper ore. Smelt with tin at a furnace into bronze bars.", |
| 116 | seedValue: 5, |
| 117 | stackable: true, |
| 118 | maxStackSize: DEFAULT_STACK, |
| 119 | uniqueInstance: false, |
| 120 | category: ItemCategory.ingredient, |
| 121 | iconKey: "metal", |
| 122 | defaultState: "ore", |
| 123 | tier: GatherMaterialId.copper, |
| 124 | tintFromTier: true |
| 125 | }), |
| 126 | [CraftingItemId.tinOre]: Object.freeze({ |
| 127 | itemId: CraftingItemId.tinOre, |
| 128 | key: "tin-ore", |
| 129 | displayName: "Tin ore", |
| 130 | description: "Pale tin ore. Smelt with copper at a furnace into bronze bars.", |
| 131 | seedValue: 5, |
| 132 | stackable: true, |
| 133 | maxStackSize: DEFAULT_STACK, |
| 134 | uniqueInstance: false, |
| 135 | category: ItemCategory.ingredient, |
| 136 | iconKey: "metal", |
| 137 | defaultState: "ore", |
| 138 | tier: GatherMaterialId.tin, |
| 139 | tintFromTier: true |
| 140 | }), |
| 141 | [CraftingItemId.bronzeBar]: Object.freeze({ |
| 142 | itemId: CraftingItemId.bronzeBar, |
| 143 | key: "bronze-bar", |
| 144 | displayName: "Bronze bar", |
| 145 | description: "A solid bronze bar, ready for the anvil.", |
| 146 | seedValue: 4, |
| 147 | stackable: true, |
| 148 | maxStackSize: DEFAULT_STACK, |
| 149 | uniqueInstance: false, |
| 150 | category: ItemCategory.intermediate, |
| 151 | iconKey: "metal", |
| 152 | defaultState: "bar", |
| 153 | tier: MaterialTier.bronze, |
| 154 | tintFromTier: true |
| 155 | }), |
| 156 | [CraftingItemId.rawMeat]: Object.freeze({ |
| 157 | itemId: CraftingItemId.rawMeat, |
| 158 | key: "uncooked-venison", |
| 159 | displayName: "Uncooked Venison", |
| 160 | description: "Fresh deer meat. Cook at an oven or campfire.", |
| 161 | seedValue: 3, |
| 162 | stackable: true, |
| 163 | maxStackSize: DEFAULT_STACK, |
| 164 | uniqueInstance: false, |
| 165 | category: ItemCategory.ingredient, |
| 166 | iconKey: "meat", |
| 167 | defaultState: "raw", |
| 168 | cookable: true, |
| 169 | cookState: "raw", |
| 170 | cookedItemId: CraftingItemId.cookedMeat, |
| 171 | burntItemId: CraftingItemId.burntMeat, |
| 172 | tint: VENISON_COOK_COLORS.raw |
| 173 | }), |
| 174 | [CraftingItemId.cookedMeat]: Object.freeze({ |
| 175 | itemId: CraftingItemId.cookedMeat, |
| 176 | key: "cooked-venison", |
| 177 | displayName: "Cooked Venison", |
| 178 | description: "Roasted deer meat, still warm from the fire.", |
| 179 | seedValue: 4, |
| 180 | stackable: true, |
| 181 | maxStackSize: DEFAULT_STACK, |
| 182 | uniqueInstance: false, |
| 183 | category: ItemCategory.food, |
| 184 | iconKey: "meat", |
| 185 | defaultState: "cooked", |
| 186 | cookable: true, |
| 187 | cookState: "cooked", |
| 188 | tint: VENISON_COOK_COLORS.cooked, |
| 189 | healing: 5, |
| 190 | eatStatusEffect: Object.freeze({ |
| 191 | type: StatusEffectType.healthRegen, |
| 192 | amountPerSecond: 1, |
| 193 | durationMs: 5_000 |
| 194 | }) |
| 195 | }), |
| 196 | [CraftingItemId.burntMeat]: Object.freeze({ |
| 197 | itemId: CraftingItemId.burntMeat, |
| 198 | key: "burnt-venison", |
| 199 | displayName: "Burnt Venison", |
| 200 | description: "Charred beyond saving — little more than a bitter lump.", |
| 201 | seedValue: 1, |
| 202 | stackable: true, |
| 203 | maxStackSize: DEFAULT_STACK, |
| 204 | uniqueInstance: false, |
| 205 | category: ItemCategory.food, |
| 206 | iconKey: "meat", |
| 207 | defaultState: "burnt", |
| 208 | cookable: true, |
| 209 | cookState: "burnt", |
| 210 | tint: VENISON_COOK_COLORS.burnt |
| 211 | }), |
| 212 | [CraftingItemId.rawMutton]: Object.freeze({ |
| 213 | itemId: CraftingItemId.rawMutton, |
| 214 | key: "uncooked-mutton", |
| 215 | displayName: "Uncooked Mutton", |
| 216 | description: "Fresh sheep meat. Cook at an oven or campfire.", |
| 217 | seedValue: 3, |
| 218 | stackable: true, |
| 219 | maxStackSize: DEFAULT_STACK, |
| 220 | uniqueInstance: false, |
| 221 | category: ItemCategory.ingredient, |
| 222 | iconKey: "meat", |
| 223 | defaultState: "raw", |
| 224 | cookable: true, |
| 225 | cookState: "raw", |
| 226 | cookedItemId: CraftingItemId.cookedMutton, |
| 227 | burntItemId: CraftingItemId.burntMutton, |
| 228 | tint: MUTTON_COOK_COLORS.raw |
| 229 | }), |
| 230 | [CraftingItemId.cookedMutton]: Object.freeze({ |
| 231 | itemId: CraftingItemId.cookedMutton, |
| 232 | key: "cooked-mutton", |
| 233 | displayName: "Cooked Mutton", |
| 234 | description: "Roasted mutton with a hearty, pastoral flavour.", |
| 235 | seedValue: 4, |
| 236 | stackable: true, |
| 237 | maxStackSize: DEFAULT_STACK, |
| 238 | uniqueInstance: false, |
| 239 | category: ItemCategory.food, |
| 240 | iconKey: "meat", |
| 241 | defaultState: "cooked", |
| 242 | cookable: true, |
| 243 | cookState: "cooked", |
| 244 | tint: MUTTON_COOK_COLORS.cooked, |
| 245 | healing: 5, |
| 246 | eatStatusEffect: Object.freeze({ |
| 247 | type: StatusEffectType.healthRegen, |
| 248 | amountPerSecond: 1, |
| 249 | durationMs: 5_000 |
| 250 | }) |
| 251 | }), |
| 252 | [CraftingItemId.burntMutton]: Object.freeze({ |
| 253 | itemId: CraftingItemId.burntMutton, |
| 254 | key: "burnt-mutton", |
| 255 | displayName: "Burnt Mutton", |
| 256 | description: "Blackened mutton — tough and bitter.", |
| 257 | seedValue: 1, |
| 258 | stackable: true, |
| 259 | maxStackSize: DEFAULT_STACK, |
| 260 | uniqueInstance: false, |
| 261 | category: ItemCategory.food, |
| 262 | iconKey: "meat", |
| 263 | defaultState: "burnt", |
| 264 | cookable: true, |
| 265 | cookState: "burnt", |
| 266 | tint: MUTTON_COOK_COLORS.burnt |
| 267 | }), |
| 268 | [CraftingItemId.rawGoat]: Object.freeze({ |
| 269 | itemId: CraftingItemId.rawGoat, |
| 270 | key: "uncooked-goat", |
| 271 | displayName: "Uncooked Goat", |
| 272 | description: "Lean goat meat. Cook at an oven or campfire.", |
| 273 | seedValue: 4, |
| 274 | stackable: true, |
| 275 | maxStackSize: DEFAULT_STACK, |
| 276 | uniqueInstance: false, |
| 277 | category: ItemCategory.ingredient, |
| 278 | iconKey: "meat", |
| 279 | defaultState: "raw", |
| 280 | cookable: true, |
| 281 | cookState: "raw", |
| 282 | cookedItemId: CraftingItemId.cookedGoat, |
| 283 | burntItemId: CraftingItemId.burntGoat, |
| 284 | tint: GOAT_COOK_COLORS.raw |
| 285 | }), |
| 286 | [CraftingItemId.cookedGoat]: Object.freeze({ |
| 287 | itemId: CraftingItemId.cookedGoat, |
| 288 | key: "cooked-goat", |
| 289 | displayName: "Cooked Goat", |
| 290 | description: "Roasted goat, lean and savoury.", |
| 291 | seedValue: 5, |
| 292 | stackable: true, |
| 293 | maxStackSize: DEFAULT_STACK, |
| 294 | uniqueInstance: false, |
| 295 | category: ItemCategory.food, |
| 296 | iconKey: "meat", |
| 297 | defaultState: "cooked", |
| 298 | cookable: true, |
| 299 | cookState: "cooked", |
| 300 | tint: GOAT_COOK_COLORS.cooked, |
| 301 | healing: 6, |
| 302 | eatStatusEffect: Object.freeze({ |
| 303 | type: StatusEffectType.healthRegen, |
| 304 | amountPerSecond: 1, |
| 305 | durationMs: 5_000 |
| 306 | }) |
| 307 | }), |
| 308 | [CraftingItemId.burntGoat]: Object.freeze({ |
| 309 | itemId: CraftingItemId.burntGoat, |
| 310 | key: "burnt-goat", |
| 311 | displayName: "Burnt Goat", |
| 312 | description: "Overcooked goat — dry and charred.", |
| 313 | seedValue: 1, |
| 314 | stackable: true, |
| 315 | maxStackSize: DEFAULT_STACK, |
| 316 | uniqueInstance: false, |
| 317 | category: ItemCategory.food, |
| 318 | iconKey: "meat", |
| 319 | defaultState: "burnt", |
| 320 | cookable: true, |
| 321 | cookState: "burnt", |
| 322 | tint: GOAT_COOK_COLORS.burnt |
| 323 | }) |
| 324 | }); |