BlueGit

timfa questward

Add tiered cloth garments, creation clothing tab, and fix starter save.

Shirt/shorts/skirt/trousers craft from cloth per tier; character creation equips dyed cotton outfit atop world starter loadout; starter-equipment dirty detection accepts normalized loadout shapes again.

timfa Tim Falken · pushed by timfa

Authored 2026-08-27 · 2 months ago

Hash
08fdf3cc6c3cd3f33560b072a57e883dca8ab092
Parent
1ebea732
26 files changed +802 −177
client/assets/items/armour/boots.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/clothing/leather-shoes-equip.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/clothing/leather-shoes.png Binary file +0 −0

The contents of this binary file are not shown.

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

The contents of this binary file are not shown.

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

The contents of this binary file are not shown.

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

The contents of this binary file are not shown.

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

The contents of this binary file are not shown.

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

The contents of this binary file are not shown.

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

The contents of this binary file are not shown.

client/index.html +48 −17
@@ -541,24 +541,55 @@
541 541 </header>
542 542 <p id="create-error" class="error"></p>
543 543 <form id="create-form">
544 <label>First name <input id="first-name" required></label>
545 <label>Last name <input id="last-name" required></label>
546 <label>Sex
547 <select id="sex">
548 <option value="male">Male</option>
549 <option value="female">Female</option>
550 </select>
551 </label>
552 <div id="create-hair" class="hair-controls">
553 <canvas id="create-hair-preview" data-hair-preview width="64" height="96" aria-label="Character preview"></canvas>
554 <label>Hair
555 <select id="create-hair-style" data-hair-style></select>
556 </label>
557 <label>Hue <input id="create-hair-hue" data-hair-hue type="range" min="0" max="360" value="30"></label>
558 <label>Saturation <input id="create-hair-saturation" data-hair-saturation type="range" min="0" max="100" value="55"></label>
559 <label>Darkness <input id="create-hair-darkness" data-hair-darkness type="range" min="0" max="100" value="45"></label>
560 <span id="create-hair-swatch" data-hair-swatch class="hair-swatch" aria-hidden="true"></span>
544 <div class="create-tabs" role="tablist">
545 <button type="button" class="create-tab active" data-create-tab="appearance" role="tab" aria-selected="true">Appearance</button>
546 <button type="button" class="create-tab" data-create-tab="clothing" role="tab" aria-selected="false">Clothing</button>
561 547 </div>
548 <section class="create-pane" data-create-pane="appearance">
549 <label>First name <input id="first-name" required></label>
550 <label>Last name <input id="last-name" required></label>
551 <label>Sex
552 <select id="sex">
553 <option value="male">Male</option>
554 <option value="female">Female</option>
555 </select>
556 </label>
557 <div id="create-hair" class="hair-controls">
558 <canvas id="create-hair-preview" data-hair-preview width="64" height="96" aria-label="Character preview"></canvas>
559 <label>Hair
560 <select id="create-hair-style" data-hair-style></select>
561 </label>
562 <label>Hue <input id="create-hair-hue" data-hair-hue type="range" min="0" max="360" value="30"></label>
563 <label>Saturation <input id="create-hair-saturation" data-hair-saturation type="range" min="0" max="100" value="55"></label>
564 <label>Darkness <input id="create-hair-darkness" data-hair-darkness type="range" min="0" max="100" value="45"></label>
565 <span id="create-hair-swatch" data-hair-swatch class="hair-swatch" aria-hidden="true"></span>
566 </div>
567 </section>
568 <section class="create-pane" data-create-pane="clothing" hidden>
569 <div id="create-clothing" class="create-clothing">
570 <canvas id="create-clothing-preview" data-clothing-preview width="64" height="96" aria-label="Clothing preview"></canvas>
571 <div class="create-clothing-fields">
572 <label>Legs
573 <select data-create-legs></select>
574 </label>
575 <p class="hint">Cotton shirt is always included. Pick trousers, shorts, or a skirt.</p>
576 <fieldset class="create-dye-fieldset">
577 <legend>Shirt colour</legend>
578 <label>Hue <input data-shirt-hue type="range" min="0" max="360" value="30"></label>
579 <label>Saturation <input data-shirt-saturation type="range" min="0" max="100" value="55"></label>
580 <label>Darkness <input data-shirt-darkness type="range" min="0" max="100" value="45"></label>
581 <span data-shirt-swatch class="hair-swatch" aria-hidden="true"></span>
582 </fieldset>
583 <fieldset class="create-dye-fieldset">
584 <legend>Legs colour</legend>
585 <label>Hue <input data-legs-hue type="range" min="0" max="360" value="210"></label>
586 <label>Saturation <input data-legs-saturation type="range" min="0" max="100" value="55"></label>
587 <label>Darkness <input data-legs-darkness type="range" min="0" max="100" value="45"></label>
588 <span data-legs-swatch class="hair-swatch" aria-hidden="true"></span>
589 </fieldset>
590 </div>
591 </div>
592 </section>
562 593 <button type="submit">Create &amp; play</button>
563 594 </form>
564 595 </aside>
@@ -541,24 +541,55 @@
541 </header>
541 </header>
542 <p id="create-error" class="error"></p>
542 <p id="create-error" class="error"></p>
543 <form id="create-form">
543 <form id="create-form">
544 <label>First name <input id="first-name" required></label>
544 <div class="create-tabs" role="tablist">
545 <label>Last name <input id="last-name" required></label>
545 <button type="button" class="create-tab active" data-create-tab="appearance" role="tab" aria-selected="true">Appearance</button>
546 <label>Sex
546 <button type="button" class="create-tab" data-create-tab="clothing" role="tab" aria-selected="false">Clothing</button>
547 <select id="sex">
548 <option value="male">Male</option>
549 <option value="female">Female</option>
550 </select>
551 </label>
552 <div id="create-hair" class="hair-controls">
553 <canvas id="create-hair-preview" data-hair-preview width="64" height="96" aria-label="Character preview"></canvas>
554 <label>Hair
555 <select id="create-hair-style" data-hair-style></select>
556 </label>
557 <label>Hue <input id="create-hair-hue" data-hair-hue type="range" min="0" max="360" value="30"></label>
558 <label>Saturation <input id="create-hair-saturation" data-hair-saturation type="range" min="0" max="100" value="55"></label>
559 <label>Darkness <input id="create-hair-darkness" data-hair-darkness type="range" min="0" max="100" value="45"></label>
560 <span id="create-hair-swatch" data-hair-swatch class="hair-swatch" aria-hidden="true"></span>
561 </div>
547 </div>
548 <section class="create-pane" data-create-pane="appearance">
549 <label>First name <input id="first-name" required></label>
550 <label>Last name <input id="last-name" required></label>
551 <label>Sex
552 <select id="sex">
553 <option value="male">Male</option>
554 <option value="female">Female</option>
555 </select>
556 </label>
557 <div id="create-hair" class="hair-controls">
558 <canvas id="create-hair-preview" data-hair-preview width="64" height="96" aria-label="Character preview"></canvas>
559 <label>Hair
560 <select id="create-hair-style" data-hair-style></select>
561 </label>
562 <label>Hue <input id="create-hair-hue" data-hair-hue type="range" min="0" max="360" value="30"></label>
563 <label>Saturation <input id="create-hair-saturation" data-hair-saturation type="range" min="0" max="100" value="55"></label>
564 <label>Darkness <input id="create-hair-darkness" data-hair-darkness type="range" min="0" max="100" value="45"></label>
565 <span id="create-hair-swatch" data-hair-swatch class="hair-swatch" aria-hidden="true"></span>
566 </div>
567 </section>
568 <section class="create-pane" data-create-pane="clothing" hidden>
569 <div id="create-clothing" class="create-clothing">
570 <canvas id="create-clothing-preview" data-clothing-preview width="64" height="96" aria-label="Clothing preview"></canvas>
571 <div class="create-clothing-fields">
572 <label>Legs
573 <select data-create-legs></select>
574 </label>
575 <p class="hint">Cotton shirt is always included. Pick trousers, shorts, or a skirt.</p>
576 <fieldset class="create-dye-fieldset">
577 <legend>Shirt colour</legend>
578 <label>Hue <input data-shirt-hue type="range" min="0" max="360" value="30"></label>
579 <label>Saturation <input data-shirt-saturation type="range" min="0" max="100" value="55"></label>
580 <label>Darkness <input data-shirt-darkness type="range" min="0" max="100" value="45"></label>
581 <span data-shirt-swatch class="hair-swatch" aria-hidden="true"></span>
582 </fieldset>
583 <fieldset class="create-dye-fieldset">
584 <legend>Legs colour</legend>
585 <label>Hue <input data-legs-hue type="range" min="0" max="360" value="210"></label>
586 <label>Saturation <input data-legs-saturation type="range" min="0" max="100" value="55"></label>
587 <label>Darkness <input data-legs-darkness type="range" min="0" max="100" value="45"></label>
588 <span data-legs-swatch class="hair-swatch" aria-hidden="true"></span>
589 </fieldset>
590 </div>
591 </div>
592 </section>
562 <button type="submit">Create &amp; play</button>
593 <button type="submit">Create &amp; play</button>
563 </form>
594 </form>
564 </aside>
595 </aside>
client/src/play/createClothingControls.js added +131 −0
@@ -0,0 +1,131 @@
1 import {
2 DEFAULT_HAIR_HUE,
3 DEFAULT_HAIR_SATURATION,
4 DEFAULT_HAIR_DARKNESS,
5 normalizeHairSliders,
6 hairColorFromSliders
7 } from "/shared/appearance/hair.js";
8 import {
9 CreationLegsKind,
10 CREATION_LEGS_KINDS,
11 defaultCreateClothing,
12 normalizeCreateClothing,
13 creationClothingPreviewBag
14 } from "/shared/items/createClothing.js";
15
16 const LEGS_LABELS = Object.freeze({
17 [CreationLegsKind.shorts]: "Shorts",
18 [CreationLegsKind.skirt]: "Skirt",
19 [CreationLegsKind.trousers]: "Trousers"
20 });
21
22 /**
23 * Character-creation clothing tab: cotton shirt + legs choice, HSL dyes per piece.
24 */
25 export function bindCreateClothingControls ({
26 root,
27 onChange = null
28 })
29 {
30 const legsSelect = root.querySelector("[data-create-legs]");
31 const shirtHue = root.querySelector("[data-shirt-hue]");
32 const shirtSat = root.querySelector("[data-shirt-saturation]");
33 const shirtDark = root.querySelector("[data-shirt-darkness]");
34 const shirtSwatch = root.querySelector("[data-shirt-swatch]");
35 const legsHue = root.querySelector("[data-legs-hue]");
36 const legsSat = root.querySelector("[data-legs-saturation]");
37 const legsDark = root.querySelector("[data-legs-darkness]");
38 const legsSwatch = root.querySelector("[data-legs-swatch]");
39
40 function fillLegs ()
41 {
42 if (!legsSelect)
43 { return; }
44 const selected = legsSelect.value || CreationLegsKind.trousers;
45 legsSelect.replaceChildren();
46 for (const kind of CREATION_LEGS_KINDS)
47 {
48 const option = document.createElement("option");
49 option.value = kind;
50 option.textContent = LEGS_LABELS[kind] ?? kind;
51 legsSelect.append(option);
52 }
53 legsSelect.value = CREATION_LEGS_KINDS.includes(selected)
54 ? selected
55 : CreationLegsKind.trousers;
56 }
57
58 function readSliders (hueEl, satEl, darkEl, fallback)
59 {
60 return normalizeHairSliders({
61 hue: hueEl?.value ?? fallback.hue,
62 saturation: Number(satEl?.value ?? fallback.saturation * 100) / 100,
63 darkness: Number(darkEl?.value ?? fallback.darkness * 100) / 100
64 });
65 }
66
67 function currentClothing ()
68 {
69 const defaults = defaultCreateClothing();
70 return normalizeCreateClothing({
71 legsKind: legsSelect?.value ?? defaults.legsKind,
72 shirt: readSliders(shirtHue, shirtSat, shirtDark, defaults.shirt),
73 legs: readSliders(legsHue, legsSat, legsDark, defaults.legs)
74 });
75 }
76
77 function syncSwatch (el, sliders)
78 {
79 if (!el)
80 { return; }
81 const color = hairColorFromSliders(sliders);
82 el.style.background = `rgb(${Math.round(color.r * 255)}, ${Math.round(color.g * 255)}, ${Math.round(color.b * 255)})`;
83 }
84
85 function applyDefaults ()
86 {
87 const defaults = defaultCreateClothing();
88 fillLegs();
89 if (legsSelect)
90 { legsSelect.value = defaults.legsKind; }
91 if (shirtHue)
92 { shirtHue.value = String(Math.round(defaults.shirt.hue)); }
93 if (shirtSat)
94 { shirtSat.value = String(Math.round(defaults.shirt.saturation * 100)); }
95 if (shirtDark)
96 { shirtDark.value = String(Math.round(defaults.shirt.darkness * 100)); }
97 if (legsHue)
98 { legsHue.value = String(Math.round(defaults.legs.hue)); }
99 if (legsSat)
100 { legsSat.value = String(Math.round(defaults.legs.saturation * 100)); }
101 if (legsDark)
102 { legsDark.value = String(Math.round(defaults.legs.darkness * 100)); }
103 }
104
105 function refresh ()
106 {
107 const clothing = currentClothing();
108 syncSwatch(shirtSwatch, clothing.shirt);
109 syncSwatch(legsSwatch, clothing.legs);
110 onChange?.(clothing);
111 }
112
113 function previewBag ()
114 {
115 return creationClothingPreviewBag(currentClothing());
116 }
117
118 applyDefaults();
119 for (const el of [legsSelect, shirtHue, shirtSat, shirtDark, legsHue, legsSat, legsDark])
120 { el?.addEventListener("input", () => refresh()); }
121 refresh();
122
123 return {
124 currentClothing,
125 previewBag,
126 refresh,
127 applyDefaults
128 };
129 }
130
131 export { CreationLegsKind, DEFAULT_HAIR_HUE, DEFAULT_HAIR_SATURATION, DEFAULT_HAIR_DARKNESS };
@@ -0,0 +1,131 @@
1import {
2 DEFAULT_HAIR_HUE,
3 DEFAULT_HAIR_SATURATION,
4 DEFAULT_HAIR_DARKNESS,
5 normalizeHairSliders,
6 hairColorFromSliders
7} from "/shared/appearance/hair.js";
8import {
9 CreationLegsKind,
10 CREATION_LEGS_KINDS,
11 defaultCreateClothing,
12 normalizeCreateClothing,
13 creationClothingPreviewBag
14} from "/shared/items/createClothing.js";
15
16const LEGS_LABELS = Object.freeze({
17 [CreationLegsKind.shorts]: "Shorts",
18 [CreationLegsKind.skirt]: "Skirt",
19 [CreationLegsKind.trousers]: "Trousers"
20});
21
22/**
23 * Character-creation clothing tab: cotton shirt + legs choice, HSL dyes per piece.
24 */
25export function bindCreateClothingControls ({
26 root,
27 onChange = null
28})
29{
30 const legsSelect = root.querySelector("[data-create-legs]");
31 const shirtHue = root.querySelector("[data-shirt-hue]");
32 const shirtSat = root.querySelector("[data-shirt-saturation]");
33 const shirtDark = root.querySelector("[data-shirt-darkness]");
34 const shirtSwatch = root.querySelector("[data-shirt-swatch]");
35 const legsHue = root.querySelector("[data-legs-hue]");
36 const legsSat = root.querySelector("[data-legs-saturation]");
37 const legsDark = root.querySelector("[data-legs-darkness]");
38 const legsSwatch = root.querySelector("[data-legs-swatch]");
39
40 function fillLegs ()
41 {
42 if (!legsSelect)
43 { return; }
44 const selected = legsSelect.value || CreationLegsKind.trousers;
45 legsSelect.replaceChildren();
46 for (const kind of CREATION_LEGS_KINDS)
47 {
48 const option = document.createElement("option");
49 option.value = kind;
50 option.textContent = LEGS_LABELS[kind] ?? kind;
51 legsSelect.append(option);
52 }
53 legsSelect.value = CREATION_LEGS_KINDS.includes(selected)
54 ? selected
55 : CreationLegsKind.trousers;
56 }
57
58 function readSliders (hueEl, satEl, darkEl, fallback)
59 {
60 return normalizeHairSliders({
61 hue: hueEl?.value ?? fallback.hue,
62 saturation: Number(satEl?.value ?? fallback.saturation * 100) / 100,
63 darkness: Number(darkEl?.value ?? fallback.darkness * 100) / 100
64 });
65 }
66
67 function currentClothing ()
68 {
69 const defaults = defaultCreateClothing();
70 return normalizeCreateClothing({
71 legsKind: legsSelect?.value ?? defaults.legsKind,
72 shirt: readSliders(shirtHue, shirtSat, shirtDark, defaults.shirt),
73 legs: readSliders(legsHue, legsSat, legsDark, defaults.legs)
74 });
75 }
76
77 function syncSwatch (el, sliders)
78 {
79 if (!el)
80 { return; }
81 const color = hairColorFromSliders(sliders);
82 el.style.background = `rgb(${Math.round(color.r * 255)}, ${Math.round(color.g * 255)}, ${Math.round(color.b * 255)})`;
83 }
84
85 function applyDefaults ()
86 {
87 const defaults = defaultCreateClothing();
88 fillLegs();
89 if (legsSelect)
90 { legsSelect.value = defaults.legsKind; }
91 if (shirtHue)
92 { shirtHue.value = String(Math.round(defaults.shirt.hue)); }
93 if (shirtSat)
94 { shirtSat.value = String(Math.round(defaults.shirt.saturation * 100)); }
95 if (shirtDark)
96 { shirtDark.value = String(Math.round(defaults.shirt.darkness * 100)); }
97 if (legsHue)
98 { legsHue.value = String(Math.round(defaults.legs.hue)); }
99 if (legsSat)
100 { legsSat.value = String(Math.round(defaults.legs.saturation * 100)); }
101 if (legsDark)
102 { legsDark.value = String(Math.round(defaults.legs.darkness * 100)); }
103 }
104
105 function refresh ()
106 {
107 const clothing = currentClothing();
108 syncSwatch(shirtSwatch, clothing.shirt);
109 syncSwatch(legsSwatch, clothing.legs);
110 onChange?.(clothing);
111 }
112
113 function previewBag ()
114 {
115 return creationClothingPreviewBag(currentClothing());
116 }
117
118 applyDefaults();
119 for (const el of [legsSelect, shirtHue, shirtSat, shirtDark, legsHue, legsSat, legsDark])
120 { el?.addEventListener("input", () => refresh()); }
121 refresh();
122
123 return {
124 currentClothing,
125 previewBag,
126 refresh,
127 applyDefaults
128 };
129}
130
131export { CreationLegsKind, DEFAULT_HAIR_HUE, DEFAULT_HAIR_SATURATION, DEFAULT_HAIR_DARKNESS };
client/src/play/main.js +76 −2
@@ -25,6 +25,8 @@ import { initMarket } from "./market.js";
25 25 import { initBounty } from "./bounty.js";
26 26 import { initBarber } from "./barber.js";
27 27 import { bindHairControls } from "./hairControls.js";
28 import { bindCreateClothingControls } from "./createClothingControls.js";
29 import { paintCharacterPreview } from "./characterPreview.js";
28 30 import { initGraphicsSettings } from "./graphicsSettings.js";
29 31 import { CraftingStationId } from "/shared/definitions/craftingStations.js";
30 32 import { isOreBoulderState } from "/shared/definitions/materialTiers.js";
@@ -68,6 +70,8 @@ let market;
68 70 let bounty;
69 71 let barber;
70 72 let createHairControls;
73 let createClothingControls;
74 let createActiveTab = "appearance";
71 75 let pendingPickup = null;
72 76 /** @type {{ kind: "bank" | "doorway" | "cauldron" | "station" | "mine" | "chop", tileX: number, tileY: number, stationId?: string, getCheques?: boolean } | { kind: "talk", targetEntityId: number } | null } */
73 77 let pendingInteract = null;
@@ -995,14 +999,32 @@ async function main ()
995 999 return catalog?.images?.find((entry) => entry.name === name)?.url ?? null;
996 1000 },
997 1001 getSex: () => document.getElementById("sex")?.value ?? "male",
998 hideHeadgear: true
1002 getBag: () => null,
1003 hideHeadgear: true,
1004 onChange ()
1005 {
1006 if (createActiveTab === "clothing")
1007 { void refreshCreateClothingPreview(); }
1008 }
1009 });
1010 createClothingControls = bindCreateClothingControls({
1011 root: document.getElementById("create-clothing"),
1012 onChange ()
1013 {
1014 if (createActiveTab === "clothing")
1015 { void refreshCreateClothingPreview(); }
1016 }
999 1017 });
1018 initCreateTabs();
1000 1019 document.getElementById("sex")?.addEventListener("change", () =>
1001 1020 {
1002 1021 createHairControls?.fillStyles();
1003 1022 void createHairControls?.refreshPreview();
1023 if (createActiveTab === "clothing")
1024 { void refreshCreateClothingPreview(); }
1004 1025 });
1005 1026 void createHairControls?.refreshPreview();
1027 void refreshCreateClothingPreview();
1006 1028 graphicsSettingsUi = initGraphicsSettings({
1007 1029 onChange: applyGraphicsSettings,
1008 1030 onSuppressWorldClick: consumeWorldClick
@@ -1528,6 +1550,7 @@ document.getElementById("create-character-open")?.addEventListener("click", () =
1528 1550 { createError.textContent = ""; }
1529 1551 document.getElementById("create-backdrop").hidden = false;
1530 1552 document.getElementById("create-panel").hidden = false;
1553 setCreateTab("appearance");
1531 1554 void createHairControls?.refreshPreview();
1532 1555 });
1533 1556
@@ -1552,10 +1575,61 @@ document.getElementById("create-form").addEventListener("submit", (event) =>
1552 1575 firstName: document.getElementById("first-name").value,
1553 1576 lastName: document.getElementById("last-name").value,
1554 1577 sex: document.getElementById("sex").value,
1555 hair: createHairControls?.currentHair?.() ?? null
1578 hair: createHairControls?.currentHair?.() ?? null,
1579 clothing: createClothingControls?.currentClothing?.() ?? null
1556 1580 });
1557 1581 });
1558 1582
1583 function initCreateTabs ()
1584 {
1585 const tabs = document.querySelectorAll(".create-tab");
1586 for (const tab of tabs)
1587 {
1588 tab.addEventListener("click", () => setCreateTab(tab.dataset.createTab));
1589 }
1590 setCreateTab("appearance");
1591 }
1592
1593 function setCreateTab (name)
1594 {
1595 createActiveTab = name === "clothing" ? "clothing" : "appearance";
1596 for (const tab of document.querySelectorAll(".create-tab"))
1597 {
1598 const on = tab.dataset.createTab === createActiveTab;
1599 tab.classList.toggle("active", on);
1600 tab.setAttribute("aria-selected", on ? "true" : "false");
1601 }
1602 for (const pane of document.querySelectorAll("[data-create-pane]"))
1603 { pane.hidden = pane.dataset.createPane !== createActiveTab; }
1604 if (createActiveTab === "clothing")
1605 { void refreshCreateClothingPreview(); }
1606 else
1607 { void createHairControls?.refreshPreview(); }
1608 }
1609
1610 async function refreshCreateClothingPreview ()
1611 {
1612 const canvas = document.getElementById("create-clothing-preview");
1613 if (!canvas || !createClothingControls)
1614 { return; }
1615 try
1616 {
1617 await paintCharacterPreview(canvas, {
1618 sex: document.getElementById("sex")?.value ?? "male",
1619 bag: createClothingControls.previewBag(),
1620 hair: createHairControls?.currentHair?.() ?? null,
1621 hideHeadgear: true,
1622 resolveSpriteUrl (name)
1623 {
1624 return catalog?.images?.find((entry) => entry.name === name)?.url ?? null;
1625 },
1626 scale: 4
1627 });
1628 }
1629 catch (error)
1630 { console.warn(error); }
1631 }
1632
1559 1633 document.getElementById("leave").addEventListener("click", () =>
1560 1634 {
1561 1635 socket.send({ type: MessageType.leaveWorld });
@@ -25,6 +25,8 @@ import { initMarket } from "./market.js";
25import { initBounty } from "./bounty.js";
25import { initBounty } from "./bounty.js";
26import { initBarber } from "./barber.js";
26import { initBarber } from "./barber.js";
27import { bindHairControls } from "./hairControls.js";
27import { bindHairControls } from "./hairControls.js";
28import { bindCreateClothingControls } from "./createClothingControls.js";
29import { paintCharacterPreview } from "./characterPreview.js";
28import { initGraphicsSettings } from "./graphicsSettings.js";
30import { initGraphicsSettings } from "./graphicsSettings.js";
29import { CraftingStationId } from "/shared/definitions/craftingStations.js";
31import { CraftingStationId } from "/shared/definitions/craftingStations.js";
30import { isOreBoulderState } from "/shared/definitions/materialTiers.js";
32import { isOreBoulderState } from "/shared/definitions/materialTiers.js";
@@ -68,6 +70,8 @@ let market;
68let bounty;
70let bounty;
69let barber;
71let barber;
70let createHairControls;
72let createHairControls;
73let createClothingControls;
74let createActiveTab = "appearance";
71let pendingPickup = null;
75let pendingPickup = null;
72/** @type {{ kind: "bank" | "doorway" | "cauldron" | "station" | "mine" | "chop", tileX: number, tileY: number, stationId?: string, getCheques?: boolean } | { kind: "talk", targetEntityId: number } | null } */
76/** @type {{ kind: "bank" | "doorway" | "cauldron" | "station" | "mine" | "chop", tileX: number, tileY: number, stationId?: string, getCheques?: boolean } | { kind: "talk", targetEntityId: number } | null } */
73let pendingInteract = null;
77let pendingInteract = null;
@@ -995,14 +999,32 @@ async function main ()
995 return catalog?.images?.find((entry) => entry.name === name)?.url ?? null;
999 return catalog?.images?.find((entry) => entry.name === name)?.url ?? null;
996 },
1000 },
997 getSex: () => document.getElementById("sex")?.value ?? "male",
1001 getSex: () => document.getElementById("sex")?.value ?? "male",
998 hideHeadgear: true
1002 getBag: () => null,
1003 hideHeadgear: true,
1004 onChange ()
1005 {
1006 if (createActiveTab === "clothing")
1007 { void refreshCreateClothingPreview(); }
1008 }
1009 });
1010 createClothingControls = bindCreateClothingControls({
1011 root: document.getElementById("create-clothing"),
1012 onChange ()
1013 {
1014 if (createActiveTab === "clothing")
1015 { void refreshCreateClothingPreview(); }
1016 }
999 });
1017 });
1018 initCreateTabs();
1000 document.getElementById("sex")?.addEventListener("change", () =>
1019 document.getElementById("sex")?.addEventListener("change", () =>
1001 {
1020 {
1002 createHairControls?.fillStyles();
1021 createHairControls?.fillStyles();
1003 void createHairControls?.refreshPreview();
1022 void createHairControls?.refreshPreview();
1023 if (createActiveTab === "clothing")
1024 { void refreshCreateClothingPreview(); }
1004 });
1025 });
1005 void createHairControls?.refreshPreview();
1026 void createHairControls?.refreshPreview();
1027 void refreshCreateClothingPreview();
1006 graphicsSettingsUi = initGraphicsSettings({
1028 graphicsSettingsUi = initGraphicsSettings({
1007 onChange: applyGraphicsSettings,
1029 onChange: applyGraphicsSettings,
1008 onSuppressWorldClick: consumeWorldClick
1030 onSuppressWorldClick: consumeWorldClick
@@ -1528,6 +1550,7 @@ document.getElementById("create-character-open")?.addEventListener("click", () =
1528 { createError.textContent = ""; }
1550 { createError.textContent = ""; }
1529 document.getElementById("create-backdrop").hidden = false;
1551 document.getElementById("create-backdrop").hidden = false;
1530 document.getElementById("create-panel").hidden = false;
1552 document.getElementById("create-panel").hidden = false;
1553 setCreateTab("appearance");
1531 void createHairControls?.refreshPreview();
1554 void createHairControls?.refreshPreview();
1532});
1555});
1533
1556
@@ -1552,10 +1575,61 @@ document.getElementById("create-form").addEventListener("submit", (event) =>
1552 firstName: document.getElementById("first-name").value,
1575 firstName: document.getElementById("first-name").value,
1553 lastName: document.getElementById("last-name").value,
1576 lastName: document.getElementById("last-name").value,
1554 sex: document.getElementById("sex").value,
1577 sex: document.getElementById("sex").value,
1555 hair: createHairControls?.currentHair?.() ?? null
1578 hair: createHairControls?.currentHair?.() ?? null,
1579 clothing: createClothingControls?.currentClothing?.() ?? null
1556 });
1580 });
1557});
1581});
1558
1582
1583function initCreateTabs ()
1584{
1585 const tabs = document.querySelectorAll(".create-tab");
1586 for (const tab of tabs)
1587 {
1588 tab.addEventListener("click", () => setCreateTab(tab.dataset.createTab));
1589 }
1590 setCreateTab("appearance");
1591}
1592
1593function setCreateTab (name)
1594{
1595 createActiveTab = name === "clothing" ? "clothing" : "appearance";
1596 for (const tab of document.querySelectorAll(".create-tab"))
1597 {
1598 const on = tab.dataset.createTab === createActiveTab;
1599 tab.classList.toggle("active", on);
1600 tab.setAttribute("aria-selected", on ? "true" : "false");
1601 }
1602 for (const pane of document.querySelectorAll("[data-create-pane]"))
1603 { pane.hidden = pane.dataset.createPane !== createActiveTab; }
1604 if (createActiveTab === "clothing")
1605 { void refreshCreateClothingPreview(); }
1606 else
1607 { void createHairControls?.refreshPreview(); }
1608}
1609
1610async function refreshCreateClothingPreview ()
1611{
1612 const canvas = document.getElementById("create-clothing-preview");
1613 if (!canvas || !createClothingControls)
1614 { return; }
1615 try
1616 {
1617 await paintCharacterPreview(canvas, {
1618 sex: document.getElementById("sex")?.value ?? "male",
1619 bag: createClothingControls.previewBag(),
1620 hair: createHairControls?.currentHair?.() ?? null,
1621 hideHeadgear: true,
1622 resolveSpriteUrl (name)
1623 {
1624 return catalog?.images?.find((entry) => entry.name === name)?.url ?? null;
1625 },
1626 scale: 4
1627 });
1628 }
1629 catch (error)
1630 { console.warn(error); }
1631}
1632
1559document.getElementById("leave").addEventListener("click", () =>
1633document.getElementById("leave").addEventListener("click", () =>
1560{
1634{
1561 socket.send({ type: MessageType.leaveWorld });
1635 socket.send({ type: MessageType.leaveWorld });
client/ui/play.css +59 −2
@@ -212,8 +212,8 @@ html, body {
212 212 top: 50%;
213 213 left: 50%;
214 214 transform: translate(-50%, -50%);
215 width: min(420px, 92vw);
216 max-height: min(90vh, 40rem);
215 width: min(480px, 94vw);
216 max-height: min(92vh, 44rem);
217 217 overflow: auto;
218 218 padding: 1rem 1.1rem 1.15rem;
219 219 border: 1px solid #3a4250;
@@ -246,6 +246,63 @@ html, body {
246 246 margin: 0.5rem 0;
247 247 }
248 248
249 .create-tabs {
250 display: flex;
251 gap: 0;
252 margin: 0.35rem 0 0.75rem;
253 border-bottom: 1px solid #2c3340;
254 }
255 .create-tab {
256 flex: 1 1 0;
257 border: 0;
258 border-radius: 0;
259 background: transparent;
260 color: #9aa3b2;
261 padding: 0.5rem 0.4rem;
262 }
263 .create-tab.active {
264 color: #e8e4d9;
265 background: #222833;
266 box-shadow: inset 0 -2px 0 #6a8cbf;
267 }
268 .create-clothing {
269 display: grid;
270 grid-template-columns: 72px 1fr;
271 gap: 0.65rem 0.75rem;
272 align-items: start;
273 }
274 .create-clothing canvas {
275 width: 64px;
276 height: 96px;
277 image-rendering: pixelated;
278 background: #0e1116;
279 border: 1px solid #2c3340;
280 }
281 .create-clothing-fields {
282 display: flex;
283 flex-direction: column;
284 gap: 0.35rem;
285 min-width: 0;
286 }
287 .create-dye-fieldset {
288 margin: 0.35rem 0 0;
289 padding: 0.45rem 0.55rem 0.55rem;
290 border: 1px solid #2c3340;
291 border-radius: 0.25rem;
292 }
293 .create-dye-fieldset legend {
294 padding: 0 0.25rem;
295 color: #9aa3b2;
296 font-size: 0.85rem;
297 }
298 .create-dye-fieldset label {
299 margin: 0.25rem 0;
300 }
301 .create-dye-fieldset input[type="range"] {
302 flex: 1 1 auto;
303 min-width: 0;
304 }
305
249 306 #create-panel #create-form > button[type="submit"] {
250 307 width: 100%;
251 308 margin-top: 0.75rem;
@@ -212,8 +212,8 @@ html, body {
212 top: 50%;
212 top: 50%;
213 left: 50%;
213 left: 50%;
214 transform: translate(-50%, -50%);
214 transform: translate(-50%, -50%);
215 width: min(420px, 92vw);
215 width: min(480px, 94vw);
216 max-height: min(90vh, 40rem);
216 max-height: min(92vh, 44rem);
217 overflow: auto;
217 overflow: auto;
218 padding: 1rem 1.1rem 1.15rem;
218 padding: 1rem 1.1rem 1.15rem;
219 border: 1px solid #3a4250;
219 border: 1px solid #3a4250;
@@ -246,6 +246,63 @@ html, body {
246 margin: 0.5rem 0;
246 margin: 0.5rem 0;
247}
247}
248
248
249.create-tabs {
250 display: flex;
251 gap: 0;
252 margin: 0.35rem 0 0.75rem;
253 border-bottom: 1px solid #2c3340;
254}
255.create-tab {
256 flex: 1 1 0;
257 border: 0;
258 border-radius: 0;
259 background: transparent;
260 color: #9aa3b2;
261 padding: 0.5rem 0.4rem;
262}
263.create-tab.active {
264 color: #e8e4d9;
265 background: #222833;
266 box-shadow: inset 0 -2px 0 #6a8cbf;
267}
268.create-clothing {
269 display: grid;
270 grid-template-columns: 72px 1fr;
271 gap: 0.65rem 0.75rem;
272 align-items: start;
273}
274.create-clothing canvas {
275 width: 64px;
276 height: 96px;
277 image-rendering: pixelated;
278 background: #0e1116;
279 border: 1px solid #2c3340;
280}
281.create-clothing-fields {
282 display: flex;
283 flex-direction: column;
284 gap: 0.35rem;
285 min-width: 0;
286}
287.create-dye-fieldset {
288 margin: 0.35rem 0 0;
289 padding: 0.45rem 0.55rem 0.55rem;
290 border: 1px solid #2c3340;
291 border-radius: 0.25rem;
292}
293.create-dye-fieldset legend {
294 padding: 0 0.25rem;
295 color: #9aa3b2;
296 font-size: 0.85rem;
297}
298.create-dye-fieldset label {
299 margin: 0.25rem 0;
300}
301.create-dye-fieldset input[type="range"] {
302 flex: 1 1 auto;
303 min-width: 0;
304}
305
249#create-panel #create-form > button[type="submit"] {
306#create-panel #create-form > button[type="submit"] {
250 width: 100%;
307 width: 100%;
251 margin-top: 0.75rem;
308 margin-top: 0.75rem;
docs/FEATURES.md +7 −7
@@ -100,8 +100,8 @@ Each entry is a short note on behaviour and where the code lives. Update this fi
100 100 ## Characters
101 101
102 102 **Status:** full
103 **Spec:** Unlimited characters per account, one in the world. First name is not globally unique; last name is globally unique per account; first+last unique per account, case-insensitive. Male/female body. Spawn requires an open tile. The login screen lists characters first; **Create Character** opens a modal and successful creation enters the world immediately. New characters receive **Starter Equipment** / inventory from live world settings (origin: “Received from the gods”); existing characters are unaffected.
104 **Code:** `server/src/characters/service.js`, `server/src/persistence/stateDb.js`, `shared/items/starterLoadout.js`, `client/index.html`
103 **Spec:** Unlimited characters per account, one in the world. First name is not globally unique; last name is globally unique per account; first+last unique per account, case-insensitive. Male/female body. Spawn requires an open tile. The login screen lists characters first; **Create Character** opens a modal (**Appearance** / **Clothing** tabs) and successful creation enters the world immediately. New characters receive **Starter Equipment** / inventory from live world settings (origin: “Received from the gods”), then **creation clothing** on top: cotton shirt + chosen cotton trousers/shorts/skirt, each with an HSL dye (same controls as hair). Existing characters are unaffected.
104 **Code:** `server/src/characters/service.js`, `server/src/persistence/stateDb.js`, `shared/items/starterLoadout.js`, `shared/items/createClothing.js`, `client/index.html`, `client/src/play/createClothingControls.js`
105 105
106 106 ## Character deletion and inheritance
107 107
@@ -241,7 +241,7 @@ Each entry is a short note on behaviour and where the code lives. Update this fi
241 241
242 242 **Status:** partial
243 243 **Spec:** Metal gear exists in seven material tiers (lowest → highest): **Bronze**, **Iron**, **Steel**, **Mithril**, **Adamantium**, **Orichalcum**, **Dragon**. Each has a **rank** (1–7), display **tint**, and equip min skill: 1 / 10 / 20 / 35 / 50 / 70 / 90. Mining a material requires **half** of that equip gate (ceil); smelting requires **75%** (ceil). **Worn combat bonuses** come from live world setting `equipmentStatBonuses` (editor **Equipment Stats** tab); defaults seed from `TIER_STAT_BONUS` (full helms +1 Defence). Leather armour can grant Agility and Defence independently; wizard armour Magic and Defence; clothing Defence. Magic casting uses worn Magic/Mind gear bonuses the same way physical combat uses Strength/Agility/Defence. Tools (pickaxes) gate on Mining and do not use the bonus tables. **Tin** and **copper** ores (no bronze ore) and **coal** use their associated bar tier for mine/smelt timing and gates (tin/copper → bronze, coal → steel). **Silver** and **Gold** are precious-only (ore + bars, no tools; silver mine/smelt like iron rank 2 / skill 10, gold like steel rank 3 / skill 20). **Wood tiers** (same gates/ranks): **Pine**, **Birch**, **Oak**, **Ebony**, **Lignum**, **Heartwood**, **Elder** (match metal ranks for hafts). **Cloth tiers** (same gates/ranks): **Cotton**, **Wool**, **Linen**, **Cashmere**, **Silk**, **Fairy silk**, **Dragonweave**. Logs/handles tint from shared `wood` sprites; **pine trees** are chopable resource nodes (more tree tiers later) — axe sprites (`items/axe`) match pickaxe style for woodcutting. Armour pieces share one set of overlays under `items/armour/` tinted per metal tier (no per-tier icon copies).
244 **Shared sprites + magenta tint:** one base sprite per shape under `items/metal` (`ore`, `bar`), `items/pickaxe`, `items/axe` (`axe`, `axe-head`, `axe-equip`), `items/wood` (`log`, `handle`), `items/cloth` (`wool`, `yarn`, `cloth`), `items/clothing` (`sweater`), boulder-ore, and **tables** (`blocks/table/0`–`15`); tintable pixels use magenta rules in `shared/render/tint.js`. Boulder ore states are catalog aliases of `boulder-ore.png` with per-material tint. Table states are `${woodTier}-${mask}` aliases of mask PNGs with wood-tier tint; tables autotile only with the same wood. Trees use per-season live + **`-stump`** PNGs (mandatory for every tree type).
244 **Shared sprites + magenta tint:** one base sprite per shape under `items/metal` (`ore`, `bar`), `items/pickaxe`, `items/axe` (`axe`, `axe-head`, `axe-equip`), `items/wood` (`log`, `handle`), `items/cloth` (`wool`, `yarn`, `cloth`), `items/clothing` (`shirt`, `shorts`, `skirt`, `greaves`/trousers, `sweater`), boulder-ore, and **tables** (`blocks/table/0`–`15`); tintable pixels use magenta rules in `shared/render/tint.js`. Boulder ore states are catalog aliases of `boulder-ore.png` with per-material tint. Table states are `${woodTier}-${mask}` aliases of mask PNGs with wood-tier tint; tables autotile only with the same wood. Trees use per-season live + **`-stump`** PNGs (mandatory for every tree type).
245 245 **TODO:** full combat gear catalog; more tree tiers / fishing / herbs; silver/gold jewelry / other precious recipes; cloth sources beyond cotton.
246 246 **Code:** `shared/definitions/materialTiers.js`, `shared/definitions/equipmentStatCategories.js`, `shared/render/tint.js`, `shared/definitions/metalItems.js`, `shared/definitions/woodItems.js`, `shared/equipment/stats.js`, tests in `server/tests/equipment.test.js`, `server/tests/mining.test.js`, `server/tests/tint.test.js`
247 247
@@ -253,8 +253,8 @@ Each entry is a short note on behaviour and where the code lives. Update this fi
253 253
254 254 ## Cloth, dyes, and tailoring
255 255
256 **Status:** partial (cotton loop + flower dyes + sweater live; higher cloth sources TBD)
257 **Spec:** **Cloth tiers** (same skill gates/ranks as metal/wood): Cotton, Wool, Linen, Cashmere, Silk, Fairy silk, Dragonweave. Shared magenta sprites under `items/cloth` (`wool` fibre, `yarn`, `cloth`) and `items/clothing` (`sweater` + equip) tinted per tier (or optional dye colour on clothing instances). **Spinning wheel** (Tailoring): fibre → yarn. **Loom**: yarn → cloth. **Tailor bench** UI is template-first: pick clothing template (sweater today; shirt/robe later) → cloth tier → optional dye from bag → sidebar shows resolved ingredients (sweater = 3 yarn). Crafted clothing can carry `instance.dyeColor`; otherwise material tint. **Flowers** (9 colours) brew 1:1 into **dye** bottles at a cauldron (needs **glass bottles** / `potion-0`). Two different dye colours mix paint-style (weighted by fill); bottle count follows inserted dyes; fill packs with overflow into the next bottle (extra glass only if overflow needs more bottles than inputs). Cannot mix flowers with dyes in one brew. Dye uses on tailor consume one fill level per craft.
256 **Status:** partial (cotton loop + flower dyes + shirt/shorts/skirt/trousers/sweater live; higher cloth sources TBD)
257 **Spec:** **Cloth tiers** (same skill gates/ranks as metal/wood): Cotton, Wool, Linen, Cashmere, Silk, Fairy silk, Dragonweave. Shared magenta sprites under `items/cloth` (`wool` fibre, `yarn`, `cloth`) and `items/clothing` (`shirt`, `shorts`, `skirt`, `trousers`, `sweater` + equip) tinted per tier (or optional dye colour on clothing instances). **Spinning wheel** (Tailoring): fibre → yarn. **Loom**: yarn → cloth. **Tailor bench** UI is template-first: pick clothing template (**shirt**, **shorts**, **skirt**, **trousers**, **sweater**) → cloth tier → optional dye from bag → sidebar shows resolved ingredients (shirt/shorts/skirt/trousers = **1 cloth**; sweater = 3 yarn). Skirts are not tight-fit (unlike shorts). Display names are tiered (`Cotton shirt`, …). Historic item id 5 remains the cotton shirt. Crafted clothing can carry `instance.dyeColor`; otherwise material tint. **Flowers** (9 colours) brew 1:1 into **dye** bottles at a cauldron (needs **glass bottles** / `potion-0`). Two different dye colours mix paint-style (weighted by fill); bottle count follows inserted dyes; fill packs with overflow into the next bottle (extra glass only if overflow needs more bottles than inputs). Cannot mix flowers with dyes in one brew. Dye uses on tailor consume one fill level per craft.
258 258 **TODO (sources):** shear animals / pick plants for wool–silk; fairy silk + dragonweave as mob drops later.
259 259 **Later design (document only for now):**
260 260 - **Wizard cloth gear** — robes and similar give Magic skill bonuses (`EquipmentKind.wizardCloth`).
@@ -333,8 +333,8 @@ Use later when deciding which ingredients fit which potions. Tiers: **2 / 3 / 3
333 333 ## Hair & barber
334 334
335 335 **Status:** full
336 **Spec:** Character creation picks a hair style (per sex body folder) plus hue/saturation/darkness; live preview tints magenta hair sprites. Hair is stored on the character and drawn as a head overlay unless headgear is worn (item defs may set `equipment.keepHair` to keep hair under a hat — none yet). Placeable **Barber** blocks reopen the same UI to restyle (preview hides headgear).
337 **Code:** `shared/appearance/hair.js`, `server/src/barber/service.js`, `client/src/play/hairControls.js`, `client/src/play/barber.js`, `client/assets/blocks/barber/`
336 **Spec:** Character creation **Appearance** tab picks a hair style (per sex body folder) plus hue/saturation/darkness; live preview tints magenta hair sprites (no clothing on that tab). The **Clothing** tab shows the same body/hair with cotton shirt + legs and per-piece dyes. Hair is stored on the character and drawn as a head overlay unless headgear is worn (item defs may set `equipment.keepHair` to keep hair under a hat — none yet). Placeable **Barber** blocks reopen the hair UI to restyle (preview hides headgear).
337 **Code:** `shared/appearance/hair.js`, `server/src/barber/service.js`, `client/src/play/hairControls.js`, `client/src/play/barber.js`, `client/src/play/createClothingControls.js`, `client/assets/blocks/barber/`
338 338
339 339 ## Bounty offices
340 340
@@ -100,8 +100,8 @@ Each entry is a short note on behaviour and where the code lives. Update this fi
100## Characters
100## Characters
101
101
102**Status:** full
102**Status:** full
103**Spec:** Unlimited characters per account, one in the world. First name is not globally unique; last name is globally unique per account; first+last unique per account, case-insensitive. Male/female body. Spawn requires an open tile. The login screen lists characters first; **Create Character** opens a modal and successful creation enters the world immediately. New characters receive **Starter Equipment** / inventory from live world settings (origin: “Received from the gods”); existing characters are unaffected.
103**Spec:** Unlimited characters per account, one in the world. First name is not globally unique; last name is globally unique per account; first+last unique per account, case-insensitive. Male/female body. Spawn requires an open tile. The login screen lists characters first; **Create Character** opens a modal (**Appearance** / **Clothing** tabs) and successful creation enters the world immediately. New characters receive **Starter Equipment** / inventory from live world settings (origin: “Received from the gods”), then **creation clothing** on top: cotton shirt + chosen cotton trousers/shorts/skirt, each with an HSL dye (same controls as hair). Existing characters are unaffected.
104**Code:** `server/src/characters/service.js`, `server/src/persistence/stateDb.js`, `shared/items/starterLoadout.js`, `client/index.html`
104**Code:** `server/src/characters/service.js`, `server/src/persistence/stateDb.js`, `shared/items/starterLoadout.js`, `shared/items/createClothing.js`, `client/index.html`, `client/src/play/createClothingControls.js`
105
105
106## Character deletion and inheritance
106## Character deletion and inheritance
107
107
@@ -241,7 +241,7 @@ Each entry is a short note on behaviour and where the code lives. Update this fi
241
241
242**Status:** partial
242**Status:** partial
243**Spec:** Metal gear exists in seven material tiers (lowest → highest): **Bronze**, **Iron**, **Steel**, **Mithril**, **Adamantium**, **Orichalcum**, **Dragon**. Each has a **rank** (1–7), display **tint**, and equip min skill: 1 / 10 / 20 / 35 / 50 / 70 / 90. Mining a material requires **half** of that equip gate (ceil); smelting requires **75%** (ceil). **Worn combat bonuses** come from live world setting `equipmentStatBonuses` (editor **Equipment Stats** tab); defaults seed from `TIER_STAT_BONUS` (full helms +1 Defence). Leather armour can grant Agility and Defence independently; wizard armour Magic and Defence; clothing Defence. Magic casting uses worn Magic/Mind gear bonuses the same way physical combat uses Strength/Agility/Defence. Tools (pickaxes) gate on Mining and do not use the bonus tables. **Tin** and **copper** ores (no bronze ore) and **coal** use their associated bar tier for mine/smelt timing and gates (tin/copper → bronze, coal → steel). **Silver** and **Gold** are precious-only (ore + bars, no tools; silver mine/smelt like iron rank 2 / skill 10, gold like steel rank 3 / skill 20). **Wood tiers** (same gates/ranks): **Pine**, **Birch**, **Oak**, **Ebony**, **Lignum**, **Heartwood**, **Elder** (match metal ranks for hafts). **Cloth tiers** (same gates/ranks): **Cotton**, **Wool**, **Linen**, **Cashmere**, **Silk**, **Fairy silk**, **Dragonweave**. Logs/handles tint from shared `wood` sprites; **pine trees** are chopable resource nodes (more tree tiers later) — axe sprites (`items/axe`) match pickaxe style for woodcutting. Armour pieces share one set of overlays under `items/armour/` tinted per metal tier (no per-tier icon copies).
243**Spec:** Metal gear exists in seven material tiers (lowest → highest): **Bronze**, **Iron**, **Steel**, **Mithril**, **Adamantium**, **Orichalcum**, **Dragon**. Each has a **rank** (1–7), display **tint**, and equip min skill: 1 / 10 / 20 / 35 / 50 / 70 / 90. Mining a material requires **half** of that equip gate (ceil); smelting requires **75%** (ceil). **Worn combat bonuses** come from live world setting `equipmentStatBonuses` (editor **Equipment Stats** tab); defaults seed from `TIER_STAT_BONUS` (full helms +1 Defence). Leather armour can grant Agility and Defence independently; wizard armour Magic and Defence; clothing Defence. Magic casting uses worn Magic/Mind gear bonuses the same way physical combat uses Strength/Agility/Defence. Tools (pickaxes) gate on Mining and do not use the bonus tables. **Tin** and **copper** ores (no bronze ore) and **coal** use their associated bar tier for mine/smelt timing and gates (tin/copper → bronze, coal → steel). **Silver** and **Gold** are precious-only (ore + bars, no tools; silver mine/smelt like iron rank 2 / skill 10, gold like steel rank 3 / skill 20). **Wood tiers** (same gates/ranks): **Pine**, **Birch**, **Oak**, **Ebony**, **Lignum**, **Heartwood**, **Elder** (match metal ranks for hafts). **Cloth tiers** (same gates/ranks): **Cotton**, **Wool**, **Linen**, **Cashmere**, **Silk**, **Fairy silk**, **Dragonweave**. Logs/handles tint from shared `wood` sprites; **pine trees** are chopable resource nodes (more tree tiers later) — axe sprites (`items/axe`) match pickaxe style for woodcutting. Armour pieces share one set of overlays under `items/armour/` tinted per metal tier (no per-tier icon copies).
244**Shared sprites + magenta tint:** one base sprite per shape under `items/metal` (`ore`, `bar`), `items/pickaxe`, `items/axe` (`axe`, `axe-head`, `axe-equip`), `items/wood` (`log`, `handle`), `items/cloth` (`wool`, `yarn`, `cloth`), `items/clothing` (`sweater`), boulder-ore, and **tables** (`blocks/table/0`–`15`); tintable pixels use magenta rules in `shared/render/tint.js`. Boulder ore states are catalog aliases of `boulder-ore.png` with per-material tint. Table states are `${woodTier}-${mask}` aliases of mask PNGs with wood-tier tint; tables autotile only with the same wood. Trees use per-season live + **`-stump`** PNGs (mandatory for every tree type).
244**Shared sprites + magenta tint:** one base sprite per shape under `items/metal` (`ore`, `bar`), `items/pickaxe`, `items/axe` (`axe`, `axe-head`, `axe-equip`), `items/wood` (`log`, `handle`), `items/cloth` (`wool`, `yarn`, `cloth`), `items/clothing` (`shirt`, `shorts`, `skirt`, `greaves`/trousers, `sweater`), boulder-ore, and **tables** (`blocks/table/0`–`15`); tintable pixels use magenta rules in `shared/render/tint.js`. Boulder ore states are catalog aliases of `boulder-ore.png` with per-material tint. Table states are `${woodTier}-${mask}` aliases of mask PNGs with wood-tier tint; tables autotile only with the same wood. Trees use per-season live + **`-stump`** PNGs (mandatory for every tree type).
245**TODO:** full combat gear catalog; more tree tiers / fishing / herbs; silver/gold jewelry / other precious recipes; cloth sources beyond cotton.
245**TODO:** full combat gear catalog; more tree tiers / fishing / herbs; silver/gold jewelry / other precious recipes; cloth sources beyond cotton.
246**Code:** `shared/definitions/materialTiers.js`, `shared/definitions/equipmentStatCategories.js`, `shared/render/tint.js`, `shared/definitions/metalItems.js`, `shared/definitions/woodItems.js`, `shared/equipment/stats.js`, tests in `server/tests/equipment.test.js`, `server/tests/mining.test.js`, `server/tests/tint.test.js`
246**Code:** `shared/definitions/materialTiers.js`, `shared/definitions/equipmentStatCategories.js`, `shared/render/tint.js`, `shared/definitions/metalItems.js`, `shared/definitions/woodItems.js`, `shared/equipment/stats.js`, tests in `server/tests/equipment.test.js`, `server/tests/mining.test.js`, `server/tests/tint.test.js`
247
247
@@ -253,8 +253,8 @@ Each entry is a short note on behaviour and where the code lives. Update this fi
253
253
254## Cloth, dyes, and tailoring
254## Cloth, dyes, and tailoring
255
255
256**Status:** partial (cotton loop + flower dyes + sweater live; higher cloth sources TBD)
256**Status:** partial (cotton loop + flower dyes + shirt/shorts/skirt/trousers/sweater live; higher cloth sources TBD)
257**Spec:** **Cloth tiers** (same skill gates/ranks as metal/wood): Cotton, Wool, Linen, Cashmere, Silk, Fairy silk, Dragonweave. Shared magenta sprites under `items/cloth` (`wool` fibre, `yarn`, `cloth`) and `items/clothing` (`sweater` + equip) tinted per tier (or optional dye colour on clothing instances). **Spinning wheel** (Tailoring): fibre → yarn. **Loom**: yarn → cloth. **Tailor bench** UI is template-first: pick clothing template (sweater today; shirt/robe later) → cloth tier → optional dye from bag → sidebar shows resolved ingredients (sweater = 3 yarn). Crafted clothing can carry `instance.dyeColor`; otherwise material tint. **Flowers** (9 colours) brew 1:1 into **dye** bottles at a cauldron (needs **glass bottles** / `potion-0`). Two different dye colours mix paint-style (weighted by fill); bottle count follows inserted dyes; fill packs with overflow into the next bottle (extra glass only if overflow needs more bottles than inputs). Cannot mix flowers with dyes in one brew. Dye uses on tailor consume one fill level per craft.
257**Spec:** **Cloth tiers** (same skill gates/ranks as metal/wood): Cotton, Wool, Linen, Cashmere, Silk, Fairy silk, Dragonweave. Shared magenta sprites under `items/cloth` (`wool` fibre, `yarn`, `cloth`) and `items/clothing` (`shirt`, `shorts`, `skirt`, `trousers`, `sweater` + equip) tinted per tier (or optional dye colour on clothing instances). **Spinning wheel** (Tailoring): fibre → yarn. **Loom**: yarn → cloth. **Tailor bench** UI is template-first: pick clothing template (**shirt**, **shorts**, **skirt**, **trousers**, **sweater**) → cloth tier → optional dye from bag → sidebar shows resolved ingredients (shirt/shorts/skirt/trousers = **1 cloth**; sweater = 3 yarn). Skirts are not tight-fit (unlike shorts). Display names are tiered (`Cotton shirt`, …). Historic item id 5 remains the cotton shirt. Crafted clothing can carry `instance.dyeColor`; otherwise material tint. **Flowers** (9 colours) brew 1:1 into **dye** bottles at a cauldron (needs **glass bottles** / `potion-0`). Two different dye colours mix paint-style (weighted by fill); bottle count follows inserted dyes; fill packs with overflow into the next bottle (extra glass only if overflow needs more bottles than inputs). Cannot mix flowers with dyes in one brew. Dye uses on tailor consume one fill level per craft.
258**TODO (sources):** shear animals / pick plants for wool–silk; fairy silk + dragonweave as mob drops later.
258**TODO (sources):** shear animals / pick plants for wool–silk; fairy silk + dragonweave as mob drops later.
259**Later design (document only for now):**
259**Later design (document only for now):**
260- **Wizard cloth gear** — robes and similar give Magic skill bonuses (`EquipmentKind.wizardCloth`).
260- **Wizard cloth gear** — robes and similar give Magic skill bonuses (`EquipmentKind.wizardCloth`).
@@ -333,8 +333,8 @@ Use later when deciding which ingredients fit which potions. Tiers: **2 / 3 / 3
333## Hair & barber
333## Hair & barber
334
334
335**Status:** full
335**Status:** full
336**Spec:** Character creation picks a hair style (per sex body folder) plus hue/saturation/darkness; live preview tints magenta hair sprites. Hair is stored on the character and drawn as a head overlay unless headgear is worn (item defs may set `equipment.keepHair` to keep hair under a hat — none yet). Placeable **Barber** blocks reopen the same UI to restyle (preview hides headgear).
336**Spec:** Character creation **Appearance** tab picks a hair style (per sex body folder) plus hue/saturation/darkness; live preview tints magenta hair sprites (no clothing on that tab). The **Clothing** tab shows the same body/hair with cotton shirt + legs and per-piece dyes. Hair is stored on the character and drawn as a head overlay unless headgear is worn (item defs may set `equipment.keepHair` to keep hair under a hat — none yet). Placeable **Barber** blocks reopen the hair UI to restyle (preview hides headgear).
337**Code:** `shared/appearance/hair.js`, `server/src/barber/service.js`, `client/src/play/hairControls.js`, `client/src/play/barber.js`, `client/assets/blocks/barber/`
337**Code:** `shared/appearance/hair.js`, `server/src/barber/service.js`, `client/src/play/hairControls.js`, `client/src/play/barber.js`, `client/src/play/createClothingControls.js`, `client/assets/blocks/barber/`
338
338
339## Bounty offices
339## Bounty offices
340
340
server/src/characters/service.js +5 −2
@@ -6,6 +6,7 @@ import {
6 6 normalizeHairSliders,
7 7 normalizeHairStyle
8 8 } from "../../../shared/appearance/hair.js";
9 import { normalizeCreateClothing } from "../../../shared/items/createClothing.js";
9 10
10 11 export class CharacterService
11 12 {
@@ -20,7 +21,7 @@ export class CharacterService
20 21 return this.stateDb.listCharacters(accountId).map(publicCharacter);
21 22 }
22 23
23 create (account, firstName, lastName, sex, hair = null, starterSettings = null)
24 create (account, firstName, lastName, sex, hair = null, starterSettings = null, clothing = null)
24 25 {
25 26 const first = String(firstName ?? "").trim();
26 27 const last = String(lastName ?? "").trim();
@@ -40,6 +41,7 @@ export class CharacterService
40 41 { throw userError("You already have a character with that name."); }
41 42
42 43 const hairFields = normalizeCreateHair(sex, hair);
44 const clothingFields = normalizeCreateClothing(clothing);
43 45 const character = this.stateDb.createCharacter(
44 46 account.account_id,
45 47 first,
@@ -48,7 +50,8 @@ export class CharacterService
48 50 8,
49 51 8,
50 52 hairFields,
51 starterSettings
53 starterSettings,
54 clothingFields
52 55 );
53 56 return publicCharacter(character);
54 57 }
@@ -6,6 +6,7 @@ import {
6 normalizeHairSliders,
6 normalizeHairSliders,
7 normalizeHairStyle
7 normalizeHairStyle
8} from "../../../shared/appearance/hair.js";
8} from "../../../shared/appearance/hair.js";
9import { normalizeCreateClothing } from "../../../shared/items/createClothing.js";
9
10
10export class CharacterService
11export class CharacterService
11{
12{
@@ -20,7 +21,7 @@ export class CharacterService
20 return this.stateDb.listCharacters(accountId).map(publicCharacter);
21 return this.stateDb.listCharacters(accountId).map(publicCharacter);
21 }
22 }
22
23
23 create (account, firstName, lastName, sex, hair = null, starterSettings = null)
24 create (account, firstName, lastName, sex, hair = null, starterSettings = null, clothing = null)
24 {
25 {
25 const first = String(firstName ?? "").trim();
26 const first = String(firstName ?? "").trim();
26 const last = String(lastName ?? "").trim();
27 const last = String(lastName ?? "").trim();
@@ -40,6 +41,7 @@ export class CharacterService
40 { throw userError("You already have a character with that name."); }
41 { throw userError("You already have a character with that name."); }
41
42
42 const hairFields = normalizeCreateHair(sex, hair);
43 const hairFields = normalizeCreateHair(sex, hair);
44 const clothingFields = normalizeCreateClothing(clothing);
43 const character = this.stateDb.createCharacter(
45 const character = this.stateDb.createCharacter(
44 account.account_id,
46 account.account_id,
45 first,
47 first,
@@ -48,7 +50,8 @@ export class CharacterService
48 8,
50 8,
49 8,
51 8,
50 hairFields,
52 hairFields,
51 starterSettings
53 starterSettings,
54 clothingFields
52 );
55 );
53 return publicCharacter(character);
56 return publicCharacter(character);
54 }
57 }
server/src/gateway/websocket.js +2 −1
@@ -111,7 +111,8 @@ export function attachGateway ({ httpServer, auth, stateDb, characters, friends,
111 111 message.lastName,
112 112 message.sex,
113 113 message.hair ?? null,
114 simulation.settings
114 simulation.settings,
115 message.clothing ?? null
115 116 );
116 117 enterWorld(session, created.characterId);
117 118 }
@@ -111,7 +111,8 @@ export function attachGateway ({ httpServer, auth, stateDb, characters, friends,
111 message.lastName,
111 message.lastName,
112 message.sex,
112 message.sex,
113 message.hair ?? null,
113 message.hair ?? null,
114 simulation.settings
114 simulation.settings,
115 message.clothing ?? null
115 );
116 );
116 enterWorld(session, created.characterId);
117 enterWorld(session, created.characterId);
117 }
118 }
server/src/persistence/stateDb.js +4 −4
@@ -338,7 +338,7 @@ export class StateDatabase
338 338 return this.db.prepare("SELECT * FROM surname_claims WHERE surname_normalized = ?").get(surnameNormalized) ?? null;
339 339 }
340 340
341 createCharacter (accountId, firstName, lastName, sex, tileX, tileY, hair = null, starterSettings = null)
341 createCharacter (accountId, firstName, lastName, sex, tileX, tileY, hair = null, starterSettings = null, creationClothing = null)
342 342 {
343 343 const firstNormalized = normalizeName(firstName);
344 344 const lastNormalized = normalizeName(lastName);
@@ -380,7 +380,7 @@ export class StateDatabase
380 380 }
381 381
382 382 this.db.exec("COMMIT");
383 this.#ensureBag(characterId, starterSettings);
383 this.#ensureBag(characterId, starterSettings, creationClothing);
384 384 return this.getCharacter(characterId);
385 385 }
386 386 catch (error)
@@ -839,12 +839,12 @@ export class StateDatabase
839 839 }
840 840 }
841 841
842 #ensureBag (characterId, starterSettings = null)
842 #ensureBag (characterId, starterSettings = null, creationClothing = null)
843 843 {
844 844 const existing = this.db.prepare("SELECT * FROM character_bags WHERE character_id = ?").get(characterId);
845 845 if (existing)
846 846 { return parseBag(existing, characterId); }
847 const contents = buildStarterBagContents(starterSettings);
847 const contents = buildStarterBagContents(starterSettings, creationClothing);
848 848 this.db.prepare(`
849 849 INSERT INTO character_bags (
850 850 character_id, inventory_blob, equipment_blob, currency, vault_blob, vault_currency, skills_blob
@@ -338,7 +338,7 @@ export class StateDatabase
338 return this.db.prepare("SELECT * FROM surname_claims WHERE surname_normalized = ?").get(surnameNormalized) ?? null;
338 return this.db.prepare("SELECT * FROM surname_claims WHERE surname_normalized = ?").get(surnameNormalized) ?? null;
339 }
339 }
340
340
341 createCharacter (accountId, firstName, lastName, sex, tileX, tileY, hair = null, starterSettings = null)
341 createCharacter (accountId, firstName, lastName, sex, tileX, tileY, hair = null, starterSettings = null, creationClothing = null)
342 {
342 {
343 const firstNormalized = normalizeName(firstName);
343 const firstNormalized = normalizeName(firstName);
344 const lastNormalized = normalizeName(lastName);
344 const lastNormalized = normalizeName(lastName);
@@ -380,7 +380,7 @@ export class StateDatabase
380 }
380 }
381
381
382 this.db.exec("COMMIT");
382 this.db.exec("COMMIT");
383 this.#ensureBag(characterId, starterSettings);
383 this.#ensureBag(characterId, starterSettings, creationClothing);
384 return this.getCharacter(characterId);
384 return this.getCharacter(characterId);
385 }
385 }
386 catch (error)
386 catch (error)
@@ -839,12 +839,12 @@ export class StateDatabase
839 }
839 }
840 }
840 }
841
841
842 #ensureBag (characterId, starterSettings = null)
842 #ensureBag (characterId, starterSettings = null, creationClothing = null)
843 {
843 {
844 const existing = this.db.prepare("SELECT * FROM character_bags WHERE character_id = ?").get(characterId);
844 const existing = this.db.prepare("SELECT * FROM character_bags WHERE character_id = ?").get(characterId);
845 if (existing)
845 if (existing)
846 { return parseBag(existing, characterId); }
846 { return parseBag(existing, characterId); }
847 const contents = buildStarterBagContents(starterSettings);
847 const contents = buildStarterBagContents(starterSettings, creationClothing);
848 this.db.prepare(`
848 this.db.prepare(`
849 INSERT INTO character_bags (
849 INSERT INTO character_bags (
850 character_id, inventory_blob, equipment_blob, currency, vault_blob, vault_currency, skills_blob
850 character_id, inventory_blob, equipment_blob, currency, vault_blob, vault_currency, skills_blob
server/tests/inventory.test.js +3 −8
@@ -92,7 +92,7 @@ test("walkTilesPerSecond controls how many tiles move per simulated second", ()
92 92 { harness.close(); }
93 93 });
94 94
95 test("equip uses the item key-equip sprite for appearance layers", () =>
95 test("creation clothing equips cotton shirt with equip sprite", () =>
96 96 {
97 97 const harness = makeSimulation({ workerCount: 1 });
98 98 try
@@ -100,13 +100,8 @@ test("equip uses the item key-equip sprite for appearance layers", () =>
100 100 const character = makeCharacter(harness.stateDb);
101 101 const entityId = harness.simulation.spawnCharacter(1, character);
102 102 const bag = harness.simulation.bagOf(entityId);
103 const shirtSlot = bag.inventory.findIndex((slot) => slot?.itemId === ItemId.clothShirt);
104 harness.simulation.enqueue(1, {
105 type: "equip-item",
106 characterId: character.character_id,
107 slotIndex: shirtSlot
108 });
109 harness.simulation.step();
103 assert.equal(bag.equipment?.slots?.chest?.itemId, ItemId.clothShirt);
104 assert.ok(bag.equipment?.slots?.legs?.itemId);
110 105 const view = harness.simulation.entityRecord(entityId);
111 106 assert.ok(view.layers.some((layer) => layer.sprite === "item:clothing:shirt:equip"));
112 107 }
@@ -92,7 +92,7 @@ test("walkTilesPerSecond controls how many tiles move per simulated second", ()
92 { harness.close(); }
92 { harness.close(); }
93});
93});
94
94
95test("equip uses the item key-equip sprite for appearance layers", () =>
95test("creation clothing equips cotton shirt with equip sprite", () =>
96{
96{
97 const harness = makeSimulation({ workerCount: 1 });
97 const harness = makeSimulation({ workerCount: 1 });
98 try
98 try
@@ -100,13 +100,8 @@ test("equip uses the item key-equip sprite for appearance layers", () =>
100 const character = makeCharacter(harness.stateDb);
100 const character = makeCharacter(harness.stateDb);
101 const entityId = harness.simulation.spawnCharacter(1, character);
101 const entityId = harness.simulation.spawnCharacter(1, character);
102 const bag = harness.simulation.bagOf(entityId);
102 const bag = harness.simulation.bagOf(entityId);
103 const shirtSlot = bag.inventory.findIndex((slot) => slot?.itemId === ItemId.clothShirt);
103 assert.equal(bag.equipment?.slots?.chest?.itemId, ItemId.clothShirt);
104 harness.simulation.enqueue(1, {
104 assert.ok(bag.equipment?.slots?.legs?.itemId);
105 type: "equip-item",
106 characterId: character.character_id,
107 slotIndex: shirtSlot
108 });
109 harness.simulation.step();
110 const view = harness.simulation.entityRecord(entityId);
105 const view = harness.simulation.entityRecord(entityId);
111 assert.ok(view.layers.some((layer) => layer.sprite === "item:clothing:shirt:equip"));
106 assert.ok(view.layers.some((layer) => layer.sprite === "item:clothing:shirt:equip"));
112 }
107 }
server/tests/npc-equipment.test.js +5 −1
@@ -3,6 +3,8 @@ import assert from "node:assert/strict";
3 3 import { npcDefaultEquipment, npcClothDyeFromSeed, NPC_CLOTH_DYE_BYTE_MIN } from "../../shared/appearance/npcEquipment.js";
4 4 import { ItemId } from "../../shared/definitions/items.js";
5 5 import { LeatherItemId } from "../../shared/definitions/leatherItems.js";
6 import { clothTierForItemId } from "../../shared/definitions/clothItems.js";
7 import { itemDefinition } from "../../shared/definitions/items.js";
6 8 import { mobComponents } from "../src/simulation/spawners.js";
7 9 import { MobId } from "../../shared/definitions/mobs.js";
8 10
@@ -12,7 +14,9 @@ test("npcDefaultEquipment picks deterministic garments from display name", () =>
12 14 const b = npcDefaultEquipment("Ada Lovelace", "female");
13 15 assert.deepEqual(a, b);
14 16 assert.ok(a.chest?.itemId);
15 assert.ok([LeatherItemId.clothShorts, LeatherItemId.clothTrousers].includes(a.legs?.itemId));
17 assert.ok(clothTierForItemId(a.legs?.itemId));
18 const legsKey = itemDefinition(a.legs.itemId)?.key ?? "";
19 assert.ok(legsKey.endsWith("-shorts") || legsKey.endsWith("-skirt") || legsKey.endsWith("-trousers"));
16 20 assert.equal(a.boots?.itemId, LeatherItemId.leatherShoes);
17 21 assert.ok(a.chest.dyeColor);
18 22 assert.ok(a.legs.dyeColor);
@@ -3,6 +3,8 @@ import assert from "node:assert/strict";
3import { npcDefaultEquipment, npcClothDyeFromSeed, NPC_CLOTH_DYE_BYTE_MIN } from "../../shared/appearance/npcEquipment.js";
3import { npcDefaultEquipment, npcClothDyeFromSeed, NPC_CLOTH_DYE_BYTE_MIN } from "../../shared/appearance/npcEquipment.js";
4import { ItemId } from "../../shared/definitions/items.js";
4import { ItemId } from "../../shared/definitions/items.js";
5import { LeatherItemId } from "../../shared/definitions/leatherItems.js";
5import { LeatherItemId } from "../../shared/definitions/leatherItems.js";
6import { clothTierForItemId } from "../../shared/definitions/clothItems.js";
7import { itemDefinition } from "../../shared/definitions/items.js";
6import { mobComponents } from "../src/simulation/spawners.js";
8import { mobComponents } from "../src/simulation/spawners.js";
7import { MobId } from "../../shared/definitions/mobs.js";
9import { MobId } from "../../shared/definitions/mobs.js";
8
10
@@ -12,7 +14,9 @@ test("npcDefaultEquipment picks deterministic garments from display name", () =>
12 const b = npcDefaultEquipment("Ada Lovelace", "female");
14 const b = npcDefaultEquipment("Ada Lovelace", "female");
13 assert.deepEqual(a, b);
15 assert.deepEqual(a, b);
14 assert.ok(a.chest?.itemId);
16 assert.ok(a.chest?.itemId);
15 assert.ok([LeatherItemId.clothShorts, LeatherItemId.clothTrousers].includes(a.legs?.itemId));
17 assert.ok(clothTierForItemId(a.legs?.itemId));
18 const legsKey = itemDefinition(a.legs.itemId)?.key ?? "";
19 assert.ok(legsKey.endsWith("-shorts") || legsKey.endsWith("-skirt") || legsKey.endsWith("-trousers"));
16 assert.equal(a.boots?.itemId, LeatherItemId.leatherShoes);
20 assert.equal(a.boots?.itemId, LeatherItemId.leatherShoes);
17 assert.ok(a.chest.dyeColor);
21 assert.ok(a.chest.dyeColor);
18 assert.ok(a.legs.dyeColor);
22 assert.ok(a.legs.dyeColor);
shared/appearance/npcEquipment.js +9 −6
@@ -1,6 +1,5 @@
1 1 import { hashString } from "./hair.js";
2 import { ItemId } from "../definitions/items.js";
3 import { sweaterItemId } from "../definitions/clothItems.js";
2 import { sweaterItemId, shirtItemId, shortsItemId, skirtItemId, trousersItemId } from "../definitions/clothItems.js";
4 3 import { CLOTH_TIER_ORDER } from "../definitions/materialTiers.js";
5 4 import { LeatherItemId } from "../definitions/leatherItems.js";
6 5 import { normalizeRgb } from "../render/tint.js";
@@ -37,11 +36,15 @@ export function npcDefaultEquipment (displayName, sex = "male")
37 36 const chestTier = CLOTH_TIER_ORDER[(seed >>> 6) % CLOTH_TIER_ORDER.length];
38 37 const chestItemId = wantsSweater
39 38 ? sweaterItemId(chestTier)
40 : ItemId.clothShirt;
39 : shirtItemId(chestTier);
41 40
42 const legsItemId = (seed & 1) === 0
43 ? LeatherItemId.clothShorts
44 : LeatherItemId.clothTrousers;
41 const legsTier = CLOTH_TIER_ORDER[(seed >>> 18) % CLOTH_TIER_ORDER.length];
42 const legsRoll = seed % 3;
43 const legsItemId = legsRoll === 0
44 ? shortsItemId(legsTier)
45 : legsRoll === 1
46 ? skirtItemId(legsTier)
47 : trousersItemId(legsTier);
45 48
46 49 return {
47 50 chest: { itemId: chestItemId, dyeColor: npcClothDyeFromSeed(name, 1) },
@@ -1,6 +1,5 @@
1import { hashString } from "./hair.js";
1import { hashString } from "./hair.js";
2import { ItemId } from "../definitions/items.js";
2import { sweaterItemId, shirtItemId, shortsItemId, skirtItemId, trousersItemId } from "../definitions/clothItems.js";
3import { sweaterItemId } from "../definitions/clothItems.js";
4import { CLOTH_TIER_ORDER } from "../definitions/materialTiers.js";
3import { CLOTH_TIER_ORDER } from "../definitions/materialTiers.js";
5import { LeatherItemId } from "../definitions/leatherItems.js";
4import { LeatherItemId } from "../definitions/leatherItems.js";
6import { normalizeRgb } from "../render/tint.js";
5import { normalizeRgb } from "../render/tint.js";
@@ -37,11 +36,15 @@ export function npcDefaultEquipment (displayName, sex = "male")
37 const chestTier = CLOTH_TIER_ORDER[(seed >>> 6) % CLOTH_TIER_ORDER.length];
36 const chestTier = CLOTH_TIER_ORDER[(seed >>> 6) % CLOTH_TIER_ORDER.length];
38 const chestItemId = wantsSweater
37 const chestItemId = wantsSweater
39 ? sweaterItemId(chestTier)
38 ? sweaterItemId(chestTier)
40 : ItemId.clothShirt;
39 : shirtItemId(chestTier);
41
40
42 const legsItemId = (seed & 1) === 0
41 const legsTier = CLOTH_TIER_ORDER[(seed >>> 18) % CLOTH_TIER_ORDER.length];
43 ? LeatherItemId.clothShorts
42 const legsRoll = seed % 3;
44 : LeatherItemId.clothTrousers;
43 const legsItemId = legsRoll === 0
44 ? shortsItemId(legsTier)
45 : legsRoll === 1
46 ? skirtItemId(legsTier)
47 : trousersItemId(legsTier);
45
48
46 return {
49 return {
47 chest: { itemId: chestItemId, dyeColor: npcClothDyeFromSeed(name, 1) },
50 chest: { itemId: chestItemId, dyeColor: npcClothDyeFromSeed(name, 1) },
shared/definitions/clothItems.js +252 −28
@@ -12,6 +12,8 @@ import {
12 12 * Cloth family: raw fibre (wool sprite), yarn, woven cloth — shared magenta
13 13 * sprites under items/cloth/{wool,yarn,cloth}.png with per-tier tint.
14 14 * Cotton raw reuses CraftingItemId.wool (11); yarn/cloth reuse 12/25.
15 * Garments: shirt / shorts / skirt / trousers / sweater, all tiered + dyeable.
16 * Cotton shirt keeps historic ItemId 5; cotton shorts/trousers keep 239/240.
15 17 */
16 18 export const ClothItemId = Object.freeze({
17 19 cotton: 11,
@@ -41,7 +43,35 @@ export const ClothItemId = Object.freeze({
41 43 cashmereSweater: 154,
42 44 silkSweater: 155,
43 45 fairySilkSweater: 156,
44 dragonweaveSweater: 157
46 dragonweaveSweater: 157,
47 cottonShirt: 5,
48 woolShirt: 250,
49 linenShirt: 251,
50 cashmereShirt: 252,
51 silkShirt: 253,
52 fairySilkShirt: 254,
53 dragonweaveShirt: 255,
54 cottonShorts: 239,
55 woolShorts: 256,
56 linenShorts: 257,
57 cashmereShorts: 258,
58 silkShorts: 259,
59 fairySilkShorts: 260,
60 dragonweaveShorts: 261,
61 cottonTrousers: 240,
62 woolTrousers: 262,
63 linenTrousers: 263,
64 cashmereTrousers: 264,
65 silkTrousers: 265,
66 fairySilkTrousers: 266,
67 dragonweaveTrousers: 267,
68 cottonSkirt: 268,
69 woolSkirt: 269,
70 linenSkirt: 270,
71 cashmereSkirt: 271,
72 silkSkirt: 272,
73 fairySilkSkirt: 273,
74 dragonweaveSkirt: 274
45 75 });
46 76
47 77 const RAW_ID = Object.freeze({
@@ -84,8 +114,53 @@ const SWEATER_ID = Object.freeze({
84 114 [ClothTier.dragonweave]: ClothItemId.dragonweaveSweater
85 115 });
86 116
117 const SHIRT_ID = Object.freeze({
118 [ClothTier.cotton]: ClothItemId.cottonShirt,
119 [ClothTier.wool]: ClothItemId.woolShirt,
120 [ClothTier.linen]: ClothItemId.linenShirt,
121 [ClothTier.cashmere]: ClothItemId.cashmereShirt,
122 [ClothTier.silk]: ClothItemId.silkShirt,
123 [ClothTier.fairySilk]: ClothItemId.fairySilkShirt,
124 [ClothTier.dragonweave]: ClothItemId.dragonweaveShirt
125 });
126
127 const SHORTS_ID = Object.freeze({
128 [ClothTier.cotton]: ClothItemId.cottonShorts,
129 [ClothTier.wool]: ClothItemId.woolShorts,
130 [ClothTier.linen]: ClothItemId.linenShorts,
131 [ClothTier.cashmere]: ClothItemId.cashmereShorts,
132 [ClothTier.silk]: ClothItemId.silkShorts,
133 [ClothTier.fairySilk]: ClothItemId.fairySilkShorts,
134 [ClothTier.dragonweave]: ClothItemId.dragonweaveShorts
135 });
136
137 const TROUSERS_ID = Object.freeze({
138 [ClothTier.cotton]: ClothItemId.cottonTrousers,
139 [ClothTier.wool]: ClothItemId.woolTrousers,
140 [ClothTier.linen]: ClothItemId.linenTrousers,
141 [ClothTier.cashmere]: ClothItemId.cashmereTrousers,
142 [ClothTier.silk]: ClothItemId.silkTrousers,
143 [ClothTier.fairySilk]: ClothItemId.fairySilkTrousers,
144 [ClothTier.dragonweave]: ClothItemId.dragonweaveTrousers
145 });
146
147 const SKIRT_ID = Object.freeze({
148 [ClothTier.cotton]: ClothItemId.cottonSkirt,
149 [ClothTier.wool]: ClothItemId.woolSkirt,
150 [ClothTier.linen]: ClothItemId.linenSkirt,
151 [ClothTier.cashmere]: ClothItemId.cashmereSkirt,
152 [ClothTier.silk]: ClothItemId.silkSkirt,
153 [ClothTier.fairySilk]: ClothItemId.fairySilkSkirt,
154 [ClothTier.dragonweave]: ClothItemId.dragonweaveSkirt
155 });
156
87 157 const DEFAULT_STACK = 99;
88 158
159 function clothKeyPrefix (tier)
160 {
161 return String(tier) === "fairySilk" ? "fairy-silk" : String(tier);
162 }
163
89 164 function rawLabel (tier)
90 165 {
91 166 if (tier === ClothTier.cotton)
@@ -153,60 +228,151 @@ function clothDef (itemId, tier, key)
153 228 });
154 229 }
155 230
156 function sweaterDef (itemId, tier, key)
231 function garmentDef ({
232 itemId,
233 tier,
234 key,
235 pieceLabel,
236 description,
237 seedValue,
238 defaultState,
239 slot,
240 warm = false,
241 tightFit = true,
242 equipStem
243 })
157 244 {
158 245 const name = CLOTH_DISPLAY_NAME[tier] ?? tier;
159 246 return Object.freeze({
160 247 itemId,
161 248 key,
162 displayName: `${name} sweater`,
163 description: `A warm ${name.toLowerCase()} sweater, soft enough for travel.`,
164 seedValue: 10,
249 displayName: `${name} ${pieceLabel}`,
250 description,
251 seedValue,
165 252 stackable: false,
166 253 maxStackSize: 1,
167 254 uniqueInstance: false,
168 255 category: ItemCategory.finished,
169 256 iconKey: "clothing",
170 defaultState: "sweater",
257 defaultState,
171 258 tier,
172 259 tintFromTier: true,
173 260 dyeable: true,
174 tightFit: true,
175 clothing: Object.freeze({ warm: true, style: true }),
261 tightFit,
262 clothing: Object.freeze({ warm, style: true }),
176 263 equipment: Object.freeze({
177 slot: "chest",
264 slot,
178 265 tier,
179 266 kind: EquipmentKind.clothArmour,
180 267 bonus: 0,
181 268 minSkillLevel: tierMinSkillLevel(tier),
182 269 tintFromTier: true,
183 equipSprite: equipImageName("item", "clothing", "sweater")
270 equipSprite: equipImageName("item", "clothing", equipStem)
184 271 })
185 272 });
186 273 }
187 274
275 function sweaterDef (itemId, tier, key)
276 {
277 const name = CLOTH_DISPLAY_NAME[tier] ?? tier;
278 return garmentDef({
279 itemId,
280 tier,
281 key,
282 pieceLabel: "sweater",
283 description: `A warm ${name.toLowerCase()} sweater, soft enough for travel.`,
284 seedValue: 10,
285 defaultState: "sweater",
286 slot: "chest",
287 warm: true,
288 equipStem: "sweater"
289 });
290 }
291
292 function shirtDef (itemId, tier, key)
293 {
294 const name = CLOTH_DISPLAY_NAME[tier] ?? tier;
295 return garmentDef({
296 itemId,
297 tier,
298 key,
299 pieceLabel: "shirt",
300 description: `A simple ${name.toLowerCase()} shirt, plain and practical.`,
301 seedValue: 8,
302 defaultState: "shirt",
303 slot: "chest",
304 warm: false,
305 equipStem: "shirt"
306 });
307 }
308
309 function shortsDef (itemId, tier, key)
310 {
311 const name = CLOTH_DISPLAY_NAME[tier] ?? tier;
312 return garmentDef({
313 itemId,
314 tier,
315 key,
316 pieceLabel: "shorts",
317 description: `Light ${name.toLowerCase()} shorts cut for warm days on the road.`,
318 seedValue: 4,
319 defaultState: "shorts",
320 slot: "legs",
321 warm: false,
322 equipStem: "shorts"
323 });
324 }
325
326 function skirtDef (itemId, tier, key)
327 {
328 const name = CLOTH_DISPLAY_NAME[tier] ?? tier;
329 return garmentDef({
330 itemId,
331 tier,
332 key,
333 pieceLabel: "skirt",
334 description: `A light ${name.toLowerCase()} skirt for easy travel.`,
335 seedValue: 4,
336 defaultState: "skirt",
337 slot: "legs",
338 warm: false,
339 tightFit: false,
340 equipStem: "skirt"
341 });
342 }
343
344 function trousersDef (itemId, tier, key)
345 {
346 const name = CLOTH_DISPLAY_NAME[tier] ?? tier;
347 return garmentDef({
348 itemId,
349 tier,
350 key,
351 pieceLabel: "trousers",
352 description: `Plain ${name.toLowerCase()} trousers, sturdy enough for travel.`,
353 seedValue: 5,
354 // Art lives as greaves.png / greaves-equip.png under items/clothing.
355 defaultState: "greaves",
356 slot: "legs",
357 warm: false,
358 equipStem: "greaves"
359 });
360 }
361
188 362 function buildClothDefinitions ()
189 363 {
190 364 const defs = {};
191 365 for (const tier of CLOTH_TIER_ORDER)
192 366 {
193 const label = String(tier);
194 defs[RAW_ID[tier]] = fibreDef(RAW_ID[tier], tier, label === "fairySilk" ? "fairy-silk" : label);
195 defs[YARN_ID[tier]] = yarnDef(
196 YARN_ID[tier],
197 tier,
198 `${label === "fairySilk" ? "fairy-silk" : label}-yarn`
199 );
200 defs[CLOTH_ID[tier]] = clothDef(
201 CLOTH_ID[tier],
202 tier,
203 `${label === "fairySilk" ? "fairy-silk" : label}-cloth`
204 );
205 defs[SWEATER_ID[tier]] = sweaterDef(
206 SWEATER_ID[tier],
207 tier,
208 `${label === "fairySilk" ? "fairy-silk" : label}-sweater`
209 );
367 const prefix = clothKeyPrefix(tier);
368 defs[RAW_ID[tier]] = fibreDef(RAW_ID[tier], tier, prefix === "fairy-silk" ? "fairy-silk" : prefix);
369 defs[YARN_ID[tier]] = yarnDef(YARN_ID[tier], tier, `${prefix}-yarn`);
370 defs[CLOTH_ID[tier]] = clothDef(CLOTH_ID[tier], tier, `${prefix}-cloth`);
371 defs[SWEATER_ID[tier]] = sweaterDef(SWEATER_ID[tier], tier, `${prefix}-sweater`);
372 defs[SHIRT_ID[tier]] = shirtDef(SHIRT_ID[tier], tier, `${prefix}-shirt`);
373 defs[SHORTS_ID[tier]] = shortsDef(SHORTS_ID[tier], tier, `${prefix}-shorts`);
374 defs[SKIRT_ID[tier]] = skirtDef(SKIRT_ID[tier], tier, `${prefix}-skirt`);
375 defs[TROUSERS_ID[tier]] = trousersDef(TROUSERS_ID[tier], tier, `${prefix}-trousers`);
210 376 }
211 377 // Prefer display key "cotton" for the plant fibre.
212 378 defs[ClothItemId.cotton] = fibreDef(ClothItemId.cotton, ClothTier.cotton, "cotton");
@@ -235,12 +401,34 @@ export function sweaterItemId (tier)
235 401 return SWEATER_ID[tier] ?? null;
236 402 }
237 403
404 export function shirtItemId (tier)
405 {
406 return SHIRT_ID[tier] ?? null;
407 }
408
409 export function shortsItemId (tier)
410 {
411 return SHORTS_ID[tier] ?? null;
412 }
413
414 export function skirtItemId (tier)
415 {
416 return SKIRT_ID[tier] ?? null;
417 }
418
419 export function trousersItemId (tier)
420 {
421 return TROUSERS_ID[tier] ?? null;
422 }
423
238 424 export function clothTierForItemId (itemId)
239 425 {
240 426 for (const tier of CLOTH_TIER_ORDER)
241 427 {
242 428 if (RAW_ID[tier] === itemId || YARN_ID[tier] === itemId
243 || CLOTH_ID[tier] === itemId || SWEATER_ID[tier] === itemId)
429 || CLOTH_ID[tier] === itemId || SWEATER_ID[tier] === itemId
430 || SHIRT_ID[tier] === itemId || SHORTS_ID[tier] === itemId
431 || SKIRT_ID[tier] === itemId || TROUSERS_ID[tier] === itemId)
244 432 { return tier; }
245 433 }
246 434 return null;
@@ -248,6 +436,42 @@ export function clothTierForItemId (itemId)
248 436
249 437 /** Tailor garment templates (UI + recipes). */
250 438 export const CLOTHING_TEMPLATES = Object.freeze({
439 shirt: Object.freeze({
440 templateId: "shirt",
441 displayName: "Shirt",
442 slot: "chest",
443 warm: false,
444 inputs: Object.freeze([{ kind: "cloth", quantity: 1 }]),
445 outputItemIdForTier: shirtItemId,
446 minSkillLevel: 1
447 }),
448 shorts: Object.freeze({
449 templateId: "shorts",
450 displayName: "Shorts",
451 slot: "legs",
452 warm: false,
453 inputs: Object.freeze([{ kind: "cloth", quantity: 1 }]),
454 outputItemIdForTier: shortsItemId,
455 minSkillLevel: 1
456 }),
457 skirt: Object.freeze({
458 templateId: "skirt",
459 displayName: "Skirt",
460 slot: "legs",
461 warm: false,
462 inputs: Object.freeze([{ kind: "cloth", quantity: 1 }]),
463 outputItemIdForTier: skirtItemId,
464 minSkillLevel: 1
465 }),
466 trousers: Object.freeze({
467 templateId: "trousers",
468 displayName: "Trousers",
469 slot: "legs",
470 warm: false,
471 inputs: Object.freeze([{ kind: "cloth", quantity: 1 }]),
472 outputItemIdForTier: trousersItemId,
473 minSkillLevel: 1
474 }),
251 475 sweater: Object.freeze({
252 476 templateId: "sweater",
253 477 displayName: "Sweater",
@@ -12,6 +12,8 @@ import {
12 * Cloth family: raw fibre (wool sprite), yarn, woven cloth — shared magenta
12 * Cloth family: raw fibre (wool sprite), yarn, woven cloth — shared magenta
13 * sprites under items/cloth/{wool,yarn,cloth}.png with per-tier tint.
13 * sprites under items/cloth/{wool,yarn,cloth}.png with per-tier tint.
14 * Cotton raw reuses CraftingItemId.wool (11); yarn/cloth reuse 12/25.
14 * Cotton raw reuses CraftingItemId.wool (11); yarn/cloth reuse 12/25.
15 * Garments: shirt / shorts / skirt / trousers / sweater, all tiered + dyeable.
16 * Cotton shirt keeps historic ItemId 5; cotton shorts/trousers keep 239/240.
15 */
17 */
16export const ClothItemId = Object.freeze({
18export const ClothItemId = Object.freeze({
17 cotton: 11,
19 cotton: 11,
@@ -41,7 +43,35 @@ export const ClothItemId = Object.freeze({
41 cashmereSweater: 154,
43 cashmereSweater: 154,
42 silkSweater: 155,
44 silkSweater: 155,
43 fairySilkSweater: 156,
45 fairySilkSweater: 156,
44 dragonweaveSweater: 157
46 dragonweaveSweater: 157,
47 cottonShirt: 5,
48 woolShirt: 250,
49 linenShirt: 251,
50 cashmereShirt: 252,
51 silkShirt: 253,
52 fairySilkShirt: 254,
53 dragonweaveShirt: 255,
54 cottonShorts: 239,
55 woolShorts: 256,
56 linenShorts: 257,
57 cashmereShorts: 258,
58 silkShorts: 259,
59 fairySilkShorts: 260,
60 dragonweaveShorts: 261,
61 cottonTrousers: 240,
62 woolTrousers: 262,
63 linenTrousers: 263,
64 cashmereTrousers: 264,
65 silkTrousers: 265,
66 fairySilkTrousers: 266,
67 dragonweaveTrousers: 267,
68 cottonSkirt: 268,
69 woolSkirt: 269,
70 linenSkirt: 270,
71 cashmereSkirt: 271,
72 silkSkirt: 272,
73 fairySilkSkirt: 273,
74 dragonweaveSkirt: 274
45});
75});
46
76
47const RAW_ID = Object.freeze({
77const RAW_ID = Object.freeze({
@@ -84,8 +114,53 @@ const SWEATER_ID = Object.freeze({
84 [ClothTier.dragonweave]: ClothItemId.dragonweaveSweater
114 [ClothTier.dragonweave]: ClothItemId.dragonweaveSweater
85});
115});
86
116
117const SHIRT_ID = Object.freeze({
118 [ClothTier.cotton]: ClothItemId.cottonShirt,
119 [ClothTier.wool]: ClothItemId.woolShirt,
120 [ClothTier.linen]: ClothItemId.linenShirt,
121 [ClothTier.cashmere]: ClothItemId.cashmereShirt,
122 [ClothTier.silk]: ClothItemId.silkShirt,
123 [ClothTier.fairySilk]: ClothItemId.fairySilkShirt,
124 [ClothTier.dragonweave]: ClothItemId.dragonweaveShirt
125});
126
127const SHORTS_ID = Object.freeze({
128 [ClothTier.cotton]: ClothItemId.cottonShorts,
129 [ClothTier.wool]: ClothItemId.woolShorts,
130 [ClothTier.linen]: ClothItemId.linenShorts,
131 [ClothTier.cashmere]: ClothItemId.cashmereShorts,
132 [ClothTier.silk]: ClothItemId.silkShorts,
133 [ClothTier.fairySilk]: ClothItemId.fairySilkShorts,
134 [ClothTier.dragonweave]: ClothItemId.dragonweaveShorts
135});
136
137const TROUSERS_ID = Object.freeze({
138 [ClothTier.cotton]: ClothItemId.cottonTrousers,
139 [ClothTier.wool]: ClothItemId.woolTrousers,
140 [ClothTier.linen]: ClothItemId.linenTrousers,
141 [ClothTier.cashmere]: ClothItemId.cashmereTrousers,
142 [ClothTier.silk]: ClothItemId.silkTrousers,
143 [ClothTier.fairySilk]: ClothItemId.fairySilkTrousers,
144 [ClothTier.dragonweave]: ClothItemId.dragonweaveTrousers
145});
146
147const SKIRT_ID = Object.freeze({
148 [ClothTier.cotton]: ClothItemId.cottonSkirt,
149 [ClothTier.wool]: ClothItemId.woolSkirt,
150 [ClothTier.linen]: ClothItemId.linenSkirt,
151 [ClothTier.cashmere]: ClothItemId.cashmereSkirt,
152 [ClothTier.silk]: ClothItemId.silkSkirt,
153 [ClothTier.fairySilk]: ClothItemId.fairySilkSkirt,
154 [ClothTier.dragonweave]: ClothItemId.dragonweaveSkirt
155});
156
87const DEFAULT_STACK = 99;
157const DEFAULT_STACK = 99;
88
158
159function clothKeyPrefix (tier)
160{
161 return String(tier) === "fairySilk" ? "fairy-silk" : String(tier);
162}
163
89function rawLabel (tier)
164function rawLabel (tier)
90{
165{
91 if (tier === ClothTier.cotton)
166 if (tier === ClothTier.cotton)
@@ -153,60 +228,151 @@ function clothDef (itemId, tier, key)
153 });
228 });
154}
229}
155
230
156function sweaterDef (itemId, tier, key)
231function garmentDef ({
232 itemId,
233 tier,
234 key,
235 pieceLabel,
236 description,
237 seedValue,
238 defaultState,
239 slot,
240 warm = false,
241 tightFit = true,
242 equipStem
243})
157{
244{
158 const name = CLOTH_DISPLAY_NAME[tier] ?? tier;
245 const name = CLOTH_DISPLAY_NAME[tier] ?? tier;
159 return Object.freeze({
246 return Object.freeze({
160 itemId,
247 itemId,
161 key,
248 key,
162 displayName: `${name} sweater`,
249 displayName: `${name} ${pieceLabel}`,
163 description: `A warm ${name.toLowerCase()} sweater, soft enough for travel.`,
250 description,
164 seedValue: 10,
251 seedValue,
165 stackable: false,
252 stackable: false,
166 maxStackSize: 1,
253 maxStackSize: 1,
167 uniqueInstance: false,
254 uniqueInstance: false,
168 category: ItemCategory.finished,
255 category: ItemCategory.finished,
169 iconKey: "clothing",
256 iconKey: "clothing",
170 defaultState: "sweater",
257 defaultState,
171 tier,
258 tier,
172 tintFromTier: true,
259 tintFromTier: true,
173 dyeable: true,
260 dyeable: true,
174 tightFit: true,
261 tightFit,
175 clothing: Object.freeze({ warm: true, style: true }),
262 clothing: Object.freeze({ warm, style: true }),
176 equipment: Object.freeze({
263 equipment: Object.freeze({
177 slot: "chest",
264 slot,
178 tier,
265 tier,
179 kind: EquipmentKind.clothArmour,
266 kind: EquipmentKind.clothArmour,
180 bonus: 0,
267 bonus: 0,
181 minSkillLevel: tierMinSkillLevel(tier),
268 minSkillLevel: tierMinSkillLevel(tier),
182 tintFromTier: true,
269 tintFromTier: true,
183 equipSprite: equipImageName("item", "clothing", "sweater")
270 equipSprite: equipImageName("item", "clothing", equipStem)
184 })
271 })
185 });
272 });
186}
273}
187
274
275function sweaterDef (itemId, tier, key)
276{
277 const name = CLOTH_DISPLAY_NAME[tier] ?? tier;
278 return garmentDef({
279 itemId,
280 tier,
281 key,
282 pieceLabel: "sweater",
283 description: `A warm ${name.toLowerCase()} sweater, soft enough for travel.`,
284 seedValue: 10,
285 defaultState: "sweater",
286 slot: "chest",
287 warm: true,
288 equipStem: "sweater"
289 });
290}
291
292function shirtDef (itemId, tier, key)
293{
294 const name = CLOTH_DISPLAY_NAME[tier] ?? tier;
295 return garmentDef({
296 itemId,
297 tier,
298 key,
299 pieceLabel: "shirt",
300 description: `A simple ${name.toLowerCase()} shirt, plain and practical.`,
301 seedValue: 8,
302 defaultState: "shirt",
303 slot: "chest",
304 warm: false,
305 equipStem: "shirt"
306 });
307}
308
309function shortsDef (itemId, tier, key)
310{
311 const name = CLOTH_DISPLAY_NAME[tier] ?? tier;
312 return garmentDef({
313 itemId,
314 tier,
315 key,
316 pieceLabel: "shorts",
317 description: `Light ${name.toLowerCase()} shorts cut for warm days on the road.`,
318 seedValue: 4,
319 defaultState: "shorts",
320 slot: "legs",
321 warm: false,
322 equipStem: "shorts"
323 });
324}
325
326function skirtDef (itemId, tier, key)
327{
328 const name = CLOTH_DISPLAY_NAME[tier] ?? tier;
329 return garmentDef({
330 itemId,
331 tier,
332 key,
333 pieceLabel: "skirt",
334 description: `A light ${name.toLowerCase()} skirt for easy travel.`,
335 seedValue: 4,
336 defaultState: "skirt",
337 slot: "legs",
338 warm: false,
339 tightFit: false,
340 equipStem: "skirt"
341 });
342}
343
344function trousersDef (itemId, tier, key)
345{
346 const name = CLOTH_DISPLAY_NAME[tier] ?? tier;
347 return garmentDef({
348 itemId,
349 tier,
350 key,
351 pieceLabel: "trousers",
352 description: `Plain ${name.toLowerCase()} trousers, sturdy enough for travel.`,
353 seedValue: 5,
354 // Art lives as greaves.png / greaves-equip.png under items/clothing.
355 defaultState: "greaves",
356 slot: "legs",
357 warm: false,
358 equipStem: "greaves"
359 });
360}
361
188function buildClothDefinitions ()
362function buildClothDefinitions ()
189{
363{
190 const defs = {};
364 const defs = {};
191 for (const tier of CLOTH_TIER_ORDER)
365 for (const tier of CLOTH_TIER_ORDER)
192 {
366 {
193 const label = String(tier);
367 const prefix = clothKeyPrefix(tier);
194 defs[RAW_ID[tier]] = fibreDef(RAW_ID[tier], tier, label === "fairySilk" ? "fairy-silk" : label);
368 defs[RAW_ID[tier]] = fibreDef(RAW_ID[tier], tier, prefix === "fairy-silk" ? "fairy-silk" : prefix);
195 defs[YARN_ID[tier]] = yarnDef(
369 defs[YARN_ID[tier]] = yarnDef(YARN_ID[tier], tier, `${prefix}-yarn`);
196 YARN_ID[tier],
370 defs[CLOTH_ID[tier]] = clothDef(CLOTH_ID[tier], tier, `${prefix}-cloth`);
197 tier,
371 defs[SWEATER_ID[tier]] = sweaterDef(SWEATER_ID[tier], tier, `${prefix}-sweater`);
198 `${label === "fairySilk" ? "fairy-silk" : label}-yarn`
372 defs[SHIRT_ID[tier]] = shirtDef(SHIRT_ID[tier], tier, `${prefix}-shirt`);
199 );
373 defs[SHORTS_ID[tier]] = shortsDef(SHORTS_ID[tier], tier, `${prefix}-shorts`);
200 defs[CLOTH_ID[tier]] = clothDef(
374 defs[SKIRT_ID[tier]] = skirtDef(SKIRT_ID[tier], tier, `${prefix}-skirt`);
201 CLOTH_ID[tier],
375 defs[TROUSERS_ID[tier]] = trousersDef(TROUSERS_ID[tier], tier, `${prefix}-trousers`);
202 tier,
203 `${label === "fairySilk" ? "fairy-silk" : label}-cloth`
204 );
205 defs[SWEATER_ID[tier]] = sweaterDef(
206 SWEATER_ID[tier],
207 tier,
208 `${label === "fairySilk" ? "fairy-silk" : label}-sweater`
209 );
210 }
376 }
211 // Prefer display key "cotton" for the plant fibre.
377 // Prefer display key "cotton" for the plant fibre.
212 defs[ClothItemId.cotton] = fibreDef(ClothItemId.cotton, ClothTier.cotton, "cotton");
378 defs[ClothItemId.cotton] = fibreDef(ClothItemId.cotton, ClothTier.cotton, "cotton");
@@ -235,12 +401,34 @@ export function sweaterItemId (tier)
235 return SWEATER_ID[tier] ?? null;
401 return SWEATER_ID[tier] ?? null;
236}
402}
237
403
404export function shirtItemId (tier)
405{
406 return SHIRT_ID[tier] ?? null;
407}
408
409export function shortsItemId (tier)
410{
411 return SHORTS_ID[tier] ?? null;
412}
413
414export function skirtItemId (tier)
415{
416 return SKIRT_ID[tier] ?? null;
417}
418
419export function trousersItemId (tier)
420{
421 return TROUSERS_ID[tier] ?? null;
422}
423
238export function clothTierForItemId (itemId)
424export function clothTierForItemId (itemId)
239{
425{
240 for (const tier of CLOTH_TIER_ORDER)
426 for (const tier of CLOTH_TIER_ORDER)
241 {
427 {
242 if (RAW_ID[tier] === itemId || YARN_ID[tier] === itemId
428 if (RAW_ID[tier] === itemId || YARN_ID[tier] === itemId
243 || CLOTH_ID[tier] === itemId || SWEATER_ID[tier] === itemId)
429 || CLOTH_ID[tier] === itemId || SWEATER_ID[tier] === itemId
430 || SHIRT_ID[tier] === itemId || SHORTS_ID[tier] === itemId
431 || SKIRT_ID[tier] === itemId || TROUSERS_ID[tier] === itemId)
244 { return tier; }
432 { return tier; }
245 }
433 }
246 return null;
434 return null;
@@ -248,6 +436,42 @@ export function clothTierForItemId (itemId)
248
436
249/** Tailor garment templates (UI + recipes). */
437/** Tailor garment templates (UI + recipes). */
250export const CLOTHING_TEMPLATES = Object.freeze({
438export const CLOTHING_TEMPLATES = Object.freeze({
439 shirt: Object.freeze({
440 templateId: "shirt",
441 displayName: "Shirt",
442 slot: "chest",
443 warm: false,
444 inputs: Object.freeze([{ kind: "cloth", quantity: 1 }]),
445 outputItemIdForTier: shirtItemId,
446 minSkillLevel: 1
447 }),
448 shorts: Object.freeze({
449 templateId: "shorts",
450 displayName: "Shorts",
451 slot: "legs",
452 warm: false,
453 inputs: Object.freeze([{ kind: "cloth", quantity: 1 }]),
454 outputItemIdForTier: shortsItemId,
455 minSkillLevel: 1
456 }),
457 skirt: Object.freeze({
458 templateId: "skirt",
459 displayName: "Skirt",
460 slot: "legs",
461 warm: false,
462 inputs: Object.freeze([{ kind: "cloth", quantity: 1 }]),
463 outputItemIdForTier: skirtItemId,
464 minSkillLevel: 1
465 }),
466 trousers: Object.freeze({
467 templateId: "trousers",
468 displayName: "Trousers",
469 slot: "legs",
470 warm: false,
471 inputs: Object.freeze([{ kind: "cloth", quantity: 1 }]),
472 outputItemIdForTier: trousersItemId,
473 minSkillLevel: 1
474 }),
251 sweater: Object.freeze({
475 sweater: Object.freeze({
252 templateId: "sweater",
476 templateId: "sweater",
253 displayName: "Sweater",
477 displayName: "Sweater",
shared/definitions/equipmentStatCategories.js +47 −23
@@ -12,13 +12,13 @@ import {
12 12 tierStatBonus
13 13 } from "./materialTiers.js";
14 14 import { ARMOUR_CRAFT_PIECES, armourItemIdForTier } from "./armourItems.js";
15 import { sweaterItemId } from "./clothItems.js";
15 import { sweaterItemId, shirtItemId, shortsItemId, skirtItemId, trousersItemId } from "./clothItems.js";
16 16 import { LeatherItemId } from "./leatherItems.js";
17 17 import { ItemId, itemDefinition, ITEM_DEFINITIONS } from "./items.js";
18 18 import { quarterstaffItemIdForWood } from "./woodItems.js";
19 19 import { arrowItemId, bowItemId } from "./rangedItems.js";
20 20
21 /** Tier key for non-tiered singleton rows (shorts, cloth shirt, …). */
21 /** Tier key for non-tiered singleton rows. */
22 22 export const SINGLETON_TIER_KEY = "_";
23 23
24 24 export const EquipmentStatCategoryId = Object.freeze({
@@ -217,34 +217,58 @@ export const EQUIPMENT_STAT_CATEGORIES = Object.freeze([
217 217 ])
218 218 }),
219 219 Object.freeze({
220 id: "singletons",
221 label: "Other",
222 tierOrder: Object.freeze([SINGLETON_TIER_KEY]),
223 tierDisplayName: () => "—",
220 id: "shirts",
221 label: "Shirts",
222 tierOrder: CLOTH_TIER_ORDER,
223 tierDisplayName: (tier) => CLOTH_DISPLAY_NAME[tier] ?? tier,
224 rows: Object.freeze([
225 Object.freeze({
226 pieceKey: "shirt",
227 label: "Shirt",
228 defaultBonus: 1,
229 resolveItemId: (tier) => shirtItemId(tier)
230 })
231 ])
232 }),
233 Object.freeze({
234 id: "shorts",
235 label: "Shorts",
236 tierOrder: CLOTH_TIER_ORDER,
237 tierDisplayName: (tier) => CLOTH_DISPLAY_NAME[tier] ?? tier,
224 238 rows: Object.freeze([
225 239 Object.freeze({
226 240 pieceKey: "shorts",
227 label: "Cloth shorts",
241 label: "Shorts",
228 242 defaultBonus: 0,
229 singleton: true,
230 itemId: LeatherItemId.clothShorts,
231 resolveItemId: () => LeatherItemId.clothShorts
232 }),
243 resolveItemId: (tier) => shortsItemId(tier)
244 })
245 ])
246 }),
247 Object.freeze({
248 id: "skirts",
249 label: "Skirts",
250 tierOrder: CLOTH_TIER_ORDER,
251 tierDisplayName: (tier) => CLOTH_DISPLAY_NAME[tier] ?? tier,
252 rows: Object.freeze([
233 253 Object.freeze({
234 pieceKey: "trousers",
235 label: "Cloth trousers",
254 pieceKey: "skirt",
255 label: "Skirt",
236 256 defaultBonus: 0,
237 singleton: true,
238 itemId: LeatherItemId.clothTrousers,
239 resolveItemId: () => LeatherItemId.clothTrousers
240 }),
257 resolveItemId: (tier) => skirtItemId(tier)
258 })
259 ])
260 }),
261 Object.freeze({
262 id: "trousers",
263 label: "Trousers",
264 tierOrder: CLOTH_TIER_ORDER,
265 tierDisplayName: (tier) => CLOTH_DISPLAY_NAME[tier] ?? tier,
266 rows: Object.freeze([
241 267 Object.freeze({
242 pieceKey: "clothShirt",
243 label: "Cloth shirt",
244 defaultBonus: 1,
245 singleton: true,
246 itemId: ItemId.clothShirt,
247 resolveItemId: () => ItemId.clothShirt
268 pieceKey: "trousers",
269 label: "Trousers",
270 defaultBonus: 0,
271 resolveItemId: (tier) => trousersItemId(tier)
248 272 })
249 273 ])
250 274 })
@@ -12,13 +12,13 @@ import {
12 tierStatBonus
12 tierStatBonus
13} from "./materialTiers.js";
13} from "./materialTiers.js";
14import { ARMOUR_CRAFT_PIECES, armourItemIdForTier } from "./armourItems.js";
14import { ARMOUR_CRAFT_PIECES, armourItemIdForTier } from "./armourItems.js";
15import { sweaterItemId } from "./clothItems.js";
15import { sweaterItemId, shirtItemId, shortsItemId, skirtItemId, trousersItemId } from "./clothItems.js";
16import { LeatherItemId } from "./leatherItems.js";
16import { LeatherItemId } from "./leatherItems.js";
17import { ItemId, itemDefinition, ITEM_DEFINITIONS } from "./items.js";
17import { ItemId, itemDefinition, ITEM_DEFINITIONS } from "./items.js";
18import { quarterstaffItemIdForWood } from "./woodItems.js";
18import { quarterstaffItemIdForWood } from "./woodItems.js";
19import { arrowItemId, bowItemId } from "./rangedItems.js";
19import { arrowItemId, bowItemId } from "./rangedItems.js";
20
20
21/** Tier key for non-tiered singleton rows (shorts, cloth shirt, …). */
21/** Tier key for non-tiered singleton rows. */
22export const SINGLETON_TIER_KEY = "_";
22export const SINGLETON_TIER_KEY = "_";
23
23
24export const EquipmentStatCategoryId = Object.freeze({
24export const EquipmentStatCategoryId = Object.freeze({
@@ -217,34 +217,58 @@ export const EQUIPMENT_STAT_CATEGORIES = Object.freeze([
217 ])
217 ])
218 }),
218 }),
219 Object.freeze({
219 Object.freeze({
220 id: "singletons",
220 id: "shirts",
221 label: "Other",
221 label: "Shirts",
222 tierOrder: Object.freeze([SINGLETON_TIER_KEY]),
222 tierOrder: CLOTH_TIER_ORDER,
223 tierDisplayName: () => "—",
223 tierDisplayName: (tier) => CLOTH_DISPLAY_NAME[tier] ?? tier,
224 rows: Object.freeze([
225 Object.freeze({
226 pieceKey: "shirt",
227 label: "Shirt",
228 defaultBonus: 1,
229 resolveItemId: (tier) => shirtItemId(tier)
230 })
231 ])
232 }),
233 Object.freeze({
234 id: "shorts",
235 label: "Shorts",
236 tierOrder: CLOTH_TIER_ORDER,
237 tierDisplayName: (tier) => CLOTH_DISPLAY_NAME[tier] ?? tier,
224 rows: Object.freeze([
238 rows: Object.freeze([
225 Object.freeze({
239 Object.freeze({
226 pieceKey: "shorts",
240 pieceKey: "shorts",
227 label: "Cloth shorts",
241 label: "Shorts",
228 defaultBonus: 0,
242 defaultBonus: 0,
229 singleton: true,
243 resolveItemId: (tier) => shortsItemId(tier)
230 itemId: LeatherItemId.clothShorts,
244 })
231 resolveItemId: () => LeatherItemId.clothShorts
245 ])
232 }),
246 }),
247 Object.freeze({
248 id: "skirts",
249 label: "Skirts",
250 tierOrder: CLOTH_TIER_ORDER,
251 tierDisplayName: (tier) => CLOTH_DISPLAY_NAME[tier] ?? tier,
252 rows: Object.freeze([
233 Object.freeze({
253 Object.freeze({
234 pieceKey: "trousers",
254 pieceKey: "skirt",
235 label: "Cloth trousers",
255 label: "Skirt",
236 defaultBonus: 0,
256 defaultBonus: 0,
237 singleton: true,
257 resolveItemId: (tier) => skirtItemId(tier)
238 itemId: LeatherItemId.clothTrousers,
258 })
239 resolveItemId: () => LeatherItemId.clothTrousers
259 ])
240 }),
260 }),
261 Object.freeze({
262 id: "trousers",
263 label: "Trousers",
264 tierOrder: CLOTH_TIER_ORDER,
265 tierDisplayName: (tier) => CLOTH_DISPLAY_NAME[tier] ?? tier,
266 rows: Object.freeze([
241 Object.freeze({
267 Object.freeze({
242 pieceKey: "clothShirt",
268 pieceKey: "trousers",
243 label: "Cloth shirt",
269 label: "Trousers",
244 defaultBonus: 1,
270 defaultBonus: 0,
245 singleton: true,
271 resolveItemId: (tier) => trousersItemId(tier)
246 itemId: ItemId.clothShirt,
247 resolveItemId: () => ItemId.clothShirt
248 })
272 })
249 ])
273 ])
250 })
274 })
shared/definitions/items.js +1 −23
@@ -22,6 +22,7 @@ export const ItemId = Object.freeze({
22 22 apple: 2,
23 23 stick: 3,
24 24 blankCheque: 4,
25 /** Cotton shirt (ClothItemId.cottonShirt). */
25 26 clothShirt: 5,
26 27 letter: 6,
27 28 filledCheque: 7,
@@ -163,28 +164,6 @@ export const ITEM_DEFINITIONS = Object.freeze({
163 164 defaultState: "filled-cheque",
164 165 marketplaceSellable: true
165 166 }),
166 [ItemId.clothShirt]: Object.freeze({
167 itemId: ItemId.clothShirt,
168 key: "cloth-shirt",
169 displayName: "Cloth shirt",
170 description: "A simple cloth shirt, plain and practical.",
171 seedValue: 8,
172 stackable: false,
173 maxStackSize: 1,
174 uniqueInstance: false,
175 category: "finished",
176 iconKey: "clothing",
177 defaultState: "shirt",
178 dyeable: true,
179 tightFit: true,
180 clothing: Object.freeze({ warm: false, style: true }),
181 equipment: Object.freeze({
182 slot: EQUIPMENT_SLOT.chest,
183 tier: MaterialTier.bronze,
184 kind: EquipmentKind.clothArmour,
185 equipSprite: equipImageName("item", "clothing", "shirt")
186 })
187 }),
188 167 [ItemId.coins]: Object.freeze({
189 168 itemId: ItemId.coins,
190 169 key: "coins",
@@ -489,6 +468,5 @@ export const STARTER_ITEMS = Object.freeze([
489 468 Object.freeze({ itemId: ItemId.paper, quantity: 5 }),
490 469 Object.freeze({ itemId: ItemId.apple, quantity: 3 }),
491 470 Object.freeze({ itemId: ItemId.stick, quantity: 1 }),
492 Object.freeze({ itemId: ItemId.clothShirt, quantity: 1 }),
493 471 Object.freeze({ itemId: ItemId.coins, quantity: 25 })
494 472 ]);
@@ -22,6 +22,7 @@ export const ItemId = Object.freeze({
22 apple: 2,
22 apple: 2,
23 stick: 3,
23 stick: 3,
24 blankCheque: 4,
24 blankCheque: 4,
25 /** Cotton shirt (ClothItemId.cottonShirt). */
25 clothShirt: 5,
26 clothShirt: 5,
26 letter: 6,
27 letter: 6,
27 filledCheque: 7,
28 filledCheque: 7,
@@ -163,28 +164,6 @@ export const ITEM_DEFINITIONS = Object.freeze({
163 defaultState: "filled-cheque",
164 defaultState: "filled-cheque",
164 marketplaceSellable: true
165 marketplaceSellable: true
165 }),
166 }),
166 [ItemId.clothShirt]: Object.freeze({
167 itemId: ItemId.clothShirt,
168 key: "cloth-shirt",
169 displayName: "Cloth shirt",
170 description: "A simple cloth shirt, plain and practical.",
171 seedValue: 8,
172 stackable: false,
173 maxStackSize: 1,
174 uniqueInstance: false,
175 category: "finished",
176 iconKey: "clothing",
177 defaultState: "shirt",
178 dyeable: true,
179 tightFit: true,
180 clothing: Object.freeze({ warm: false, style: true }),
181 equipment: Object.freeze({
182 slot: EQUIPMENT_SLOT.chest,
183 tier: MaterialTier.bronze,
184 kind: EquipmentKind.clothArmour,
185 equipSprite: equipImageName("item", "clothing", "shirt")
186 })
187 }),
188 [ItemId.coins]: Object.freeze({
167 [ItemId.coins]: Object.freeze({
189 itemId: ItemId.coins,
168 itemId: ItemId.coins,
190 key: "coins",
169 key: "coins",
@@ -489,6 +468,5 @@ export const STARTER_ITEMS = Object.freeze([
489 Object.freeze({ itemId: ItemId.paper, quantity: 5 }),
468 Object.freeze({ itemId: ItemId.paper, quantity: 5 }),
490 Object.freeze({ itemId: ItemId.apple, quantity: 3 }),
469 Object.freeze({ itemId: ItemId.apple, quantity: 3 }),
491 Object.freeze({ itemId: ItemId.stick, quantity: 1 }),
470 Object.freeze({ itemId: ItemId.stick, quantity: 1 }),
492 Object.freeze({ itemId: ItemId.clothShirt, quantity: 1 }),
493 Object.freeze({ itemId: ItemId.coins, quantity: 25 })
471 Object.freeze({ itemId: ItemId.coins, quantity: 25 })
494]);
472]);
shared/definitions/leatherItems.js +2 −44
@@ -18,7 +18,9 @@ export const LeatherItemId = Object.freeze({
18 18 scaledLeather: 236,
19 19 wyvernHide: 237,
20 20 dragonhide: 238,
21 /** @deprecated Prefer ClothItemId.cottonShorts — kept for existing refs. */
21 22 clothShorts: 239,
23 /** @deprecated Prefer ClothItemId.cottonTrousers — kept for existing refs. */
22 24 clothTrousers: 240,
23 25 leatherShoes: 241,
24 26 steelStud: 242,
@@ -71,53 +73,9 @@ function buildLeatherMaterialDefinitions ()
71 73 return defs;
72 74 }
73 75
74 const LEGWEAR_BASE = Object.freeze({
75 stackable: false,
76 maxStackSize: 1,
77 uniqueInstance: false,
78 category: ItemCategory.finished,
79 iconKey: "clothing",
80 dyeable: true,
81 tightFit: true,
82 clothing: Object.freeze({ style: true }),
83 equipment: Object.freeze({
84 slot: "legs",
85 kind: EquipmentKind.clothArmour,
86 bonus: 0,
87 minSkillLevel: 1,
88 tintFromTier: false
89 })
90 });
91
92 76 /** @type {Record<number, object>} */
93 77 export const LEATHER_ITEM_DEFINITIONS = Object.freeze({
94 78 ...buildLeatherMaterialDefinitions(),
95 [LeatherItemId.clothShorts]: Object.freeze({
96 ...LEGWEAR_BASE,
97 itemId: LeatherItemId.clothShorts,
98 key: "cloth-shorts",
99 displayName: "Cloth shorts",
100 description: "Light cloth shorts cut for warm days on the road.",
101 seedValue: 4,
102 defaultState: "shorts",
103 equipment: Object.freeze({
104 ...LEGWEAR_BASE.equipment,
105 equipSprite: equipImageName("item", "clothing", "shorts")
106 })
107 }),
108 [LeatherItemId.clothTrousers]: Object.freeze({
109 ...LEGWEAR_BASE,
110 itemId: LeatherItemId.clothTrousers,
111 key: "cloth-trousers",
112 displayName: "Cloth trousers",
113 description: "Plain cloth trousers, sturdy enough for travel.",
114 seedValue: 5,
115 defaultState: "trousers",
116 equipment: Object.freeze({
117 ...LEGWEAR_BASE.equipment,
118 equipSprite: equipImageName("item", "clothing", "trousers")
119 })
120 }),
121 79 [LeatherItemId.leatherShoes]: Object.freeze({
122 80 itemId: LeatherItemId.leatherShoes,
123 81 key: "leather-shoes",
@@ -18,7 +18,9 @@ export const LeatherItemId = Object.freeze({
18 scaledLeather: 236,
18 scaledLeather: 236,
19 wyvernHide: 237,
19 wyvernHide: 237,
20 dragonhide: 238,
20 dragonhide: 238,
21 /** @deprecated Prefer ClothItemId.cottonShorts — kept for existing refs. */
21 clothShorts: 239,
22 clothShorts: 239,
23 /** @deprecated Prefer ClothItemId.cottonTrousers — kept for existing refs. */
22 clothTrousers: 240,
24 clothTrousers: 240,
23 leatherShoes: 241,
25 leatherShoes: 241,
24 steelStud: 242,
26 steelStud: 242,
@@ -71,53 +73,9 @@ function buildLeatherMaterialDefinitions ()
71 return defs;
73 return defs;
72}
74}
73
75
74const LEGWEAR_BASE = Object.freeze({
75 stackable: false,
76 maxStackSize: 1,
77 uniqueInstance: false,
78 category: ItemCategory.finished,
79 iconKey: "clothing",
80 dyeable: true,
81 tightFit: true,
82 clothing: Object.freeze({ style: true }),
83 equipment: Object.freeze({
84 slot: "legs",
85 kind: EquipmentKind.clothArmour,
86 bonus: 0,
87 minSkillLevel: 1,
88 tintFromTier: false
89 })
90});
91
92/** @type {Record<number, object>} */
76/** @type {Record<number, object>} */
93export const LEATHER_ITEM_DEFINITIONS = Object.freeze({
77export const LEATHER_ITEM_DEFINITIONS = Object.freeze({
94 ...buildLeatherMaterialDefinitions(),
78 ...buildLeatherMaterialDefinitions(),
95 [LeatherItemId.clothShorts]: Object.freeze({
96 ...LEGWEAR_BASE,
97 itemId: LeatherItemId.clothShorts,
98 key: "cloth-shorts",
99 displayName: "Cloth shorts",
100 description: "Light cloth shorts cut for warm days on the road.",
101 seedValue: 4,
102 defaultState: "shorts",
103 equipment: Object.freeze({
104 ...LEGWEAR_BASE.equipment,
105 equipSprite: equipImageName("item", "clothing", "shorts")
106 })
107 }),
108 [LeatherItemId.clothTrousers]: Object.freeze({
109 ...LEGWEAR_BASE,
110 itemId: LeatherItemId.clothTrousers,
111 key: "cloth-trousers",
112 displayName: "Cloth trousers",
113 description: "Plain cloth trousers, sturdy enough for travel.",
114 seedValue: 5,
115 defaultState: "trousers",
116 equipment: Object.freeze({
117 ...LEGWEAR_BASE.equipment,
118 equipSprite: equipImageName("item", "clothing", "trousers")
119 })
120 }),
121 [LeatherItemId.leatherShoes]: Object.freeze({
79 [LeatherItemId.leatherShoes]: Object.freeze({
122 itemId: LeatherItemId.leatherShoes,
80 itemId: LeatherItemId.leatherShoes,
123 key: "leather-shoes",
81 key: "leather-shoes",
shared/items/createClothing.js added +142 −0
@@ -0,0 +1,142 @@
1 /**
2 * Character-creation clothing: cotton shirt + chosen cotton legs, with HSL dyes.
3 * Applied on top of world-editor starter equipment (chest/legs overwrite).
4 */
5
6 import { ClothTier } from "../definitions/materialTiers.js";
7 import {
8 shirtItemId,
9 shortsItemId,
10 skirtItemId,
11 trousersItemId
12 } from "../definitions/clothItems.js";
13 import {
14 normalizeHairSliders,
15 hairColorFromSliders,
16 DEFAULT_HAIR_HUE,
17 DEFAULT_HAIR_SATURATION,
18 DEFAULT_HAIR_DARKNESS
19 } from "../appearance/hair.js";
20 import { EQUIPMENT_SLOT } from "../definitions/items.js";
21 import { emptyEquipment } from "./inventory.js";
22 import { godsOrigin, attachOrigins } from "./origin.js";
23
24 export const CreationLegsKind = Object.freeze({
25 shorts: "shorts",
26 skirt: "skirt",
27 trousers: "trousers"
28 });
29
30 export const CREATION_LEGS_KINDS = Object.freeze([
31 CreationLegsKind.shorts,
32 CreationLegsKind.skirt,
33 CreationLegsKind.trousers
34 ]);
35
36 const LEGS_ITEM_ID = Object.freeze({
37 [CreationLegsKind.shorts]: () => shortsItemId(ClothTier.cotton),
38 [CreationLegsKind.skirt]: () => skirtItemId(ClothTier.cotton),
39 [CreationLegsKind.trousers]: () => trousersItemId(ClothTier.cotton)
40 });
41
42 export function defaultCreateClothing ()
43 {
44 return Object.freeze({
45 legsKind: CreationLegsKind.trousers,
46 shirt: Object.freeze({
47 hue: DEFAULT_HAIR_HUE,
48 saturation: DEFAULT_HAIR_SATURATION,
49 darkness: DEFAULT_HAIR_DARKNESS
50 }),
51 legs: Object.freeze({
52 hue: 210,
53 saturation: DEFAULT_HAIR_SATURATION,
54 darkness: DEFAULT_HAIR_DARKNESS
55 })
56 });
57 }
58
59 function normalizePieceSliders (raw)
60 {
61 return normalizeHairSliders(raw ?? {});
62 }
63
64 /**
65 * @returns {{ legsKind: string, shirt: object, legs: object }}
66 */
67 export function normalizeCreateClothing (raw)
68 {
69 const defaults = defaultCreateClothing();
70 const legsKind = CREATION_LEGS_KINDS.includes(raw?.legsKind)
71 ? raw.legsKind
72 : defaults.legsKind;
73 return {
74 legsKind,
75 shirt: normalizePieceSliders(raw?.shirt),
76 legs: normalizePieceSliders(raw?.legs)
77 };
78 }
79
80 export function creationLegsItemId (legsKind)
81 {
82 const resolve = LEGS_ITEM_ID[legsKind] ?? LEGS_ITEM_ID[CreationLegsKind.trousers];
83 return resolve();
84 }
85
86 export function creationShirtItemId ()
87 {
88 return shirtItemId(ClothTier.cotton);
89 }
90
91 function dyedClothingStack (itemId, sliders, origin)
92 {
93 const dyeColor = hairColorFromSliders(sliders);
94 return attachOrigins({
95 itemId,
96 quantity: 1,
97 instance: Object.freeze({ kind: "clothing", dyeColor }),
98 origins: [{ origin, quantity: 1 }]
99 });
100 }
101
102 /**
103 * Build a preview bag (equipment only) for the creation clothing UI.
104 */
105 export function creationClothingPreviewBag (clothingInput)
106 {
107 const clothing = normalizeCreateClothing(clothingInput);
108 const origin = godsOrigin();
109 const equipment = emptyEquipment();
110 equipment.slots[EQUIPMENT_SLOT.chest] = dyedClothingStack(
111 creationShirtItemId(),
112 clothing.shirt,
113 origin
114 );
115 equipment.slots[EQUIPMENT_SLOT.legs] = dyedClothingStack(
116 creationLegsItemId(clothing.legsKind),
117 clothing.legs,
118 origin
119 );
120 return { equipment };
121 }
122
123 /**
124 * Overlay creation clothing onto an existing starter equipment object (mutates slots).
125 */
126 export function applyCreationClothingToEquipment (equipment, clothingInput)
127 {
128 const clothing = normalizeCreateClothing(clothingInput);
129 const origin = godsOrigin();
130 const slots = equipment?.slots ?? emptyEquipment().slots;
131 slots[EQUIPMENT_SLOT.chest] = dyedClothingStack(
132 creationShirtItemId(),
133 clothing.shirt,
134 origin
135 );
136 slots[EQUIPMENT_SLOT.legs] = dyedClothingStack(
137 creationLegsItemId(clothing.legsKind),
138 clothing.legs,
139 origin
140 );
141 return equipment;
142 }
@@ -0,0 +1,142 @@
1/**
2 * Character-creation clothing: cotton shirt + chosen cotton legs, with HSL dyes.
3 * Applied on top of world-editor starter equipment (chest/legs overwrite).
4 */
5
6import { ClothTier } from "../definitions/materialTiers.js";
7import {
8 shirtItemId,
9 shortsItemId,
10 skirtItemId,
11 trousersItemId
12} from "../definitions/clothItems.js";
13import {
14 normalizeHairSliders,
15 hairColorFromSliders,
16 DEFAULT_HAIR_HUE,
17 DEFAULT_HAIR_SATURATION,
18 DEFAULT_HAIR_DARKNESS
19} from "../appearance/hair.js";
20import { EQUIPMENT_SLOT } from "../definitions/items.js";
21import { emptyEquipment } from "./inventory.js";
22import { godsOrigin, attachOrigins } from "./origin.js";
23
24export const CreationLegsKind = Object.freeze({
25 shorts: "shorts",
26 skirt: "skirt",
27 trousers: "trousers"
28});
29
30export const CREATION_LEGS_KINDS = Object.freeze([
31 CreationLegsKind.shorts,
32 CreationLegsKind.skirt,
33 CreationLegsKind.trousers
34]);
35
36const LEGS_ITEM_ID = Object.freeze({
37 [CreationLegsKind.shorts]: () => shortsItemId(ClothTier.cotton),
38 [CreationLegsKind.skirt]: () => skirtItemId(ClothTier.cotton),
39 [CreationLegsKind.trousers]: () => trousersItemId(ClothTier.cotton)
40});
41
42export function defaultCreateClothing ()
43{
44 return Object.freeze({
45 legsKind: CreationLegsKind.trousers,
46 shirt: Object.freeze({
47 hue: DEFAULT_HAIR_HUE,
48 saturation: DEFAULT_HAIR_SATURATION,
49 darkness: DEFAULT_HAIR_DARKNESS
50 }),
51 legs: Object.freeze({
52 hue: 210,
53 saturation: DEFAULT_HAIR_SATURATION,
54 darkness: DEFAULT_HAIR_DARKNESS
55 })
56 });
57}
58
59function normalizePieceSliders (raw)
60{
61 return normalizeHairSliders(raw ?? {});
62}
63
64/**
65 * @returns {{ legsKind: string, shirt: object, legs: object }}
66 */
67export function normalizeCreateClothing (raw)
68{
69 const defaults = defaultCreateClothing();
70 const legsKind = CREATION_LEGS_KINDS.includes(raw?.legsKind)
71 ? raw.legsKind
72 : defaults.legsKind;
73 return {
74 legsKind,
75 shirt: normalizePieceSliders(raw?.shirt),
76 legs: normalizePieceSliders(raw?.legs)
77 };
78}
79
80export function creationLegsItemId (legsKind)
81{
82 const resolve = LEGS_ITEM_ID[legsKind] ?? LEGS_ITEM_ID[CreationLegsKind.trousers];
83 return resolve();
84}
85
86export function creationShirtItemId ()
87{
88 return shirtItemId(ClothTier.cotton);
89}
90
91function dyedClothingStack (itemId, sliders, origin)
92{
93 const dyeColor = hairColorFromSliders(sliders);
94 return attachOrigins({
95 itemId,
96 quantity: 1,
97 instance: Object.freeze({ kind: "clothing", dyeColor }),
98 origins: [{ origin, quantity: 1 }]
99 });
100}
101
102/**
103 * Build a preview bag (equipment only) for the creation clothing UI.
104 */
105export function creationClothingPreviewBag (clothingInput)
106{
107 const clothing = normalizeCreateClothing(clothingInput);
108 const origin = godsOrigin();
109 const equipment = emptyEquipment();
110 equipment.slots[EQUIPMENT_SLOT.chest] = dyedClothingStack(
111 creationShirtItemId(),
112 clothing.shirt,
113 origin
114 );
115 equipment.slots[EQUIPMENT_SLOT.legs] = dyedClothingStack(
116 creationLegsItemId(clothing.legsKind),
117 clothing.legs,
118 origin
119 );
120 return { equipment };
121}
122
123/**
124 * Overlay creation clothing onto an existing starter equipment object (mutates slots).
125 */
126export function applyCreationClothingToEquipment (equipment, clothingInput)
127{
128 const clothing = normalizeCreateClothing(clothingInput);
129 const origin = godsOrigin();
130 const slots = equipment?.slots ?? emptyEquipment().slots;
131 slots[EQUIPMENT_SLOT.chest] = dyedClothingStack(
132 creationShirtItemId(),
133 clothing.shirt,
134 origin
135 );
136 slots[EQUIPMENT_SLOT.legs] = dyedClothingStack(
137 creationLegsItemId(clothing.legsKind),
138 clothing.legs,
139 origin
140 );
141 return equipment;
142}
shared/items/starterLoadout.js +9 −9
@@ -6,8 +6,9 @@
6 6 import { ItemId, itemDefinition, EQUIPMENT_SLOT } from "../definitions/items.js";
7 7 import { EQUIPMENT_SLOTS, emptyEquipment, emptySlots, insertStack } from "./inventory.js";
8 8 import { godsOrigin, attachOrigins } from "./origin.js";
9 import { applyCreationClothingToEquipment, normalizeCreateClothing } from "./createClothing.js";
9 10
10 /** Defaults match the previous hard-coded starter kit. */
11 /** Defaults match the previous hard-coded starter kit (clothing comes from character creation). */
11 12 export const DEFAULT_STARTER_EQUIPMENT = Object.freeze({
12 13 [EQUIPMENT_SLOT.head]: null,
13 14 [EQUIPMENT_SLOT.chest]: null,
@@ -21,7 +22,6 @@ export const DEFAULT_STARTER_INVENTORY = Object.freeze([
21 22 Object.freeze({ itemId: ItemId.paper, quantity: 5 }),
22 23 Object.freeze({ itemId: ItemId.apple, quantity: 3 }),
23 24 Object.freeze({ itemId: ItemId.stick, quantity: 1 }),
24 Object.freeze({ itemId: ItemId.clothShirt, quantity: 1 }),
25 25 Object.freeze({ itemId: ItemId.coins, quantity: 25 })
26 26 ]);
27 27
@@ -69,12 +69,11 @@ export function normalizeStarterInventory (raw)
69 69
70 70 export function normalizeStarterLoadout (settings)
71 71 {
72 const equipment = normalizeStarterEquipment(
73 settings?.starterEquipment ?? DEFAULT_STARTER_EQUIPMENT
74 );
75 const inventory = normalizeStarterInventory(
76 settings?.starterInventory ?? DEFAULT_STARTER_INVENTORY
77 );
72 // Accept world-settings shape or already-normalized `{ equipment, inventory }`.
73 const equipmentRaw = settings?.starterEquipment ?? settings?.equipment ?? DEFAULT_STARTER_EQUIPMENT;
74 const inventoryRaw = settings?.starterInventory ?? settings?.inventory ?? DEFAULT_STARTER_INVENTORY;
75 const equipment = normalizeStarterEquipment(equipmentRaw);
76 const inventory = normalizeStarterInventory(inventoryRaw);
78 77 return { equipment, inventory };
79 78 }
80 79
@@ -124,7 +123,7 @@ export function diffStarterLoadout (previous, next)
124 123 }
125 124
126 125 /** Build bag contents for a brand-new character. */
127 export function buildStarterBagContents (settings)
126 export function buildStarterBagContents (settings, creationClothing = null)
128 127 {
129 128 const { equipment: equipIds, inventory } = normalizeStarterLoadout(settings);
130 129 const origin = godsOrigin();
@@ -159,5 +158,6 @@ export function buildStarterBagContents (settings)
159 158 origins: [{ origin, quantity: 1 }]
160 159 });
161 160 }
161 applyCreationClothingToEquipment(equipment, normalizeCreateClothing(creationClothing));
162 162 return { slots, equipment };
163 163 }
@@ -6,8 +6,9 @@
6import { ItemId, itemDefinition, EQUIPMENT_SLOT } from "../definitions/items.js";
6import { ItemId, itemDefinition, EQUIPMENT_SLOT } from "../definitions/items.js";
7import { EQUIPMENT_SLOTS, emptyEquipment, emptySlots, insertStack } from "./inventory.js";
7import { EQUIPMENT_SLOTS, emptyEquipment, emptySlots, insertStack } from "./inventory.js";
8import { godsOrigin, attachOrigins } from "./origin.js";
8import { godsOrigin, attachOrigins } from "./origin.js";
9import { applyCreationClothingToEquipment, normalizeCreateClothing } from "./createClothing.js";
9
10
10/** Defaults match the previous hard-coded starter kit. */
11/** Defaults match the previous hard-coded starter kit (clothing comes from character creation). */
11export const DEFAULT_STARTER_EQUIPMENT = Object.freeze({
12export const DEFAULT_STARTER_EQUIPMENT = Object.freeze({
12 [EQUIPMENT_SLOT.head]: null,
13 [EQUIPMENT_SLOT.head]: null,
13 [EQUIPMENT_SLOT.chest]: null,
14 [EQUIPMENT_SLOT.chest]: null,
@@ -21,7 +22,6 @@ export const DEFAULT_STARTER_INVENTORY = Object.freeze([
21 Object.freeze({ itemId: ItemId.paper, quantity: 5 }),
22 Object.freeze({ itemId: ItemId.paper, quantity: 5 }),
22 Object.freeze({ itemId: ItemId.apple, quantity: 3 }),
23 Object.freeze({ itemId: ItemId.apple, quantity: 3 }),
23 Object.freeze({ itemId: ItemId.stick, quantity: 1 }),
24 Object.freeze({ itemId: ItemId.stick, quantity: 1 }),
24 Object.freeze({ itemId: ItemId.clothShirt, quantity: 1 }),
25 Object.freeze({ itemId: ItemId.coins, quantity: 25 })
25 Object.freeze({ itemId: ItemId.coins, quantity: 25 })
26]);
26]);
27
27
@@ -69,12 +69,11 @@ export function normalizeStarterInventory (raw)
69
69
70export function normalizeStarterLoadout (settings)
70export function normalizeStarterLoadout (settings)
71{
71{
72 const equipment = normalizeStarterEquipment(
72 // Accept world-settings shape or already-normalized `{ equipment, inventory }`.
73 settings?.starterEquipment ?? DEFAULT_STARTER_EQUIPMENT
73 const equipmentRaw = settings?.starterEquipment ?? settings?.equipment ?? DEFAULT_STARTER_EQUIPMENT;
74 );
74 const inventoryRaw = settings?.starterInventory ?? settings?.inventory ?? DEFAULT_STARTER_INVENTORY;
75 const inventory = normalizeStarterInventory(
75 const equipment = normalizeStarterEquipment(equipmentRaw);
76 settings?.starterInventory ?? DEFAULT_STARTER_INVENTORY
76 const inventory = normalizeStarterInventory(inventoryRaw);
77 );
78 return { equipment, inventory };
77 return { equipment, inventory };
79}
78}
80
79
@@ -124,7 +123,7 @@ export function diffStarterLoadout (previous, next)
124}
123}
125
124
126/** Build bag contents for a brand-new character. */
125/** Build bag contents for a brand-new character. */
127export function buildStarterBagContents (settings)
126export function buildStarterBagContents (settings, creationClothing = null)
128{
127{
129 const { equipment: equipIds, inventory } = normalizeStarterLoadout(settings);
128 const { equipment: equipIds, inventory } = normalizeStarterLoadout(settings);
130 const origin = godsOrigin();
129 const origin = godsOrigin();
@@ -159,5 +158,6 @@ export function buildStarterBagContents (settings)
159 origins: [{ origin, quantity: 1 }]
158 origins: [{ origin, quantity: 1 }]
160 });
159 });
161 }
160 }
161 applyCreationClothingToEquipment(equipment, normalizeCreateClothing(creationClothing));
162 return { slots, equipment };
162 return { slots, equipment };
163}
163}