BlueGit

timfa questward

Files

questward / shared / definitions / armourItems.js

armourItems.js

lots of things
timfa Tim Falken · pushed by timfa · 2 months ago
07a95f71 History
armourItems.js 3.8 KiB Download Raw
1import { ItemCategory } from "./itemCategories.js";
2import {
3 MaterialTier,
4 MATERIAL_TIER_ORDER,
5 MATERIAL_DISPLAY_NAME,
6 tierMinSkillLevel
7} from "./materialTiers.js";
8import { EquipmentKind } from "./equipmentKinds.js";
9import { equipImageName } from "./tileSprites.js";
10
11/**
12 * Metal armour — shared overlay sprites in items/armour/*-equip.png,
13 * per-tier tint via magenta mask. Shield (offhand) not included yet.
14 */
15export const ArmourItemId = Object.freeze({
16 bronzeChestplate: 91,
17 bronzeGreaves: 92,
18 bronzeBoots: 93,
19 bronzeHelmet: 94,
20 bronzeFullHelm: 95,
21 bronzeHornedHelm: 96,
22 ironChestplate: 97,
23 ironGreaves: 98,
24 ironBoots: 99,
25 ironHelmet: 100,
26 ironFullHelm: 101,
27 ironHornedHelm: 102,
28 steelChestplate: 103,
29 steelGreaves: 104,
30 steelBoots: 105,
31 steelHelmet: 106,
32 steelFullHelm: 107,
33 steelHornedHelm: 108,
34 mithrilChestplate: 109,
35 mithrilGreaves: 110,
36 mithrilBoots: 111,
37 mithrilHelmet: 112,
38 mithrilFullHelm: 113,
39 mithrilHornedHelm: 114,
40 adamantiumChestplate: 115,
41 adamantiumGreaves: 116,
42 adamantiumBoots: 117,
43 adamantiumHelmet: 118,
44 adamantiumFullHelm: 119,
45 adamantiumHornedHelm: 120,
46 orichalcumChestplate: 121,
47 orichalcumGreaves: 122,
48 orichalcumBoots: 123,
49 orichalcumHelmet: 124,
50 orichalcumFullHelm: 125,
51 orichalcumHornedHelm: 126,
52 dragonChestplate: 127,
53 dragonGreaves: 128,
54 dragonBoots: 129,
55 dragonHelmet: 130,
56 dragonFullHelm: 131,
57 dragonHornedHelm: 132
58});
59
60const ARMOUR_PIECES = Object.freeze([
61 Object.freeze({
62 suffix: "chestplate",
63 slot: "chest",
64 label: "chestplate",
65 overlay: "chestplate",
66 idKey: "Chestplate",
67 ingots: 6
68 }),
69 Object.freeze({
70 suffix: "greaves",
71 slot: "legs",
72 label: "greaves",
73 overlay: "greaves",
74 idKey: "Greaves",
75 ingots: 4
76 }),
77 Object.freeze({
78 suffix: "boots",
79 slot: "boots",
80 label: "boots",
81 overlay: "boots",
82 idKey: "Boots",
83 ingots: 2
84 }),
85 Object.freeze({
86 suffix: "helmet",
87 slot: "head",
88 label: "helmet",
89 overlay: "helmet",
90 idKey: "Helmet",
91 ingots: 2
92 }),
93 Object.freeze({
94 suffix: "full-helm",
95 slot: "head",
96 label: "full helm",
97 overlay: "fullhelm",
98 idKey: "FullHelm",
99 ingots: 3,
100 fullHelm: true
101 }),
102 Object.freeze({
103 suffix: "horned-helm",
104 slot: "head",
105 label: "horned helm",
106 overlay: "hornedhelm",
107 idKey: "HornedHelm",
108 ingots: 2,
109 needsBone: true
110 })
111]);
112
113export function armourItemIdForTier (tier, idKey)
114{
115 return ArmourItemId[`${tier}${idKey}`] ?? null;
116}
117
118function armourDef (itemId, tier, piece)
119{
120 const tierName = MATERIAL_DISPLAY_NAME[tier] ?? tier;
121 const key = `${tier}-${piece.suffix}`;
122 const equipment = {
123 slot: piece.slot,
124 tier,
125 kind: EquipmentKind.metalArmour,
126 tintFromTier: true,
127 equipSprite: equipImageName("item", "armour", piece.overlay)
128 };
129 if (piece.fullHelm)
130 {
131 equipment.minSkillLevel = tierMinSkillLevel(tier) + 1;
132 }
133 return Object.freeze({
134 itemId,
135 key,
136 displayName: `${tierName} ${piece.label}`,
137 description: `Worn ${tierName.toLowerCase()} ${piece.label}, forged for the road.`,
138 seedValue: 12,
139 stackable: false,
140 maxStackSize: 1,
141 uniqueInstance: false,
142 category: ItemCategory.finished,
143 /** Shared magenta icons under items/armour/{overlay}.png */
144 iconKey: "armour",
145 defaultState: piece.overlay,
146 tintFromTier: true,
147 equipment: Object.freeze(equipment)
148 });
149}
150
151function buildArmourDefinitions ()
152{
153 const defs = {};
154 for (const tier of MATERIAL_TIER_ORDER)
155 {
156 for (const piece of ARMOUR_PIECES)
157 {
158 const idProp = `${tier}${piece.idKey}`;
159 const itemId = ArmourItemId[idProp];
160 if (itemId == null)
161 { throw new Error(`Missing ArmourItemId for ${idProp}`); }
162 defs[itemId] = armourDef(itemId, tier, piece);
163 }
164 }
165 return Object.freeze(defs);
166}
167
168export const ARMOUR_ITEM_DEFINITIONS = buildArmourDefinitions();
169
170/** Shared piece metadata for smithing recipes (anvil). */
171export { ARMOUR_PIECES as ARMOUR_CRAFT_PIECES };