import { ItemCategory } from "./itemCategories.js"; import { EquipmentKind } from "./equipmentKinds.js"; import { equipImageName } from "./tileSprites.js"; import { CraftingItemId } from "./craftingItems.js"; import { LeatherTier, MaterialTier, LEATHER_TIER_ORDER, LEATHER_DISPLAY_NAME, tierMinSkillLevel } from "./materialTiers.js"; /** Leather materials, garments, and leatherworking intermediates. */ export const LeatherItemId = Object.freeze({ softLeather: CraftingItemId.leather, hardLeather: 233, studdedLeather: 234, reinforcedLeather: 235, scaledLeather: 236, wyvernHide: 237, dragonhide: 238, /** @deprecated Prefer ClothItemId.cottonShorts — kept for existing refs. */ clothShorts: 239, /** @deprecated Prefer ClothItemId.cottonTrousers — kept for existing refs. */ clothTrousers: 240, /** Soft-leather shoes (historic id). Prefer {@link leatherShoesItemId}. */ leatherShoes: 241, hardLeatherShoes: 491, studdedLeatherShoes: 492, reinforcedLeatherShoes: 493, scaledLeatherShoes: 494, wyvernHideShoes: 495, dragonhideShoes: 496, steelStud: 242, tanningBrew: 243 }); const LEATHER_MATERIAL_ID = Object.freeze({ [LeatherTier.softLeather]: LeatherItemId.softLeather, [LeatherTier.hardLeather]: LeatherItemId.hardLeather, [LeatherTier.studdedLeather]: LeatherItemId.studdedLeather, [LeatherTier.reinforcedLeather]: LeatherItemId.reinforcedLeather, [LeatherTier.scaledLeather]: LeatherItemId.scaledLeather, [LeatherTier.wyvernHide]: LeatherItemId.wyvernHide, [LeatherTier.dragonhide]: LeatherItemId.dragonhide }); const LEATHER_SHOES_ID = Object.freeze({ [LeatherTier.softLeather]: LeatherItemId.leatherShoes, [LeatherTier.hardLeather]: LeatherItemId.hardLeatherShoes, [LeatherTier.studdedLeather]: LeatherItemId.studdedLeatherShoes, [LeatherTier.reinforcedLeather]: LeatherItemId.reinforcedLeatherShoes, [LeatherTier.scaledLeather]: LeatherItemId.scaledLeatherShoes, [LeatherTier.wyvernHide]: LeatherItemId.wyvernHideShoes, [LeatherTier.dragonhide]: LeatherItemId.dragonhideShoes }); function leatherMaterialDef (itemId, tier, key) { const name = LEATHER_DISPLAY_NAME[tier] ?? tier; return Object.freeze({ itemId, key, displayName: name, description: tier === LeatherTier.softLeather ? "Supple hide, warm from the field and ready for curing." : `Cured ${name.toLowerCase()}, tough enough for straps and armour.`, seedValue: tier === LeatherTier.softLeather ? 3 : 6, stackable: true, maxStackSize: 99, uniqueInstance: false, category: ItemCategory.ingredient, iconKey: "leather", defaultState: "leather", tier, tintFromTier: true }); } function leatherShoesDef (itemId, tier, key) { const name = LEATHER_DISPLAY_NAME[tier] ?? tier; return Object.freeze({ itemId, key, displayName: `${name} shoes`, description: `Simple ${name.toLowerCase()} shoes, broken in from long walks.`, seedValue: 6, stackable: false, maxStackSize: 1, uniqueInstance: false, category: ItemCategory.finished, iconKey: "clothing", defaultState: "leather-shoes", tier, tintFromTier: true, equipment: Object.freeze({ slot: "boots", tier, kind: EquipmentKind.leatherArmour, bonus: 0, minSkillLevel: tierMinSkillLevel(tier), tintFromTier: true, equipSprite: equipImageName("item", "clothing", "leather-shoes") }) }); } function buildLeatherMaterialDefinitions () { const defs = {}; for (const tier of LEATHER_TIER_ORDER) { const itemId = LEATHER_MATERIAL_ID[tier]; if (itemId == null) { throw new Error(`Missing leather item id for ${tier}`); } const key = tier === LeatherTier.softLeather ? "soft-leather" : tier.replace(/([A-Z])/g, "-$1").toLowerCase(); defs[itemId] = leatherMaterialDef(itemId, tier, key); } return defs; } function buildLeatherShoesDefinitions () { const defs = {}; for (const tier of LEATHER_TIER_ORDER) { const itemId = LEATHER_SHOES_ID[tier]; if (itemId == null) { throw new Error(`Missing leather shoes item id for ${tier}`); } const prefix = tier === LeatherTier.softLeather ? "leather" : tier.replace(/([A-Z])/g, "-$1").toLowerCase(); defs[itemId] = leatherShoesDef(itemId, tier, `${prefix}-shoes`); } return defs; } /** @type {Record} */ export const LEATHER_ITEM_DEFINITIONS = Object.freeze({ ...buildLeatherMaterialDefinitions(), ...buildLeatherShoesDefinitions(), [LeatherItemId.steelStud]: Object.freeze({ itemId: LeatherItemId.steelStud, key: "steel-stud", displayName: "Steel stud", description: "A small steel rivet for reinforcing leather.", seedValue: 2, stackable: true, maxStackSize: 99, uniqueInstance: false, category: ItemCategory.intermediate, iconKey: "metal", defaultState: "stud", tier: MaterialTier.steel }), [LeatherItemId.tanningBrew]: Object.freeze({ itemId: LeatherItemId.tanningBrew, key: "tanning-brew", displayName: "Tanning brew", description: "A jar of dark curing liquor left from older tannery work.", seedValue: 8, stackable: true, maxStackSize: 99, uniqueInstance: false, category: ItemCategory.ingredient, iconKey: "potion", defaultState: "potion" }) }); export function leatherMaterialItemId (tier) { return LEATHER_MATERIAL_ID[tier] ?? null; } export function leatherShoesItemId (tier) { return LEATHER_SHOES_ID[tier] ?? null; }