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.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
@@ -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 & 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>Sex546
<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>Hair555
<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>Sex552
<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>Hair560
<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>Legs573
<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 & play</button>593
<button type="submit">Create & play</button>563
</form>594
</form>564
</aside>595
</aside>@@ -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 @@1
import {2
DEFAULT_HAIR_HUE,3
DEFAULT_HAIR_SATURATION,4
DEFAULT_HAIR_DARKNESS,5
normalizeHairSliders,6
hairColorFromSliders7
} from "/shared/appearance/hair.js";8
import {9
CreationLegsKind,10
CREATION_LEGS_KINDS,11
defaultCreateClothing,12
normalizeCreateClothing,13
creationClothingPreviewBag14
} 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 = null28
})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
? selected55
: 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) / 10064
});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
applyDefaults128
};129
}130
131
export { CreationLegsKind, DEFAULT_HAIR_HUE, DEFAULT_HAIR_SATURATION, DEFAULT_HAIR_DARKNESS };@@ -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";25
import { initBounty } from "./bounty.js";25
import { initBounty } from "./bounty.js";26
import { initBarber } from "./barber.js";26
import { initBarber } from "./barber.js";27
import { bindHairControls } from "./hairControls.js";27
import { bindHairControls } from "./hairControls.js";28
import { bindCreateClothingControls } from "./createClothingControls.js";29
import { paintCharacterPreview } from "./characterPreview.js";28
import { initGraphicsSettings } from "./graphicsSettings.js";30
import { initGraphicsSettings } from "./graphicsSettings.js";29
import { CraftingStationId } from "/shared/definitions/craftingStations.js";31
import { CraftingStationId } from "/shared/definitions/craftingStations.js";30
import { isOreBoulderState } from "/shared/definitions/materialTiers.js";32
import { isOreBoulderState } from "/shared/definitions/materialTiers.js";@@ -68,6 +70,8 @@ let market;68
let bounty;70
let bounty;69
let barber;71
let barber;70
let createHairControls;72
let createHairControls;73
let createClothingControls;74
let createActiveTab = "appearance";71
let pendingPickup = null;75
let 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 } */73
let pendingInteract = null;77
let 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: true1002
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: consumeWorldClick1030
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?.() ?? null1578
hair: createHairControls?.currentHair?.() ?? null,1579
clothing: createClothingControls?.currentClothing?.() ?? null1556
});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
else1607
{ 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
try1616
{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: 41627
});1628
}1629
catch (error)1630
{ console.warn(error); }1631
}1632
1559
document.getElementById("leave").addEventListener("click", () =>1633
document.getElementById("leave").addEventListener("click", () =>1560
{1634
{1561
socket.send({ type: MessageType.leaveWorld });1635
socket.send({ type: MessageType.leaveWorld });@@ -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;@@ -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 fi100
## 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 fi241
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 fi253
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 / 3333
## 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
@@ -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
normalizeHairStyle7
normalizeHairStyle8
} from "../../../shared/appearance/hair.js";8
} from "../../../shared/appearance/hair.js";9
import { normalizeCreateClothing } from "../../../shared/items/createClothing.js";9
10
10
export class CharacterService11
export class CharacterService11
{12
{@@ -20,7 +21,7 @@ export class CharacterService20
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 CharacterService40
{ 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 CharacterService48
8,50
8,49
8,51
8,50
hairFields,52
hairFields,51
starterSettings53
starterSettings,54
clothingFields52
);55
);53
return publicCharacter(character);56
return publicCharacter(character);54
}57
}@@ -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.settings114
simulation.settings,115
message.clothing ?? null115
);116
);116
enterWorld(session, created.characterId);117
enterWorld(session, created.characterId);117
}118
}@@ -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 StateDatabase338
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 StateDatabase380
}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 StateDatabase839
}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_blob850
character_id, inventory_blob, equipment_blob, currency, vault_blob, vault_currency, skills_blob@@ -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
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
const harness = makeSimulation({ workerCount: 1 });97
const harness = makeSimulation({ workerCount: 1 });98
try98
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: shirtSlot108
});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
}@@ -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";3
import { npcDefaultEquipment, npcClothDyeFromSeed, NPC_CLOTH_DYE_BYTE_MIN } from "../../shared/appearance/npcEquipment.js";3
import { npcDefaultEquipment, npcClothDyeFromSeed, NPC_CLOTH_DYE_BYTE_MIN } from "../../shared/appearance/npcEquipment.js";4
import { ItemId } from "../../shared/definitions/items.js";4
import { ItemId } from "../../shared/definitions/items.js";5
import { LeatherItemId } from "../../shared/definitions/leatherItems.js";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
import { mobComponents } from "../src/simulation/spawners.js";8
import { mobComponents } from "../src/simulation/spawners.js";7
import { MobId } from "../../shared/definitions/mobs.js";9
import { 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);