BlueGit

timfa questward

Files

questward / shared / definitions / gemItems.js

gemItems.js

gemItems.js 6.8 KiB Download Raw
1import { ItemCategory } from "./itemCategories.js";
2import
3 {
4 GemTier,
5 GEM_TIER_ORDER,
6 MATERIAL_DISPLAY_NAME,
7 WOOD_TIER_ORDER,
8 gemTierForWood,
9 tierMinSkillLevel,
10 tierRank,
11 tierSmeltSkillLevel
12 } from "./materialTiers.js";
13import { EquipmentKind } from "./equipmentKinds.js";
14import { CraftingStationId } from "./craftingStations.js";
15import { logItemIdForWood, ashItemIdForWood } from "./woodItems.js";
16import { SkillId } from "./skills.js";
17import { AttackType } from "./attackTypes.js";
18
19const DEFAULT_STACK = 99;
20
21/**
22 * Rough gemstones (377–383, mined), cut gemstones (402–408), magic staves (384–390).
23 * Staves: red = wood, blue = gem (dual-tint staff sprite); require cut gems.
24 */
25export const GemItemId = Object.freeze({
26 tourmaline: 377,
27 alexandrite: 378,
28 opal: 379,
29 diamond: 380,
30 emerald: 381,
31 ruby: 382,
32 jadeite: 383,
33 pineStaff: 384,
34 birchStaff: 385,
35 oakStaff: 386,
36 ebonyStaff: 387,
37 lignumStaff: 388,
38 heartwoodStaff: 389,
39 elderStaff: 390,
40 tourmalineCut: 402,
41 alexandriteCut: 403,
42 opalCut: 404,
43 diamondCut: 405,
44 emeraldCut: 406,
45 rubyCut: 407,
46 jadeiteCut: 408
47});
48
49/** Mined / uncut gem item id by tier. */
50export const ROUGH_GEM_ITEM_BY_TIER = Object.freeze({
51 [GemTier.tourmaline]: GemItemId.tourmaline,
52 [GemTier.alexandrite]: GemItemId.alexandrite,
53 [GemTier.opal]: GemItemId.opal,
54 [GemTier.diamond]: GemItemId.diamond,
55 [GemTier.emerald]: GemItemId.emerald,
56 [GemTier.ruby]: GemItemId.ruby,
57 [GemTier.jadeite]: GemItemId.jadeite
58});
59
60/** Cut gem item id by tier (jewelering + staves). */
61export const CUT_GEM_ITEM_BY_TIER = Object.freeze({
62 [GemTier.tourmaline]: GemItemId.tourmalineCut,
63 [GemTier.alexandrite]: GemItemId.alexandriteCut,
64 [GemTier.opal]: GemItemId.opalCut,
65 [GemTier.diamond]: GemItemId.diamondCut,
66 [GemTier.emerald]: GemItemId.emeraldCut,
67 [GemTier.ruby]: GemItemId.rubyCut,
68 [GemTier.jadeite]: GemItemId.jadeiteCut
69});
70
71/** @deprecated Prefer {@link ROUGH_GEM_ITEM_BY_TIER} / {@link roughGemItemId}. */
72export const GEM_ITEM_BY_TIER = ROUGH_GEM_ITEM_BY_TIER;
73
74export const STAFF_ITEM_BY_WOOD = Object.freeze({
75 pine: GemItemId.pineStaff,
76 birch: GemItemId.birchStaff,
77 oak: GemItemId.oakStaff,
78 ebony: GemItemId.ebonyStaff,
79 lignum: GemItemId.lignumStaff,
80 heartwood: GemItemId.heartwoodStaff,
81 elder: GemItemId.elderStaff
82});
83
84/** Rough (mined) gem item id. */
85export function roughGemItemId (gemTier)
86{
87 return ROUGH_GEM_ITEM_BY_TIER[gemTier] ?? null;
88}
89
90/** Alias for mining drops — always the rough stone. */
91export function gemItemId (gemTier)
92{
93 return roughGemItemId(gemTier);
94}
95
96export function cutGemItemId (gemTier)
97{
98 return CUT_GEM_ITEM_BY_TIER[gemTier] ?? null;
99}
100
101export function staffItemIdForWood (woodTier)
102{
103 return STAFF_ITEM_BY_WOOD[woodTier] ?? null;
104}
105
106function buildRoughGemDefinitions ()
107{
108 const out = {};
109 for (const gemTier of GEM_TIER_ORDER)
110 {
111 const itemId = ROUGH_GEM_ITEM_BY_TIER[gemTier];
112 const name = MATERIAL_DISPLAY_NAME[gemTier] ?? gemTier;
113 out[itemId] = Object.freeze({
114 itemId,
115 key: `${gemTier}-rough`,
116 displayName: `Rough ${name.toLowerCase()}`,
117 description: `An uncut ${name.toLowerCase()}, still rough from the rock.`,
118 seedValue: tierRank(gemTier) * 2,
119 stackable: true,
120 maxStackSize: DEFAULT_STACK,
121 uniqueInstance: false,
122 category: ItemCategory.ingredient,
123 iconKey: "gems",
124 defaultState: "rough",
125 tier: gemTier,
126 tintFromTier: true,
127 gemstone: true,
128 gemForm: "rough",
129 npcShopAllowed: true
130 });
131 }
132 return out;
133}
134
135function buildCutGemDefinitions ()
136{
137 const out = {};
138 for (const gemTier of GEM_TIER_ORDER)
139 {
140 const itemId = CUT_GEM_ITEM_BY_TIER[gemTier];
141 const name = MATERIAL_DISPLAY_NAME[gemTier] ?? gemTier;
142 out[itemId] = Object.freeze({
143 itemId,
144 key: `${gemTier}-cut`,
145 displayName: `Cut ${name.toLowerCase()}`,
146 description: `A faceted ${name.toLowerCase()}, cool and bright in the hand.`,
147 seedValue: tierRank(gemTier) * 3,
148 stackable: true,
149 maxStackSize: DEFAULT_STACK,
150 uniqueInstance: false,
151 category: ItemCategory.ingredient,
152 iconKey: "gems",
153 defaultState: "cut",
154 tier: gemTier,
155 tintFromTier: true,
156 gemstone: true,
157 gemForm: "cut",
158 npcShopAllowed: true
159 });
160 }
161 return out;
162}
163
164function buildStaffDefinitions ()
165{
166 const out = {};
167 for (const woodTier of WOOD_TIER_ORDER)
168 {
169 const itemId = STAFF_ITEM_BY_WOOD[woodTier];
170 const gemTier = gemTierForWood(woodTier);
171 const woodName = MATERIAL_DISPLAY_NAME[woodTier] ?? woodTier;
172 const gemName = MATERIAL_DISPLAY_NAME[gemTier] ?? gemTier;
173 out[itemId] = Object.freeze({
174 itemId,
175 key: `${woodTier}-staff`,
176 displayName: `${woodName} staff`,
177 description: `A ${woodName.toLowerCase()} shaft capped with ${gemName.toLowerCase()}.`,
178 seedValue: tierRank(woodTier) * 4,
179 stackable: false,
180 maxStackSize: 1,
181 uniqueInstance: false,
182 category: ItemCategory.tool,
183 iconKey: "staff",
184 defaultState: "staff",
185 tier: woodTier,
186 gemTier,
187 tintFromTier: true,
188 dualTintFromTier: true,
189 equipment: Object.freeze({
190 slot: "weapon",
191 tier: woodTier,
192 kind: EquipmentKind.staff,
193 tintFromTier: true,
194 dualTintFromTier: true,
195 /** Melee like a quarterstaff; magic bonus still applies to casts only. */
196 attack: Object.freeze({
197 mode: "melee",
198 rangeTiles: 1,
199 hitSkillId: SkillId.clubfighting,
200 damageSkillId: SkillId.strength,
201 attackType: AttackType.crushing,
202 cooldownMs: 700
203 })
204 }),
205 npcShopAllowed: true
206 });
207 }
208 return out;
209}
210
211export const GEM_ITEM_DEFINITIONS = Object.freeze({
212 ...buildRoughGemDefinitions(),
213 ...buildCutGemDefinitions(),
214 ...buildStaffDefinitions()
215});
216
217/** Jewelering: rough → cut (skill gate matches smithing ore → bar). */
218export function gemCutRecipes ()
219{
220 return GEM_TIER_ORDER.map((gemTier) =>
221 {
222 const gemName = MATERIAL_DISPLAY_NAME[gemTier] ?? gemTier;
223 return Object.freeze({
224 recipeId: `cut-${gemTier}`,
225 craftGroup: "cut-gem",
226 craftGroupLabel: "Cut gem",
227 stationId: CraftingStationId.jeweleringStation,
228 output: { itemId: cutGemItemId(gemTier), quantity: 1 },
229 inputs: [{ itemId: roughGemItemId(gemTier), quantity: 1 }],
230 minSkillLevel: tierSmeltSkillLevel(gemTier),
231 skillId: SkillId.jewelering,
232 xpMaterial: gemTier
233 });
234 });
235}
236
237/** Craft recipes: 1 log + 1 cut gem + 1 ash → staff (matching wood/gem tier). */
238export function staffCraftRecipes ()
239{
240 return WOOD_TIER_ORDER.map((woodTier) =>
241 {
242 const gemTier = gemTierForWood(woodTier);
243 return Object.freeze({
244 recipeId: `staff-${woodTier}`,
245 craftGroup: "staff",
246 craftGroupLabel: "Staff",
247 stationId: CraftingStationId.woodworkingBench,
248 output: { itemId: staffItemIdForWood(woodTier), quantity: 1 },
249 inputs: [
250 { itemId: logItemIdForWood(woodTier), quantity: 1 },
251 { itemId: cutGemItemId(gemTier), quantity: 1 },
252 { itemId: ashItemIdForWood(woodTier), quantity: 1 }
253 ],
254 minSkillLevel: tierMinSkillLevel(woodTier),
255 skillId: SkillId.crafting,
256 xpMaterial: woodTier
257 });
258 });
259}