import { ItemCategory } from "./itemCategories.js"; import { GemTier, GEM_TIER_ORDER, GatherMaterialId, MATERIAL_DISPLAY_NAME, clothTierForGem, tierMinSkillLevel, tierRank } from "./materialTiers.js"; import { EquipmentKind } from "./equipmentKinds.js"; import { CraftingStationId } from "./craftingStations.js"; import { MetalItemId } from "./metalItems.js"; import { cutGemItemId } from "./gemItems.js"; import { yarnItemId } from "./clothItems.js"; import { SkillId } from "./skills.js"; import { equipImageName } from "./tileSprites.js"; /** * Jewellery pieces (ring / bracelet / amulet) set at the jewelering station. * Metal: silver (gem tiers 1–3), gold (4–6), electrum (7). * Inputs: 1 bar + 1 cut gem; amulets also need 1 matching-tier yarn. * Tint: red = metal, blue = gem, green = yarn (amulet only). * Descriptions are filled once unique effects are authored. */ export const JewelryPiece = Object.freeze({ ring: "ring", bracelet: "bracelet", amulet: "amulet" }); export const JEWELRY_PIECE_ORDER = Object.freeze([ JewelryPiece.ring, JewelryPiece.bracelet, JewelryPiece.amulet ]); /** Item IDs 561–581: rings, bracelets, amulets × 7 gem tiers. */ export const JewelryItemId = Object.freeze({ tourmalineRing: 561, alexandriteRing: 562, opalRing: 563, diamondRing: 564, emeraldRing: 565, rubyRing: 566, jadeiteRing: 567, tourmalineBracelet: 568, alexandriteBracelet: 569, opalBracelet: 570, diamondBracelet: 571, emeraldBracelet: 572, rubyBracelet: 573, jadeiteBracelet: 574, tourmalineAmulet: 575, alexandriteAmulet: 576, opalAmulet: 577, diamondAmulet: 578, emeraldAmulet: 579, rubyAmulet: 580, jadeiteAmulet: 581 }); const RING_BY_GEM = Object.freeze({ [GemTier.tourmaline]: JewelryItemId.tourmalineRing, [GemTier.alexandrite]: JewelryItemId.alexandriteRing, [GemTier.opal]: JewelryItemId.opalRing, [GemTier.diamond]: JewelryItemId.diamondRing, [GemTier.emerald]: JewelryItemId.emeraldRing, [GemTier.ruby]: JewelryItemId.rubyRing, [GemTier.jadeite]: JewelryItemId.jadeiteRing }); const BRACELET_BY_GEM = Object.freeze({ [GemTier.tourmaline]: JewelryItemId.tourmalineBracelet, [GemTier.alexandrite]: JewelryItemId.alexandriteBracelet, [GemTier.opal]: JewelryItemId.opalBracelet, [GemTier.diamond]: JewelryItemId.diamondBracelet, [GemTier.emerald]: JewelryItemId.emeraldBracelet, [GemTier.ruby]: JewelryItemId.rubyBracelet, [GemTier.jadeite]: JewelryItemId.jadeiteBracelet }); const AMULET_BY_GEM = Object.freeze({ [GemTier.tourmaline]: JewelryItemId.tourmalineAmulet, [GemTier.alexandrite]: JewelryItemId.alexandriteAmulet, [GemTier.opal]: JewelryItemId.opalAmulet, [GemTier.diamond]: JewelryItemId.diamondAmulet, [GemTier.emerald]: JewelryItemId.emeraldAmulet, [GemTier.ruby]: JewelryItemId.rubyAmulet, [GemTier.jadeite]: JewelryItemId.jadeiteAmulet }); export function jewelryMetalIdForGemTier (gemTier) { const rank = tierRank(gemTier); if (rank <= 3) { return GatherMaterialId.silver; } if (rank <= 6) { return GatherMaterialId.gold; } return GatherMaterialId.electrum; } export function jewelryMetalBarItemId (metalId) { if (metalId === GatherMaterialId.electrum) { return MetalItemId.electrumBar; } if (metalId === GatherMaterialId.gold) { return MetalItemId.goldBar; } return MetalItemId.silverBar; } export function jewelryItemIdFor (piece, gemTier) { if (piece === JewelryPiece.ring) { return RING_BY_GEM[gemTier] ?? null; } if (piece === JewelryPiece.bracelet) { return BRACELET_BY_GEM[gemTier] ?? null; } if (piece === JewelryPiece.amulet) { return AMULET_BY_GEM[gemTier] ?? null; } return null; } function pieceEquipSlot (piece) { if (piece === JewelryPiece.ring) { return "ring"; } if (piece === JewelryPiece.bracelet) { return "bracelet"; } return "amulet"; } function pieceDisplayNoun (piece) { if (piece === JewelryPiece.ring) { return "ring"; } if (piece === JewelryPiece.bracelet) { return "bracelet"; } return "amulet"; } const JEWELRY_FLAVOR = Object.freeze({ [JewelryItemId.tourmalineRing]: "Silver set with tourmaline. While it rests on the finger, wounds close twice as readily when the fighting has stopped.", [JewelryItemId.tourmalineBracelet]: "Silver and tourmaline upon the wrist. Breath and vigour return twice as swiftly when you stand still.", [JewelryItemId.tourmalineAmulet]: "A tourmaline pendant on cotton yarn. It favours the craft you know least, doubling what you learn of it.", [JewelryItemId.alexandriteRing]: "Silver alexandrite that drinks hostile magic. Spells that strike you bite only half as hard.", [JewelryItemId.alexandriteBracelet]: "Alexandrite at the wrist steadies the hand. Work at the bench finishes in half the time.", [JewelryItemId.alexandriteAmulet]: "An alexandrite charm on wool. Ore, timber, plants, and fish yield to you twice as quickly.", [JewelryItemId.opalRing]: "Silver and opal that turn arrows aside. Piercing shots land with half their usual force.", [JewelryItemId.opalBracelet]: "Opal along the wrist. A soft circle of sight opens about you in the dark, as of a dim torch.", [JewelryItemId.opalAmulet]: "An opal pendant on linen. Blows that reach you answer in kind — a tenth of the hurt returns to the striker.", [JewelryItemId.diamondRing]: "Gold and diamond that harden against steel and fist. Melee wounds fall with half their strength.", [JewelryItemId.diamondBracelet]: "A diamond bracelet that grants luck in battle. Blows and castings find their mark more often.", [JewelryItemId.diamondAmulet]: "A diamond on cashmere yarn. Spoils of creatures you fell gather themselves into your pack.", [JewelryItemId.emeraldRing]: "Gold emerald that casts bad luck upon your foes. Their strikes go astray more often than they should.", [JewelryItemId.emeraldBracelet]: "Emerald at the wrist invites divine intervention. Call upon it to seek the nearest altar.", [JewelryItemId.emeraldAmulet]: "An emerald pendant on silk. Blade, bow, and spell alike find the foe a little more readily.", [JewelryItemId.rubyRing]: "Gold and ruby that know the way to coin and vault. Call upon it to seek the nearest bank.", [JewelryItemId.rubyBracelet]: "A ruby bracelet that thickens the blood. While worn, your body endures a tenth more harm.", [JewelryItemId.rubyAmulet]: "A ruby on fairy-silk yarn. In death your coin stays with you — the amulet falls in its place.", [JewelryItemId.jadeiteRing]: "Electrum and jadeite. Resources you harvest surrender twice the usual yield.", [JewelryItemId.jadeiteBracelet]: "Jadeite at the wrist. All but the fiercest beasts leave you be until you raise a hand against them.", [JewelryItemId.jadeiteAmulet]: "Jadeite on dragonweave. A fairy companion answers the call, fighting those who share your battle." }); function buildPieceDefinitions (piece, byGem) { const out = {}; for (const gemTier of GEM_TIER_ORDER) { const itemId = byGem[gemTier]; const metalId = jewelryMetalIdForGemTier(gemTier); const clothTier = piece === JewelryPiece.amulet ? clothTierForGem(gemTier) : null; const metalName = MATERIAL_DISPLAY_NAME[metalId] ?? metalId; const gemName = MATERIAL_DISPLAY_NAME[gemTier] ?? gemTier; const noun = pieceDisplayNoun(piece); const equipment = { slot: pieceEquipSlot(piece), tier: gemTier, kind: EquipmentKind.jewelry, minCombatLevel: tierMinSkillLevel(gemTier), tintFromTier: true, dualTintFromTier: true, equipSprite: equipImageName("item", "jewelery", piece) }; if (itemId === JewelryItemId.opalBracelet) { equipment.lightRadiusTiles = 8; equipment.lightIntensity = 0.5; } out[itemId] = Object.freeze({ itemId, key: `${gemTier}-${piece}`, displayName: `${metalName} ${gemName.toLowerCase()} ${noun}`, description: JEWELRY_FLAVOR[itemId] ?? "", seedValue: tierRank(gemTier) * (piece === JewelryPiece.amulet ? 5 : 4), stackable: false, maxStackSize: 1, uniqueInstance: false, category: ItemCategory.finished, iconKey: "jewelery", defaultState: piece, tier: gemTier, gemTier, metalTier: metalId, ...(clothTier ? { clothTier } : {}), tintFromTier: true, dualTintFromTier: true, jewelryTint: true, equipment: Object.freeze(equipment), npcShopAllowed: true }); } return out; } export const JEWELRY_ITEM_DEFINITIONS = Object.freeze({ ...buildPieceDefinitions(JewelryPiece.ring, RING_BY_GEM), ...buildPieceDefinitions(JewelryPiece.bracelet, BRACELET_BY_GEM), ...buildPieceDefinitions(JewelryPiece.amulet, AMULET_BY_GEM) }); /** * Live jewelering recipes: 1 precious bar + 1 cut gem (+ 1 yarn for amulets). * Metal quantity is always 1 (not gem-tier rank). */ export function jewelryCraftRecipes () { const out = []; for (const piece of JEWELRY_PIECE_ORDER) { const noun = pieceDisplayNoun(piece); const label = noun.charAt(0).toUpperCase() + noun.slice(1); for (const gemTier of GEM_TIER_ORDER) { const metalId = jewelryMetalIdForGemTier(gemTier); const inputs = [ { itemId: jewelryMetalBarItemId(metalId), quantity: 1 }, { itemId: cutGemItemId(gemTier), quantity: 1 } ]; if (piece === JewelryPiece.amulet) { inputs.push({ itemId: yarnItemId(clothTierForGem(gemTier)), quantity: 1 }); } out.push(Object.freeze({ recipeId: `${piece}-${gemTier}`, craftGroup: piece, craftGroupLabel: label, stationId: CraftingStationId.jeweleringStation, output: { itemId: jewelryItemIdFor(piece, gemTier), quantity: 1 }, inputs, minSkillLevel: tierMinSkillLevel(gemTier), skillId: SkillId.jewelering, xpMaterial: gemTier })); } } return out; } /** @deprecated Prefer {@link jewelryCraftRecipes}; kept for callers that listed metal/gem pairing. */ export const JEWELRY_RECIPE_GUIDELINES = Object.freeze( GEM_TIER_ORDER.map((gemTier) => { const metalId = jewelryMetalIdForGemTier(gemTier); return Object.freeze({ tier: tierRank(gemTier), gemTier, cutGemItemId: cutGemItemId(gemTier), metalId, metalBarItemId: jewelryMetalBarItemId(metalId), metalQuantity: 1, yarnItemId: yarnItemId(clothTierForGem(gemTier)), stationId: CraftingStationId.jeweleringStation, skillId: SkillId.jewelering, minSkillLevel: tierMinSkillLevel(gemTier) }); }) );