| 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 | leatherShoes: 241, |
| 27 | steelStud: 242, |
| 28 | tanningBrew: 243 |
| 29 | }); |
| 30 | |
| 31 | const LEATHER_MATERIAL_ID = Object.freeze({ |
| 32 | [LeatherTier.softLeather]: LeatherItemId.softLeather, |
| 33 | [LeatherTier.hardLeather]: LeatherItemId.hardLeather, |
| 34 | [LeatherTier.studdedLeather]: LeatherItemId.studdedLeather, |
| 35 | [LeatherTier.reinforcedLeather]: LeatherItemId.reinforcedLeather, |
| 36 | [LeatherTier.scaledLeather]: LeatherItemId.scaledLeather, |
| 37 | [LeatherTier.wyvernHide]: LeatherItemId.wyvernHide, |
| 38 | [LeatherTier.dragonhide]: LeatherItemId.dragonhide |
| 39 | }); |
| 40 | |
| 41 | function leatherMaterialDef (itemId, tier, key) |
| 42 | { |
| 43 | const name = LEATHER_DISPLAY_NAME[tier] ?? tier; |
| 44 | return Object.freeze({ |
| 45 | itemId, |
| 46 | key, |
| 47 | displayName: name, |
| 48 | description: tier === LeatherTier.softLeather |
| 49 | ? "Supple hide, warm from the field and ready for curing." |
| 50 | : `Cured ${name.toLowerCase()}, tough enough for straps and armour.`, |
| 51 | seedValue: tier === LeatherTier.softLeather ? 3 : 6, |
| 52 | stackable: true, |
| 53 | maxStackSize: 99, |
| 54 | uniqueInstance: false, |
| 55 | category: ItemCategory.ingredient, |
| 56 | iconKey: "leather", |
| 57 | defaultState: "leather", |
| 58 | tier, |
| 59 | tintFromTier: true |
| 60 | }); |
| 61 | } |
| 62 | |
| 63 | function buildLeatherMaterialDefinitions () |
| 64 | { |
| 65 | const defs = {}; |
| 66 | for (const tier of LEATHER_TIER_ORDER) |
| 67 | { |
| 68 | const itemId = LEATHER_MATERIAL_ID[tier]; |
| 69 | if (itemId == null) |
| 70 | { throw new Error(`Missing leather item id for ${tier}`); } |
| 71 | const key = tier === LeatherTier.softLeather ? "soft-leather" : tier.replace(/([A-Z])/g, "-$1").toLowerCase(); |
| 72 | defs[itemId] = leatherMaterialDef(itemId, tier, key); |
| 73 | } |
| 74 | return defs; |
| 75 | } |
| 76 | |
| 77 | /** @type {Record<number, object>} */ |
| 78 | export const LEATHER_ITEM_DEFINITIONS = Object.freeze({ |
| 79 | ...buildLeatherMaterialDefinitions(), |
| 80 | [LeatherItemId.leatherShoes]: Object.freeze({ |
| 81 | itemId: LeatherItemId.leatherShoes, |
| 82 | key: "leather-shoes", |
| 83 | displayName: "Leather shoes", |
| 84 | description: "Simple soft-leather shoes, broken in from long walks.", |
| 85 | seedValue: 6, |
| 86 | stackable: false, |
| 87 | maxStackSize: 1, |
| 88 | uniqueInstance: false, |
| 89 | category: ItemCategory.finished, |
| 90 | iconKey: "clothing", |
| 91 | defaultState: "leather-shoes", |
| 92 | tier: LeatherTier.softLeather, |
| 93 | tintFromTier: true, |
| 94 | equipment: Object.freeze({ |
| 95 | slot: "boots", |
| 96 | tier: LeatherTier.softLeather, |
| 97 | kind: EquipmentKind.leatherArmour, |
| 98 | bonus: 0, |
| 99 | minSkillLevel: tierMinSkillLevel(LeatherTier.softLeather), |
| 100 | tintFromTier: true, |
| 101 | equipSprite: equipImageName("item", "clothing", "leather-shoes") |
| 102 | }) |
| 103 | }), |
| 104 | [LeatherItemId.steelStud]: Object.freeze({ |
| 105 | itemId: LeatherItemId.steelStud, |
| 106 | key: "steel-stud", |
| 107 | displayName: "Steel stud", |
| 108 | description: "A small steel rivet for reinforcing leather.", |
| 109 | seedValue: 2, |
| 110 | stackable: true, |
| 111 | maxStackSize: 99, |
| 112 | uniqueInstance: false, |
| 113 | category: ItemCategory.intermediate, |
| 114 | iconKey: "metal", |
| 115 | defaultState: "stud", |
| 116 | tier: MaterialTier.steel |
| 117 | }), |
| 118 | [LeatherItemId.tanningBrew]: Object.freeze({ |
| 119 | itemId: LeatherItemId.tanningBrew, |
| 120 | key: "tanning-brew", |
| 121 | displayName: "Tanning brew", |
| 122 | description: "A sharp-smelling alchemy wash that cures hide into hard leather.", |
| 123 | seedValue: 8, |
| 124 | stackable: true, |
| 125 | maxStackSize: 99, |
| 126 | uniqueInstance: false, |
| 127 | category: ItemCategory.ingredient, |
| 128 | iconKey: "potion", |
| 129 | defaultState: "potion" |
| 130 | }) |
| 131 | }); |
| 132 | |
| 133 | export function leatherMaterialItemId (tier) |
| 134 | { |
| 135 | return LEATHER_MATERIAL_ID[tier] ?? null; |
| 136 | } |