BlueGit

timfa questward

Files

questward / shared / definitions / craftingItems.js

craftingItems.js

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