BlueGit

timfa questward

Add leather armour, wizard robes, and equipment stat rules.

Wire tiered chestguard/chausses/helmet and mage robe pieces with dual tint,
tailor/leatherworking recipes, and design-accurate worn bonuses: leather agility
+ half defence, wizard magic only, metal defence with rank penalties on magic
and archery plus quarter-tier strength and agility rounded up.

timfa Tim Falken · pushed by timfa

Authored 2026-09-01 · 2 months ago

Hash
ee9ea685917c65ef98dc0db796af1a471c29d62f
Parent
29e470e9
14 files changed +663 −52
client/src/editor/settingsModal.js +32 −28
@@ -1,31 +1,35 @@
1 import {
2 WORLD_SETTING_CATEGORIES,
3 coerceSettingValue,
4 formatSettingValue,
5 settingsValuesEqual,
6 itemSeedMapsEqual
7 } from "/shared/definitions/worldSettings.js";
8 import {
9 listPricedItems,
10 itemPriceSnapshot,
11 normalizeItemSeedValues,
12 effectiveSeedValue
13 } from "/shared/shop/pricing.js";
1 import
2 {
3 WORLD_SETTING_CATEGORIES,
4 coerceSettingValue,
5 formatSettingValue,
6 settingsValuesEqual,
7 itemSeedMapsEqual
8 } from "/shared/definitions/worldSettings.js";
9 import
10 {
11 listPricedItems,
12 itemPriceSnapshot,
13 normalizeItemSeedValues,
14 effectiveSeedValue
15 } from "/shared/shop/pricing.js";
14 16 import { ITEM_DEFINITIONS, itemAssetPathForStack } from "/shared/definitions/items.js";
15 17 import { EQUIPMENT_SLOTS } from "/shared/items/inventory.js";
16 import {
17 normalizeStarterLoadout,
18 starterLoadoutsEqual,
19 DEFAULT_STARTER_EQUIPMENT,
20 DEFAULT_STARTER_INVENTORY
21 } from "/shared/items/starterLoadout.js";
22 import {
23 EQUIPMENT_STAT_CATEGORIES,
24 normalizeEquipmentStatBonuses,
25 equipmentStatBonusMapsEqual,
26 equipmentStatRowItemId,
27 equipmentStatRowDefaultTier
28 } from "/shared/definitions/equipmentStatCategories.js";
18 import
19 {
20 normalizeStarterLoadout,
21 starterLoadoutsEqual,
22 DEFAULT_STARTER_EQUIPMENT,
23 DEFAULT_STARTER_INVENTORY
24 } from "/shared/items/starterLoadout.js";
25 import
26 {
27 EQUIPMENT_STAT_CATEGORIES,
28 normalizeEquipmentStatBonuses,
29 equipmentStatBonusMapsEqual,
30 equipmentStatRowItemId,
31 equipmentStatRowDefaultTier
32 } from "/shared/definitions/equipmentStatCategories.js";
29 33 import { applyItemIcon } from "/src/render/potionIcon.js";
30 34
31 35 const SEED_PAGE_SIZE = 20;
@@ -634,7 +638,7 @@ export function initSettingsModal ({ socket, MessageType, onApplied, onPreviewNi
634 638 skillIcon.height = 14;
635 639 const input = document.createElement("input");
636 640 input.type = "number";
637 input.min = "0";
641 input.min = "-99";
638 642 input.max = "99";
639 643 input.step = "1";
640 644 input.dataset.equipStat = "1";
@@ -647,7 +651,7 @@ export function initSettingsModal ({ socket, MessageType, onApplied, onPreviewNi
647 651 { line.classList.add("dirty"); }
648 652 input.addEventListener("input", () =>
649 653 {
650 const value = Math.max(0, Math.min(99, Math.floor(Number(input.value) || 0)));
654 const value = Math.max(-99, Math.min(99, Math.floor(Number(input.value) || 0)));
651 655 input.value = String(value);
652 656 const nextCat = {
653 657 ...(draftEquipmentStats[category.id] ?? {}),
@@ -1,31 +1,35 @@
1import {
1import
2 WORLD_SETTING_CATEGORIES,
2 {
3 coerceSettingValue,
3 WORLD_SETTING_CATEGORIES,
4 formatSettingValue,
4 coerceSettingValue,
5 settingsValuesEqual,
5 formatSettingValue,
6 itemSeedMapsEqual
6 settingsValuesEqual,
7} from "/shared/definitions/worldSettings.js";
7 itemSeedMapsEqual
8import {
8 } from "/shared/definitions/worldSettings.js";
9 listPricedItems,
9import
10 itemPriceSnapshot,
10 {
11 normalizeItemSeedValues,
11 listPricedItems,
12 effectiveSeedValue
12 itemPriceSnapshot,
13} from "/shared/shop/pricing.js";
13 normalizeItemSeedValues,
14 effectiveSeedValue
15 } from "/shared/shop/pricing.js";
14import { ITEM_DEFINITIONS, itemAssetPathForStack } from "/shared/definitions/items.js";
16import { ITEM_DEFINITIONS, itemAssetPathForStack } from "/shared/definitions/items.js";
15import { EQUIPMENT_SLOTS } from "/shared/items/inventory.js";
17import { EQUIPMENT_SLOTS } from "/shared/items/inventory.js";
16import {
18import
17 normalizeStarterLoadout,
19 {
18 starterLoadoutsEqual,
20 normalizeStarterLoadout,
19 DEFAULT_STARTER_EQUIPMENT,
21 starterLoadoutsEqual,
20 DEFAULT_STARTER_INVENTORY
22 DEFAULT_STARTER_EQUIPMENT,
21} from "/shared/items/starterLoadout.js";
23 DEFAULT_STARTER_INVENTORY
22import {
24 } from "/shared/items/starterLoadout.js";
23 EQUIPMENT_STAT_CATEGORIES,
25import
24 normalizeEquipmentStatBonuses,
26 {
25 equipmentStatBonusMapsEqual,
27 EQUIPMENT_STAT_CATEGORIES,
26 equipmentStatRowItemId,
28 normalizeEquipmentStatBonuses,
27 equipmentStatRowDefaultTier
29 equipmentStatBonusMapsEqual,
28} from "/shared/definitions/equipmentStatCategories.js";
30 equipmentStatRowItemId,
31 equipmentStatRowDefaultTier
32 } from "/shared/definitions/equipmentStatCategories.js";
29import { applyItemIcon } from "/src/render/potionIcon.js";
33import { applyItemIcon } from "/src/render/potionIcon.js";
30
34
31const SEED_PAGE_SIZE = 20;
35const SEED_PAGE_SIZE = 20;
@@ -634,7 +638,7 @@ export function initSettingsModal ({ socket, MessageType, onApplied, onPreviewNi
634 skillIcon.height = 14;
638 skillIcon.height = 14;
635 const input = document.createElement("input");
639 const input = document.createElement("input");
636 input.type = "number";
640 input.type = "number";
637 input.min = "0";
641 input.min = "-99";
638 input.max = "99";
642 input.max = "99";
639 input.step = "1";
643 input.step = "1";
640 input.dataset.equipStat = "1";
644 input.dataset.equipStat = "1";
@@ -647,7 +651,7 @@ export function initSettingsModal ({ socket, MessageType, onApplied, onPreviewNi
647 { line.classList.add("dirty"); }
651 { line.classList.add("dirty"); }
648 input.addEventListener("input", () =>
652 input.addEventListener("input", () =>
649 {
653 {
650 const value = Math.max(0, Math.min(99, Math.floor(Number(input.value) || 0)));
654 const value = Math.max(-99, Math.min(99, Math.floor(Number(input.value) || 0)));
651 input.value = String(value);
655 input.value = String(value);
652 const nextCat = {
656 const nextCat = {
653 ...(draftEquipmentStats[category.id] ?? {}),
657 ...(draftEquipmentStats[category.id] ?? {}),
server/tests/combat.test.js +4 −2
@@ -1144,6 +1144,10 @@ test("stacked combatants against the same target spread to different tiles", ()
1144 1144 const playerHealth = worker.world.ecs.get(handle, Component.health);
1145 1145 playerHealth.max = 500;
1146 1146 playerHealth.current = 500;
1147 engageTarget(worker.world.ecs, rat1, playerId);
1148 engageTarget(worker.world.ecs, rat2, playerId);
1149 assert.equal(componentsOf(harness.simulation, rat1).combat?.targetEntityId, playerId);
1150 assert.equal(componentsOf(harness.simulation, rat2).combat?.targetEntityId, playerId);
1147 1151 teleportEntity(worker, rat2, 9, 8);
1148 1152
1149 1153 for (let i = 0; i < 200; i++)
@@ -1159,8 +1163,6 @@ test("stacked combatants against the same target spread to different tiles", ()
1159 1163 `${pos2.tileX},${pos2.tileY}`,
1160 1164 "expected stacked rats to spread apart"
1161 1165 );
1162 assert.equal(componentsOf(harness.simulation, rat1).combat?.targetEntityId, playerId);
1163 assert.equal(componentsOf(harness.simulation, rat2).combat?.targetEntityId, playerId);
1164 1166 }
1165 1167 finally
1166 1168 { harness.close(); }
@@ -1144,6 +1144,10 @@ test("stacked combatants against the same target spread to different tiles", ()
1144 const playerHealth = worker.world.ecs.get(handle, Component.health);
1144 const playerHealth = worker.world.ecs.get(handle, Component.health);
1145 playerHealth.max = 500;
1145 playerHealth.max = 500;
1146 playerHealth.current = 500;
1146 playerHealth.current = 500;
1147 engageTarget(worker.world.ecs, rat1, playerId);
1148 engageTarget(worker.world.ecs, rat2, playerId);
1149 assert.equal(componentsOf(harness.simulation, rat1).combat?.targetEntityId, playerId);
1150 assert.equal(componentsOf(harness.simulation, rat2).combat?.targetEntityId, playerId);
1147 teleportEntity(worker, rat2, 9, 8);
1151 teleportEntity(worker, rat2, 9, 8);
1148
1152
1149 for (let i = 0; i < 200; i++)
1153 for (let i = 0; i < 200; i++)
@@ -1159,8 +1163,6 @@ test("stacked combatants against the same target spread to different tiles", ()
1159 `${pos2.tileX},${pos2.tileY}`,
1163 `${pos2.tileX},${pos2.tileY}`,
1160 "expected stacked rats to spread apart"
1164 "expected stacked rats to spread apart"
1161 );
1165 );
1162 assert.equal(componentsOf(harness.simulation, rat1).combat?.targetEntityId, playerId);
1163 assert.equal(componentsOf(harness.simulation, rat2).combat?.targetEntityId, playerId);
1164 }
1166 }
1165 finally
1167 finally
1166 { harness.close(); }
1168 { harness.close(); }
server/tests/crafting.test.js +38 −0
@@ -5,6 +5,10 @@ import { CraftingStationId, CRAFT_DURATION_MS } from "../../shared/definitions/c
5 5 import { ItemId } from "../../shared/definitions/items.js";
6 6 import { ArmourItemId } from "../../shared/definitions/armourItems.js";
7 7 import { LeatherItemId } from "../../shared/definitions/leatherItems.js";
8 import { LeatherArmourItemId } from "../../shared/definitions/leatherArmourItems.js";
9 import { WizardItemId } from "../../shared/definitions/wizardItems.js";
10 import { ClothItemId } from "../../shared/definitions/clothItems.js";
11 import { resolveTailorCraft } from "../../shared/crafting/tailor.js";
8 12 import { SkillId } from "../../shared/definitions/skills.js";
9 13 import
10 14 {
@@ -505,3 +509,37 @@ test("leatherworking shoes recipes use 2 leather per tier", () =>
505 509 assert.equal(hide.output.itemId, LeatherItemId.dragonhideShoes);
506 510 assert.deepEqual(hide.inputs, [{ itemId: LeatherItemId.dragonhide, quantity: 2 }]);
507 511 });
512
513 test("leatherworking armour recipes use leather and cloth per tier", () =>
514 {
515 const chest = recipeDefinition("leather-chestguard-softLeather");
516 assert.ok(chest);
517 assert.equal(chest.output.itemId, LeatherArmourItemId.softLeatherChestguard);
518 assert.deepEqual(chest.inputs, [
519 { itemId: ItemId.leather, quantity: 4 },
520 { itemId: ClothItemId.cottonCloth, quantity: 2 }
521 ]);
522 const chausses = recipeDefinition("leather-chausses-studdedLeather");
523 assert.ok(chausses);
524 assert.equal(chausses.inputs[0].quantity, 3);
525 assert.equal(chausses.inputs[1].quantity, 1);
526 const helmet = recipeDefinition("leather-helmet-dragonhide");
527 assert.ok(helmet);
528 assert.equal(helmet.inputs.length, 1);
529 assert.equal(helmet.inputs[0].quantity, 2);
530 });
531
532 test("tailor wizard robe recipes resolve cloth and leather inputs", () =>
533 {
534 const hat = resolveTailorCraft({ templateId: "wizard-hat", clothTier: "wool" });
535 assert.equal(hat.ok, true);
536 assert.equal(hat.recipe.output.itemId, WizardItemId.woolHat);
537 assert.deepEqual(hat.recipe.inputs, [
538 { itemId: ClothItemId.woolCloth, quantity: 2 },
539 { itemId: LeatherItemId.hardLeather, quantity: 1 }
540 ]);
541 const bottoms = resolveTailorCraft({ templateId: "wizard-robebottoms", clothTier: "cotton" });
542 assert.equal(bottoms.ok, true);
543 assert.equal(bottoms.recipe.output.itemId, WizardItemId.cottonRobeBottoms);
544 assert.deepEqual(bottoms.recipe.inputs, [{ itemId: ClothItemId.cottonCloth, quantity: 4 }]);
545 });
@@ -5,6 +5,10 @@ import { CraftingStationId, CRAFT_DURATION_MS } from "../../shared/definitions/c
5import { ItemId } from "../../shared/definitions/items.js";
5import { ItemId } from "../../shared/definitions/items.js";
6import { ArmourItemId } from "../../shared/definitions/armourItems.js";
6import { ArmourItemId } from "../../shared/definitions/armourItems.js";
7import { LeatherItemId } from "../../shared/definitions/leatherItems.js";
7import { LeatherItemId } from "../../shared/definitions/leatherItems.js";
8import { LeatherArmourItemId } from "../../shared/definitions/leatherArmourItems.js";
9import { WizardItemId } from "../../shared/definitions/wizardItems.js";
10import { ClothItemId } from "../../shared/definitions/clothItems.js";
11import { resolveTailorCraft } from "../../shared/crafting/tailor.js";
8import { SkillId } from "../../shared/definitions/skills.js";
12import { SkillId } from "../../shared/definitions/skills.js";
9import
13import
10{
14{
@@ -505,3 +509,37 @@ test("leatherworking shoes recipes use 2 leather per tier", () =>
505 assert.equal(hide.output.itemId, LeatherItemId.dragonhideShoes);
509 assert.equal(hide.output.itemId, LeatherItemId.dragonhideShoes);
506 assert.deepEqual(hide.inputs, [{ itemId: LeatherItemId.dragonhide, quantity: 2 }]);
510 assert.deepEqual(hide.inputs, [{ itemId: LeatherItemId.dragonhide, quantity: 2 }]);
507});
511});
512
513test("leatherworking armour recipes use leather and cloth per tier", () =>
514{
515 const chest = recipeDefinition("leather-chestguard-softLeather");
516 assert.ok(chest);
517 assert.equal(chest.output.itemId, LeatherArmourItemId.softLeatherChestguard);
518 assert.deepEqual(chest.inputs, [
519 { itemId: ItemId.leather, quantity: 4 },
520 { itemId: ClothItemId.cottonCloth, quantity: 2 }
521 ]);
522 const chausses = recipeDefinition("leather-chausses-studdedLeather");
523 assert.ok(chausses);
524 assert.equal(chausses.inputs[0].quantity, 3);
525 assert.equal(chausses.inputs[1].quantity, 1);
526 const helmet = recipeDefinition("leather-helmet-dragonhide");
527 assert.ok(helmet);
528 assert.equal(helmet.inputs.length, 1);
529 assert.equal(helmet.inputs[0].quantity, 2);
530});
531
532test("tailor wizard robe recipes resolve cloth and leather inputs", () =>
533{
534 const hat = resolveTailorCraft({ templateId: "wizard-hat", clothTier: "wool" });
535 assert.equal(hat.ok, true);
536 assert.equal(hat.recipe.output.itemId, WizardItemId.woolHat);
537 assert.deepEqual(hat.recipe.inputs, [
538 { itemId: ClothItemId.woolCloth, quantity: 2 },
539 { itemId: LeatherItemId.hardLeather, quantity: 1 }
540 ]);
541 const bottoms = resolveTailorCraft({ templateId: "wizard-robebottoms", clothTier: "cotton" });
542 assert.equal(bottoms.ok, true);
543 assert.equal(bottoms.recipe.output.itemId, WizardItemId.cottonRobeBottoms);
544 assert.deepEqual(bottoms.recipe.inputs, [{ itemId: ClothItemId.cottonCloth, quantity: 4 }]);
545});
server/tests/equipment.test.js +103 −3
@@ -3,8 +3,10 @@ import assert from "node:assert/strict";
3 3 import { ItemId, itemDefinition } from "../../shared/definitions/items.js";
4 4 import { ArmourItemId } from "../../shared/definitions/armourItems.js";
5 5 import { LeatherItemId } from "../../shared/definitions/leatherItems.js";
6 import { LeatherArmourItemId } from "../../shared/definitions/leatherArmourItems.js";
7 import { WizardItemId } from "../../shared/definitions/wizardItems.js";
6 8 import { CraftingItemId } from "../../shared/definitions/craftingItems.js";
7 import { MaterialTier, LeatherTier, WoodTier, tierStatBonus, tierMinSkillLevel } from "../../shared/definitions/materialTiers.js";
9 import { MaterialTier, LeatherTier, WoodTier, ClothTier, tierStatBonus, tierMinSkillLevel } from "../../shared/definitions/materialTiers.js";
8 10 import { EquipmentKind } from "../../shared/definitions/equipmentKinds.js";
9 11 import { SkillId } from "../../shared/definitions/skills.js";
10 12 import { normalizePlayerSkills } from "../../shared/skills/state.js";
@@ -186,11 +188,16 @@ test("normalizeEquipmentStatBonuses fills defaults and clamps", () =>
186 188 const defaults = defaultEquipmentStatBonuses();
187 189 const normalized = normalizeEquipmentStatBonuses({
188 190 metalArmour: {
189 chestplate: { bronze: { defence: -3 } }
191 chestplate: {
192 bronze: { defence: -3, magic: -150 },
193 iron: { defence: 999 }
194 }
190 195 },
191 196 unknownCategory: { x: 1 }
192 197 });
193 assert.equal(normalized.metalArmour.chestplate.bronze.defence, 0);
198 assert.equal(normalized.metalArmour.chestplate.bronze.defence, -3);
199 assert.equal(normalized.metalArmour.chestplate.bronze.magic, -99);
200 assert.equal(normalized.metalArmour.chestplate.iron.defence, 99);
194 201 assert.equal(normalized.metalArmour.greaves.bronze.defence, defaults.metalArmour.greaves.bronze.defence);
195 202 assert.equal(normalized.unknownCategory, undefined);
196 203 });
@@ -216,3 +223,96 @@ test("bonusForEquippedItem returns null for tools", () =>
216 223 {
217 224 assert.equal(bonusForEquippedItem(itemDefinition(CraftingItemId.bronzePickaxe)), null);
218 225 });
226
227 test("leather armour uses leather-cloth dual tint", () =>
228 {
229 const def = itemDefinition(LeatherArmourItemId.softLeatherChestguard);
230 assert.equal(def?.equipment?.kind, EquipmentKind.leatherArmour);
231 assert.equal(def?.dualTintLeatherCloth, true);
232 assert.equal(def?.leatherTier, LeatherTier.softLeather);
233 assert.equal(def?.clothTier, "cotton");
234 const dual = resolveItemDualTint({ itemId: LeatherArmourItemId.softLeatherChestguard }, def);
235 assert.ok(dual?.shaft);
236 assert.ok(dual?.tip);
237 });
238
239 test("wizard robe top grants magic bonus for cloth tier", () =>
240 {
241 const defaults = defaultEquipmentStatBonuses().wizardArmour.robetop;
242 assert.equal(defaults.cotton.magic, tierStatBonus(ClothTier.cotton));
243 assert.equal(defaults.cotton.defence, undefined);
244 const slots = {
245 ...emptyEquipment().slots,
246 chest: { itemId: WizardItemId.cottonRobeTop, quantity: 1 }
247 };
248 const bonuses = equipmentBonusesFromSlots(slots);
249 assert.equal(bonuses[SkillId.magic], tierStatBonus(ClothTier.cotton));
250 assert.equal(bonuses[SkillId.defence], 0);
251 });
252
253 test("leather chestguard grants full agility and half defence", () =>
254 {
255 const defaults = defaultEquipmentStatBonuses().leatherArmour.chestguard;
256 assert.equal(defaults.softLeather.agility, tierStatBonus(LeatherTier.softLeather));
257 assert.equal(defaults.softLeather.defence, Math.floor(tierStatBonus(LeatherTier.softLeather) / 2));
258 const slots = {
259 ...emptyEquipment().slots,
260 chest: { itemId: LeatherArmourItemId.softLeatherChestguard, quantity: 1 }
261 };
262 const bonuses = equipmentBonusesFromSlots(slots);
263 assert.equal(bonuses[SkillId.agility], tierStatBonus(LeatherTier.softLeather));
264 assert.equal(bonuses[SkillId.defence], Math.floor(tierStatBonus(LeatherTier.softLeather) / 2));
265 });
266
267 test("metal armour grants quarter-tier strength and agility rounded up", () =>
268 {
269 const defaults = defaultEquipmentStatBonuses().metalArmour.chestplate;
270 assert.equal(defaults.bronze.strength, 1);
271 assert.equal(defaults.bronze.agility, 1);
272 assert.equal(defaults.iron.strength, 1);
273 assert.equal(defaults.steel.strength, 1);
274 assert.equal(defaults.mithril.strength, 2);
275 assert.equal(defaults.dragon.strength, 3);
276 const slots = {
277 ...emptyEquipment().slots,
278 chest: { itemId: ArmourItemId.steelChestplate, quantity: 1 }
279 };
280 const bonuses = equipmentBonusesFromSlots(slots);
281 assert.equal(bonuses[SkillId.strength], 1);
282 assert.equal(bonuses[SkillId.agility], 1);
283 });
284
285 test("metal armour penalizes magic and archery by material rank", () =>
286 {
287 const defaults = defaultEquipmentStatBonuses().metalArmour.chestplate;
288 assert.equal(defaults.bronze.defence, tierStatBonus(MaterialTier.bronze));
289 assert.equal(defaults.bronze.magic, -1);
290 assert.equal(defaults.bronze.archery, -1);
291 assert.equal(defaults.dragon.defence, tierStatBonus(MaterialTier.dragon));
292 assert.equal(defaults.dragon.magic, -7);
293 assert.equal(defaults.dragon.archery, -7);
294 const slots = {
295 ...emptyEquipment().slots,
296 chest: { itemId: ArmourItemId.ironChestplate, quantity: 1 }
297 };
298 const bonuses = equipmentBonusesFromSlots(slots);
299 assert.equal(bonuses[SkillId.magic], -2);
300 assert.equal(bonuses[SkillId.archery], -2);
301 assert.equal(bonuses[SkillId.defence], tierStatBonus(MaterialTier.iron));
302 });
303
304 test("full helm keeps +1 defence only, not magic or archery penalty", () =>
305 {
306 const defaults = defaultEquipmentStatBonuses().metalArmour.fullHelm;
307 assert.equal(defaults.bronze.defence, tierStatBonus(MaterialTier.bronze) + 1);
308 assert.equal(defaults.bronze.magic, -1);
309 assert.equal(defaults.bronze.archery, -1);
310 });
311
312 test("wizard robe bottoms use single cloth tint", () =>
313 {
314 const def = itemDefinition(WizardItemId.cottonRobeBottoms);
315 assert.equal(def?.tintFromTier, true);
316 assert.equal(def?.dualTintFromTier, undefined);
317 assert.equal(resolveItemDualTint({ itemId: WizardItemId.cottonRobeBottoms }, def), null);
318 });
@@ -3,8 +3,10 @@ import assert from "node:assert/strict";
3import { ItemId, itemDefinition } from "../../shared/definitions/items.js";
3import { ItemId, itemDefinition } from "../../shared/definitions/items.js";
4import { ArmourItemId } from "../../shared/definitions/armourItems.js";
4import { ArmourItemId } from "../../shared/definitions/armourItems.js";
5import { LeatherItemId } from "../../shared/definitions/leatherItems.js";
5import { LeatherItemId } from "../../shared/definitions/leatherItems.js";
6import { LeatherArmourItemId } from "../../shared/definitions/leatherArmourItems.js";
7import { WizardItemId } from "../../shared/definitions/wizardItems.js";
6import { CraftingItemId } from "../../shared/definitions/craftingItems.js";
8import { CraftingItemId } from "../../shared/definitions/craftingItems.js";
7import { MaterialTier, LeatherTier, WoodTier, tierStatBonus, tierMinSkillLevel } from "../../shared/definitions/materialTiers.js";
9import { MaterialTier, LeatherTier, WoodTier, ClothTier, tierStatBonus, tierMinSkillLevel } from "../../shared/definitions/materialTiers.js";
8import { EquipmentKind } from "../../shared/definitions/equipmentKinds.js";
10import { EquipmentKind } from "../../shared/definitions/equipmentKinds.js";
9import { SkillId } from "../../shared/definitions/skills.js";
11import { SkillId } from "../../shared/definitions/skills.js";
10import { normalizePlayerSkills } from "../../shared/skills/state.js";
12import { normalizePlayerSkills } from "../../shared/skills/state.js";
@@ -186,11 +188,16 @@ test("normalizeEquipmentStatBonuses fills defaults and clamps", () =>
186 const defaults = defaultEquipmentStatBonuses();
188 const defaults = defaultEquipmentStatBonuses();
187 const normalized = normalizeEquipmentStatBonuses({
189 const normalized = normalizeEquipmentStatBonuses({
188 metalArmour: {
190 metalArmour: {
189 chestplate: { bronze: { defence: -3 } }
191 chestplate: {
192 bronze: { defence: -3, magic: -150 },
193 iron: { defence: 999 }
194 }
190 },
195 },
191 unknownCategory: { x: 1 }
196 unknownCategory: { x: 1 }
192 });
197 });
193 assert.equal(normalized.metalArmour.chestplate.bronze.defence, 0);
198 assert.equal(normalized.metalArmour.chestplate.bronze.defence, -3);
199 assert.equal(normalized.metalArmour.chestplate.bronze.magic, -99);
200 assert.equal(normalized.metalArmour.chestplate.iron.defence, 99);
194 assert.equal(normalized.metalArmour.greaves.bronze.defence, defaults.metalArmour.greaves.bronze.defence);
201 assert.equal(normalized.metalArmour.greaves.bronze.defence, defaults.metalArmour.greaves.bronze.defence);
195 assert.equal(normalized.unknownCategory, undefined);
202 assert.equal(normalized.unknownCategory, undefined);
196});
203});
@@ -216,3 +223,96 @@ test("bonusForEquippedItem returns null for tools", () =>
216{
223{
217 assert.equal(bonusForEquippedItem(itemDefinition(CraftingItemId.bronzePickaxe)), null);
224 assert.equal(bonusForEquippedItem(itemDefinition(CraftingItemId.bronzePickaxe)), null);
218});
225});
226
227test("leather armour uses leather-cloth dual tint", () =>
228{
229 const def = itemDefinition(LeatherArmourItemId.softLeatherChestguard);
230 assert.equal(def?.equipment?.kind, EquipmentKind.leatherArmour);
231 assert.equal(def?.dualTintLeatherCloth, true);
232 assert.equal(def?.leatherTier, LeatherTier.softLeather);
233 assert.equal(def?.clothTier, "cotton");
234 const dual = resolveItemDualTint({ itemId: LeatherArmourItemId.softLeatherChestguard }, def);
235 assert.ok(dual?.shaft);
236 assert.ok(dual?.tip);
237});
238
239test("wizard robe top grants magic bonus for cloth tier", () =>
240{
241 const defaults = defaultEquipmentStatBonuses().wizardArmour.robetop;
242 assert.equal(defaults.cotton.magic, tierStatBonus(ClothTier.cotton));
243 assert.equal(defaults.cotton.defence, undefined);
244 const slots = {
245 ...emptyEquipment().slots,
246 chest: { itemId: WizardItemId.cottonRobeTop, quantity: 1 }
247 };
248 const bonuses = equipmentBonusesFromSlots(slots);
249 assert.equal(bonuses[SkillId.magic], tierStatBonus(ClothTier.cotton));
250 assert.equal(bonuses[SkillId.defence], 0);
251});
252
253test("leather chestguard grants full agility and half defence", () =>
254{
255 const defaults = defaultEquipmentStatBonuses().leatherArmour.chestguard;
256 assert.equal(defaults.softLeather.agility, tierStatBonus(LeatherTier.softLeather));
257 assert.equal(defaults.softLeather.defence, Math.floor(tierStatBonus(LeatherTier.softLeather) / 2));
258 const slots = {
259 ...emptyEquipment().slots,
260 chest: { itemId: LeatherArmourItemId.softLeatherChestguard, quantity: 1 }
261 };
262 const bonuses = equipmentBonusesFromSlots(slots);
263 assert.equal(bonuses[SkillId.agility], tierStatBonus(LeatherTier.softLeather));
264 assert.equal(bonuses[SkillId.defence], Math.floor(tierStatBonus(LeatherTier.softLeather) / 2));
265});
266
267test("metal armour grants quarter-tier strength and agility rounded up", () =>
268{
269 const defaults = defaultEquipmentStatBonuses().metalArmour.chestplate;
270 assert.equal(defaults.bronze.strength, 1);
271 assert.equal(defaults.bronze.agility, 1);
272 assert.equal(defaults.iron.strength, 1);
273 assert.equal(defaults.steel.strength, 1);
274 assert.equal(defaults.mithril.strength, 2);
275 assert.equal(defaults.dragon.strength, 3);
276 const slots = {
277 ...emptyEquipment().slots,
278 chest: { itemId: ArmourItemId.steelChestplate, quantity: 1 }
279 };
280 const bonuses = equipmentBonusesFromSlots(slots);
281 assert.equal(bonuses[SkillId.strength], 1);
282 assert.equal(bonuses[SkillId.agility], 1);
283});
284
285test("metal armour penalizes magic and archery by material rank", () =>
286{
287 const defaults = defaultEquipmentStatBonuses().metalArmour.chestplate;
288 assert.equal(defaults.bronze.defence, tierStatBonus(MaterialTier.bronze));
289 assert.equal(defaults.bronze.magic, -1);
290 assert.equal(defaults.bronze.archery, -1);
291 assert.equal(defaults.dragon.defence, tierStatBonus(MaterialTier.dragon));
292 assert.equal(defaults.dragon.magic, -7);
293 assert.equal(defaults.dragon.archery, -7);
294 const slots = {
295 ...emptyEquipment().slots,
296 chest: { itemId: ArmourItemId.ironChestplate, quantity: 1 }
297 };
298 const bonuses = equipmentBonusesFromSlots(slots);
299 assert.equal(bonuses[SkillId.magic], -2);
300 assert.equal(bonuses[SkillId.archery], -2);
301 assert.equal(bonuses[SkillId.defence], tierStatBonus(MaterialTier.iron));
302});
303
304test("full helm keeps +1 defence only, not magic or archery penalty", () =>
305{
306 const defaults = defaultEquipmentStatBonuses().metalArmour.fullHelm;
307 assert.equal(defaults.bronze.defence, tierStatBonus(MaterialTier.bronze) + 1);
308 assert.equal(defaults.bronze.magic, -1);
309 assert.equal(defaults.bronze.archery, -1);
310});
311
312test("wizard robe bottoms use single cloth tint", () =>
313{
314 const def = itemDefinition(WizardItemId.cottonRobeBottoms);
315 assert.equal(def?.tintFromTier, true);
316 assert.equal(def?.dualTintFromTier, undefined);
317 assert.equal(resolveItemDualTint({ itemId: WizardItemId.cottonRobeBottoms }, def), null);
318});
server/tests/item-ids.test.js +4 −0
@@ -3,6 +3,8 @@ import assert from "node:assert/strict";
3 3 import { ITEM_DEFINITIONS, listAllItemPickerEntries } from "../../shared/definitions/items.js";
4 4 import { CRAFTING_ITEM_STUBS } from "../../shared/definitions/craftingItems.js";
5 5 import { LEATHER_ITEM_DEFINITIONS } from "../../shared/definitions/leatherItems.js";
6 import { LEATHER_ARMOUR_ITEM_DEFINITIONS } from "../../shared/definitions/leatherArmourItems.js";
7 import { WIZARD_ITEM_DEFINITIONS } from "../../shared/definitions/wizardItems.js";
6 8 import { METAL_ITEM_DEFINITIONS } from "../../shared/definitions/metalItems.js";
7 9 import { WOOD_ITEM_DEFINITIONS } from "../../shared/definitions/woodItems.js";
8 10 import { ARMOUR_ITEM_DEFINITIONS } from "../../shared/definitions/armourItems.js";
@@ -29,6 +31,8 @@ const ITEM_DEFINITION_SOURCES = Object.freeze([
29 31 ["core", Object.fromEntries(CORE_ITEM_IDS.map((id) => [id, ITEM_DEFINITIONS[id]]))],
30 32 ["crafting", CRAFTING_ITEM_STUBS],
31 33 ["leather", LEATHER_ITEM_DEFINITIONS],
34 ["leatherArmour", LEATHER_ARMOUR_ITEM_DEFINITIONS],
35 ["wizard", WIZARD_ITEM_DEFINITIONS],
32 36 ["metal", METAL_ITEM_DEFINITIONS],
33 37 ["wood", WOOD_ITEM_DEFINITIONS],
34 38 ["armour", ARMOUR_ITEM_DEFINITIONS],
@@ -3,6 +3,8 @@ import assert from "node:assert/strict";
3import { ITEM_DEFINITIONS, listAllItemPickerEntries } from "../../shared/definitions/items.js";
3import { ITEM_DEFINITIONS, listAllItemPickerEntries } from "../../shared/definitions/items.js";
4import { CRAFTING_ITEM_STUBS } from "../../shared/definitions/craftingItems.js";
4import { CRAFTING_ITEM_STUBS } from "../../shared/definitions/craftingItems.js";
5import { LEATHER_ITEM_DEFINITIONS } from "../../shared/definitions/leatherItems.js";
5import { LEATHER_ITEM_DEFINITIONS } from "../../shared/definitions/leatherItems.js";
6import { LEATHER_ARMOUR_ITEM_DEFINITIONS } from "../../shared/definitions/leatherArmourItems.js";
7import { WIZARD_ITEM_DEFINITIONS } from "../../shared/definitions/wizardItems.js";
6import { METAL_ITEM_DEFINITIONS } from "../../shared/definitions/metalItems.js";
8import { METAL_ITEM_DEFINITIONS } from "../../shared/definitions/metalItems.js";
7import { WOOD_ITEM_DEFINITIONS } from "../../shared/definitions/woodItems.js";
9import { WOOD_ITEM_DEFINITIONS } from "../../shared/definitions/woodItems.js";
8import { ARMOUR_ITEM_DEFINITIONS } from "../../shared/definitions/armourItems.js";
10import { ARMOUR_ITEM_DEFINITIONS } from "../../shared/definitions/armourItems.js";
@@ -29,6 +31,8 @@ const ITEM_DEFINITION_SOURCES = Object.freeze([
29 ["core", Object.fromEntries(CORE_ITEM_IDS.map((id) => [id, ITEM_DEFINITIONS[id]]))],
31 ["core", Object.fromEntries(CORE_ITEM_IDS.map((id) => [id, ITEM_DEFINITIONS[id]]))],
30 ["crafting", CRAFTING_ITEM_STUBS],
32 ["crafting", CRAFTING_ITEM_STUBS],
31 ["leather", LEATHER_ITEM_DEFINITIONS],
33 ["leather", LEATHER_ITEM_DEFINITIONS],
34 ["leatherArmour", LEATHER_ARMOUR_ITEM_DEFINITIONS],
35 ["wizard", WIZARD_ITEM_DEFINITIONS],
32 ["metal", METAL_ITEM_DEFINITIONS],
36 ["metal", METAL_ITEM_DEFINITIONS],
33 ["wood", WOOD_ITEM_DEFINITIONS],
37 ["wood", WOOD_ITEM_DEFINITIONS],
34 ["armour", ARMOUR_ITEM_DEFINITIONS],
38 ["armour", ARMOUR_ITEM_DEFINITIONS],
shared/crafting/stationRecipes.js +21 −9
@@ -4,6 +4,7 @@ import { CraftingItemId } from "../definitions/craftingItems.js";
4 4 import { MetalItemId } from "../definitions/metalItems.js";
5 5 import { LeatherItemId } from "../definitions/leatherItems.js";
6 6 import { ClothItemId, wovenClothItemId, rawClothItemId, yarnItemId, CLOTHING_TEMPLATES } from "../definitions/clothItems.js";
7 import { WIZARD_TEMPLATES } from "../definitions/wizardItems.js";
7 8 import
8 9 {
9 10 MaterialTier,
@@ -77,15 +78,26 @@ const YARN_SPIN_RECIPES = CLOTH_TIER_ORDER.map((tier) => yarnSpinRecipe(tier));
77 78 const CLOTH_WEAVE_RECIPES = CLOTH_TIER_ORDER.map((tier) => clothWeaveRecipe(tier));
78 79
79 80 /** Tailor templates — client picks material; server resolves inputs/output. */
80 const TAILOR_TEMPLATE_RECIPES = Object.values(CLOTHING_TEMPLATES).map((template) => Object.freeze({
81 recipeId: `tailor-${template.templateId}`,
82 stationId: CraftingStationId.tailorBench,
83 tailorTemplate: template.templateId,
84 output: { itemId: template.outputItemIdForTier(CLOTH_TIER_ORDER[0]), quantity: 1 },
85 inputs: [],
86 minSkillLevel: template.minSkillLevel ?? 1,
87 skillId: "tailoring"
88 }));
81 const TAILOR_TEMPLATE_RECIPES = Object.freeze([
82 ...Object.values(CLOTHING_TEMPLATES).map((template) => Object.freeze({
83 recipeId: `tailor-${template.templateId}`,
84 stationId: CraftingStationId.tailorBench,
85 tailorTemplate: template.templateId,
86 output: { itemId: template.outputItemIdForTier(CLOTH_TIER_ORDER[0]), quantity: 1 },
87 inputs: [],
88 minSkillLevel: template.minSkillLevel ?? 1,
89 skillId: "tailoring"
90 })),
91 ...Object.values(WIZARD_TEMPLATES).map((template) => Object.freeze({
92 recipeId: template.templateId,
93 stationId: CraftingStationId.tailorBench,
94 tailorTemplate: template.templateId,
95 output: { itemId: template.outputItemIdForTier(CLOTH_TIER_ORDER[0]), quantity: 1 },
96 inputs: [],
97 minSkillLevel: template.minSkillLevel ?? 1,
98 skillId: "tailoring"
99 }))
100 ]);
89 101
90 102 /** @type {ReadonlyArray<object>} */
91 103 export const CRAFT_RECIPES = Object.freeze([
@@ -4,6 +4,7 @@ import { CraftingItemId } from "../definitions/craftingItems.js";
4import { MetalItemId } from "../definitions/metalItems.js";
4import { MetalItemId } from "../definitions/metalItems.js";
5import { LeatherItemId } from "../definitions/leatherItems.js";
5import { LeatherItemId } from "../definitions/leatherItems.js";
6import { ClothItemId, wovenClothItemId, rawClothItemId, yarnItemId, CLOTHING_TEMPLATES } from "../definitions/clothItems.js";
6import { ClothItemId, wovenClothItemId, rawClothItemId, yarnItemId, CLOTHING_TEMPLATES } from "../definitions/clothItems.js";
7import { WIZARD_TEMPLATES } from "../definitions/wizardItems.js";
7import
8import
8 {
9 {
9 MaterialTier,
10 MaterialTier,
@@ -77,15 +78,26 @@ const YARN_SPIN_RECIPES = CLOTH_TIER_ORDER.map((tier) => yarnSpinRecipe(tier));
77const CLOTH_WEAVE_RECIPES = CLOTH_TIER_ORDER.map((tier) => clothWeaveRecipe(tier));
78const CLOTH_WEAVE_RECIPES = CLOTH_TIER_ORDER.map((tier) => clothWeaveRecipe(tier));
78
79
79/** Tailor templates — client picks material; server resolves inputs/output. */
80/** Tailor templates — client picks material; server resolves inputs/output. */
80const TAILOR_TEMPLATE_RECIPES = Object.values(CLOTHING_TEMPLATES).map((template) => Object.freeze({
81const TAILOR_TEMPLATE_RECIPES = Object.freeze([
81 recipeId: `tailor-${template.templateId}`,
82 ...Object.values(CLOTHING_TEMPLATES).map((template) => Object.freeze({
82 stationId: CraftingStationId.tailorBench,
83 recipeId: `tailor-${template.templateId}`,
83 tailorTemplate: template.templateId,
84 stationId: CraftingStationId.tailorBench,
84 output: { itemId: template.outputItemIdForTier(CLOTH_TIER_ORDER[0]), quantity: 1 },
85 tailorTemplate: template.templateId,
85 inputs: [],
86 output: { itemId: template.outputItemIdForTier(CLOTH_TIER_ORDER[0]), quantity: 1 },
86 minSkillLevel: template.minSkillLevel ?? 1,
87 inputs: [],
87 skillId: "tailoring"
88 minSkillLevel: template.minSkillLevel ?? 1,
88}));
89 skillId: "tailoring"
90 })),
91 ...Object.values(WIZARD_TEMPLATES).map((template) => Object.freeze({
92 recipeId: template.templateId,
93 stationId: CraftingStationId.tailorBench,
94 tailorTemplate: template.templateId,
95 output: { itemId: template.outputItemIdForTier(CLOTH_TIER_ORDER[0]), quantity: 1 },
96 inputs: [],
97 minSkillLevel: template.minSkillLevel ?? 1,
98 skillId: "tailoring"
99 }))
100]);
89
101
90/** @type {ReadonlyArray<object>} */
102/** @type {ReadonlyArray<object>} */
91export const CRAFT_RECIPES = Object.freeze([
103export const CRAFT_RECIPES = Object.freeze([
shared/crafting/tailor.js +13 −3
@@ -1,5 +1,7 @@
1 1 import { clothingTemplate, yarnItemId, wovenClothItemId } from "../definitions/clothItems.js";
2 import { CLOTH_TIER_ORDER, ClothTier, tierCraftSkillLevel } from "../definitions/materialTiers.js";
2 import { wizardTemplate } from "../definitions/wizardItems.js";
3 import { leatherMaterialItemId } from "../definitions/leatherItems.js";
4 import { CLOTH_TIER_ORDER, ClothTier, tierCraftSkillLevel, leatherTierForCloth } from "../definitions/materialTiers.js";
3 5 import { ItemId } from "../definitions/items.js";
4 6
5 7 /**
@@ -8,9 +10,10 @@ import { ItemId } from "../definitions/items.js";
8 10 */
9 11 export function resolveTailorCraft ({ templateId, clothTier, dyeStack = null })
10 12 {
11 const template = clothingTemplate(templateId);
13 const template = clothingTemplate(templateId) ?? wizardTemplate(templateId);
12 14 if (!template)
13 15 { return { ok: false, reason: "Unknown garment template." }; }
16 const isWizardGarment = wizardTemplate(templateId) != null;
14 17 const tier = CLOTH_TIER_ORDER.includes(clothTier) ? clothTier : ClothTier.cotton;
15 18 const outputItemId = template.outputItemIdForTier(tier);
16 19 if (!outputItemId)
@@ -24,12 +27,19 @@ export function resolveTailorCraft ({ templateId, clothTier, dyeStack = null })
24 27 { inputs.push({ itemId: yarnItemId(tier), quantity }); }
25 28 else if (need.kind === "cloth")
26 29 { inputs.push({ itemId: wovenClothItemId(tier), quantity }); }
30 else if (need.kind === "leather")
31 {
32 const leatherId = leatherMaterialItemId(leatherTierForCloth(tier));
33 if (leatherId == null)
34 { return { ok: false, reason: "That material cannot make this garment." }; }
35 inputs.push({ itemId: leatherId, quantity });
36 }
27 37 else
28 38 { return { ok: false, reason: "Unsupported tailor ingredient." }; }
29 39 }
30 40
31 41 let dyeColor = null;
32 if (dyeStack)
42 if (dyeStack && !isWizardGarment)
33 43 {
34 44 if (dyeStack.itemId !== ItemId.dye || dyeStack.instance?.kind !== "dye")
35 45 { return { ok: false, reason: "That is not a dye." }; }
@@ -1,5 +1,7 @@
1import { clothingTemplate, yarnItemId, wovenClothItemId } from "../definitions/clothItems.js";
1import { clothingTemplate, yarnItemId, wovenClothItemId } from "../definitions/clothItems.js";
2import { CLOTH_TIER_ORDER, ClothTier, tierCraftSkillLevel } from "../definitions/materialTiers.js";
2import { wizardTemplate } from "../definitions/wizardItems.js";
3import { leatherMaterialItemId } from "../definitions/leatherItems.js";
4import { CLOTH_TIER_ORDER, ClothTier, tierCraftSkillLevel, leatherTierForCloth } from "../definitions/materialTiers.js";
3import { ItemId } from "../definitions/items.js";
5import { ItemId } from "../definitions/items.js";
4
6
5/**
7/**
@@ -8,9 +10,10 @@ import { ItemId } from "../definitions/items.js";
8 */
10 */
9export function resolveTailorCraft ({ templateId, clothTier, dyeStack = null })
11export function resolveTailorCraft ({ templateId, clothTier, dyeStack = null })
10{
12{
11 const template = clothingTemplate(templateId);
13 const template = clothingTemplate(templateId) ?? wizardTemplate(templateId);
12 if (!template)
14 if (!template)
13 { return { ok: false, reason: "Unknown garment template." }; }
15 { return { ok: false, reason: "Unknown garment template." }; }
16 const isWizardGarment = wizardTemplate(templateId) != null;
14 const tier = CLOTH_TIER_ORDER.includes(clothTier) ? clothTier : ClothTier.cotton;
17 const tier = CLOTH_TIER_ORDER.includes(clothTier) ? clothTier : ClothTier.cotton;
15 const outputItemId = template.outputItemIdForTier(tier);
18 const outputItemId = template.outputItemIdForTier(tier);
16 if (!outputItemId)
19 if (!outputItemId)
@@ -24,12 +27,19 @@ export function resolveTailorCraft ({ templateId, clothTier, dyeStack = null })
24 { inputs.push({ itemId: yarnItemId(tier), quantity }); }
27 { inputs.push({ itemId: yarnItemId(tier), quantity }); }
25 else if (need.kind === "cloth")
28 else if (need.kind === "cloth")
26 { inputs.push({ itemId: wovenClothItemId(tier), quantity }); }
29 { inputs.push({ itemId: wovenClothItemId(tier), quantity }); }
30 else if (need.kind === "leather")
31 {
32 const leatherId = leatherMaterialItemId(leatherTierForCloth(tier));
33 if (leatherId == null)
34 { return { ok: false, reason: "That material cannot make this garment." }; }
35 inputs.push({ itemId: leatherId, quantity });
36 }
27 else
37 else
28 { return { ok: false, reason: "Unsupported tailor ingredient." }; }
38 { return { ok: false, reason: "Unsupported tailor ingredient." }; }
29 }
39 }
30
40
31 let dyeColor = null;
41 let dyeColor = null;
32 if (dyeStack)
42 if (dyeStack && !isWizardGarment)
33 {
43 {
34 if (dyeStack.itemId !== ItemId.dye || dyeStack.instance?.kind !== "dye")
44 if (dyeStack.itemId !== ItemId.dye || dyeStack.instance?.kind !== "dye")
35 { return { ok: false, reason: "That is not a dye." }; }
45 { return { ok: false, reason: "That is not a dye." }; }
shared/crafting/tierRecipes.js +3 −1
@@ -27,6 +27,7 @@ import
27 27 import { RangedItemId } from "../definitions/rangedItems.js";
28 28 import { yarnItemId } from "../definitions/clothItems.js";
29 29 import { leatherMaterialItemId, leatherShoesItemId } from "../definitions/leatherItems.js";
30 import { leatherArmourRecipes } from "../definitions/leatherArmourItems.js";
30 31
31 32 /**
32 33 * Tier-scaled craft recipes generated from {@link ItemFamilyId} templates.
@@ -499,5 +500,6 @@ export const TIER_FAMILY_RECIPES = Object.freeze([
499 500 ...bowstringRecipes(),
500 501 ...bowAssembleRecipes(),
501 502 ...armourRecipes(),
502 ...leatherShoesRecipes()
503 ...leatherShoesRecipes(),
504 ...leatherArmourRecipes()
503 505 ]);
@@ -27,6 +27,7 @@ import
27import { RangedItemId } from "../definitions/rangedItems.js";
27import { RangedItemId } from "../definitions/rangedItems.js";
28import { yarnItemId } from "../definitions/clothItems.js";
28import { yarnItemId } from "../definitions/clothItems.js";
29import { leatherMaterialItemId, leatherShoesItemId } from "../definitions/leatherItems.js";
29import { leatherMaterialItemId, leatherShoesItemId } from "../definitions/leatherItems.js";
30import { leatherArmourRecipes } from "../definitions/leatherArmourItems.js";
30
31
31/**
32/**
32 * Tier-scaled craft recipes generated from {@link ItemFamilyId} templates.
33 * Tier-scaled craft recipes generated from {@link ItemFamilyId} templates.
@@ -499,5 +500,6 @@ export const TIER_FAMILY_RECIPES = Object.freeze([
499 ...bowstringRecipes(),
500 ...bowstringRecipes(),
500 ...bowAssembleRecipes(),
501 ...bowAssembleRecipes(),
501 ...armourRecipes(),
502 ...armourRecipes(),
502 ...leatherShoesRecipes()
503 ...leatherShoesRecipes(),
504 ...leatherArmourRecipes()
503]);
505]);
shared/definitions/equipmentStatCategories.js +69 −6
@@ -16,6 +16,14 @@ import
16 16 import { ARMOUR_CRAFT_PIECES, armourItemIdForTier } from "./armourItems.js";
17 17 import { sweaterItemId, shirtItemId, shortsItemId, skirtItemId, trousersItemId } from "./clothItems.js";
18 18 import { leatherShoesItemId } from "./leatherItems.js";
19 import { LEATHER_ARMOUR_PIECES, leatherArmourItemIdForTier } from "./leatherArmourItems.js";
20 import
21 {
22 wizardHatItemId,
23 wizardRobeTopItemId,
24 wizardRobeBottomsItemId,
25 wizardShoesItemId
26 } from "./wizardItems.js";
19 27 import { ItemId, itemDefinition, ITEM_DEFINITIONS } from "./items.js";
20 28 import { quarterstaffItemIdForWood } from "./woodItems.js";
21 29 import { swordItemIdForMetal } from "./swordItems.js";
@@ -85,7 +93,13 @@ export const EQUIPMENT_STAT_CATEGORIES = Object.freeze([
85 93 Object.freeze({
86 94 id: EquipmentStatCategoryId.metalArmour,
87 95 label: "Metal armour",
88 stats: Object.freeze([SkillId.defence]),
96 stats: Object.freeze([
97 SkillId.defence,
98 SkillId.strength,
99 SkillId.agility,
100 SkillId.magic,
101 SkillId.archery
102 ]),
89 103 sections: Object.freeze([
90 104 Object.freeze({
91 105 id: "metal",
@@ -97,6 +111,13 @@ export const EQUIPMENT_STAT_CATEGORIES = Object.freeze([
97 111 : piece.suffix,
98 112 label: piece.label.charAt(0).toUpperCase() + piece.label.slice(1),
99 113 defaultBonusExtra: piece.fullHelm ? 1 : 0,
114 defaultBonusByStat: Object.freeze({
115 [SkillId.defence]: "tier",
116 [SkillId.strength]: "tierQuarterCeil",
117 [SkillId.agility]: "tierQuarterCeil",
118 [SkillId.magic]: "negativeRank",
119 [SkillId.archery]: "negativeRank"
120 }),
100 121 resolveItemId: (tier) => armourItemIdForTier(tier, piece.idKey)
101 122 })))
102 123 })
@@ -115,13 +136,21 @@ export const EQUIPMENT_STAT_CATEGORIES = Object.freeze([
115 136 Object.freeze({
116 137 pieceKey: "shoes",
117 138 label: "Leather shoes",
118 /** Full agility; defence is half the matching metal tier (floored). */
119 139 defaultBonusByStat: Object.freeze({
120 140 [SkillId.agility]: "tier",
121 141 [SkillId.defence]: "tierHalf"
122 142 }),
123 143 resolveItemId: (tier) => leatherShoesItemId(tier)
124 })
144 }),
145 ...LEATHER_ARMOUR_PIECES.map((piece) => Object.freeze({
146 pieceKey: piece.pieceKey,
147 label: piece.label.charAt(0).toUpperCase() + piece.label.slice(1),
148 defaultBonusByStat: Object.freeze({
149 [SkillId.agility]: "tier",
150 [SkillId.defence]: "tierHalf"
151 }),
152 resolveItemId: (tier) => leatherArmourItemIdForTier(tier, piece.idKey)
153 }))
125 154 ])
126 155 })
127 156 ])
@@ -239,13 +268,38 @@ export const EQUIPMENT_STAT_CATEGORIES = Object.freeze([
239 268 Object.freeze({
240 269 id: EquipmentStatCategoryId.wizardArmour,
241 270 label: "Wizard armour",
242 stats: Object.freeze([SkillId.magic, SkillId.defence]),
271 stats: Object.freeze([SkillId.magic]),
243 272 sections: Object.freeze([
244 273 Object.freeze({
245 274 id: "cloth",
246 275 tierOrder: CLOTH_TIER_ORDER,
247 276 tierDisplayName: (tier) => CLOTH_DISPLAY_NAME[tier] ?? tier,
248 rows: Object.freeze([])
277 rows: Object.freeze([
278 Object.freeze({
279 pieceKey: "hat",
280 label: "Hat",
281 defaultBonusByStat: Object.freeze({ [SkillId.magic]: "tier" }),
282 resolveItemId: (tier) => wizardHatItemId(tier)
283 }),
284 Object.freeze({
285 pieceKey: "robetop",
286 label: "Robe top",
287 defaultBonusByStat: Object.freeze({ [SkillId.magic]: "tier" }),
288 resolveItemId: (tier) => wizardRobeTopItemId(tier)
289 }),
290 Object.freeze({
291 pieceKey: "robebottoms",
292 label: "Robe bottoms",
293 defaultBonusByStat: Object.freeze({ [SkillId.magic]: "tier" }),
294 resolveItemId: (tier) => wizardRobeBottomsItemId(tier)
295 }),
296 Object.freeze({
297 pieceKey: "shoes",
298 label: "Shoes",
299 defaultBonusByStat: Object.freeze({ [SkillId.magic]: "tier" }),
300 resolveItemId: (tier) => wizardShoesItemId(tier)
301 })
302 ])
249 303 })
250 304 ])
251 305 }),
@@ -411,6 +465,8 @@ function resolveDefaultBonusMode (mode, tier, row)
411 465 const extra = Number(row.defaultBonusExtra) || 0;
412 466 if (mode === "rank")
413 467 { return Math.max(0, Math.floor(tierRank(key) + extra)); }
468 if (mode === "negativeRank")
469 { return -Math.max(0, Math.floor(tierRank(key))); }
414 470 if (mode === "tierHalf")
415 471 {
416 472 const base = row.defaultBonus != null
@@ -418,6 +474,13 @@ function resolveDefaultBonusMode (mode, tier, row)
418 474 : tierStatBonus(key);
419 475 return Math.max(0, Math.floor(base / 2) + extra);
420 476 }
477 if (mode === "tierQuarterCeil")
478 {
479 const base = row.defaultBonus != null
480 ? Number(row.defaultBonus) || 0
481 : tierStatBonus(key);
482 return Math.max(0, Math.ceil(base / 4));
483 }
421 484 if (mode === "tier" || mode == null)
422 485 {
423 486 const base = row.defaultBonus != null
@@ -487,7 +550,7 @@ function coerceBonusInt (raw)
487 550 const n = Math.floor(Number(raw));
488 551 if (!Number.isFinite(n))
489 552 { return 0; }
490 return Math.max(0, Math.min(99, n));
553 return Math.max(-99, Math.min(99, n));
491 554 }
492 555
493 556 /**
@@ -16,6 +16,14 @@ import
16import { ARMOUR_CRAFT_PIECES, armourItemIdForTier } from "./armourItems.js";
16import { ARMOUR_CRAFT_PIECES, armourItemIdForTier } from "./armourItems.js";
17import { sweaterItemId, shirtItemId, shortsItemId, skirtItemId, trousersItemId } from "./clothItems.js";
17import { sweaterItemId, shirtItemId, shortsItemId, skirtItemId, trousersItemId } from "./clothItems.js";
18import { leatherShoesItemId } from "./leatherItems.js";
18import { leatherShoesItemId } from "./leatherItems.js";
19import { LEATHER_ARMOUR_PIECES, leatherArmourItemIdForTier } from "./leatherArmourItems.js";
20import
21{
22 wizardHatItemId,
23 wizardRobeTopItemId,
24 wizardRobeBottomsItemId,
25 wizardShoesItemId
26} from "./wizardItems.js";
19import { ItemId, itemDefinition, ITEM_DEFINITIONS } from "./items.js";
27import { ItemId, itemDefinition, ITEM_DEFINITIONS } from "./items.js";
20import { quarterstaffItemIdForWood } from "./woodItems.js";
28import { quarterstaffItemIdForWood } from "./woodItems.js";
21import { swordItemIdForMetal } from "./swordItems.js";
29import { swordItemIdForMetal } from "./swordItems.js";
@@ -85,7 +93,13 @@ export const EQUIPMENT_STAT_CATEGORIES = Object.freeze([
85 Object.freeze({
93 Object.freeze({
86 id: EquipmentStatCategoryId.metalArmour,
94 id: EquipmentStatCategoryId.metalArmour,
87 label: "Metal armour",
95 label: "Metal armour",
88 stats: Object.freeze([SkillId.defence]),
96 stats: Object.freeze([
97 SkillId.defence,
98 SkillId.strength,
99 SkillId.agility,
100 SkillId.magic,
101 SkillId.archery
102 ]),
89 sections: Object.freeze([
103 sections: Object.freeze([
90 Object.freeze({
104 Object.freeze({
91 id: "metal",
105 id: "metal",
@@ -97,6 +111,13 @@ export const EQUIPMENT_STAT_CATEGORIES = Object.freeze([
97 : piece.suffix,
111 : piece.suffix,
98 label: piece.label.charAt(0).toUpperCase() + piece.label.slice(1),
112 label: piece.label.charAt(0).toUpperCase() + piece.label.slice(1),
99 defaultBonusExtra: piece.fullHelm ? 1 : 0,
113 defaultBonusExtra: piece.fullHelm ? 1 : 0,
114 defaultBonusByStat: Object.freeze({
115 [SkillId.defence]: "tier",
116 [SkillId.strength]: "tierQuarterCeil",
117 [SkillId.agility]: "tierQuarterCeil",
118 [SkillId.magic]: "negativeRank",
119 [SkillId.archery]: "negativeRank"
120 }),
100 resolveItemId: (tier) => armourItemIdForTier(tier, piece.idKey)
121 resolveItemId: (tier) => armourItemIdForTier(tier, piece.idKey)
101 })))
122 })))
102 })
123 })
@@ -115,13 +136,21 @@ export const EQUIPMENT_STAT_CATEGORIES = Object.freeze([
115 Object.freeze({
136 Object.freeze({
116 pieceKey: "shoes",
137 pieceKey: "shoes",
117 label: "Leather shoes",
138 label: "Leather shoes",
118 /** Full agility; defence is half the matching metal tier (floored). */
119 defaultBonusByStat: Object.freeze({
139 defaultBonusByStat: Object.freeze({
120 [SkillId.agility]: "tier",
140 [SkillId.agility]: "tier",
121 [SkillId.defence]: "tierHalf"
141 [SkillId.defence]: "tierHalf"
122 }),
142 }),
123 resolveItemId: (tier) => leatherShoesItemId(tier)
143 resolveItemId: (tier) => leatherShoesItemId(tier)
124 })
144 }),
145 ...LEATHER_ARMOUR_PIECES.map((piece) => Object.freeze({
146 pieceKey: piece.pieceKey,
147 label: piece.label.charAt(0).toUpperCase() + piece.label.slice(1),
148 defaultBonusByStat: Object.freeze({
149 [SkillId.agility]: "tier",
150 [SkillId.defence]: "tierHalf"
151 }),
152 resolveItemId: (tier) => leatherArmourItemIdForTier(tier, piece.idKey)
153 }))
125 ])
154 ])
126 })
155 })
127 ])
156 ])
@@ -239,13 +268,38 @@ export const EQUIPMENT_STAT_CATEGORIES = Object.freeze([
239 Object.freeze({
268 Object.freeze({
240 id: EquipmentStatCategoryId.wizardArmour,
269 id: EquipmentStatCategoryId.wizardArmour,
241 label: "Wizard armour",
270 label: "Wizard armour",
242 stats: Object.freeze([SkillId.magic, SkillId.defence]),
271 stats: Object.freeze([SkillId.magic]),
243 sections: Object.freeze([
272 sections: Object.freeze([
244 Object.freeze({
273 Object.freeze({
245 id: "cloth",
274 id: "cloth",
246 tierOrder: CLOTH_TIER_ORDER,
275 tierOrder: CLOTH_TIER_ORDER,
247 tierDisplayName: (tier) => CLOTH_DISPLAY_NAME[tier] ?? tier,
276 tierDisplayName: (tier) => CLOTH_DISPLAY_NAME[tier] ?? tier,
248 rows: Object.freeze([])
277 rows: Object.freeze([
278 Object.freeze({
279 pieceKey: "hat",
280 label: "Hat",
281 defaultBonusByStat: Object.freeze({ [SkillId.magic]: "tier" }),
282 resolveItemId: (tier) => wizardHatItemId(tier)
283 }),
284 Object.freeze({
285 pieceKey: "robetop",
286 label: "Robe top",
287 defaultBonusByStat: Object.freeze({ [SkillId.magic]: "tier" }),
288 resolveItemId: (tier) => wizardRobeTopItemId(tier)
289 }),
290 Object.freeze({
291 pieceKey: "robebottoms",
292 label: "Robe bottoms",
293 defaultBonusByStat: Object.freeze({ [SkillId.magic]: "tier" }),
294 resolveItemId: (tier) => wizardRobeBottomsItemId(tier)
295 }),
296 Object.freeze({
297 pieceKey: "shoes",
298 label: "Shoes",
299 defaultBonusByStat: Object.freeze({ [SkillId.magic]: "tier" }),
300 resolveItemId: (tier) => wizardShoesItemId(tier)
301 })
302 ])
249 })
303 })
250 ])
304 ])
251 }),
305 }),
@@ -411,6 +465,8 @@ function resolveDefaultBonusMode (mode, tier, row)
411 const extra = Number(row.defaultBonusExtra) || 0;
465 const extra = Number(row.defaultBonusExtra) || 0;
412 if (mode === "rank")
466 if (mode === "rank")
413 { return Math.max(0, Math.floor(tierRank(key) + extra)); }
467 { return Math.max(0, Math.floor(tierRank(key) + extra)); }
468 if (mode === "negativeRank")
469 { return -Math.max(0, Math.floor(tierRank(key))); }
414 if (mode === "tierHalf")
470 if (mode === "tierHalf")
415 {
471 {
416 const base = row.defaultBonus != null
472 const base = row.defaultBonus != null
@@ -418,6 +474,13 @@ function resolveDefaultBonusMode (mode, tier, row)
418 : tierStatBonus(key);
474 : tierStatBonus(key);
419 return Math.max(0, Math.floor(base / 2) + extra);
475 return Math.max(0, Math.floor(base / 2) + extra);
420 }
476 }
477 if (mode === "tierQuarterCeil")
478 {
479 const base = row.defaultBonus != null
480 ? Number(row.defaultBonus) || 0
481 : tierStatBonus(key);
482 return Math.max(0, Math.ceil(base / 4));
483 }
421 if (mode === "tier" || mode == null)
484 if (mode === "tier" || mode == null)
422 {
485 {
423 const base = row.defaultBonus != null
486 const base = row.defaultBonus != null
@@ -487,7 +550,7 @@ function coerceBonusInt (raw)
487 const n = Math.floor(Number(raw));
550 const n = Math.floor(Number(raw));
488 if (!Number.isFinite(n))
551 if (!Number.isFinite(n))
489 { return 0; }
552 { return 0; }
490 return Math.max(0, Math.min(99, n));
553 return Math.max(-99, Math.min(99, n));
491}
554}
492
555
493/**
556/**
shared/definitions/items.js +6 −0
@@ -11,6 +11,8 @@ import { WoodItemId, WOOD_ITEM_DEFINITIONS } from "./woodItems.js";
11 11 import { ArmourItemId, ARMOUR_ITEM_DEFINITIONS } from "./armourItems.js";
12 12 import { ClothItemId, CLOTH_ITEM_DEFINITIONS } from "./clothItems.js";
13 13 import { LeatherItemId, LEATHER_ITEM_DEFINITIONS } from "./leatherItems.js";
14 import { LeatherArmourItemId, LEATHER_ARMOUR_ITEM_DEFINITIONS } from "./leatherArmourItems.js";
15 import { WizardItemId, WIZARD_ITEM_DEFINITIONS } from "./wizardItems.js";
14 16 import { DyeItemId, FLOWER_ITEM_DEFINITION, DYE_ITEM_DEFINITION, FLOWER_COLOR_DISPLAY } from "./dyes.js";
15 17 import { HERB_ITEM_DEFINITIONS, HerbItemId } from "./herbs.js";
16 18 import { RANGED_ITEM_DEFINITIONS, RangedItemId } from "./rangedItems.js";
@@ -49,6 +51,8 @@ export const ItemId = Object.freeze({
49 51 ...ArmourItemId,
50 52 ...ClothItemId,
51 53 ...LeatherItemId,
54 ...LeatherArmourItemId,
55 ...WizardItemId,
52 56 ...DyeItemId,
53 57 ...HerbItemId,
54 58 ...RangedItemId,
@@ -308,6 +312,8 @@ export const ITEM_DEFINITIONS = Object.freeze({
308 312 }),
309 313 ...CRAFTING_ITEM_STUBS,
310 314 ...LEATHER_ITEM_DEFINITIONS,
315 ...LEATHER_ARMOUR_ITEM_DEFINITIONS,
316 ...WIZARD_ITEM_DEFINITIONS,
311 317 ...METAL_ITEM_DEFINITIONS,
312 318 ...WOOD_ITEM_DEFINITIONS,
313 319 ...ARMOUR_ITEM_DEFINITIONS,
@@ -11,6 +11,8 @@ import { WoodItemId, WOOD_ITEM_DEFINITIONS } from "./woodItems.js";
11import { ArmourItemId, ARMOUR_ITEM_DEFINITIONS } from "./armourItems.js";
11import { ArmourItemId, ARMOUR_ITEM_DEFINITIONS } from "./armourItems.js";
12import { ClothItemId, CLOTH_ITEM_DEFINITIONS } from "./clothItems.js";
12import { ClothItemId, CLOTH_ITEM_DEFINITIONS } from "./clothItems.js";
13import { LeatherItemId, LEATHER_ITEM_DEFINITIONS } from "./leatherItems.js";
13import { LeatherItemId, LEATHER_ITEM_DEFINITIONS } from "./leatherItems.js";
14import { LeatherArmourItemId, LEATHER_ARMOUR_ITEM_DEFINITIONS } from "./leatherArmourItems.js";
15import { WizardItemId, WIZARD_ITEM_DEFINITIONS } from "./wizardItems.js";
14import { DyeItemId, FLOWER_ITEM_DEFINITION, DYE_ITEM_DEFINITION, FLOWER_COLOR_DISPLAY } from "./dyes.js";
16import { DyeItemId, FLOWER_ITEM_DEFINITION, DYE_ITEM_DEFINITION, FLOWER_COLOR_DISPLAY } from "./dyes.js";
15import { HERB_ITEM_DEFINITIONS, HerbItemId } from "./herbs.js";
17import { HERB_ITEM_DEFINITIONS, HerbItemId } from "./herbs.js";
16import { RANGED_ITEM_DEFINITIONS, RangedItemId } from "./rangedItems.js";
18import { RANGED_ITEM_DEFINITIONS, RangedItemId } from "./rangedItems.js";
@@ -49,6 +51,8 @@ export const ItemId = Object.freeze({
49 ...ArmourItemId,
51 ...ArmourItemId,
50 ...ClothItemId,
52 ...ClothItemId,
51 ...LeatherItemId,
53 ...LeatherItemId,
54 ...LeatherArmourItemId,
55 ...WizardItemId,
52 ...DyeItemId,
56 ...DyeItemId,
53 ...HerbItemId,
57 ...HerbItemId,
54 ...RangedItemId,
58 ...RangedItemId,
@@ -308,6 +312,8 @@ export const ITEM_DEFINITIONS = Object.freeze({
308 }),
312 }),
309 ...CRAFTING_ITEM_STUBS,
313 ...CRAFTING_ITEM_STUBS,
310 ...LEATHER_ITEM_DEFINITIONS,
314 ...LEATHER_ITEM_DEFINITIONS,
315 ...LEATHER_ARMOUR_ITEM_DEFINITIONS,
316 ...WIZARD_ITEM_DEFINITIONS,
311 ...METAL_ITEM_DEFINITIONS,
317 ...METAL_ITEM_DEFINITIONS,
312 ...WOOD_ITEM_DEFINITIONS,
318 ...WOOD_ITEM_DEFINITIONS,
313 ...ARMOUR_ITEM_DEFINITIONS,
319 ...ARMOUR_ITEM_DEFINITIONS,
shared/definitions/leatherArmourItems.js added +156 −0
@@ -0,0 +1,156 @@
1 import { ItemCategory } from "./itemCategories.js";
2 import { EquipmentKind } from "./equipmentKinds.js";
3 import { equipImageName } from "./tileSprites.js";
4 import { leatherMaterialItemId } from "./leatherItems.js";
5 import { wovenClothItemId } from "./clothItems.js";
6 import { CraftingStationId } from "./craftingStations.js";
7 import
8 {
9 LeatherTier,
10 LEATHER_TIER_ORDER,
11 LEATHER_DISPLAY_NAME,
12 clothTierForLeather,
13 tierMinSkillLevel,
14 tierCraftSkillLevel
15 } from "./materialTiers.js";
16
17 /** Leather chestguard, chausses, and helmet — dual tint (red leather, blue cloth trim). */
18 export const LEATHER_ARMOUR_PIECES = Object.freeze([
19 Object.freeze({
20 suffix: "chestguard",
21 slot: "chest",
22 label: "chestguard",
23 idKey: "Chestguard",
24 leatherQty: 4,
25 clothQty: 2,
26 pieceKey: "chestguard"
27 }),
28 Object.freeze({
29 suffix: "chausses",
30 slot: "legs",
31 label: "chausses",
32 idKey: "Chausses",
33 leatherQty: 3,
34 clothQty: 1,
35 pieceKey: "chausses"
36 }),
37 Object.freeze({
38 suffix: "helmet",
39 slot: "head",
40 label: "helmet",
41 idKey: "Helmet",
42 leatherQty: 2,
43 clothQty: 0,
44 pieceKey: "helmet"
45 })
46 ]);
47
48 function buildLeatherArmourItemIds ()
49 {
50 const ids = {};
51 let nextId = 512;
52 for (const tier of LEATHER_TIER_ORDER)
53 {
54 for (const piece of LEATHER_ARMOUR_PIECES)
55 {
56 ids[`${tier}${piece.idKey}`] = nextId++;
57 }
58 }
59 return Object.freeze(ids);
60 }
61
62 export const LeatherArmourItemId = buildLeatherArmourItemIds();
63
64 export function leatherArmourItemIdForTier (tier, idKey)
65 {
66 return LeatherArmourItemId[`${tier}${idKey}`] ?? null;
67 }
68
69 function leatherArmourDef (itemId, tier, piece)
70 {
71 const name = LEATHER_DISPLAY_NAME[tier] ?? tier;
72 const clothTier = clothTierForLeather(tier);
73 const prefix = tier === LeatherTier.softLeather
74 ? "soft-leather"
75 : tier.replace(/([A-Z])/g, "-$1").toLowerCase();
76 return Object.freeze({
77 itemId,
78 key: `${prefix}-${piece.suffix}`,
79 displayName: `${name} ${piece.label}`,
80 description: `Sturdy ${name.toLowerCase()} ${piece.label}, lined for long marches.`,
81 seedValue: 10,
82 stackable: false,
83 maxStackSize: 1,
84 uniqueInstance: false,
85 category: ItemCategory.finished,
86 iconKey: "leatherarmour",
87 defaultState: piece.suffix,
88 tier,
89 leatherTier: tier,
90 clothTier,
91 dualTintLeatherCloth: true,
92 dualTintFromTier: true,
93 equipment: Object.freeze({
94 slot: piece.slot,
95 tier,
96 kind: EquipmentKind.leatherArmour,
97 minSkillLevel: tierMinSkillLevel(tier),
98 dualTintFromTier: true,
99 equipSprite: equipImageName("item", "leatherarmour", piece.suffix)
100 })
101 });
102 }
103
104 function buildLeatherArmourDefinitions ()
105 {
106 const defs = {};
107 for (const tier of LEATHER_TIER_ORDER)
108 {
109 for (const piece of LEATHER_ARMOUR_PIECES)
110 {
111 const prop = `${tier}${piece.idKey}`;
112 const itemId = LeatherArmourItemId[prop];
113 if (itemId == null)
114 { throw new Error(`Missing LeatherArmourItemId for ${prop}`); }
115 defs[itemId] = leatherArmourDef(itemId, tier, piece);
116 }
117 }
118 return Object.freeze(defs);
119 }
120
121 export const LEATHER_ARMOUR_ITEM_DEFINITIONS = buildLeatherArmourDefinitions();
122
123 /** Leatherworking station recipes for chestguard, chausses, and helmet. */
124 export function leatherArmourRecipes ()
125 {
126 return LEATHER_TIER_ORDER.flatMap((leatherTier) =>
127 LEATHER_ARMOUR_PIECES.map((piece) =>
128 {
129 const leatherId = leatherMaterialItemId(leatherTier);
130 const outputId = leatherArmourItemIdForTier(leatherTier, piece.idKey);
131 if (leatherId == null || outputId == null)
132 { throw new Error(`Missing leather armour recipe ids for ${leatherTier} ${piece.suffix}`); }
133 const inputs = [{ itemId: leatherId, quantity: piece.leatherQty }];
134 if (piece.clothQty > 0)
135 {
136 const clothId = wovenClothItemId(clothTierForLeather(leatherTier));
137 if (clothId == null)
138 { throw new Error(`Missing cloth for ${leatherTier} ${piece.suffix}`); }
139 inputs.push({ itemId: clothId, quantity: piece.clothQty });
140 }
141 const label = piece.label.charAt(0).toUpperCase() + piece.label.slice(1);
142 return Object.freeze({
143 recipeId: `leather-${piece.suffix}-${leatherTier}`,
144 craftGroup: `leather-${piece.suffix}`,
145 craftGroupLabel: label,
146 stationId: CraftingStationId.leatherworkingStation,
147 output: { itemId: outputId, quantity: 1 },
148 inputs,
149 minSkillLevel: tierCraftSkillLevel(leatherTier),
150 skillId: "leatherworking",
151 xpMaterial: leatherTier
152 });
153 }));
154 }
155
156 export { tierMinSkillLevel, tierCraftSkillLevel };
@@ -0,0 +1,156 @@
1import { ItemCategory } from "./itemCategories.js";
2import { EquipmentKind } from "./equipmentKinds.js";
3import { equipImageName } from "./tileSprites.js";
4import { leatherMaterialItemId } from "./leatherItems.js";
5import { wovenClothItemId } from "./clothItems.js";
6import { CraftingStationId } from "./craftingStations.js";
7import
8{
9 LeatherTier,
10 LEATHER_TIER_ORDER,
11 LEATHER_DISPLAY_NAME,
12 clothTierForLeather,
13 tierMinSkillLevel,
14 tierCraftSkillLevel
15} from "./materialTiers.js";
16
17/** Leather chestguard, chausses, and helmet — dual tint (red leather, blue cloth trim). */
18export const LEATHER_ARMOUR_PIECES = Object.freeze([
19 Object.freeze({
20 suffix: "chestguard",
21 slot: "chest",
22 label: "chestguard",
23 idKey: "Chestguard",
24 leatherQty: 4,
25 clothQty: 2,
26 pieceKey: "chestguard"
27 }),
28 Object.freeze({
29 suffix: "chausses",
30 slot: "legs",
31 label: "chausses",
32 idKey: "Chausses",
33 leatherQty: 3,
34 clothQty: 1,
35 pieceKey: "chausses"
36 }),
37 Object.freeze({
38 suffix: "helmet",
39 slot: "head",
40 label: "helmet",
41 idKey: "Helmet",
42 leatherQty: 2,
43 clothQty: 0,
44 pieceKey: "helmet"
45 })
46]);
47
48function buildLeatherArmourItemIds ()
49{
50 const ids = {};
51 let nextId = 512;
52 for (const tier of LEATHER_TIER_ORDER)
53 {
54 for (const piece of LEATHER_ARMOUR_PIECES)
55 {
56 ids[`${tier}${piece.idKey}`] = nextId++;
57 }
58 }
59 return Object.freeze(ids);
60}
61
62export const LeatherArmourItemId = buildLeatherArmourItemIds();
63
64export function leatherArmourItemIdForTier (tier, idKey)
65{
66 return LeatherArmourItemId[`${tier}${idKey}`] ?? null;
67}
68
69function leatherArmourDef (itemId, tier, piece)
70{
71 const name = LEATHER_DISPLAY_NAME[tier] ?? tier;
72 const clothTier = clothTierForLeather(tier);
73 const prefix = tier === LeatherTier.softLeather
74 ? "soft-leather"
75 : tier.replace(/([A-Z])/g, "-$1").toLowerCase();
76 return Object.freeze({
77 itemId,
78 key: `${prefix}-${piece.suffix}`,
79 displayName: `${name} ${piece.label}`,
80 description: `Sturdy ${name.toLowerCase()} ${piece.label}, lined for long marches.`,
81 seedValue: 10,
82 stackable: false,
83 maxStackSize: 1,
84 uniqueInstance: false,
85 category: ItemCategory.finished,
86 iconKey: "leatherarmour",
87 defaultState: piece.suffix,
88 tier,
89 leatherTier: tier,
90 clothTier,
91 dualTintLeatherCloth: true,
92 dualTintFromTier: true,
93 equipment: Object.freeze({
94 slot: piece.slot,
95 tier,
96 kind: EquipmentKind.leatherArmour,
97 minSkillLevel: tierMinSkillLevel(tier),
98 dualTintFromTier: true,
99 equipSprite: equipImageName("item", "leatherarmour", piece.suffix)
100 })
101 });
102}
103
104function buildLeatherArmourDefinitions ()
105{
106 const defs = {};
107 for (const tier of LEATHER_TIER_ORDER)
108 {
109 for (const piece of LEATHER_ARMOUR_PIECES)
110 {
111 const prop = `${tier}${piece.idKey}`;
112 const itemId = LeatherArmourItemId[prop];
113 if (itemId == null)
114 { throw new Error(`Missing LeatherArmourItemId for ${prop}`); }
115 defs[itemId] = leatherArmourDef(itemId, tier, piece);
116 }
117 }
118 return Object.freeze(defs);
119}
120
121export const LEATHER_ARMOUR_ITEM_DEFINITIONS = buildLeatherArmourDefinitions();
122
123/** Leatherworking station recipes for chestguard, chausses, and helmet. */
124export function leatherArmourRecipes ()
125{
126 return LEATHER_TIER_ORDER.flatMap((leatherTier) =>
127 LEATHER_ARMOUR_PIECES.map((piece) =>
128 {
129 const leatherId = leatherMaterialItemId(leatherTier);
130 const outputId = leatherArmourItemIdForTier(leatherTier, piece.idKey);
131 if (leatherId == null || outputId == null)
132 { throw new Error(`Missing leather armour recipe ids for ${leatherTier} ${piece.suffix}`); }
133 const inputs = [{ itemId: leatherId, quantity: piece.leatherQty }];
134 if (piece.clothQty > 0)
135 {
136 const clothId = wovenClothItemId(clothTierForLeather(leatherTier));
137 if (clothId == null)
138 { throw new Error(`Missing cloth for ${leatherTier} ${piece.suffix}`); }
139 inputs.push({ itemId: clothId, quantity: piece.clothQty });
140 }
141 const label = piece.label.charAt(0).toUpperCase() + piece.label.slice(1);
142 return Object.freeze({
143 recipeId: `leather-${piece.suffix}-${leatherTier}`,
144 craftGroup: `leather-${piece.suffix}`,
145 craftGroupLabel: label,
146 stationId: CraftingStationId.leatherworkingStation,
147 output: { itemId: outputId, quantity: 1 },
148 inputs,
149 minSkillLevel: tierCraftSkillLevel(leatherTier),
150 skillId: "leatherworking",
151 xpMaterial: leatherTier
152 });
153 }));
154}
155
156export { tierMinSkillLevel, tierCraftSkillLevel };
shared/definitions/materialTiers.js +14 −0
@@ -591,6 +591,20 @@ export function metalTierForCloth (clothTier)
591 591 return MATERIAL_TIER_ORDER[idx >= 0 ? idx : 0] ?? MaterialTier.bronze;
592 592 }
593 593
594 /** Matching leather tier for a cloth tier (cotton↔soft … dragonweave↔dragonhide). */
595 export function leatherTierForCloth (clothTier)
596 {
597 const idx = CLOTH_TIER_ORDER.indexOf(clothTier);
598 return LEATHER_TIER_ORDER[idx >= 0 ? idx : 0] ?? LeatherTier.softLeather;
599 }
600
601 /** Matching cloth tier for a leather tier. */
602 export function clothTierForLeather (leatherTier)
603 {
604 const idx = LEATHER_TIER_ORDER.indexOf(leatherTier);
605 return CLOTH_TIER_ORDER[idx >= 0 ? idx : 0] ?? ClothTier.cotton;
606 }
607
594 608 /** Fleece / plant fibre node exhaust duration (same curve as ore/trees). */
595 609 export function clothExhaustDurationMs (clothTier)
596 610 {
@@ -591,6 +591,20 @@ export function metalTierForCloth (clothTier)
591 return MATERIAL_TIER_ORDER[idx >= 0 ? idx : 0] ?? MaterialTier.bronze;
591 return MATERIAL_TIER_ORDER[idx >= 0 ? idx : 0] ?? MaterialTier.bronze;
592}
592}
593
593
594/** Matching leather tier for a cloth tier (cotton↔soft … dragonweave↔dragonhide). */
595export function leatherTierForCloth (clothTier)
596{
597 const idx = CLOTH_TIER_ORDER.indexOf(clothTier);
598 return LEATHER_TIER_ORDER[idx >= 0 ? idx : 0] ?? LeatherTier.softLeather;
599}
600
601/** Matching cloth tier for a leather tier. */
602export function clothTierForLeather (leatherTier)
603{
604 const idx = LEATHER_TIER_ORDER.indexOf(leatherTier);
605 return CLOTH_TIER_ORDER[idx >= 0 ? idx : 0] ?? ClothTier.cotton;
606}
607
594/** Fleece / plant fibre node exhaust duration (same curve as ore/trees). */
608/** Fleece / plant fibre node exhaust duration (same curve as ore/trees). */
595export function clothExhaustDurationMs (clothTier)
609export function clothExhaustDurationMs (clothTier)
596{
610{
shared/definitions/wizardItems.js added +187 −0
@@ -0,0 +1,187 @@
1 import { ItemCategory } from "./itemCategories.js";
2 import { EquipmentKind } from "./equipmentKinds.js";
3 import { equipImageName } from "./tileSprites.js";
4 import
5 {
6 ClothTier,
7 CLOTH_TIER_ORDER,
8 CLOTH_DISPLAY_NAME,
9 leatherTierForCloth,
10 tierMinSkillLevel
11 } from "./materialTiers.js";
12
13 export const WIZARD_PIECES = Object.freeze([
14 Object.freeze({
15 templateId: "wizard-hat",
16 suffix: "hat",
17 slot: "head",
18 label: "hat",
19 idKey: "Hat",
20 pieceKey: "hat",
21 clothQty: 2,
22 leatherQty: 1,
23 dualTint: true
24 }),
25 Object.freeze({
26 templateId: "wizard-robetop",
27 suffix: "robetop",
28 slot: "chest",
29 label: "robe top",
30 idKey: "RobeTop",
31 pieceKey: "robetop",
32 clothQty: 5,
33 leatherQty: 1,
34 dualTint: true
35 }),
36 Object.freeze({
37 templateId: "wizard-robebottoms",
38 suffix: "robebottoms",
39 slot: "legs",
40 label: "robe bottoms",
41 idKey: "RobeBottoms",
42 pieceKey: "robebottoms",
43 clothQty: 4,
44 leatherQty: 0,
45 dualTint: false
46 }),
47 Object.freeze({
48 templateId: "wizard-shoes",
49 suffix: "shoes",
50 slot: "boots",
51 label: "shoes",
52 idKey: "Shoes",
53 pieceKey: "shoes",
54 clothQty: 1,
55 leatherQty: 1,
56 dualTint: true
57 })
58 ]);
59
60 function buildWizardItemIds ()
61 {
62 const ids = {};
63 let nextId = 533;
64 for (const tier of CLOTH_TIER_ORDER)
65 {
66 for (const piece of WIZARD_PIECES)
67 {
68 ids[`${tier}${piece.idKey}`] = nextId++;
69 }
70 }
71 return Object.freeze(ids);
72 }
73
74 export const WizardItemId = buildWizardItemIds();
75
76 export function wizardItemIdForTier (clothTier, idKey)
77 {
78 return WizardItemId[`${clothTier}${idKey}`] ?? null;
79 }
80
81 function wizardPieceDef (itemId, clothTier, piece)
82 {
83 const name = CLOTH_DISPLAY_NAME[clothTier] ?? clothTier;
84 const leatherTier = leatherTierForCloth(clothTier);
85 const tierSlug = clothTier === ClothTier.cotton
86 ? "cotton"
87 : clothTier.replace(/([A-Z])/g, "-$1").toLowerCase();
88 const def = {
89 itemId,
90 key: `${tierSlug}-wizard-${piece.suffix}`,
91 displayName: `${name} ${piece.label}`,
92 description: piece.suffix === "hat"
93 ? `A pointed ${name.toLowerCase()} hat, cut for study and spellcraft.`
94 : piece.suffix === "robetop"
95 ? `A long ${name.toLowerCase()} robe top, loose enough for gestures and runes.`
96 : piece.suffix === "robebottoms"
97 ? `Flowing ${name.toLowerCase()} robe bottoms that brush the ground when you walk.`
98 : `Soft ${name.toLowerCase()} shoes, quiet on stone floors.`,
99 seedValue: 8,
100 stackable: false,
101 maxStackSize: 1,
102 uniqueInstance: false,
103 category: ItemCategory.finished,
104 iconKey: "magicrobes",
105 defaultState: piece.suffix,
106 tier: clothTier,
107 equipment: Object.freeze({
108 slot: piece.slot,
109 tier: clothTier,
110 kind: EquipmentKind.wizardCloth,
111 minSkillLevel: tierMinSkillLevel(clothTier),
112 equipSprite: equipImageName("item", "magicrobes", piece.suffix)
113 })
114 };
115 if (piece.dualTint)
116 {
117 def.leatherTier = leatherTier;
118 def.clothTier = clothTier;
119 def.dualTintLeatherCloth = true;
120 def.dualTintFromTier = true;
121 def.equipment = Object.freeze({
122 ...def.equipment,
123 dualTintFromTier: true
124 });
125 }
126 else
127 {
128 def.tintFromTier = true;
129 def.equipment = Object.freeze({
130 ...def.equipment,
131 tintFromTier: true
132 });
133 }
134 return Object.freeze(def);
135 }
136
137 function buildWizardDefinitions ()
138 {
139 const defs = {};
140 for (const tier of CLOTH_TIER_ORDER)
141 {
142 for (const piece of WIZARD_PIECES)
143 {
144 const prop = `${tier}${piece.idKey}`;
145 const itemId = WizardItemId[prop];
146 if (itemId == null)
147 { throw new Error(`Missing WizardItemId for ${prop}`); }
148 defs[itemId] = wizardPieceDef(itemId, tier, piece);
149 }
150 }
151 return Object.freeze(defs);
152 }
153
154 export const WIZARD_ITEM_DEFINITIONS = buildWizardDefinitions();
155
156 /** Tailor bench templates for wizard robes. */
157 export const WIZARD_TEMPLATES = Object.freeze(
158 Object.fromEntries(WIZARD_PIECES.map((piece) =>
159 {
160 const inputs = [{ kind: "cloth", quantity: piece.clothQty }];
161 if (piece.leatherQty > 0)
162 { inputs.push({ kind: "leather", quantity: piece.leatherQty }); }
163 return [piece.templateId, Object.freeze({
164 templateId: piece.templateId,
165 displayName: piece.label.charAt(0).toUpperCase() + piece.label.slice(1),
166 slot: piece.slot,
167 inputs: Object.freeze(inputs),
168 outputItemIdForTier: (tier) => wizardItemIdForTier(tier, piece.idKey),
169 minSkillLevel: 1
170 })];
171 }))
172 );
173
174 export function wizardTemplate (templateId)
175 {
176 return WIZARD_TEMPLATES[templateId] ?? null;
177 }
178
179 export function listWizardTemplates ()
180 {
181 return Object.values(WIZARD_TEMPLATES);
182 }
183
184 export function wizardHatItemId (tier) { return wizardItemIdForTier(tier, "Hat"); }
185 export function wizardRobeTopItemId (tier) { return wizardItemIdForTier(tier, "RobeTop"); }
186 export function wizardRobeBottomsItemId (tier) { return wizardItemIdForTier(tier, "RobeBottoms"); }
187 export function wizardShoesItemId (tier) { return wizardItemIdForTier(tier, "Shoes"); }
@@ -0,0 +1,187 @@
1import { ItemCategory } from "./itemCategories.js";
2import { EquipmentKind } from "./equipmentKinds.js";
3import { equipImageName } from "./tileSprites.js";
4import
5{
6 ClothTier,
7 CLOTH_TIER_ORDER,
8 CLOTH_DISPLAY_NAME,
9 leatherTierForCloth,
10 tierMinSkillLevel
11} from "./materialTiers.js";
12
13export const WIZARD_PIECES = Object.freeze([
14 Object.freeze({
15 templateId: "wizard-hat",
16 suffix: "hat",
17 slot: "head",
18 label: "hat",
19 idKey: "Hat",
20 pieceKey: "hat",
21 clothQty: 2,
22 leatherQty: 1,
23 dualTint: true
24 }),
25 Object.freeze({
26 templateId: "wizard-robetop",
27 suffix: "robetop",
28 slot: "chest",
29 label: "robe top",
30 idKey: "RobeTop",
31 pieceKey: "robetop",
32 clothQty: 5,
33 leatherQty: 1,
34 dualTint: true
35 }),
36 Object.freeze({
37 templateId: "wizard-robebottoms",
38 suffix: "robebottoms",
39 slot: "legs",
40 label: "robe bottoms",
41 idKey: "RobeBottoms",
42 pieceKey: "robebottoms",
43 clothQty: 4,
44 leatherQty: 0,
45 dualTint: false
46 }),
47 Object.freeze({
48 templateId: "wizard-shoes",
49 suffix: "shoes",
50 slot: "boots",
51 label: "shoes",
52 idKey: "Shoes",
53 pieceKey: "shoes",
54 clothQty: 1,
55 leatherQty: 1,
56 dualTint: true
57 })
58]);
59
60function buildWizardItemIds ()
61{
62 const ids = {};
63 let nextId = 533;
64 for (const tier of CLOTH_TIER_ORDER)
65 {
66 for (const piece of WIZARD_PIECES)
67 {
68 ids[`${tier}${piece.idKey}`] = nextId++;
69 }
70 }
71 return Object.freeze(ids);
72}
73
74export const WizardItemId = buildWizardItemIds();
75
76export function wizardItemIdForTier (clothTier, idKey)
77{
78 return WizardItemId[`${clothTier}${idKey}`] ?? null;
79}
80
81function wizardPieceDef (itemId, clothTier, piece)
82{
83 const name = CLOTH_DISPLAY_NAME[clothTier] ?? clothTier;
84 const leatherTier = leatherTierForCloth(clothTier);
85 const tierSlug = clothTier === ClothTier.cotton
86 ? "cotton"
87 : clothTier.replace(/([A-Z])/g, "-$1").toLowerCase();
88 const def = {
89 itemId,
90 key: `${tierSlug}-wizard-${piece.suffix}`,
91 displayName: `${name} ${piece.label}`,
92 description: piece.suffix === "hat"
93 ? `A pointed ${name.toLowerCase()} hat, cut for study and spellcraft.`
94 : piece.suffix === "robetop"
95 ? `A long ${name.toLowerCase()} robe top, loose enough for gestures and runes.`
96 : piece.suffix === "robebottoms"
97 ? `Flowing ${name.toLowerCase()} robe bottoms that brush the ground when you walk.`
98 : `Soft ${name.toLowerCase()} shoes, quiet on stone floors.`,
99 seedValue: 8,
100 stackable: false,
101 maxStackSize: 1,
102 uniqueInstance: false,
103 category: ItemCategory.finished,
104 iconKey: "magicrobes",
105 defaultState: piece.suffix,
106 tier: clothTier,
107 equipment: Object.freeze({
108 slot: piece.slot,
109 tier: clothTier,
110 kind: EquipmentKind.wizardCloth,
111 minSkillLevel: tierMinSkillLevel(clothTier),
112 equipSprite: equipImageName("item", "magicrobes", piece.suffix)
113 })
114 };
115 if (piece.dualTint)
116 {
117 def.leatherTier = leatherTier;
118 def.clothTier = clothTier;
119 def.dualTintLeatherCloth = true;
120 def.dualTintFromTier = true;
121 def.equipment = Object.freeze({
122 ...def.equipment,
123 dualTintFromTier: true
124 });
125 }
126 else
127 {
128 def.tintFromTier = true;
129 def.equipment = Object.freeze({
130 ...def.equipment,
131 tintFromTier: true
132 });
133 }
134 return Object.freeze(def);
135}
136
137function buildWizardDefinitions ()
138{
139 const defs = {};
140 for (const tier of CLOTH_TIER_ORDER)
141 {
142 for (const piece of WIZARD_PIECES)
143 {
144 const prop = `${tier}${piece.idKey}`;
145 const itemId = WizardItemId[prop];
146 if (itemId == null)
147 { throw new Error(`Missing WizardItemId for ${prop}`); }
148 defs[itemId] = wizardPieceDef(itemId, tier, piece);
149 }
150 }
151 return Object.freeze(defs);
152}
153
154export const WIZARD_ITEM_DEFINITIONS = buildWizardDefinitions();
155
156/** Tailor bench templates for wizard robes. */
157export const WIZARD_TEMPLATES = Object.freeze(
158 Object.fromEntries(WIZARD_PIECES.map((piece) =>
159 {
160 const inputs = [{ kind: "cloth", quantity: piece.clothQty }];
161 if (piece.leatherQty > 0)
162 { inputs.push({ kind: "leather", quantity: piece.leatherQty }); }
163 return [piece.templateId, Object.freeze({
164 templateId: piece.templateId,
165 displayName: piece.label.charAt(0).toUpperCase() + piece.label.slice(1),
166 slot: piece.slot,
167 inputs: Object.freeze(inputs),
168 outputItemIdForTier: (tier) => wizardItemIdForTier(tier, piece.idKey),
169 minSkillLevel: 1
170 })];
171 }))
172);
173
174export function wizardTemplate (templateId)
175{
176 return WIZARD_TEMPLATES[templateId] ?? null;
177}
178
179export function listWizardTemplates ()
180{
181 return Object.values(WIZARD_TEMPLATES);
182}
183
184export function wizardHatItemId (tier) { return wizardItemIdForTier(tier, "Hat"); }
185export function wizardRobeTopItemId (tier) { return wizardItemIdForTier(tier, "RobeTop"); }
186export function wizardRobeBottomsItemId (tier) { return wizardItemIdForTier(tier, "RobeBottoms"); }
187export function wizardShoesItemId (tier) { return wizardItemIdForTier(tier, "Shoes"); }
shared/render/tint.js +13 −0
@@ -144,6 +144,19 @@ export function resolveItemDualTint (stackOrDef, def = null)
144 144 if (!definition?.dualTintFromTier)
145 145 { return null; }
146 146
147 // Leather + cloth (red = leather, blue = cloth trim).
148 if (definition.dualTintLeatherCloth)
149 {
150 const leatherTier = definition.leatherTier ?? null;
151 const clothTier = definition.clothTier ?? null;
152 if (!leatherTier || !clothTier)
153 { return null; }
154 return {
155 shaft: tierTintColor(leatherTier),
156 tip: tierTintColor(clothTier)
157 };
158 }
159
147 160 // Tools / arrows: metal primary tier + matching wood shaft (red = wood, blue = metal).
148 161 if (definition.woodTier)
149 162 {
@@ -144,6 +144,19 @@ export function resolveItemDualTint (stackOrDef, def = null)
144 if (!definition?.dualTintFromTier)
144 if (!definition?.dualTintFromTier)
145 { return null; }
145 { return null; }
146
146
147 // Leather + cloth (red = leather, blue = cloth trim).
148 if (definition.dualTintLeatherCloth)
149 {
150 const leatherTier = definition.leatherTier ?? null;
151 const clothTier = definition.clothTier ?? null;
152 if (!leatherTier || !clothTier)
153 { return null; }
154 return {
155 shaft: tierTintColor(leatherTier),
156 tip: tierTintColor(clothTier)
157 };
158 }
159
147 // Tools / arrows: metal primary tier + matching wood shaft (red = wood, blue = metal).
160 // Tools / arrows: metal primary tier + matching wood shaft (red = wood, blue = metal).
148 if (definition.woodTier)
161 if (definition.woodTier)
149 {
162 {