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