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