| 1 | import { ItemCategory } from "./itemCategories.js"; |
| 2 | import { |
| 3 | MaterialTier, |
| 4 | MATERIAL_TIER_ORDER, |
| 5 | MATERIAL_DISPLAY_NAME, |
| 6 | tierMinSkillLevel, |
| 7 | tierStatBonus |
| 8 | } from "./materialTiers.js"; |
| 9 | import { EquipmentKind } from "./equipmentKinds.js"; |
| 10 | import { equipImageName } from "./tileSprites.js"; |
| 11 | |
| 12 | /** |
| 13 | * Metal armour — shared overlay sprites in items/armour/*-equip.png, |
| 14 | * per-tier tint via magenta mask. Shield (offhand) not included yet. |
| 15 | */ |
| 16 | export const ArmourItemId = Object.freeze({ |
| 17 | bronzeChestplate: 91, |
| 18 | bronzeGreaves: 92, |
| 19 | bronzeBoots: 93, |
| 20 | bronzeHelmet: 94, |
| 21 | bronzeFullHelm: 95, |
| 22 | bronzeHornedHelm: 96, |
| 23 | ironChestplate: 97, |
| 24 | ironGreaves: 98, |
| 25 | ironBoots: 99, |
| 26 | ironHelmet: 100, |
| 27 | ironFullHelm: 101, |
| 28 | ironHornedHelm: 102, |
| 29 | steelChestplate: 103, |
| 30 | steelGreaves: 104, |
| 31 | steelBoots: 105, |
| 32 | steelHelmet: 106, |
| 33 | steelFullHelm: 107, |
| 34 | steelHornedHelm: 108, |
| 35 | mithrilChestplate: 109, |
| 36 | mithrilGreaves: 110, |
| 37 | mithrilBoots: 111, |
| 38 | mithrilHelmet: 112, |
| 39 | mithrilFullHelm: 113, |
| 40 | mithrilHornedHelm: 114, |
| 41 | adamantiumChestplate: 115, |
| 42 | adamantiumGreaves: 116, |
| 43 | adamantiumBoots: 117, |
| 44 | adamantiumHelmet: 118, |
| 45 | adamantiumFullHelm: 119, |
| 46 | adamantiumHornedHelm: 120, |
| 47 | orichalcumChestplate: 121, |
| 48 | orichalcumGreaves: 122, |
| 49 | orichalcumBoots: 123, |
| 50 | orichalcumHelmet: 124, |
| 51 | orichalcumFullHelm: 125, |
| 52 | orichalcumHornedHelm: 126, |
| 53 | dragonChestplate: 127, |
| 54 | dragonGreaves: 128, |
| 55 | dragonBoots: 129, |
| 56 | dragonHelmet: 130, |
| 57 | dragonFullHelm: 131, |
| 58 | dragonHornedHelm: 132 |
| 59 | }); |
| 60 | |
| 61 | const ARMOUR_PIECES = Object.freeze([ |
| 62 | Object.freeze({ |
| 63 | suffix: "chestplate", |
| 64 | slot: "chest", |
| 65 | label: "chestplate", |
| 66 | overlay: "chestplate", |
| 67 | idKey: "Chestplate", |
| 68 | ingots: 6 |
| 69 | }), |
| 70 | Object.freeze({ |
| 71 | suffix: "greaves", |
| 72 | slot: "legs", |
| 73 | label: "greaves", |
| 74 | overlay: "greaves", |
| 75 | idKey: "Greaves", |
| 76 | ingots: 4 |
| 77 | }), |
| 78 | Object.freeze({ |
| 79 | suffix: "boots", |
| 80 | slot: "boots", |
| 81 | label: "boots", |
| 82 | overlay: "boots", |
| 83 | idKey: "Boots", |
| 84 | ingots: 2 |
| 85 | }), |
| 86 | Object.freeze({ |
| 87 | suffix: "helmet", |
| 88 | slot: "head", |
| 89 | label: "helmet", |
| 90 | overlay: "helmet", |
| 91 | idKey: "Helmet", |
| 92 | ingots: 2 |
| 93 | }), |
| 94 | Object.freeze({ |
| 95 | suffix: "full-helm", |
| 96 | slot: "head", |
| 97 | label: "full helm", |
| 98 | overlay: "fullhelm", |
| 99 | idKey: "FullHelm", |
| 100 | ingots: 3, |
| 101 | fullHelm: true |
| 102 | }), |
| 103 | Object.freeze({ |
| 104 | suffix: "horned-helm", |
| 105 | slot: "head", |
| 106 | label: "horned helm", |
| 107 | overlay: "hornedhelm", |
| 108 | idKey: "HornedHelm", |
| 109 | ingots: 2, |
| 110 | needsBone: true |
| 111 | }) |
| 112 | ]); |
| 113 | |
| 114 | export function armourItemIdForTier (tier, idKey) |
| 115 | { |
| 116 | return ArmourItemId[`${tier}${idKey}`] ?? null; |
| 117 | } |
| 118 | |
| 119 | function armourDef (itemId, tier, piece) |
| 120 | { |
| 121 | const tierName = MATERIAL_DISPLAY_NAME[tier] ?? tier; |
| 122 | const key = `${tier}-${piece.suffix}`; |
| 123 | const equipment = { |
| 124 | slot: piece.slot, |
| 125 | tier, |
| 126 | kind: EquipmentKind.metalArmour, |
| 127 | tintFromTier: true, |
| 128 | equipSprite: equipImageName("item", "armour", piece.overlay) |
| 129 | }; |
| 130 | if (piece.fullHelm) |
| 131 | { |
| 132 | equipment.bonus = tierStatBonus(tier) + 1; |
| 133 | equipment.minSkillLevel = tierMinSkillLevel(tier) + 1; |
| 134 | } |
| 135 | return Object.freeze({ |
| 136 | itemId, |
| 137 | key, |
| 138 | displayName: `${tierName} ${piece.label}`, |
| 139 | description: `Worn ${tierName.toLowerCase()} ${piece.label}.`, |
| 140 | seedValue: 12, |
| 141 | stackable: false, |
| 142 | maxStackSize: 1, |
| 143 | uniqueInstance: false, |
| 144 | category: ItemCategory.finished, |
| 145 | /** Shared magenta icons under items/armour/{overlay}.png */ |
| 146 | iconKey: "armour", |
| 147 | defaultState: piece.overlay, |
| 148 | tintFromTier: true, |
| 149 | equipment: Object.freeze(equipment) |
| 150 | }); |
| 151 | } |
| 152 | |
| 153 | function buildArmourDefinitions () |
| 154 | { |
| 155 | const defs = {}; |
| 156 | for (const tier of MATERIAL_TIER_ORDER) |
| 157 | { |
| 158 | for (const piece of ARMOUR_PIECES) |
| 159 | { |
| 160 | const idProp = `${tier}${piece.idKey}`; |
| 161 | const itemId = ArmourItemId[idProp]; |
| 162 | if (itemId == null) |
| 163 | { throw new Error(`Missing ArmourItemId for ${idProp}`); } |
| 164 | defs[itemId] = armourDef(itemId, tier, piece); |
| 165 | } |
| 166 | } |
| 167 | return Object.freeze(defs); |
| 168 | } |
| 169 | |
| 170 | export const ARMOUR_ITEM_DEFINITIONS = buildArmourDefinitions(); |
| 171 | |
| 172 | /** Shared piece metadata for smithing recipes (anvil). */ |
| 173 | export { ARMOUR_PIECES as ARMOUR_CRAFT_PIECES }; |