BlueGit

timfa questward

Files

questward / shared / definitions / craftingItems.js

craftingItems.js

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