BlueGit

timfa questward

Files

questward / shared / definitions / leatherItems.js

leatherItems.js

leatherItems.js 4.9 KiB Download Raw
1import { ItemCategory } from "./itemCategories.js";
2import { EquipmentKind } from "./equipmentKinds.js";
3import { equipImageName } from "./tileSprites.js";
4import { CraftingItemId } from "./craftingItems.js";
5import {
6 LeatherTier,
7 LEATHER_TIER_ORDER,
8 LEATHER_DISPLAY_NAME,
9 tierMinSkillLevel
10} from "./materialTiers.js";
11
12/** Leather materials, garments, and leatherworking intermediates. */
13export 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 clothShorts: 239,
22 clothTrousers: 240,
23 leatherShoes: 241,
24 steelStud: 242,
25 tanningBrew: 243
26});
27
28const LEATHER_MATERIAL_ID = Object.freeze({
29 [LeatherTier.softLeather]: LeatherItemId.softLeather,
30 [LeatherTier.hardLeather]: LeatherItemId.hardLeather,
31 [LeatherTier.studdedLeather]: LeatherItemId.studdedLeather,
32 [LeatherTier.reinforcedLeather]: LeatherItemId.reinforcedLeather,
33 [LeatherTier.scaledLeather]: LeatherItemId.scaledLeather,
34 [LeatherTier.wyvernHide]: LeatherItemId.wyvernHide,
35 [LeatherTier.dragonhide]: LeatherItemId.dragonhide
36});
37
38function leatherMaterialDef (itemId, tier, key)
39{
40 const name = LEATHER_DISPLAY_NAME[tier] ?? tier;
41 return Object.freeze({
42 itemId,
43 key,
44 displayName: name,
45 description: tier === LeatherTier.softLeather
46 ? "Supple hide, warm from the field and ready for curing."
47 : `Cured ${name.toLowerCase()}, tough enough for straps and armour.`,
48 seedValue: tier === LeatherTier.softLeather ? 3 : 6,
49 stackable: true,
50 maxStackSize: 99,
51 uniqueInstance: false,
52 category: ItemCategory.ingredient,
53 iconKey: "leather",
54 defaultState: "leather",
55 tier,
56 tintFromTier: true
57 });
58}
59
60function buildLeatherMaterialDefinitions ()
61{
62 const defs = {};
63 for (const tier of LEATHER_TIER_ORDER)
64 {
65 const itemId = LEATHER_MATERIAL_ID[tier];
66 if (itemId == null)
67 { throw new Error(`Missing leather item id for ${tier}`); }
68 const key = tier === LeatherTier.softLeather ? "soft-leather" : tier.replace(/([A-Z])/g, "-$1").toLowerCase();
69 defs[itemId] = leatherMaterialDef(itemId, tier, key);
70 }
71 return defs;
72}
73
74const LEGWEAR_BASE = Object.freeze({
75 stackable: false,
76 maxStackSize: 1,
77 uniqueInstance: false,
78 category: ItemCategory.finished,
79 iconKey: "clothing",
80 dyeable: true,
81 tightFit: true,
82 clothing: Object.freeze({ style: true }),
83 equipment: Object.freeze({
84 slot: "legs",
85 kind: EquipmentKind.clothArmour,
86 bonus: 0,
87 minSkillLevel: 1,
88 tintFromTier: false
89 })
90});
91
92/** @type {Record<number, object>} */
93export const LEATHER_ITEM_DEFINITIONS = Object.freeze({
94 ...buildLeatherMaterialDefinitions(),
95 [LeatherItemId.clothShorts]: Object.freeze({
96 ...LEGWEAR_BASE,
97 itemId: LeatherItemId.clothShorts,
98 key: "cloth-shorts",
99 displayName: "Cloth shorts",
100 description: "Light cloth shorts cut for warm days on the road.",
101 seedValue: 4,
102 defaultState: "shorts",
103 equipment: Object.freeze({
104 ...LEGWEAR_BASE.equipment,
105 equipSprite: equipImageName("item", "clothing", "shorts")
106 })
107 }),
108 [LeatherItemId.clothTrousers]: Object.freeze({
109 ...LEGWEAR_BASE,
110 itemId: LeatherItemId.clothTrousers,
111 key: "cloth-trousers",
112 displayName: "Cloth trousers",
113 description: "Plain cloth trousers, sturdy enough for travel.",
114 seedValue: 5,
115 defaultState: "trousers",
116 equipment: Object.freeze({
117 ...LEGWEAR_BASE.equipment,
118 equipSprite: equipImageName("item", "clothing", "trousers")
119 })
120 }),
121 [LeatherItemId.leatherShoes]: Object.freeze({
122 itemId: LeatherItemId.leatherShoes,
123 key: "leather-shoes",
124 displayName: "Leather shoes",
125 description: "Simple soft-leather shoes, broken in from long walks.",
126 seedValue: 6,
127 stackable: false,
128 maxStackSize: 1,
129 uniqueInstance: false,
130 category: ItemCategory.finished,
131 iconKey: "clothing",
132 defaultState: "leather-shoes",
133 tier: LeatherTier.softLeather,
134 tintFromTier: true,
135 equipment: Object.freeze({
136 slot: "boots",
137 tier: LeatherTier.softLeather,
138 kind: EquipmentKind.leatherArmour,
139 bonus: 0,
140 minSkillLevel: tierMinSkillLevel(LeatherTier.softLeather),
141 tintFromTier: true,
142 equipSprite: equipImageName("item", "clothing", "leather-shoes")
143 })
144 }),
145 [LeatherItemId.steelStud]: Object.freeze({
146 itemId: LeatherItemId.steelStud,
147 key: "steel-stud",
148 displayName: "Steel stud",
149 description: "A small steel rivet for reinforcing leather.",
150 seedValue: 2,
151 stackable: true,
152 maxStackSize: 99,
153 uniqueInstance: false,
154 category: ItemCategory.intermediate,
155 iconKey: "metal",
156 defaultState: "stud"
157 }),
158 [LeatherItemId.tanningBrew]: Object.freeze({
159 itemId: LeatherItemId.tanningBrew,
160 key: "tanning-brew",
161 displayName: "Tanning brew",
162 description: "A sharp-smelling alchemy wash that cures hide into hard leather.",
163 seedValue: 8,
164 stackable: true,
165 maxStackSize: 99,
166 uniqueInstance: false,
167 category: ItemCategory.ingredient,
168 iconKey: "potion",
169 defaultState: "potion"
170 })
171});
172
173export function leatherMaterialItemId (tier)
174{
175 return LEATHER_MATERIAL_ID[tier] ?? null;
176}