BlueGit

timfa questward

Add tiered leather shoes at the leatherworking station.

Shoes craft from 2 leather per tier via a leather-tier dropdown; leather armour keeps full Agility and half Defence (floored).

timfa Tim Falken · pushed by timfa

Authored 2026-08-31 · 2 months ago

Hash
c41d8cda11894f88857d5bc6a5a20d08259e65c0
Parent
93052ca6
6 files changed +165 −32
client/src/play/crafting.js +21 −2
@@ -26,6 +26,9 @@ import
26 26 WOOD_TIER_ORDER,
27 27 WoodTier,
28 28 MaterialTier,
29 LEATHER_TIER_ORDER,
30 LEATHER_DISPLAY_NAME,
31 LeatherTier,
29 32 woodTierForMetal,
30 33 clothTierForWood
31 34 } from "/shared/definitions/materialTiers.js";
@@ -70,6 +73,7 @@ export function initCrafting ({
70 73 let selectedRecipeId = null;
71 74 let selectedCraftGroup = null;
72 75 let selectedMaterial = ClothTier.cotton;
76
73 77 let dyeSlotIndex = null;
74 78 let crafting = false;
75 79 let craftTimer = null;
@@ -138,6 +142,11 @@ export function initCrafting ({
138 142 return stationId === CraftingStationId.loom;
139 143 }
140 144
145 function isLeatherworkingStation ()
146 {
147 return stationId === CraftingStationId.leatherworkingStation;
148 }
149
141 150 function usesMaterialDropdown ()
142 151 {
143 152 return isTailorStation()
@@ -145,7 +154,8 @@ export function initCrafting ({
145 154 || isWoodworkingStation()
146 155 || isCraftingBenchStation()
147 156 || isSpinningWheelStation()
148 || isLoomStation();
157 || isLoomStation()
158 || isLeatherworkingStation();
149 159 }
150 160
151 161 /** One grid cell per craft group; material dropdown picks the tier variant. */
@@ -155,7 +165,8 @@ export function initCrafting ({
155 165 || isWoodworkingStation()
156 166 || isCraftingBenchStation()
157 167 || isSpinningWheelStation()
158 || isLoomStation();
168 || isLoomStation()
169 || isLeatherworkingStation();
159 170 }
160 171
161 172 function craftGroupKey (recipe)
@@ -229,6 +240,14 @@ export function initCrafting ({
229 240 fallback: ClothTier.cotton
230 241 };
231 242 }
243 if (isLeatherworkingStation())
244 {
245 return {
246 order: LEATHER_TIER_ORDER,
247 names: LEATHER_DISPLAY_NAME,
248 fallback: LeatherTier.softLeather
249 };
250 }
232 251 if (isWoodworkingStation())
233 252 {
234 253 return {
@@ -26,6 +26,9 @@ import
26 WOOD_TIER_ORDER,
26 WOOD_TIER_ORDER,
27 WoodTier,
27 WoodTier,
28 MaterialTier,
28 MaterialTier,
29 LEATHER_TIER_ORDER,
30 LEATHER_DISPLAY_NAME,
31 LeatherTier,
29 woodTierForMetal,
32 woodTierForMetal,
30 clothTierForWood
33 clothTierForWood
31} from "/shared/definitions/materialTiers.js";
34} from "/shared/definitions/materialTiers.js";
@@ -70,6 +73,7 @@ export function initCrafting ({
70 let selectedRecipeId = null;
73 let selectedRecipeId = null;
71 let selectedCraftGroup = null;
74 let selectedCraftGroup = null;
72 let selectedMaterial = ClothTier.cotton;
75 let selectedMaterial = ClothTier.cotton;
76
73 let dyeSlotIndex = null;
77 let dyeSlotIndex = null;
74 let crafting = false;
78 let crafting = false;
75 let craftTimer = null;
79 let craftTimer = null;
@@ -138,6 +142,11 @@ export function initCrafting ({
138 return stationId === CraftingStationId.loom;
142 return stationId === CraftingStationId.loom;
139 }
143 }
140
144
145 function isLeatherworkingStation ()
146 {
147 return stationId === CraftingStationId.leatherworkingStation;
148 }
149
141 function usesMaterialDropdown ()
150 function usesMaterialDropdown ()
142 {
151 {
143 return isTailorStation()
152 return isTailorStation()
@@ -145,7 +154,8 @@ export function initCrafting ({
145 || isWoodworkingStation()
154 || isWoodworkingStation()
146 || isCraftingBenchStation()
155 || isCraftingBenchStation()
147 || isSpinningWheelStation()
156 || isSpinningWheelStation()
148 || isLoomStation();
157 || isLoomStation()
158 || isLeatherworkingStation();
149 }
159 }
150
160
151 /** One grid cell per craft group; material dropdown picks the tier variant. */
161 /** One grid cell per craft group; material dropdown picks the tier variant. */
@@ -155,7 +165,8 @@ export function initCrafting ({
155 || isWoodworkingStation()
165 || isWoodworkingStation()
156 || isCraftingBenchStation()
166 || isCraftingBenchStation()
157 || isSpinningWheelStation()
167 || isSpinningWheelStation()
158 || isLoomStation();
168 || isLoomStation()
169 || isLeatherworkingStation();
159 }
170 }
160
171
161 function craftGroupKey (recipe)
172 function craftGroupKey (recipe)
@@ -229,6 +240,14 @@ export function initCrafting ({
229 fallback: ClothTier.cotton
240 fallback: ClothTier.cotton
230 };
241 };
231 }
242 }
243 if (isLeatherworkingStation())
244 {
245 return {
246 order: LEATHER_TIER_ORDER,
247 names: LEATHER_DISPLAY_NAME,
248 fallback: LeatherTier.softLeather
249 };
250 }
232 if (isWoodworkingStation())
251 if (isWoodworkingStation())
233 {
252 {
234 return {
253 return {
server/tests/crafting.test.js +24 −0
@@ -4,6 +4,7 @@ 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 6 import { ArmourItemId } from "../../shared/definitions/armourItems.js";
7 import { LeatherItemId } from "../../shared/definitions/leatherItems.js";
7 8 import { SkillId } from "../../shared/definitions/skills.js";
8 9 import
9 10 {
@@ -481,3 +482,26 @@ test("anvil armour recipes use bar counts per piece", () =>
481 482 .filter((recipe) => recipe.recipeId.startsWith("armour-"));
482 483 assert.equal(anvilArmour.length, 7 * 8);
483 484 });
485
486 test("leatherworking shoes recipes use 2 leather per tier", () =>
487 {
488 const shoes = recipesForStation(CraftingStationId.leatherworkingStation)
489 .filter((recipe) => recipe.craftGroup === "leather-shoes");
490 assert.equal(shoes.length, 7);
491 for (const recipe of shoes)
492 {
493 assert.equal(recipe.inputs.length, 1);
494 assert.equal(recipe.inputs[0].quantity, 2);
495 assert.equal(recipe.skillId, "leatherworking");
496 assert.ok(recipe.xpMaterial);
497 assert.equal(recipe.craftGroupLabel, "Shoes");
498 }
499 const soft = recipeDefinition("leather-shoes-softLeather");
500 assert.ok(soft);
501 assert.equal(soft.output.itemId, LeatherItemId.leatherShoes);
502 assert.deepEqual(soft.inputs, [{ itemId: ItemId.leather, quantity: 2 }]);
503 const hide = recipeDefinition("leather-shoes-dragonhide");
504 assert.ok(hide);
505 assert.equal(hide.output.itemId, LeatherItemId.dragonhideShoes);
506 assert.deepEqual(hide.inputs, [{ itemId: LeatherItemId.dragonhide, quantity: 2 }]);
507 });
@@ -4,6 +4,7 @@ import { 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 { ArmourItemId } from "../../shared/definitions/armourItems.js";
7import { LeatherItemId } from "../../shared/definitions/leatherItems.js";
7import { SkillId } from "../../shared/definitions/skills.js";
8import { SkillId } from "../../shared/definitions/skills.js";
8import
9import
9{
10{
@@ -481,3 +482,26 @@ test("anvil armour recipes use bar counts per piece", () =>
481 .filter((recipe) => recipe.recipeId.startsWith("armour-"));
482 .filter((recipe) => recipe.recipeId.startsWith("armour-"));
482 assert.equal(anvilArmour.length, 7 * 8);
483 assert.equal(anvilArmour.length, 7 * 8);
483});
484});
485
486test("leatherworking shoes recipes use 2 leather per tier", () =>
487{
488 const shoes = recipesForStation(CraftingStationId.leatherworkingStation)
489 .filter((recipe) => recipe.craftGroup === "leather-shoes");
490 assert.equal(shoes.length, 7);
491 for (const recipe of shoes)
492 {
493 assert.equal(recipe.inputs.length, 1);
494 assert.equal(recipe.inputs[0].quantity, 2);
495 assert.equal(recipe.skillId, "leatherworking");
496 assert.ok(recipe.xpMaterial);
497 assert.equal(recipe.craftGroupLabel, "Shoes");
498 }
499 const soft = recipeDefinition("leather-shoes-softLeather");
500 assert.ok(soft);
501 assert.equal(soft.output.itemId, LeatherItemId.leatherShoes);
502 assert.deepEqual(soft.inputs, [{ itemId: ItemId.leather, quantity: 2 }]);
503 const hide = recipeDefinition("leather-shoes-dragonhide");
504 assert.ok(hide);
505 assert.equal(hide.output.itemId, LeatherItemId.dragonhideShoes);
506 assert.deepEqual(hide.inputs, [{ itemId: LeatherItemId.dragonhide, quantity: 2 }]);
507});
server/tests/equipment.test.js +12 −1
@@ -4,7 +4,7 @@ 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 6 import { CraftingItemId } from "../../shared/definitions/craftingItems.js";
7 import { MaterialTier, WoodTier, tierStatBonus, tierMinSkillLevel } from "../../shared/definitions/materialTiers.js";
7 import { MaterialTier, LeatherTier, WoodTier, tierStatBonus, tierMinSkillLevel } from "../../shared/definitions/materialTiers.js";
8 8 import { EquipmentKind } from "../../shared/definitions/equipmentKinds.js";
9 9 import { SkillId } from "../../shared/definitions/skills.js";
10 10 import { normalizePlayerSkills } from "../../shared/skills/state.js";
@@ -114,6 +114,17 @@ test("leather shoes grant independent agility and defence from settings", () =>
114 114 assert.equal(bonuses[SkillId.defence], 1);
115 115 });
116 116
117 test("leather armour defaults to full agility and half metal defence", () =>
118 {
119 const defaults = defaultEquipmentStatBonuses().leatherArmour.shoes;
120 assert.equal(defaults.softLeather.agility, tierStatBonus(LeatherTier.softLeather));
121 assert.equal(defaults.softLeather.defence, Math.floor(tierStatBonus(LeatherTier.softLeather) / 2));
122 assert.equal(defaults.studdedLeather.agility, tierStatBonus(LeatherTier.studdedLeather));
123 assert.equal(defaults.studdedLeather.defence, Math.floor(tierStatBonus(MaterialTier.steel) / 2));
124 assert.equal(defaults.dragonhide.agility, tierStatBonus(LeatherTier.dragonhide));
125 assert.equal(defaults.dragonhide.defence, Math.floor(tierStatBonus(MaterialTier.dragon) / 2));
126 });
127
117 128 test("bronze gear equips at level 1", () =>
118 129 {
119 130 const skills = normalizePlayerSkills(null);
@@ -4,7 +4,7 @@ import { 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 { CraftingItemId } from "../../shared/definitions/craftingItems.js";
6import { CraftingItemId } from "../../shared/definitions/craftingItems.js";
7import { MaterialTier, WoodTier, tierStatBonus, tierMinSkillLevel } from "../../shared/definitions/materialTiers.js";
7import { MaterialTier, LeatherTier, WoodTier, tierStatBonus, tierMinSkillLevel } from "../../shared/definitions/materialTiers.js";
8import { EquipmentKind } from "../../shared/definitions/equipmentKinds.js";
8import { EquipmentKind } from "../../shared/definitions/equipmentKinds.js";
9import { SkillId } from "../../shared/definitions/skills.js";
9import { SkillId } from "../../shared/definitions/skills.js";
10import { normalizePlayerSkills } from "../../shared/skills/state.js";
10import { normalizePlayerSkills } from "../../shared/skills/state.js";
@@ -114,6 +114,17 @@ test("leather shoes grant independent agility and defence from settings", () =>
114 assert.equal(bonuses[SkillId.defence], 1);
114 assert.equal(bonuses[SkillId.defence], 1);
115});
115});
116
116
117test("leather armour defaults to full agility and half metal defence", () =>
118{
119 const defaults = defaultEquipmentStatBonuses().leatherArmour.shoes;
120 assert.equal(defaults.softLeather.agility, tierStatBonus(LeatherTier.softLeather));
121 assert.equal(defaults.softLeather.defence, Math.floor(tierStatBonus(LeatherTier.softLeather) / 2));
122 assert.equal(defaults.studdedLeather.agility, tierStatBonus(LeatherTier.studdedLeather));
123 assert.equal(defaults.studdedLeather.defence, Math.floor(tierStatBonus(MaterialTier.steel) / 2));
124 assert.equal(defaults.dragonhide.agility, tierStatBonus(LeatherTier.dragonhide));
125 assert.equal(defaults.dragonhide.defence, Math.floor(tierStatBonus(MaterialTier.dragon) / 2));
126});
127
117test("bronze gear equips at level 1", () =>
128test("bronze gear equips at level 1", () =>
118{
129{
119 const skills = normalizePlayerSkills(null);
130 const skills = normalizePlayerSkills(null);
shared/crafting/tierRecipes.js +26 −2
@@ -8,6 +8,7 @@ import
8 8 WOOD_TIER_ORDER,
9 9 MATERIAL_TIER_ORDER,
10 10 CLOTH_TIER_ORDER,
11 LEATHER_TIER_ORDER,
11 12 MATERIAL_DISPLAY_NAME,
12 13 WoodTier,
13 14 woodTierForMetal,
@@ -24,7 +25,7 @@ import
24 25 } from "../definitions/armourItems.js";
25 26 import { RangedItemId } from "../definitions/rangedItems.js";
26 27 import { yarnItemId } from "../definitions/clothItems.js";
27 import { leatherMaterialItemId } from "../definitions/leatherItems.js";
28 import { leatherMaterialItemId, leatherShoesItemId } from "../definitions/leatherItems.js";
28 29
29 30 /**
30 31 * Tier-scaled craft recipes generated from {@link ItemFamilyId} templates.
@@ -428,6 +429,28 @@ function armourRecipes ()
428 429 }));
429 430 }
430 431
432 function leatherShoesRecipes ()
433 {
434 return LEATHER_TIER_ORDER.map((leatherTier) =>
435 {
436 const leatherId = leatherMaterialItemId(leatherTier);
437 const shoesId = leatherShoesItemId(leatherTier);
438 if (leatherId == null || shoesId == null)
439 { throw new Error(`Missing leather shoes recipe ids for ${leatherTier}`); }
440 return Object.freeze({
441 recipeId: `leather-shoes-${leatherTier}`,
442 craftGroup: "leather-shoes",
443 craftGroupLabel: "Shoes",
444 stationId: CraftingStationId.leatherworkingStation,
445 output: { itemId: shoesId, quantity: 1 },
446 inputs: [{ itemId: leatherId, quantity: 2 }],
447 minSkillLevel: tierCraftSkillLevel(leatherTier),
448 skillId: "leatherworking",
449 xpMaterial: leatherTier
450 });
451 });
452 }
453
431 454 /** All recipes driven by tier families (tools, wood/metal intermediates, ranged). */
432 455 export const TIER_FAMILY_RECIPES = Object.freeze([
433 456 ...handleRecipes(),
@@ -447,5 +470,6 @@ export const TIER_FAMILY_RECIPES = Object.freeze([
447 470 ...unstrungBowRecipes(),
448 471 ...bowstringRecipes(),
449 472 ...bowAssembleRecipes(),
450 ...armourRecipes()
473 ...armourRecipes(),
474 ...leatherShoesRecipes()
451 475 ]);
@@ -8,6 +8,7 @@ import
8 WOOD_TIER_ORDER,
8 WOOD_TIER_ORDER,
9 MATERIAL_TIER_ORDER,
9 MATERIAL_TIER_ORDER,
10 CLOTH_TIER_ORDER,
10 CLOTH_TIER_ORDER,
11 LEATHER_TIER_ORDER,
11 MATERIAL_DISPLAY_NAME,
12 MATERIAL_DISPLAY_NAME,
12 WoodTier,
13 WoodTier,
13 woodTierForMetal,
14 woodTierForMetal,
@@ -24,7 +25,7 @@ import
24 } from "../definitions/armourItems.js";
25 } from "../definitions/armourItems.js";
25import { RangedItemId } from "../definitions/rangedItems.js";
26import { RangedItemId } from "../definitions/rangedItems.js";
26import { yarnItemId } from "../definitions/clothItems.js";
27import { yarnItemId } from "../definitions/clothItems.js";
27import { leatherMaterialItemId } from "../definitions/leatherItems.js";
28import { leatherMaterialItemId, leatherShoesItemId } from "../definitions/leatherItems.js";
28
29
29/**
30/**
30 * Tier-scaled craft recipes generated from {@link ItemFamilyId} templates.
31 * Tier-scaled craft recipes generated from {@link ItemFamilyId} templates.
@@ -428,6 +429,28 @@ function armourRecipes ()
428 }));
429 }));
429}
430}
430
431
432function leatherShoesRecipes ()
433{
434 return LEATHER_TIER_ORDER.map((leatherTier) =>
435 {
436 const leatherId = leatherMaterialItemId(leatherTier);
437 const shoesId = leatherShoesItemId(leatherTier);
438 if (leatherId == null || shoesId == null)
439 { throw new Error(`Missing leather shoes recipe ids for ${leatherTier}`); }
440 return Object.freeze({
441 recipeId: `leather-shoes-${leatherTier}`,
442 craftGroup: "leather-shoes",
443 craftGroupLabel: "Shoes",
444 stationId: CraftingStationId.leatherworkingStation,
445 output: { itemId: shoesId, quantity: 1 },
446 inputs: [{ itemId: leatherId, quantity: 2 }],
447 minSkillLevel: tierCraftSkillLevel(leatherTier),
448 skillId: "leatherworking",
449 xpMaterial: leatherTier
450 });
451 });
452}
453
431/** All recipes driven by tier families (tools, wood/metal intermediates, ranged). */
454/** All recipes driven by tier families (tools, wood/metal intermediates, ranged). */
432export const TIER_FAMILY_RECIPES = Object.freeze([
455export const TIER_FAMILY_RECIPES = Object.freeze([
433 ...handleRecipes(),
456 ...handleRecipes(),
@@ -447,5 +470,6 @@ export const TIER_FAMILY_RECIPES = Object.freeze([
447 ...unstrungBowRecipes(),
470 ...unstrungBowRecipes(),
448 ...bowstringRecipes(),
471 ...bowstringRecipes(),
449 ...bowAssembleRecipes(),
472 ...bowAssembleRecipes(),
450 ...armourRecipes()
473 ...armourRecipes(),
474 ...leatherShoesRecipes()
451]);
475]);
shared/definitions/equipmentStatCategories.js +14 −3
@@ -15,7 +15,7 @@ import
15 15 } from "./materialTiers.js";
16 16 import { ARMOUR_CRAFT_PIECES, armourItemIdForTier } from "./armourItems.js";
17 17 import { sweaterItemId, shirtItemId, shortsItemId, skirtItemId, trousersItemId } from "./clothItems.js";
18 import { LeatherItemId } from "./leatherItems.js";
18 import { leatherShoesItemId } from "./leatherItems.js";
19 19 import { ItemId, itemDefinition, ITEM_DEFINITIONS } from "./items.js";
20 20 import { quarterstaffItemIdForWood } from "./woodItems.js";
21 21 import { swordItemIdForMetal } from "./swordItems.js";
@@ -115,8 +115,12 @@ export const EQUIPMENT_STAT_CATEGORIES = Object.freeze([
115 115 Object.freeze({
116 116 pieceKey: "shoes",
117 117 label: "Leather shoes",
118 defaultBonus: 0,
119 resolveItemId: (tier) => (tier === "softLeather" ? LeatherItemId.leatherShoes : null)
118 /** Full agility; defence is half the matching metal tier (floored). */
119 defaultBonusByStat: Object.freeze({
120 [SkillId.agility]: "tier",
121 [SkillId.defence]: "tierHalf"
122 }),
123 resolveItemId: (tier) => leatherShoesItemId(tier)
120 124 })
121 125 ])
122 126 })
@@ -407,6 +411,13 @@ function resolveDefaultBonusMode (mode, tier, row)
407 411 const extra = Number(row.defaultBonusExtra) || 0;
408 412 if (mode === "rank")
409 413 { return Math.max(0, Math.floor(tierRank(key) + extra)); }
414 if (mode === "tierHalf")
415 {
416 const base = row.defaultBonus != null
417 ? Number(row.defaultBonus) || 0
418 : tierStatBonus(key);
419 return Math.max(0, Math.floor(base / 2) + extra);
420 }
410 421 if (mode === "tier" || mode == null)
411 422 {
412 423 const base = row.defaultBonus != null
@@ -15,7 +15,7 @@ import
15} from "./materialTiers.js";
15} from "./materialTiers.js";
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 { LeatherItemId } from "./leatherItems.js";
18import { leatherShoesItemId } from "./leatherItems.js";
19import { ItemId, itemDefinition, ITEM_DEFINITIONS } from "./items.js";
19import { ItemId, itemDefinition, ITEM_DEFINITIONS } from "./items.js";
20import { quarterstaffItemIdForWood } from "./woodItems.js";
20import { quarterstaffItemIdForWood } from "./woodItems.js";
21import { swordItemIdForMetal } from "./swordItems.js";
21import { swordItemIdForMetal } from "./swordItems.js";
@@ -115,8 +115,12 @@ export const EQUIPMENT_STAT_CATEGORIES = Object.freeze([
115 Object.freeze({
115 Object.freeze({
116 pieceKey: "shoes",
116 pieceKey: "shoes",
117 label: "Leather shoes",
117 label: "Leather shoes",
118 defaultBonus: 0,
118 /** Full agility; defence is half the matching metal tier (floored). */
119 resolveItemId: (tier) => (tier === "softLeather" ? LeatherItemId.leatherShoes : null)
119 defaultBonusByStat: Object.freeze({
120 [SkillId.agility]: "tier",
121 [SkillId.defence]: "tierHalf"
122 }),
123 resolveItemId: (tier) => leatherShoesItemId(tier)
120 })
124 })
121 ])
125 ])
122 })
126 })
@@ -407,6 +411,13 @@ function resolveDefaultBonusMode (mode, tier, row)
407 const extra = Number(row.defaultBonusExtra) || 0;
411 const extra = Number(row.defaultBonusExtra) || 0;
408 if (mode === "rank")
412 if (mode === "rank")
409 { return Math.max(0, Math.floor(tierRank(key) + extra)); }
413 { return Math.max(0, Math.floor(tierRank(key) + extra)); }
414 if (mode === "tierHalf")
415 {
416 const base = row.defaultBonus != null
417 ? Number(row.defaultBonus) || 0
418 : tierStatBonus(key);
419 return Math.max(0, Math.floor(base / 2) + extra);
420 }
410 if (mode === "tier" || mode == null)
421 if (mode === "tier" || mode == null)
411 {
422 {
412 const base = row.defaultBonus != null
423 const base = row.defaultBonus != null
shared/definitions/leatherItems.js +68 −24
@@ -23,7 +23,14 @@ export const LeatherItemId = Object.freeze({
23 23 clothShorts: 239,
24 24 /** @deprecated Prefer ClothItemId.cottonTrousers — kept for existing refs. */
25 25 clothTrousers: 240,
26 /** Soft-leather shoes (historic id). Prefer {@link leatherShoesItemId}. */
26 27 leatherShoes: 241,
28 hardLeatherShoes: 491,
29 studdedLeatherShoes: 492,
30 reinforcedLeatherShoes: 493,
31 scaledLeatherShoes: 494,
32 wyvernHideShoes: 495,
33 dragonhideShoes: 496,
27 34 steelStud: 242,
28 35 tanningBrew: 243
29 36 });
@@ -38,6 +45,16 @@ const LEATHER_MATERIAL_ID = Object.freeze({
38 45 [LeatherTier.dragonhide]: LeatherItemId.dragonhide
39 46 });
40 47
48 const LEATHER_SHOES_ID = Object.freeze({
49 [LeatherTier.softLeather]: LeatherItemId.leatherShoes,
50 [LeatherTier.hardLeather]: LeatherItemId.hardLeatherShoes,
51 [LeatherTier.studdedLeather]: LeatherItemId.studdedLeatherShoes,
52 [LeatherTier.reinforcedLeather]: LeatherItemId.reinforcedLeatherShoes,
53 [LeatherTier.scaledLeather]: LeatherItemId.scaledLeatherShoes,
54 [LeatherTier.wyvernHide]: LeatherItemId.wyvernHideShoes,
55 [LeatherTier.dragonhide]: LeatherItemId.dragonhideShoes
56 });
57
41 58 function leatherMaterialDef (itemId, tier, key)
42 59 {
43 60 const name = LEATHER_DISPLAY_NAME[tier] ?? tier;
@@ -60,6 +77,35 @@ function leatherMaterialDef (itemId, tier, key)
60 77 });
61 78 }
62 79
80 function leatherShoesDef (itemId, tier, key)
81 {
82 const name = LEATHER_DISPLAY_NAME[tier] ?? tier;
83 return Object.freeze({
84 itemId,
85 key,
86 displayName: `${name} shoes`,
87 description: `Simple ${name.toLowerCase()} shoes, broken in from long walks.`,
88 seedValue: 6,
89 stackable: false,
90 maxStackSize: 1,
91 uniqueInstance: false,
92 category: ItemCategory.finished,
93 iconKey: "clothing",
94 defaultState: "leather-shoes",
95 tier,
96 tintFromTier: true,
97 equipment: Object.freeze({
98 slot: "boots",
99 tier,
100 kind: EquipmentKind.leatherArmour,
101 bonus: 0,
102 minSkillLevel: tierMinSkillLevel(tier),
103 tintFromTier: true,
104 equipSprite: equipImageName("item", "clothing", "leather-shoes")
105 })
106 });
107 }
108
63 109 function buildLeatherMaterialDefinitions ()
64 110 {
65 111 const defs = {};
@@ -74,33 +120,26 @@ function buildLeatherMaterialDefinitions ()
74 120 return defs;
75 121 }
76 122
123 function buildLeatherShoesDefinitions ()
124 {
125 const defs = {};
126 for (const tier of LEATHER_TIER_ORDER)
127 {
128 const itemId = LEATHER_SHOES_ID[tier];
129 if (itemId == null)
130 { throw new Error(`Missing leather shoes item id for ${tier}`); }
131 const prefix = tier === LeatherTier.softLeather
132 ? "leather"
133 : tier.replace(/([A-Z])/g, "-$1").toLowerCase();
134 defs[itemId] = leatherShoesDef(itemId, tier, `${prefix}-shoes`);
135 }
136 return defs;
137 }
138
77 139 /** @type {Record<number, object>} */
78 140 export const LEATHER_ITEM_DEFINITIONS = Object.freeze({
79 141 ...buildLeatherMaterialDefinitions(),
80 [LeatherItemId.leatherShoes]: Object.freeze({
81 itemId: LeatherItemId.leatherShoes,
82 key: "leather-shoes",
83 displayName: "Leather shoes",
84 description: "Simple soft-leather shoes, broken in from long walks.",
85 seedValue: 6,
86 stackable: false,
87 maxStackSize: 1,
88 uniqueInstance: false,
89 category: ItemCategory.finished,
90 iconKey: "clothing",
91 defaultState: "leather-shoes",
92 tier: LeatherTier.softLeather,
93 tintFromTier: true,
94 equipment: Object.freeze({
95 slot: "boots",
96 tier: LeatherTier.softLeather,
97 kind: EquipmentKind.leatherArmour,
98 bonus: 0,
99 minSkillLevel: tierMinSkillLevel(LeatherTier.softLeather),
100 tintFromTier: true,
101 equipSprite: equipImageName("item", "clothing", "leather-shoes")
102 })
103 }),
142 ...buildLeatherShoesDefinitions(),
104 143 [LeatherItemId.steelStud]: Object.freeze({
105 144 itemId: LeatherItemId.steelStud,
106 145 key: "steel-stud",
@@ -134,3 +173,8 @@ export function leatherMaterialItemId (tier)
134 173 {
135 174 return LEATHER_MATERIAL_ID[tier] ?? null;
136 175 }
176
177 export function leatherShoesItemId (tier)
178 {
179 return LEATHER_SHOES_ID[tier] ?? null;
180 }
@@ -23,7 +23,14 @@ export const LeatherItemId = Object.freeze({
23 clothShorts: 239,
23 clothShorts: 239,
24 /** @deprecated Prefer ClothItemId.cottonTrousers — kept for existing refs. */
24 /** @deprecated Prefer ClothItemId.cottonTrousers — kept for existing refs. */
25 clothTrousers: 240,
25 clothTrousers: 240,
26 /** Soft-leather shoes (historic id). Prefer {@link leatherShoesItemId}. */
26 leatherShoes: 241,
27 leatherShoes: 241,
28 hardLeatherShoes: 491,
29 studdedLeatherShoes: 492,
30 reinforcedLeatherShoes: 493,
31 scaledLeatherShoes: 494,
32 wyvernHideShoes: 495,
33 dragonhideShoes: 496,
27 steelStud: 242,
34 steelStud: 242,
28 tanningBrew: 243
35 tanningBrew: 243
29});
36});
@@ -38,6 +45,16 @@ const LEATHER_MATERIAL_ID = Object.freeze({
38 [LeatherTier.dragonhide]: LeatherItemId.dragonhide
45 [LeatherTier.dragonhide]: LeatherItemId.dragonhide
39});
46});
40
47
48const LEATHER_SHOES_ID = Object.freeze({
49 [LeatherTier.softLeather]: LeatherItemId.leatherShoes,
50 [LeatherTier.hardLeather]: LeatherItemId.hardLeatherShoes,
51 [LeatherTier.studdedLeather]: LeatherItemId.studdedLeatherShoes,
52 [LeatherTier.reinforcedLeather]: LeatherItemId.reinforcedLeatherShoes,
53 [LeatherTier.scaledLeather]: LeatherItemId.scaledLeatherShoes,
54 [LeatherTier.wyvernHide]: LeatherItemId.wyvernHideShoes,
55 [LeatherTier.dragonhide]: LeatherItemId.dragonhideShoes
56});
57
41function leatherMaterialDef (itemId, tier, key)
58function leatherMaterialDef (itemId, tier, key)
42{
59{
43 const name = LEATHER_DISPLAY_NAME[tier] ?? tier;
60 const name = LEATHER_DISPLAY_NAME[tier] ?? tier;
@@ -60,6 +77,35 @@ function leatherMaterialDef (itemId, tier, key)
60 });
77 });
61}
78}
62
79
80function leatherShoesDef (itemId, tier, key)
81{
82 const name = LEATHER_DISPLAY_NAME[tier] ?? tier;
83 return Object.freeze({
84 itemId,
85 key,
86 displayName: `${name} shoes`,
87 description: `Simple ${name.toLowerCase()} shoes, broken in from long walks.`,
88 seedValue: 6,
89 stackable: false,
90 maxStackSize: 1,
91 uniqueInstance: false,
92 category: ItemCategory.finished,
93 iconKey: "clothing",
94 defaultState: "leather-shoes",
95 tier,
96 tintFromTier: true,
97 equipment: Object.freeze({
98 slot: "boots",
99 tier,
100 kind: EquipmentKind.leatherArmour,
101 bonus: 0,
102 minSkillLevel: tierMinSkillLevel(tier),
103 tintFromTier: true,
104 equipSprite: equipImageName("item", "clothing", "leather-shoes")
105 })
106 });
107}
108
63function buildLeatherMaterialDefinitions ()
109function buildLeatherMaterialDefinitions ()
64{
110{
65 const defs = {};
111 const defs = {};
@@ -74,33 +120,26 @@ function buildLeatherMaterialDefinitions ()
74 return defs;
120 return defs;
75}
121}
76
122
123function buildLeatherShoesDefinitions ()
124{
125 const defs = {};
126 for (const tier of LEATHER_TIER_ORDER)
127 {
128 const itemId = LEATHER_SHOES_ID[tier];
129 if (itemId == null)
130 { throw new Error(`Missing leather shoes item id for ${tier}`); }
131 const prefix = tier === LeatherTier.softLeather
132 ? "leather"
133 : tier.replace(/([A-Z])/g, "-$1").toLowerCase();
134 defs[itemId] = leatherShoesDef(itemId, tier, `${prefix}-shoes`);
135 }
136 return defs;
137}
138
77/** @type {Record<number, object>} */
139/** @type {Record<number, object>} */
78export const LEATHER_ITEM_DEFINITIONS = Object.freeze({
140export const LEATHER_ITEM_DEFINITIONS = Object.freeze({
79 ...buildLeatherMaterialDefinitions(),
141 ...buildLeatherMaterialDefinitions(),
80 [LeatherItemId.leatherShoes]: Object.freeze({
142 ...buildLeatherShoesDefinitions(),
81 itemId: LeatherItemId.leatherShoes,
82 key: "leather-shoes",
83 displayName: "Leather shoes",
84 description: "Simple soft-leather shoes, broken in from long walks.",
85 seedValue: 6,
86 stackable: false,
87 maxStackSize: 1,
88 uniqueInstance: false,
89 category: ItemCategory.finished,
90 iconKey: "clothing",
91 defaultState: "leather-shoes",
92 tier: LeatherTier.softLeather,
93 tintFromTier: true,
94 equipment: Object.freeze({
95 slot: "boots",
96 tier: LeatherTier.softLeather,
97 kind: EquipmentKind.leatherArmour,
98 bonus: 0,
99 minSkillLevel: tierMinSkillLevel(LeatherTier.softLeather),
100 tintFromTier: true,
101 equipSprite: equipImageName("item", "clothing", "leather-shoes")
102 })
103 }),
104 [LeatherItemId.steelStud]: Object.freeze({
143 [LeatherItemId.steelStud]: Object.freeze({
105 itemId: LeatherItemId.steelStud,
144 itemId: LeatherItemId.steelStud,
106 key: "steel-stud",
145 key: "steel-stud",
@@ -134,3 +173,8 @@ export function leatherMaterialItemId (tier)
134{
173{
135 return LEATHER_MATERIAL_ID[tier] ?? null;
174 return LEATHER_MATERIAL_ID[tier] ?? null;
136}
175}
176
177export function leatherShoesItemId (tier)
178{
179 return LEATHER_SHOES_ID[tier] ?? null;
180}