BlueGit

timfa questward

Files

questward / shared / definitions / armourItems.js

armourItems.js

armourItems.js 4.9 KiB Download Raw
1import { ItemCategory } from "./itemCategories.js";
2import
3{
4 MATERIAL_TIER_ORDER,
5 MATERIAL_DISPLAY_NAME,
6 tierMinSkillLevel,
7 leatherTierForMetal
8} from "./materialTiers.js";
9import { EquipmentKind } from "./equipmentKinds.js";
10import { equipImageName } from "./tileSprites.js";
11
12/**
13 * Metal armour — shared overlay sprites in items/armour/*-equip.png.
14 * Most pieces: magenta → metal. Shield equip is dual-channel (red metal, blue leather);
15 * shield inventory icon stays magenta metal only.
16 */
17export const ArmourItemId = Object.freeze({
18 bronzeChestplate: 91,
19 bronzeGreaves: 92,
20 bronzeBoots: 93,
21 bronzeHelmet: 94,
22 bronzeFullHelm: 95,
23 bronzeHornedHelm: 96,
24 ironChestplate: 97,
25 ironGreaves: 98,
26 ironBoots: 99,
27 ironHelmet: 100,
28 ironFullHelm: 101,
29 ironHornedHelm: 102,
30 steelChestplate: 103,
31 steelGreaves: 104,
32 steelBoots: 105,
33 steelHelmet: 106,
34 steelFullHelm: 107,
35 steelHornedHelm: 108,
36 mithrilChestplate: 109,
37 mithrilGreaves: 110,
38 mithrilBoots: 111,
39 mithrilHelmet: 112,
40 mithrilFullHelm: 113,
41 mithrilHornedHelm: 114,
42 adamantiumChestplate: 115,
43 adamantiumGreaves: 116,
44 adamantiumBoots: 117,
45 adamantiumHelmet: 118,
46 adamantiumFullHelm: 119,
47 adamantiumHornedHelm: 120,
48 orichalcumChestplate: 121,
49 orichalcumGreaves: 122,
50 orichalcumBoots: 123,
51 orichalcumHelmet: 124,
52 orichalcumFullHelm: 125,
53 orichalcumHornedHelm: 126,
54 dragonChestplate: 127,
55 dragonGreaves: 128,
56 dragonBoots: 129,
57 dragonHelmet: 130,
58 dragonFullHelm: 131,
59 dragonHornedHelm: 132,
60 bronzeSkirt: 475,
61 ironSkirt: 476,
62 steelSkirt: 477,
63 mithrilSkirt: 478,
64 adamantiumSkirt: 479,
65 orichalcumSkirt: 480,
66 dragonSkirt: 481,
67 bronzeShield: 482,
68 ironShield: 483,
69 steelShield: 484,
70 mithrilShield: 485,
71 adamantiumShield: 486,
72 orichalcumShield: 487,
73 dragonShield: 488
74});
75
76const ARMOUR_PIECES = Object.freeze([
77 Object.freeze({
78 suffix: "chestplate",
79 slot: "chest",
80 label: "chestplate",
81 overlay: "chestplate",
82 idKey: "Chestplate",
83 ingots: 6
84 }),
85 Object.freeze({
86 suffix: "greaves",
87 slot: "legs",
88 label: "greaves",
89 overlay: "greaves",
90 idKey: "Greaves",
91 ingots: 4
92 }),
93 /** Same slot/cost/defence as greaves; alternate legs look. */
94 Object.freeze({
95 suffix: "skirt",
96 slot: "legs",
97 label: "skirt",
98 overlay: "skirt",
99 idKey: "Skirt",
100 ingots: 4
101 }),
102 Object.freeze({
103 suffix: "boots",
104 slot: "boots",
105 label: "boots",
106 overlay: "boots",
107 idKey: "Boots",
108 ingots: 2
109 }),
110 Object.freeze({
111 suffix: "helmet",
112 slot: "head",
113 label: "helmet",
114 overlay: "helmet",
115 idKey: "Helmet",
116 ingots: 2
117 }),
118 Object.freeze({
119 suffix: "full-helm",
120 slot: "head",
121 label: "full helm",
122 overlay: "fullhelm",
123 idKey: "FullHelm",
124 ingots: 3,
125 fullHelm: true
126 }),
127 Object.freeze({
128 suffix: "horned-helm",
129 slot: "head",
130 label: "horned helm",
131 overlay: "hornedhelm",
132 idKey: "HornedHelm",
133 ingots: 2,
134 needsBone: true
135 }),
136 Object.freeze({
137 suffix: "shield",
138 slot: "offhand",
139 label: "shield",
140 overlay: "shield",
141 idKey: "Shield",
142 ingots: 4,
143 kind: EquipmentKind.shield,
144 needsLeather: true,
145 /** Equip: red = metal, blue = leather. Icon: magenta metal only. */
146 dualTintLeather: true
147 })
148]);
149
150export function armourItemIdForTier (tier, idKey)
151{
152 return ArmourItemId[`${tier}${idKey}`] ?? null;
153}
154
155function armourDef (itemId, tier, piece)
156{
157 const tierName = MATERIAL_DISPLAY_NAME[tier] ?? tier;
158 const key = `${tier}-${piece.suffix}`;
159 const kind = piece.kind ?? EquipmentKind.metalArmour;
160 const dualTintLeather = !!piece.dualTintLeather;
161 const equipment = {
162 slot: piece.slot,
163 tier,
164 kind,
165 equipSprite: equipImageName("item", "armour", piece.overlay)
166 };
167 if (!dualTintLeather)
168 { equipment.tintFromTier = true; }
169 if (piece.fullHelm)
170 {
171 equipment.minSkillLevel = tierMinSkillLevel(tier) + 1;
172 }
173 const def = {
174 itemId,
175 key,
176 displayName: `${tierName} ${piece.label}`,
177 description: `Worn ${tierName.toLowerCase()} ${piece.label}, forged for the road.`,
178 seedValue: 12,
179 stackable: false,
180 maxStackSize: 1,
181 uniqueInstance: false,
182 category: ItemCategory.finished,
183 /** Shared magenta icons under items/armour/{overlay}.png */
184 iconKey: "armour",
185 defaultState: piece.overlay,
186 tintFromTier: true,
187 equipment: Object.freeze(equipment)
188 };
189 if (dualTintLeather)
190 {
191 def.leatherTier = leatherTierForMetal(tier);
192 def.dualTintFromTier = true;
193 /** Inventory icon stays single-channel magenta; worn overlay uses dual tint. */
194 def.iconTintFromTier = true;
195 }
196 return Object.freeze(def);
197}
198
199function buildArmourDefinitions ()
200{
201 const defs = {};
202 for (const tier of MATERIAL_TIER_ORDER)
203 {
204 for (const piece of ARMOUR_PIECES)
205 {
206 const idProp = `${tier}${piece.idKey}`;
207 const itemId = ArmourItemId[idProp];
208 if (itemId == null)
209 { throw new Error(`Missing ArmourItemId for ${idProp}`); }
210 defs[itemId] = armourDef(itemId, tier, piece);
211 }
212 }
213 return Object.freeze(defs);
214}
215
216export const ARMOUR_ITEM_DEFINITIONS = buildArmourDefinitions();
217
218/** Shared piece metadata for smithing recipes (anvil). */
219export { ARMOUR_PIECES as ARMOUR_CRAFT_PIECES };