BlueGit

timfa questward

metal armour

timfa Tim Falken · pushed by timfa

Authored 2026-08-26 · 2 months ago

Hash
69bf23af6d1ddae1f48757186b060cf4ae5648f6
Parent
48b50124
78 files changed +281 −4
client/assets/blocks/flower/flower.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/characters/player-body-female/player-body-female.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/characters/player-body-male/player-body-male.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/characters/ref-unisex-silhouette/silhouette.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/adamantium-boots/adamantium-boots.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/adamantium-chestplate/adamantium-chestplate.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/adamantium-full-helm/adamantium-full-helm.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/adamantium-greaves/adamantium-greaves.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/adamantium-helmet/adamantium-helmet.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/adamantium-horned-helm/adamantium-horned-helm.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/armour/boots-equip.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/armour/boots.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/armour/chestplate-equip.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/armour/chestplate.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/armour/fullhelm-equip.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/armour/fullhelm.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/armour/greaves-equip.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/armour/greaves.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/armour/helmet-equip.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/armour/helmet.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/armour/hornedhelm-equip.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/armour/hornedhelm.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/axe/axe-equip.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/bronze-boots/bronze-boots.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/bronze-chestplate/bronze-chestplate.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/bronze-full-helm/bronze-full-helm.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/bronze-greaves/bronze-greaves.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/bronze-helmet/bronze-helmet.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/bronze-horned-helm/bronze-horned-helm.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/bronze-plant-clippers/bronze-plant-clippers-equip.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/cloth-shirt/cloth-shirt-equip.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/cloth/cloth.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/cloth/wool.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/cloth/yarn.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/clothing/sweater-equip.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/clothing/sweater.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/dragon-boots/dragon-boots.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/dragon-chestplate/dragon-chestplate.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/dragon-full-helm/dragon-full-helm.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/dragon-greaves/dragon-greaves.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/dragon-helmet/dragon-helmet.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/dragon-horned-helm/dragon-horned-helm.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/iron-boots/iron-boots.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/iron-chestplate/iron-chestplate.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/iron-full-helm/iron-full-helm.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/iron-greaves/iron-greaves.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/iron-helmet/iron-helmet.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/iron-horned-helm/iron-horned-helm.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/lantern/lantern-equip-bloom.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/lantern/lantern-equip.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/mithril-boots/mithril-boots.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/mithril-chestplate/mithril-chestplate.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/mithril-full-helm/mithril-full-helm.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/mithril-greaves/mithril-greaves.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/mithril-helmet/mithril-helmet.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/mithril-horned-helm/mithril-horned-helm.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/orichalcum-boots/orichalcum-boots.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/orichalcum-chestplate/orichalcum-chestplate.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/orichalcum-full-helm/orichalcum-full-helm.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/orichalcum-greaves/orichalcum-greaves.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/orichalcum-helmet/orichalcum-helmet.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/orichalcum-horned-helm/orichalcum-horned-helm.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/pickaxe/pickaxe-equip.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/potion/potion-0.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/steel-boots/steel-boots.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/steel-chestplate/steel-chestplate.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/steel-full-helm/steel-full-helm.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/steel-greaves/steel-greaves.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/steel-helmet/steel-helmet.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/steel-horned-helm/steel-horned-helm.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/stick/stick-equip.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/stick/stick.png Binary file +0 −0

The contents of this binary file are not shown.

server/src/assets/spriteCatalog.js +11 −0
@@ -67,6 +67,17 @@ function itemScanDefs ()
67 67 animationSpeed: def.animationSpeed ?? 0
68 68 };
69 69 }
70 /** Shared metal armour worn overlays (items/armour/*-equip.png). */
71 if (!defs.armour)
72 {
73 defs.armour = {
74 key: "armour",
75 id: "armour-overlays",
76 frames: 1,
77 framesPerRow: 1,
78 animationSpeed: 0
79 };
80 }
70 81 return defs;
71 82 }
72 83
@@ -67,6 +67,17 @@ function itemScanDefs ()
67 animationSpeed: def.animationSpeed ?? 0
67 animationSpeed: def.animationSpeed ?? 0
68 };
68 };
69 }
69 }
70 /** Shared metal armour worn overlays (items/armour/*-equip.png). */
71 if (!defs.armour)
72 {
73 defs.armour = {
74 key: "armour",
75 id: "armour-overlays",
76 frames: 1,
77 framesPerRow: 1,
78 animationSpeed: 0
79 };
80 }
70 return defs;
81 return defs;
71}
82}
72
83
server/tests/crafting.test.js +32 −0
@@ -3,6 +3,7 @@ import assert from "node:assert/strict";
3 3 import { BlockType, blockDefinition } from "../../shared/definitions/tiles.js";
4 4 import { CraftingStationId, CRAFT_DURATION_MS } from "../../shared/definitions/craftingStations.js";
5 5 import { ItemId } from "../../shared/definitions/items.js";
6 import { ArmourItemId } from "../../shared/definitions/armourItems.js";
6 7 import { SkillId } from "../../shared/definitions/skills.js";
7 8 import {
8 9 MaterialTier,
@@ -395,3 +396,34 @@ test("bronze pickaxe chain: pine log → handle, bar → head, assemble pickaxe"
395 396 finally
396 397 { harness.close(); }
397 398 });
399
400 test("anvil armour recipes use bar counts per piece", () =>
401 {
402 const chest = recipeDefinition("armour-chestplate-bronze");
403 assert.ok(chest);
404 assert.equal(chest.stationId, CraftingStationId.anvil);
405 assert.equal(chest.output.itemId, ArmourItemId.bronzeChestplate);
406 assert.deepEqual(chest.inputs, [{ itemId: ItemId.bronzeBar, quantity: 6 }]);
407
408 const greaves = recipeDefinition("armour-greaves-iron");
409 assert.deepEqual(greaves.inputs, [{ itemId: ItemId.ironBar, quantity: 4 }]);
410
411 const boots = recipeDefinition("armour-boots-steel");
412 assert.deepEqual(boots.inputs, [{ itemId: ItemId.steelBar, quantity: 2 }]);
413
414 const helmet = recipeDefinition("armour-helmet-mithril");
415 assert.deepEqual(helmet.inputs, [{ itemId: ItemId.mithrilBar, quantity: 2 }]);
416
417 const fullHelm = recipeDefinition("armour-full-helm-adamantium");
418 assert.deepEqual(fullHelm.inputs, [{ itemId: ItemId.adamantiumBar, quantity: 3 }]);
419
420 const horned = recipeDefinition("armour-horned-helm-orichalcum");
421 assert.deepEqual(horned.inputs, [
422 { itemId: ItemId.orichalcumBar, quantity: 2 },
423 { itemId: ItemId.bones, quantity: 1 }
424 ]);
425
426 const anvilArmour = recipesForStation(CraftingStationId.anvil)
427 .filter((recipe) => recipe.recipeId.startsWith("armour-"));
428 assert.equal(anvilArmour.length, 7 * 6);
429 });
@@ -3,6 +3,7 @@ import assert from "node:assert/strict";
3import { BlockType, blockDefinition } from "../../shared/definitions/tiles.js";
3import { BlockType, blockDefinition } from "../../shared/definitions/tiles.js";
4import { CraftingStationId, CRAFT_DURATION_MS } from "../../shared/definitions/craftingStations.js";
4import { CraftingStationId, CRAFT_DURATION_MS } from "../../shared/definitions/craftingStations.js";
5import { ItemId } from "../../shared/definitions/items.js";
5import { ItemId } from "../../shared/definitions/items.js";
6import { ArmourItemId } from "../../shared/definitions/armourItems.js";
6import { SkillId } from "../../shared/definitions/skills.js";
7import { SkillId } from "../../shared/definitions/skills.js";
7import {
8import {
8 MaterialTier,
9 MaterialTier,
@@ -395,3 +396,34 @@ test("bronze pickaxe chain: pine log → handle, bar → head, assemble pickaxe"
395 finally
396 finally
396 { harness.close(); }
397 { harness.close(); }
397});
398});
399
400test("anvil armour recipes use bar counts per piece", () =>
401{
402 const chest = recipeDefinition("armour-chestplate-bronze");
403 assert.ok(chest);
404 assert.equal(chest.stationId, CraftingStationId.anvil);
405 assert.equal(chest.output.itemId, ArmourItemId.bronzeChestplate);
406 assert.deepEqual(chest.inputs, [{ itemId: ItemId.bronzeBar, quantity: 6 }]);
407
408 const greaves = recipeDefinition("armour-greaves-iron");
409 assert.deepEqual(greaves.inputs, [{ itemId: ItemId.ironBar, quantity: 4 }]);
410
411 const boots = recipeDefinition("armour-boots-steel");
412 assert.deepEqual(boots.inputs, [{ itemId: ItemId.steelBar, quantity: 2 }]);
413
414 const helmet = recipeDefinition("armour-helmet-mithril");
415 assert.deepEqual(helmet.inputs, [{ itemId: ItemId.mithrilBar, quantity: 2 }]);
416
417 const fullHelm = recipeDefinition("armour-full-helm-adamantium");
418 assert.deepEqual(fullHelm.inputs, [{ itemId: ItemId.adamantiumBar, quantity: 3 }]);
419
420 const horned = recipeDefinition("armour-horned-helm-orichalcum");
421 assert.deepEqual(horned.inputs, [
422 { itemId: ItemId.orichalcumBar, quantity: 2 },
423 { itemId: ItemId.bones, quantity: 1 }
424 ]);
425
426 const anvilArmour = recipesForStation(CraftingStationId.anvil)
427 .filter((recipe) => recipe.recipeId.startsWith("armour-"));
428 assert.equal(anvilArmour.length, 7 * 6);
429});
server/tests/equipment.test.js +37 −1
@@ -1,10 +1,12 @@
1 1 import test from "node:test";
2 2 import assert from "node:assert/strict";
3 3 import { ItemId, itemDefinition } from "../../shared/definitions/items.js";
4 import { MaterialTier, tierStatBonus } from "../../shared/definitions/materialTiers.js";
4 import { ArmourItemId } from "../../shared/definitions/armourItems.js";
5 import { MaterialTier, tierStatBonus, tierMinSkillLevel } from "../../shared/definitions/materialTiers.js";
5 6 import { EquipmentKind } from "../../shared/definitions/equipmentKinds.js";
6 7 import { SkillId } from "../../shared/definitions/skills.js";
7 8 import { normalizePlayerSkills } from "../../shared/skills/state.js";
9 import { totalXpForLevel } from "../../shared/skills/progression.js";
8 10 import {
9 11 canEquipItem,
10 12 effectiveSkillLevel,
@@ -58,3 +60,37 @@ test("higher tiers require the relevant skill level", () =>
58 60 skills.xp[SkillId.swordfighting] = 999999;
59 61 assert.equal(canEquipItem(skills, ironSword).ok, true);
60 62 });
63
64 test("full helm grants +1 defence bonus and +1 equip level", () =>
65 {
66 const helmet = itemDefinition(ArmourItemId.bronzeHelmet);
67 const fullHelm = itemDefinition(ArmourItemId.bronzeFullHelm);
68 const horned = itemDefinition(ArmourItemId.bronzeHornedHelm);
69 const skills = normalizePlayerSkills(null);
70
71 assert.equal(helmet.equipment.bonus, undefined);
72 assert.equal(fullHelm.equipment.bonus, tierStatBonus(MaterialTier.bronze) + 1);
73 assert.equal(horned.equipment.bonus, undefined);
74
75 assert.equal(canEquipItem(skills, helmet).ok, true);
76 assert.equal(canEquipItem(skills, fullHelm).ok, false);
77 skills.xp[SkillId.defence] = totalXpForLevel(tierMinSkillLevel(MaterialTier.bronze) + 1);
78 assert.equal(canEquipItem(skills, fullHelm).ok, true);
79
80 const slots = {
81 ...emptyEquipment().slots,
82 head: { itemId: ArmourItemId.bronzeFullHelm, quantity: 1 }
83 };
84 assert.equal(
85 equipmentBonusesFromSlots(slots)[SkillId.defence],
86 tierStatBonus(MaterialTier.bronze) + 1
87 );
88 const hornedSlots = {
89 ...emptyEquipment().slots,
90 head: { itemId: ArmourItemId.bronzeHornedHelm, quantity: 1 }
91 };
92 assert.equal(
93 equipmentBonusesFromSlots(hornedSlots)[SkillId.defence],
94 tierStatBonus(MaterialTier.bronze)
95 );
96 });
@@ -1,10 +1,12 @@
1import test from "node:test";
1import test from "node:test";
2import assert from "node:assert/strict";
2import assert from "node:assert/strict";
3import { ItemId, itemDefinition } from "../../shared/definitions/items.js";
3import { ItemId, itemDefinition } from "../../shared/definitions/items.js";
4import { MaterialTier, tierStatBonus } from "../../shared/definitions/materialTiers.js";
4import { ArmourItemId } from "../../shared/definitions/armourItems.js";
5import { MaterialTier, tierStatBonus, tierMinSkillLevel } from "../../shared/definitions/materialTiers.js";
5import { EquipmentKind } from "../../shared/definitions/equipmentKinds.js";
6import { EquipmentKind } from "../../shared/definitions/equipmentKinds.js";
6import { SkillId } from "../../shared/definitions/skills.js";
7import { SkillId } from "../../shared/definitions/skills.js";
7import { normalizePlayerSkills } from "../../shared/skills/state.js";
8import { normalizePlayerSkills } from "../../shared/skills/state.js";
9import { totalXpForLevel } from "../../shared/skills/progression.js";
8import {
10import {
9 canEquipItem,
11 canEquipItem,
10 effectiveSkillLevel,
12 effectiveSkillLevel,
@@ -58,3 +60,37 @@ test("higher tiers require the relevant skill level", () =>
58 skills.xp[SkillId.swordfighting] = 999999;
60 skills.xp[SkillId.swordfighting] = 999999;
59 assert.equal(canEquipItem(skills, ironSword).ok, true);
61 assert.equal(canEquipItem(skills, ironSword).ok, true);
60});
62});
63
64test("full helm grants +1 defence bonus and +1 equip level", () =>
65{
66 const helmet = itemDefinition(ArmourItemId.bronzeHelmet);
67 const fullHelm = itemDefinition(ArmourItemId.bronzeFullHelm);
68 const horned = itemDefinition(ArmourItemId.bronzeHornedHelm);
69 const skills = normalizePlayerSkills(null);
70
71 assert.equal(helmet.equipment.bonus, undefined);
72 assert.equal(fullHelm.equipment.bonus, tierStatBonus(MaterialTier.bronze) + 1);
73 assert.equal(horned.equipment.bonus, undefined);
74
75 assert.equal(canEquipItem(skills, helmet).ok, true);
76 assert.equal(canEquipItem(skills, fullHelm).ok, false);
77 skills.xp[SkillId.defence] = totalXpForLevel(tierMinSkillLevel(MaterialTier.bronze) + 1);
78 assert.equal(canEquipItem(skills, fullHelm).ok, true);
79
80 const slots = {
81 ...emptyEquipment().slots,
82 head: { itemId: ArmourItemId.bronzeFullHelm, quantity: 1 }
83 };
84 assert.equal(
85 equipmentBonusesFromSlots(slots)[SkillId.defence],
86 tierStatBonus(MaterialTier.bronze) + 1
87 );
88 const hornedSlots = {
89 ...emptyEquipment().slots,
90 head: { itemId: ArmourItemId.bronzeHornedHelm, quantity: 1 }
91 };
92 assert.equal(
93 equipmentBonusesFromSlots(hornedSlots)[SkillId.defence],
94 tierStatBonus(MaterialTier.bronze)
95 );
96});
shared/crafting/stationRecipes.js +26 −1
@@ -21,6 +21,10 @@ import {
21 21 logItemIdForWood,
22 22 handleItemIdForWood
23 23 } from "../definitions/woodItems.js";
24 import {
25 ARMOUR_CRAFT_PIECES,
26 armourItemIdForTier
27 } from "../definitions/armourItems.js";
24 28
25 29 /**
26 30 * Craft recipe schema (shared client + server):
@@ -119,6 +123,23 @@ function axeAssembleRecipe (metalTier, handleItemId, headItemId, axeItemId)
119 123 });
120 124 }
121 125
126 function armourRecipe (metalTier, piece)
127 {
128 const outputItemId = armourItemIdForTier(metalTier, piece.idKey);
129 const inputs = [{ itemId: BAR_BY_METAL[metalTier], quantity: piece.ingots }];
130 if (piece.needsBone)
131 { inputs.push({ itemId: ItemId.bones, quantity: 1 }); }
132 return Object.freeze({
133 recipeId: `armour-${piece.suffix}-${metalTier}`,
134 stationId: CraftingStationId.anvil,
135 output: { itemId: outputItemId, quantity: 1 },
136 inputs,
137 minSkillLevel: tierSmeltSkillLevel(metalTier),
138 skillId: "smithing",
139 xpMaterial: metalTier
140 });
141 }
142
122 143 const BAR_BY_METAL = Object.freeze({
123 144 [MaterialTier.bronze]: CraftingItemId.bronzeBar,
124 145 [MaterialTier.iron]: MetalItemId.ironBar,
@@ -169,6 +190,9 @@ const AXE_ASSEMBLE_RECIPES = MATERIAL_TIER_ORDER.map((tier) =>
169 190 );
170 191 });
171 192
193 const ARMOUR_RECIPES = MATERIAL_TIER_ORDER.flatMap((tier) =>
194 ARMOUR_CRAFT_PIECES.map((piece) => armourRecipe(tier, piece)));
195
172 196 /** @type {ReadonlyArray<object>} */
173 197 export const CRAFT_RECIPES = Object.freeze([
174 198 Object.freeze({
@@ -224,7 +248,8 @@ export const CRAFT_RECIPES = Object.freeze([
224 248 ...PICKAXE_HEAD_RECIPES,
225 249 ...PICKAXE_ASSEMBLE_RECIPES,
226 250 ...AXE_HEAD_RECIPES,
227 ...AXE_ASSEMBLE_RECIPES
251 ...AXE_ASSEMBLE_RECIPES,
252 ...ARMOUR_RECIPES
228 253 ]);
229 254
230 255 const RECIPE_BY_ID = new Map(CRAFT_RECIPES.map((recipe) => [recipe.recipeId, recipe]));
@@ -21,6 +21,10 @@ import {
21 logItemIdForWood,
21 logItemIdForWood,
22 handleItemIdForWood
22 handleItemIdForWood
23} from "../definitions/woodItems.js";
23} from "../definitions/woodItems.js";
24import {
25 ARMOUR_CRAFT_PIECES,
26 armourItemIdForTier
27} from "../definitions/armourItems.js";
24
28
25/**
29/**
26 * Craft recipe schema (shared client + server):
30 * Craft recipe schema (shared client + server):
@@ -119,6 +123,23 @@ function axeAssembleRecipe (metalTier, handleItemId, headItemId, axeItemId)
119 });
123 });
120}
124}
121
125
126function armourRecipe (metalTier, piece)
127{
128 const outputItemId = armourItemIdForTier(metalTier, piece.idKey);
129 const inputs = [{ itemId: BAR_BY_METAL[metalTier], quantity: piece.ingots }];
130 if (piece.needsBone)
131 { inputs.push({ itemId: ItemId.bones, quantity: 1 }); }
132 return Object.freeze({
133 recipeId: `armour-${piece.suffix}-${metalTier}`,
134 stationId: CraftingStationId.anvil,
135 output: { itemId: outputItemId, quantity: 1 },
136 inputs,
137 minSkillLevel: tierSmeltSkillLevel(metalTier),
138 skillId: "smithing",
139 xpMaterial: metalTier
140 });
141}
142
122const BAR_BY_METAL = Object.freeze({
143const BAR_BY_METAL = Object.freeze({
123 [MaterialTier.bronze]: CraftingItemId.bronzeBar,
144 [MaterialTier.bronze]: CraftingItemId.bronzeBar,
124 [MaterialTier.iron]: MetalItemId.ironBar,
145 [MaterialTier.iron]: MetalItemId.ironBar,
@@ -169,6 +190,9 @@ const AXE_ASSEMBLE_RECIPES = MATERIAL_TIER_ORDER.map((tier) =>
169 );
190 );
170});
191});
171
192
193const ARMOUR_RECIPES = MATERIAL_TIER_ORDER.flatMap((tier) =>
194 ARMOUR_CRAFT_PIECES.map((piece) => armourRecipe(tier, piece)));
195
172/** @type {ReadonlyArray<object>} */
196/** @type {ReadonlyArray<object>} */
173export const CRAFT_RECIPES = Object.freeze([
197export const CRAFT_RECIPES = Object.freeze([
174 Object.freeze({
198 Object.freeze({
@@ -224,7 +248,8 @@ export const CRAFT_RECIPES = Object.freeze([
224 ...PICKAXE_HEAD_RECIPES,
248 ...PICKAXE_HEAD_RECIPES,
225 ...PICKAXE_ASSEMBLE_RECIPES,
249 ...PICKAXE_ASSEMBLE_RECIPES,
226 ...AXE_HEAD_RECIPES,
250 ...AXE_HEAD_RECIPES,
227 ...AXE_ASSEMBLE_RECIPES
251 ...AXE_ASSEMBLE_RECIPES,
252 ...ARMOUR_RECIPES
228]);
253]);
229
254
230const RECIPE_BY_ID = new Map(CRAFT_RECIPES.map((recipe) => [recipe.recipeId, recipe]));
255const RECIPE_BY_ID = new Map(CRAFT_RECIPES.map((recipe) => [recipe.recipeId, recipe]));
shared/definitions/armourItems.js added +170 −0
@@ -0,0 +1,170 @@
1 import { ItemCategory } from "./itemCategories.js";
2 import {
3 MaterialTier,
4 MATERIAL_TIER_ORDER,
5 MATERIAL_DISPLAY_NAME,
6 tierMinSkillLevel,
7 tierStatBonus
8 } from "./materialTiers.js";
9 import { EquipmentKind } from "./equipmentKinds.js";
10 import { equipImageName } from "./tileSprites.js";
11
12 /**
13 * Metal armour — shared overlay sprites in items/armour/*-equip.png,
14 * per-tier tint via magenta mask. Shield (offhand) not included yet.
15 */
16 export const ArmourItemId = Object.freeze({
17 bronzeChestplate: 91,
18 bronzeGreaves: 92,
19 bronzeBoots: 93,
20 bronzeHelmet: 94,
21 bronzeFullHelm: 95,
22 bronzeHornedHelm: 96,
23 ironChestplate: 97,
24 ironGreaves: 98,
25 ironBoots: 99,
26 ironHelmet: 100,
27 ironFullHelm: 101,
28 ironHornedHelm: 102,
29 steelChestplate: 103,
30 steelGreaves: 104,
31 steelBoots: 105,
32 steelHelmet: 106,
33 steelFullHelm: 107,
34 steelHornedHelm: 108,
35 mithrilChestplate: 109,
36 mithrilGreaves: 110,
37 mithrilBoots: 111,
38 mithrilHelmet: 112,
39 mithrilFullHelm: 113,
40 mithrilHornedHelm: 114,
41 adamantiumChestplate: 115,
42 adamantiumGreaves: 116,
43 adamantiumBoots: 117,
44 adamantiumHelmet: 118,
45 adamantiumFullHelm: 119,
46 adamantiumHornedHelm: 120,
47 orichalcumChestplate: 121,
48 orichalcumGreaves: 122,
49 orichalcumBoots: 123,
50 orichalcumHelmet: 124,
51 orichalcumFullHelm: 125,
52 orichalcumHornedHelm: 126,
53 dragonChestplate: 127,
54 dragonGreaves: 128,
55 dragonBoots: 129,
56 dragonHelmet: 130,
57 dragonFullHelm: 131,
58 dragonHornedHelm: 132
59 });
60
61 const ARMOUR_PIECES = Object.freeze([
62 Object.freeze({
63 suffix: "chestplate",
64 slot: "chest",
65 label: "chestplate",
66 overlay: "chestplate",
67 idKey: "Chestplate",
68 ingots: 6
69 }),
70 Object.freeze({
71 suffix: "greaves",
72 slot: "legs",
73 label: "greaves",
74 overlay: "greaves",
75 idKey: "Greaves",
76 ingots: 4
77 }),
78 Object.freeze({
79 suffix: "boots",
80 slot: "boots",
81 label: "boots",
82 overlay: "boots",
83 idKey: "Boots",
84 ingots: 2
85 }),
86 Object.freeze({
87 suffix: "helmet",
88 slot: "head",
89 label: "helmet",
90 overlay: "helmet",
91 idKey: "Helmet",
92 ingots: 2
93 }),
94 Object.freeze({
95 suffix: "full-helm",
96 slot: "head",
97 label: "full helm",
98 overlay: "fullhelm",
99 idKey: "FullHelm",
100 ingots: 3,
101 fullHelm: true
102 }),
103 Object.freeze({
104 suffix: "horned-helm",
105 slot: "head",
106 label: "horned helm",
107 overlay: "hornedhelm",
108 idKey: "HornedHelm",
109 ingots: 2,
110 needsBone: true
111 })
112 ]);
113
114 export function armourItemIdForTier (tier, idKey)
115 {
116 return ArmourItemId[`${tier}${idKey}`] ?? null;
117 }
118
119 function armourDef (itemId, tier, piece)
120 {
121 const tierName = MATERIAL_DISPLAY_NAME[tier] ?? tier;
122 const key = `${tier}-${piece.suffix}`;
123 const equipment = {
124 slot: piece.slot,
125 tier,
126 kind: EquipmentKind.metalArmour,
127 tintFromTier: true,
128 equipSprite: equipImageName("item", "armour", piece.overlay)
129 };
130 if (piece.fullHelm)
131 {
132 equipment.bonus = tierStatBonus(tier) + 1;
133 equipment.minSkillLevel = tierMinSkillLevel(tier) + 1;
134 }
135 return Object.freeze({
136 itemId,
137 key,
138 displayName: `${tierName} ${piece.label}`,
139 description: `Worn ${tierName.toLowerCase()} ${piece.label}.`,
140 seedValue: 12,
141 stackable: false,
142 maxStackSize: 1,
143 uniqueInstance: false,
144 category: ItemCategory.finished,
145 tintFromTier: true,
146 equipment: Object.freeze(equipment)
147 });
148 }
149
150 function buildArmourDefinitions ()
151 {
152 const defs = {};
153 for (const tier of MATERIAL_TIER_ORDER)
154 {
155 for (const piece of ARMOUR_PIECES)
156 {
157 const idProp = `${tier}${piece.idKey}`;
158 const itemId = ArmourItemId[idProp];
159 if (itemId == null)
160 { throw new Error(`Missing ArmourItemId for ${idProp}`); }
161 defs[itemId] = armourDef(itemId, tier, piece);
162 }
163 }
164 return Object.freeze(defs);
165 }
166
167 export const ARMOUR_ITEM_DEFINITIONS = buildArmourDefinitions();
168
169 /** Shared piece metadata for smithing recipes (anvil). */
170 export { ARMOUR_PIECES as ARMOUR_CRAFT_PIECES };
@@ -0,0 +1,170 @@
1import { ItemCategory } from "./itemCategories.js";
2import {
3 MaterialTier,
4 MATERIAL_TIER_ORDER,
5 MATERIAL_DISPLAY_NAME,
6 tierMinSkillLevel,
7 tierStatBonus
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 * per-tier tint via magenta mask. Shield (offhand) not included yet.
15 */
16export const ArmourItemId = Object.freeze({
17 bronzeChestplate: 91,
18 bronzeGreaves: 92,
19 bronzeBoots: 93,
20 bronzeHelmet: 94,
21 bronzeFullHelm: 95,
22 bronzeHornedHelm: 96,
23 ironChestplate: 97,
24 ironGreaves: 98,
25 ironBoots: 99,
26 ironHelmet: 100,
27 ironFullHelm: 101,
28 ironHornedHelm: 102,
29 steelChestplate: 103,
30 steelGreaves: 104,
31 steelBoots: 105,
32 steelHelmet: 106,
33 steelFullHelm: 107,
34 steelHornedHelm: 108,
35 mithrilChestplate: 109,
36 mithrilGreaves: 110,
37 mithrilBoots: 111,
38 mithrilHelmet: 112,
39 mithrilFullHelm: 113,
40 mithrilHornedHelm: 114,
41 adamantiumChestplate: 115,
42 adamantiumGreaves: 116,
43 adamantiumBoots: 117,
44 adamantiumHelmet: 118,
45 adamantiumFullHelm: 119,
46 adamantiumHornedHelm: 120,
47 orichalcumChestplate: 121,
48 orichalcumGreaves: 122,
49 orichalcumBoots: 123,
50 orichalcumHelmet: 124,
51 orichalcumFullHelm: 125,
52 orichalcumHornedHelm: 126,
53 dragonChestplate: 127,
54 dragonGreaves: 128,
55 dragonBoots: 129,
56 dragonHelmet: 130,
57 dragonFullHelm: 131,
58 dragonHornedHelm: 132
59});
60
61const ARMOUR_PIECES = Object.freeze([
62 Object.freeze({
63 suffix: "chestplate",
64 slot: "chest",
65 label: "chestplate",
66 overlay: "chestplate",
67 idKey: "Chestplate",
68 ingots: 6
69 }),
70 Object.freeze({
71 suffix: "greaves",
72 slot: "legs",
73 label: "greaves",
74 overlay: "greaves",
75 idKey: "Greaves",
76 ingots: 4
77 }),
78 Object.freeze({
79 suffix: "boots",
80 slot: "boots",
81 label: "boots",
82 overlay: "boots",
83 idKey: "Boots",
84 ingots: 2
85 }),
86 Object.freeze({
87 suffix: "helmet",
88 slot: "head",
89 label: "helmet",
90 overlay: "helmet",
91 idKey: "Helmet",
92 ingots: 2
93 }),
94 Object.freeze({
95 suffix: "full-helm",
96 slot: "head",
97 label: "full helm",
98 overlay: "fullhelm",
99 idKey: "FullHelm",
100 ingots: 3,
101 fullHelm: true
102 }),
103 Object.freeze({
104 suffix: "horned-helm",
105 slot: "head",
106 label: "horned helm",
107 overlay: "hornedhelm",
108 idKey: "HornedHelm",
109 ingots: 2,
110 needsBone: true
111 })
112]);
113
114export function armourItemIdForTier (tier, idKey)
115{
116 return ArmourItemId[`${tier}${idKey}`] ?? null;
117}
118
119function armourDef (itemId, tier, piece)
120{
121 const tierName = MATERIAL_DISPLAY_NAME[tier] ?? tier;
122 const key = `${tier}-${piece.suffix}`;
123 const equipment = {
124 slot: piece.slot,
125 tier,
126 kind: EquipmentKind.metalArmour,
127 tintFromTier: true,
128 equipSprite: equipImageName("item", "armour", piece.overlay)
129 };
130 if (piece.fullHelm)
131 {
132 equipment.bonus = tierStatBonus(tier) + 1;
133 equipment.minSkillLevel = tierMinSkillLevel(tier) + 1;
134 }
135 return Object.freeze({
136 itemId,
137 key,
138 displayName: `${tierName} ${piece.label}`,
139 description: `Worn ${tierName.toLowerCase()} ${piece.label}.`,
140 seedValue: 12,
141 stackable: false,
142 maxStackSize: 1,
143 uniqueInstance: false,
144 category: ItemCategory.finished,
145 tintFromTier: true,
146 equipment: Object.freeze(equipment)
147 });
148}
149
150function buildArmourDefinitions ()
151{
152 const defs = {};
153 for (const tier of MATERIAL_TIER_ORDER)
154 {
155 for (const piece of ARMOUR_PIECES)
156 {
157 const idProp = `${tier}${piece.idKey}`;
158 const itemId = ArmourItemId[idProp];
159 if (itemId == null)
160 { throw new Error(`Missing ArmourItemId for ${idProp}`); }
161 defs[itemId] = armourDef(itemId, tier, piece);
162 }
163 }
164 return Object.freeze(defs);
165}
166
167export const ARMOUR_ITEM_DEFINITIONS = buildArmourDefinitions();
168
169/** Shared piece metadata for smithing recipes (anvil). */
170export { ARMOUR_PIECES as ARMOUR_CRAFT_PIECES };
shared/definitions/items.js +5 −2
@@ -8,6 +8,7 @@ import { formatOriginBreakdown } from "../items/origin.js";
8 8 import { CraftingItemId, CRAFTING_ITEM_STUBS } from "./craftingItems.js";
9 9 import { MetalItemId, METAL_ITEM_DEFINITIONS } from "./metalItems.js";
10 10 import { WoodItemId, WOOD_ITEM_DEFINITIONS } from "./woodItems.js";
11 import { ArmourItemId, ARMOUR_ITEM_DEFINITIONS } from "./armourItems.js";
11 12 import { POTION_MAX_STACK } from "./alchemy.js";
12 13
13 14 export const ItemId = Object.freeze({
@@ -30,7 +31,8 @@ export const ItemId = Object.freeze({
30 31 recipePaper: 33,
31 32 bronzePlantClippers: 34,
32 33 ...MetalItemId,
33 ...WoodItemId
34 ...WoodItemId,
35 ...ArmourItemId
34 36 });
35 37
36 38 export const EQUIPMENT_SLOT = Object.freeze({
@@ -294,7 +296,8 @@ export const ITEM_DEFINITIONS = Object.freeze({
294 296 }),
295 297 ...CRAFTING_ITEM_STUBS,
296 298 ...METAL_ITEM_DEFINITIONS,
297 ...WOOD_ITEM_DEFINITIONS
299 ...WOOD_ITEM_DEFINITIONS,
300 ...ARMOUR_ITEM_DEFINITIONS
298 301 });
299 302
300 303 export function itemDefinition (itemId)
@@ -8,6 +8,7 @@ import { formatOriginBreakdown } from "../items/origin.js";
8import { CraftingItemId, CRAFTING_ITEM_STUBS } from "./craftingItems.js";
8import { CraftingItemId, CRAFTING_ITEM_STUBS } from "./craftingItems.js";
9import { MetalItemId, METAL_ITEM_DEFINITIONS } from "./metalItems.js";
9import { MetalItemId, METAL_ITEM_DEFINITIONS } from "./metalItems.js";
10import { WoodItemId, WOOD_ITEM_DEFINITIONS } from "./woodItems.js";
10import { WoodItemId, WOOD_ITEM_DEFINITIONS } from "./woodItems.js";
11import { ArmourItemId, ARMOUR_ITEM_DEFINITIONS } from "./armourItems.js";
11import { POTION_MAX_STACK } from "./alchemy.js";
12import { POTION_MAX_STACK } from "./alchemy.js";
12
13
13export const ItemId = Object.freeze({
14export const ItemId = Object.freeze({
@@ -30,7 +31,8 @@ export const ItemId = Object.freeze({
30 recipePaper: 33,
31 recipePaper: 33,
31 bronzePlantClippers: 34,
32 bronzePlantClippers: 34,
32 ...MetalItemId,
33 ...MetalItemId,
33 ...WoodItemId
34 ...WoodItemId,
35 ...ArmourItemId
34});
36});
35
37
36export const EQUIPMENT_SLOT = Object.freeze({
38export const EQUIPMENT_SLOT = Object.freeze({
@@ -294,7 +296,8 @@ export const ITEM_DEFINITIONS = Object.freeze({
294 }),
296 }),
295 ...CRAFTING_ITEM_STUBS,
297 ...CRAFTING_ITEM_STUBS,
296 ...METAL_ITEM_DEFINITIONS,
298 ...METAL_ITEM_DEFINITIONS,
297 ...WOOD_ITEM_DEFINITIONS
299 ...WOOD_ITEM_DEFINITIONS,
300 ...ARMOUR_ITEM_DEFINITIONS
298});
301});
299
302
300export function itemDefinition (itemId)
303export function itemDefinition (itemId)