import { ItemCategory } from "./itemCategories.js"; import { MATERIAL_TIER_ORDER, MATERIAL_DISPLAY_NAME, tierMinSkillLevel, leatherTierForMetal } from "./materialTiers.js"; import { EquipmentKind } from "./equipmentKinds.js"; import { equipImageName } from "./tileSprites.js"; /** * Metal armour — shared overlay sprites in items/armour/*-equip.png. * Most pieces: magenta → metal. Shield equip is dual-channel (red metal, blue leather); * shield inventory icon stays magenta metal only. */ export const ArmourItemId = Object.freeze({ bronzeChestplate: 91, bronzeGreaves: 92, bronzeBoots: 93, bronzeHelmet: 94, bronzeFullHelm: 95, bronzeHornedHelm: 96, ironChestplate: 97, ironGreaves: 98, ironBoots: 99, ironHelmet: 100, ironFullHelm: 101, ironHornedHelm: 102, steelChestplate: 103, steelGreaves: 104, steelBoots: 105, steelHelmet: 106, steelFullHelm: 107, steelHornedHelm: 108, mithrilChestplate: 109, mithrilGreaves: 110, mithrilBoots: 111, mithrilHelmet: 112, mithrilFullHelm: 113, mithrilHornedHelm: 114, adamantiumChestplate: 115, adamantiumGreaves: 116, adamantiumBoots: 117, adamantiumHelmet: 118, adamantiumFullHelm: 119, adamantiumHornedHelm: 120, orichalcumChestplate: 121, orichalcumGreaves: 122, orichalcumBoots: 123, orichalcumHelmet: 124, orichalcumFullHelm: 125, orichalcumHornedHelm: 126, dragonChestplate: 127, dragonGreaves: 128, dragonBoots: 129, dragonHelmet: 130, dragonFullHelm: 131, dragonHornedHelm: 132, bronzeSkirt: 475, ironSkirt: 476, steelSkirt: 477, mithrilSkirt: 478, adamantiumSkirt: 479, orichalcumSkirt: 480, dragonSkirt: 481, bronzeShield: 482, ironShield: 483, steelShield: 484, mithrilShield: 485, adamantiumShield: 486, orichalcumShield: 487, dragonShield: 488 }); const ARMOUR_PIECES = Object.freeze([ Object.freeze({ suffix: "chestplate", slot: "chest", label: "chestplate", overlay: "chestplate", idKey: "Chestplate", ingots: 6 }), Object.freeze({ suffix: "greaves", slot: "legs", label: "greaves", overlay: "greaves", idKey: "Greaves", ingots: 4 }), /** Same slot/cost/defence as greaves; alternate legs look. */ Object.freeze({ suffix: "skirt", slot: "legs", label: "skirt", overlay: "skirt", idKey: "Skirt", ingots: 4 }), Object.freeze({ suffix: "boots", slot: "boots", label: "boots", overlay: "boots", idKey: "Boots", ingots: 2 }), Object.freeze({ suffix: "helmet", slot: "head", label: "helmet", overlay: "helmet", idKey: "Helmet", ingots: 2 }), Object.freeze({ suffix: "full-helm", slot: "head", label: "full helm", overlay: "fullhelm", idKey: "FullHelm", ingots: 3, fullHelm: true }), Object.freeze({ suffix: "horned-helm", slot: "head", label: "horned helm", overlay: "hornedhelm", idKey: "HornedHelm", ingots: 2, needsBone: true }), Object.freeze({ suffix: "shield", slot: "offhand", label: "shield", overlay: "shield", idKey: "Shield", ingots: 4, kind: EquipmentKind.shield, needsLeather: true, /** Equip: red = metal, blue = leather. Icon: magenta metal only. */ dualTintLeather: true }) ]); export function armourItemIdForTier (tier, idKey) { return ArmourItemId[`${tier}${idKey}`] ?? null; } function armourDef (itemId, tier, piece) { const tierName = MATERIAL_DISPLAY_NAME[tier] ?? tier; const key = `${tier}-${piece.suffix}`; const kind = piece.kind ?? EquipmentKind.metalArmour; const dualTintLeather = !!piece.dualTintLeather; const equipment = { slot: piece.slot, tier, kind, equipSprite: equipImageName("item", "armour", piece.overlay) }; if (!dualTintLeather) { equipment.tintFromTier = true; } if (piece.fullHelm) { equipment.minSkillLevel = tierMinSkillLevel(tier) + 1; } const def = { itemId, key, displayName: `${tierName} ${piece.label}`, description: `Worn ${tierName.toLowerCase()} ${piece.label}, forged for the road.`, seedValue: 12, stackable: false, maxStackSize: 1, uniqueInstance: false, category: ItemCategory.finished, /** Shared magenta icons under items/armour/{overlay}.png */ iconKey: "armour", defaultState: piece.overlay, tintFromTier: true, equipment: Object.freeze(equipment) }; if (dualTintLeather) { def.leatherTier = leatherTierForMetal(tier); def.dualTintFromTier = true; /** Inventory icon stays single-channel magenta; worn overlay uses dual tint. */ def.iconTintFromTier = true; } return Object.freeze(def); } function buildArmourDefinitions () { const defs = {}; for (const tier of MATERIAL_TIER_ORDER) { for (const piece of ARMOUR_PIECES) { const idProp = `${tier}${piece.idKey}`; const itemId = ArmourItemId[idProp]; if (itemId == null) { throw new Error(`Missing ArmourItemId for ${idProp}`); } defs[itemId] = armourDef(itemId, tier, piece); } } return Object.freeze(defs); } export const ARMOUR_ITEM_DEFINITIONS = buildArmourDefinitions(); /** Shared piece metadata for smithing recipes (anvil). */ export { ARMOUR_PIECES as ARMOUR_CRAFT_PIECES };