| 1 | import { ItemCategory } from "./itemCategories.js"; |
| 2 | import { EquipmentKind } from "./equipmentKinds.js"; |
| 3 | import { equipImageName } from "./tileSprites.js"; |
| 4 | import { CraftingItemId } from "./craftingItems.js"; |
| 5 | import { |
| 6 | LeatherTier, |
| 7 | MaterialTier, |
| 8 | LEATHER_TIER_ORDER, |
| 9 | LEATHER_DISPLAY_NAME, |
| 10 | tierMinSkillLevel |
| 11 | } from "./materialTiers.js"; |
| 12 | |
| 13 | /** Leather materials, garments, and leatherworking intermediates. */ |
| 14 | export const LeatherItemId = Object.freeze({ |
| 15 | softLeather: CraftingItemId.leather, |
| 16 | hardLeather: 233, |
| 17 | studdedLeather: 234, |
| 18 | reinforcedLeather: 235, |
| 19 | scaledLeather: 236, |
| 20 | wyvernHide: 237, |
| 21 | dragonhide: 238, |
| 22 | /** @deprecated Prefer ClothItemId.cottonShorts — kept for existing refs. */ |
| 23 | clothShorts: 239, |
| 24 | /** @deprecated Prefer ClothItemId.cottonTrousers — kept for existing refs. */ |
| 25 | clothTrousers: 240, |
| 26 | /** Soft-leather shoes (historic id). Prefer {@link leatherShoesItemId}. */ |
| 27 | leatherShoes: 241, |
| 28 | hardLeatherShoes: 491, |
| 29 | studdedLeatherShoes: 492, |
| 30 | reinforcedLeatherShoes: 493, |
| 31 | scaledLeatherShoes: 494, |
| 32 | wyvernHideShoes: 495, |
| 33 | dragonhideShoes: 496, |
| 34 | steelStud: 242, |
| 35 | tanningBrew: 243 |
| 36 | }); |
| 37 | |
| 38 | const LEATHER_MATERIAL_ID = Object.freeze({ |
| 39 | [LeatherTier.softLeather]: LeatherItemId.softLeather, |
| 40 | [LeatherTier.hardLeather]: LeatherItemId.hardLeather, |
| 41 | [LeatherTier.studdedLeather]: LeatherItemId.studdedLeather, |
| 42 | [LeatherTier.reinforcedLeather]: LeatherItemId.reinforcedLeather, |
| 43 | [LeatherTier.scaledLeather]: LeatherItemId.scaledLeather, |
| 44 | [LeatherTier.wyvernHide]: LeatherItemId.wyvernHide, |
| 45 | [LeatherTier.dragonhide]: LeatherItemId.dragonhide |
| 46 | }); |
| 47 | |
| 48 | const LEATHER_SHOES_ID = Object.freeze({ |
| 49 | [LeatherTier.softLeather]: LeatherItemId.leatherShoes, |
| 50 | [LeatherTier.hardLeather]: LeatherItemId.hardLeatherShoes, |
| 51 | [LeatherTier.studdedLeather]: LeatherItemId.studdedLeatherShoes, |
| 52 | [LeatherTier.reinforcedLeather]: LeatherItemId.reinforcedLeatherShoes, |
| 53 | [LeatherTier.scaledLeather]: LeatherItemId.scaledLeatherShoes, |
| 54 | [LeatherTier.wyvernHide]: LeatherItemId.wyvernHideShoes, |
| 55 | [LeatherTier.dragonhide]: LeatherItemId.dragonhideShoes |
| 56 | }); |
| 57 | |
| 58 | function leatherMaterialDef (itemId, tier, key) |
| 59 | { |
| 60 | const name = LEATHER_DISPLAY_NAME[tier] ?? tier; |
| 61 | return Object.freeze({ |
| 62 | itemId, |
| 63 | key, |
| 64 | displayName: name, |
| 65 | description: tier === LeatherTier.softLeather |
| 66 | ? "Supple hide, warm from the field and ready for curing." |
| 67 | : `Cured ${name.toLowerCase()}, tough enough for straps and armour.`, |
| 68 | seedValue: tier === LeatherTier.softLeather ? 3 : 6, |
| 69 | stackable: true, |
| 70 | maxStackSize: 99, |
| 71 | uniqueInstance: false, |
| 72 | category: ItemCategory.ingredient, |
| 73 | iconKey: "leather", |
| 74 | defaultState: "leather", |
| 75 | tier, |
| 76 | tintFromTier: true |
| 77 | }); |
| 78 | } |
| 79 | |
| 80 | function leatherShoesDef (itemId, tier, key) |
| 81 | { |
| 82 | const name = LEATHER_DISPLAY_NAME[tier] ?? tier; |
| 83 | return Object.freeze({ |
| 84 | itemId, |
| 85 | key, |
| 86 | displayName: `${name} shoes`, |
| 87 | description: `Simple ${name.toLowerCase()} shoes, broken in from long walks.`, |
| 88 | seedValue: 6, |
| 89 | stackable: false, |
| 90 | maxStackSize: 1, |
| 91 | uniqueInstance: false, |
| 92 | category: ItemCategory.finished, |
| 93 | iconKey: "clothing", |
| 94 | defaultState: "leather-shoes", |
| 95 | tier, |
| 96 | tintFromTier: true, |
| 97 | equipment: Object.freeze({ |
| 98 | slot: "boots", |
| 99 | tier, |
| 100 | kind: EquipmentKind.leatherArmour, |
| 101 | bonus: 0, |
| 102 | minSkillLevel: tierMinSkillLevel(tier), |
| 103 | tintFromTier: true, |
| 104 | equipSprite: equipImageName("item", "clothing", "leather-shoes") |
| 105 | }) |
| 106 | }); |
| 107 | } |
| 108 | |
| 109 | function buildLeatherMaterialDefinitions () |
| 110 | { |
| 111 | const defs = {}; |
| 112 | for (const tier of LEATHER_TIER_ORDER) |
| 113 | { |
| 114 | const itemId = LEATHER_MATERIAL_ID[tier]; |
| 115 | if (itemId == null) |
| 116 | { throw new Error(`Missing leather item id for ${tier}`); } |
| 117 | const key = tier === LeatherTier.softLeather ? "soft-leather" : tier.replace(/([A-Z])/g, "-$1").toLowerCase(); |
| 118 | defs[itemId] = leatherMaterialDef(itemId, tier, key); |
| 119 | } |
| 120 | return defs; |
| 121 | } |
| 122 | |
| 123 | function buildLeatherShoesDefinitions () |
| 124 | { |
| 125 | const defs = {}; |
| 126 | for (const tier of LEATHER_TIER_ORDER) |
| 127 | { |
| 128 | const itemId = LEATHER_SHOES_ID[tier]; |
| 129 | if (itemId == null) |
| 130 | { throw new Error(`Missing leather shoes item id for ${tier}`); } |
| 131 | const prefix = tier === LeatherTier.softLeather |
| 132 | ? "leather" |
| 133 | : tier.replace(/([A-Z])/g, "-$1").toLowerCase(); |
| 134 | defs[itemId] = leatherShoesDef(itemId, tier, `${prefix}-shoes`); |
| 135 | } |
| 136 | return defs; |
| 137 | } |
| 138 | |
| 139 | /** @type {Record<number, object>} */ |
| 140 | export const LEATHER_ITEM_DEFINITIONS = Object.freeze({ |
| 141 | ...buildLeatherMaterialDefinitions(), |
| 142 | ...buildLeatherShoesDefinitions(), |
| 143 | [LeatherItemId.steelStud]: Object.freeze({ |
| 144 | itemId: LeatherItemId.steelStud, |
| 145 | key: "steel-stud", |
| 146 | displayName: "Steel stud", |
| 147 | description: "A small steel rivet for reinforcing leather.", |
| 148 | seedValue: 2, |
| 149 | stackable: true, |
| 150 | maxStackSize: 99, |
| 151 | uniqueInstance: false, |
| 152 | category: ItemCategory.intermediate, |
| 153 | iconKey: "metal", |
| 154 | defaultState: "stud", |
| 155 | tier: MaterialTier.steel |
| 156 | }), |
| 157 | [LeatherItemId.tanningBrew]: Object.freeze({ |
| 158 | itemId: LeatherItemId.tanningBrew, |
| 159 | key: "tanning-brew", |
| 160 | displayName: "Tanning brew", |
| 161 | description: "A jar of dark curing liquor left from older tannery work.", |
| 162 | seedValue: 8, |
| 163 | stackable: true, |
| 164 | maxStackSize: 99, |
| 165 | uniqueInstance: false, |
| 166 | category: ItemCategory.ingredient, |
| 167 | iconKey: "potion", |
| 168 | defaultState: "potion" |
| 169 | }) |
| 170 | }); |
| 171 | |
| 172 | export function leatherMaterialItemId (tier) |
| 173 | { |
| 174 | return LEATHER_MATERIAL_ID[tier] ?? null; |
| 175 | } |
| 176 | |
| 177 | export function leatherShoesItemId (tier) |
| 178 | { |
| 179 | return LEATHER_SHOES_ID[tier] ?? null; |
| 180 | } |