BlueGit

timfa questward

Files

questward / shared / definitions / craftingItems.js

craftingItems.js

craftingItems.js 5.2 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 = 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 */
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});
32
33/** Magenta cookable base; tinted per cook state. */
34const 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 */
44export 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
52function 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. */
71export 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 npcShopAllowed: true,
84 defaultInstance: tinderboxItemInstance()
85 }),
86 [CraftingItemId.copperOre]: Object.freeze({
87 itemId: CraftingItemId.copperOre,
88 key: "copper-ore",
89 displayName: "Copper ore",
90 description: "Reddish copper ore. Smelt with tin at a furnace into bronze bars.",
91 seedValue: 5,
92 stackable: true,
93 maxStackSize: DEFAULT_STACK,
94 uniqueInstance: false,
95 category: ItemCategory.ingredient,
96 iconKey: "metal",
97 defaultState: "ore",
98 tier: GatherMaterialId.copper,
99 tintFromTier: true
100 }),
101 [CraftingItemId.tinOre]: Object.freeze({
102 itemId: CraftingItemId.tinOre,
103 key: "tin-ore",
104 displayName: "Tin ore",
105 description: "Pale tin ore. Smelt with copper at a furnace into bronze bars.",
106 seedValue: 5,
107 stackable: true,
108 maxStackSize: DEFAULT_STACK,
109 uniqueInstance: false,
110 category: ItemCategory.ingredient,
111 iconKey: "metal",
112 defaultState: "ore",
113 tier: GatherMaterialId.tin,
114 tintFromTier: true
115 }),
116 [CraftingItemId.bronzeBar]: Object.freeze({
117 itemId: CraftingItemId.bronzeBar,
118 key: "bronze-bar",
119 displayName: "Bronze bar",
120 description: "A solid bronze bar, ready for the anvil.",
121 seedValue: 4,
122 stackable: true,
123 maxStackSize: DEFAULT_STACK,
124 uniqueInstance: false,
125 category: ItemCategory.intermediate,
126 iconKey: "metal",
127 defaultState: "bar",
128 tier: MaterialTier.bronze,
129 tintFromTier: true
130 }),
131 [CraftingItemId.rawMeat]: Object.freeze({
132 itemId: CraftingItemId.rawMeat,
133 key: "uncooked-venison",
134 displayName: "Uncooked Venison",
135 description: "Fresh deer meat. Cook at an oven or campfire.",
136 seedValue: 3,
137 stackable: true,
138 maxStackSize: DEFAULT_STACK,
139 uniqueInstance: false,
140 category: ItemCategory.ingredient,
141 iconKey: "meat",
142 defaultState: "raw",
143 cookable: true,
144 cookState: "raw",
145 burntItemId: CraftingItemId.burntMeat,
146 tint: VENISON_COOK_COLORS.raw
147 }),
148 [CraftingItemId.cookedMeat]: Object.freeze({
149 itemId: CraftingItemId.cookedMeat,
150 key: "cooked-venison",
151 displayName: "Cooked Venison",
152 description: "Roasted deer meat, still warm from the fire.",
153 seedValue: 4,
154 stackable: true,
155 maxStackSize: DEFAULT_STACK,
156 uniqueInstance: false,
157 category: ItemCategory.food,
158 iconKey: "meat",
159 defaultState: "cooked",
160 cookable: true,
161 cookState: "cooked",
162 tint: VENISON_COOK_COLORS.cooked,
163 healing: 5,
164 eatStatusEffect: Object.freeze({
165 type: StatusEffectType.healthRegen,
166 amountPerSecond: 1,
167 durationMs: 5_000
168 })
169 }),
170 [CraftingItemId.burntMeat]: Object.freeze({
171 itemId: CraftingItemId.burntMeat,
172 key: "burnt-venison",
173 displayName: "Burnt Venison",
174 description: "Charred beyond saving — little more than a bitter lump.",
175 seedValue: 1,
176 stackable: true,
177 maxStackSize: DEFAULT_STACK,
178 uniqueInstance: false,
179 category: ItemCategory.food,
180 iconKey: "meat",
181 defaultState: "burnt",
182 cookable: true,
183 cookState: "burnt",
184 tint: VENISON_COOK_COLORS.burnt
185 })
186});