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