Show encumbrance on HUD and document modular creator direction

This commit is contained in:
dingo
2026-09-12 08:53:32 -04:00
parent faf2ab3040
commit 75f71d5ded
9 changed files with 218 additions and 5 deletions
+1 -1
View File
@@ -22,7 +22,7 @@
<div id="target" class="target" hidden><span id="target-name"></span><span id="target-health"></span></div>
<div id="notice" role="status" class="notice" hidden></div>
<footer class="bottom" id="game-controls" hidden>
<section class="vitals"><div><strong id="character-name">Traveler</strong><span id="health-number">100 / 100</span></div><div class="bar"><i id="health-fill"></i></div><div class="vital-detail"><span><i data-lucide="hourglass"></i><span id="play-time">2h left today</span></span><span id="kills">0 kills</span></div><div class="progression-line"><strong id="character-level">Level 1</strong><span id="character-experience">0 XP</span></div><progress id="experience-meter" class="experience-meter" aria-label="Level experience" max="1" value="0"></progress><div class="progression-bank"><span id="stat-point-bank">0 stat points saved</span><span id="title-count">0 titles</span></div></section>
<section class="vitals"><div><strong id="character-name">Traveler</strong><span id="health-number">100 / 100</span></div><div class="bar"><i id="health-fill"></i></div><div class="vital-detail"><span><i data-lucide="hourglass"></i><span id="play-time">2h left today</span></span><span id="kills">0 kills</span></div><div class="progression-line"><strong id="character-level">Level 1</strong><span id="character-experience">0 XP</span></div><progress id="experience-meter" class="experience-meter" aria-label="Level experience" max="1" value="0"></progress><div class="progression-bank"><span id="stat-point-bank">0 stat points saved</span><span id="title-count">0 titles</span></div><button id="carry-manage" class="carry-manage" type="button" aria-label="Manage bag"><span id="carry-weight">Carry weight</span><span id="carry-movement" role="status"></span><small>Manage bag →</small></button></section>
<nav class="actions" aria-label="Actions"><button id="jump" title="Jump (Space)" aria-label="Jump">↑</button><button id="attack" title="Attack (F)" aria-label="Attack"><i data-lucide="swords"></i></button><button id="gather" title="Gather" aria-label="Gather"><i data-lucide="pickaxe"></i></button><button id="heal" title="Use bandage" aria-label="Use bandage"><i data-lucide="heart-pulse"></i><small id="bandage-count">0</small></button><button id="keystone" title="Return with keystone" aria-label="Return with keystone"><i data-lucide="gem"></i></button><span></span><button id="inventory-toggle" title="Inventory and crafting" aria-label="Inventory and crafting"><i data-lucide="backpack"></i></button></nav>
<section class="location"><canvas id="minimap" width="140" height="140" aria-label="World map"></canvas><span id="coordinates">0, 0</span><small id="chunk-count">9 chunks</small></section>
</footer>
+4 -3
View File
@@ -2,7 +2,7 @@ import type { Character } from './generated';
import {itemControls,chooseItemTarget} from './item-actions';
import { itemIcon } from './item-icon';
import { experienceText, permanentTitles } from './progression';
import { equipmentSlots, itemDetails, modifiersView, node, numberText, primaryStats, statLabel, statsBreakdown } from './character-stats';
import { carryStatus, equipmentSlots, itemDetails, modifiersView, node, numberText, primaryStats, statLabel, statsBreakdown } from './character-stats';
type Send = (op:string,target?:string,x?:number,z?:number,slot?:string)=>void;
const root=node('section','','character-panel'),resources=node('p','','character-resources'),body=node('div');
root.append(resources,body);
@@ -12,7 +12,7 @@ function active(){return latest.entity.state==='alive'&&latest.remainingSeconds>
function button(label:string,key:string,fn:()=>void,disabled=false){const b=node('button',label);b.type='button';b.dataset.focusKey=key;b.disabled=disabled;b.onclick=fn;return b;}
function request(op:string,target:string,slot=''){sendIntent(op,target,0,0,slot);}
function render(){
const next=JSON.stringify([selected,selectedItem,latest.entity.name,latest.level,latest.experience,latest.experienceToNextLevel,latest.titles,latest.entity.state,latest.remainingSeconds>0,latest.statPoints,latest.pendingVitalChoices,latest.allocatedStats,latest.stats,latest.items,latest.equipment,latest.inventory,latest.stackNames,latest.craftedStacks,latest.carryWeight,latest.gathering,latest.gatheringEffects,latest.consumables,latest.crafting,latest.weapons,latest.powers]);
const next=JSON.stringify([selected,selectedItem,latest.entity.name,latest.level,latest.experience,latest.experienceToNextLevel,latest.titles,latest.entity.state,latest.remainingSeconds>0,latest.statPoints,latest.pendingVitalChoices,latest.allocatedStats,latest.stats,latest.items,latest.equipment,latest.inventory,latest.stackNames,latest.craftedStacks,latest.carryWeight,latest.movementFactor,latest.gathering,latest.gatheringEffects,latest.consumables,latest.crafting,latest.weapons,latest.powers]);
if(next===signature)return;signature=next;
const focus=root.contains(document.activeElement)?(document.activeElement as HTMLElement).dataset.focusKey:undefined;
const opened=new Set(Array.from(body.querySelectorAll<HTMLDetailsElement>('details[open]')).map(d=>d.dataset.key));body.replaceChildren();
@@ -30,7 +30,8 @@ function render(){
const effects=node('details','','stat-inspection');effects.dataset.key='equipment-effects';effects.append(node('summary','Equipment modifiers'));
for(const item of c.items??[])if(Object.values(c.equipment??{}).includes(item.id))effects.append(node('h3',item.name),modifiersView(item.modifiers));body.append(effects);
} else {
body.append(node('p',`Carry weight ${numberText(c.carryWeight)} / ${numberText(c.stats?.carryCapacity?.final)} · Movement ${Math.round((c.movementFactor??1)*100)}%${c.movementFactor===0?' · Drop or store items to move again':''}`,'progression-note'));
const carry = carryStatus(c);
body.append(node('p',`${carry.weight} · ${carry.movement}. ${carry.help}`,'progression-note'));
const held=new Set(Object.values(c.equipment??{})),grid=node('div','','bag-grid'),inspection=node('div','','bag-inspection');
grid.setAttribute('aria-label','Bag items');
function tile(id:string,name:string,count:number,category:string){const b=button('',`item-${id}`,()=>{if(chooseItemTarget(id))return;selectedItem=selectedItem===id?'':id;signature='';render()});b.className='bag-slot';b.title=name;b.setAttribute('aria-label',`${name} × ${count}`);b.setAttribute('aria-pressed',String(selectedItem===id));b.append(itemIcon(category),node('span',name,'bag-name'),node('b',String(count),'bag-count'));grid.append(b);return selectedItem===id;}
+14 -1
View File
@@ -9,6 +9,18 @@ const labels: Record<string,string> = { meleeDamage:'Close combat weapons damage
export const statLabel = (key:string) => labels[key] ?? key.replace(/([a-z])([A-Z0-9])/g,'$1 $2').replaceAll('_',' ').replace(/^./,c=>c.toUpperCase());
export const numberText = (value:number|undefined) => Number.isFinite(value) ? new Intl.NumberFormat(undefined,{maximumFractionDigits:2}).format(value!) : '—';
export const signed = (value:number) => `${value>0?'+':''}${numberText(value)}`;
export function carryStatus(c: Character) {
const factor = c.movementFactor;
const impaired = factor !== undefined && factor < 1;
return {
impaired,
weight: `Carry weight ${numberText(c.carryWeight)} / ${numberText(c.stats?.carryCapacity?.final)}`,
movement: factor === 0 ? 'Overburdened · Cannot move' : impaired
? `Encumbered · Movement ${numberText(factor * 100)}%`
: factor === undefined ? 'Movement unavailable' : 'Full movement',
help: factor === 0 ? 'Drop or store items to move again.' : impaired ? 'Reduce carried weight to restore movement speed.' : '',
};
}
export function node<K extends keyof HTMLElementTagNameMap>(tag:K,text='',className='') { const e=document.createElement(tag);e.textContent=text;e.className=className;return e; }
export function modifiersView(modifiers:StatModifier[] = []) {
const list=node('div','','title-effects');
@@ -43,7 +55,8 @@ export function itemDetails(item:ItemInstance,c:Character) {
}
export function equipmentDetails(c:Character) {
const root=node('div','','gear-list');
root.append(node('p',`Mana ${numberText(c.mana)} / ${numberText(c.stats?.manaPoints?.final)} · Stamina ${numberText(c.stamina)} / ${numberText(c.stats?.stamina?.final)} · Carry weight ${numberText(c.carryWeight)} / ${numberText(c.stats?.carryCapacity?.final)} (advisory)`));
const carry = carryStatus(c);
root.append(node('p',`Mana ${numberText(c.mana)} / ${numberText(c.stats?.manaPoints?.final)} · Stamina ${numberText(c.stamina)} / ${numberText(c.stats?.stamina?.final)} · ${carry.weight} · ${carry.movement}. ${carry.help}`));
for(const slot of equipmentSlots){const item=c.items?.find(i=>i.id===c.equipment?.[slot]);root.append(node('p',`${statLabel(slot)}: ${item?.name??'Empty'}`));}
for(const item of c.items??[]){const card=itemDetails(item,c);card.append(node('small',`Instance ${item.id}`));root.append(card);}
return root;
+14
View File
@@ -14,6 +14,7 @@ import type { BuildingContent, Character, Chunk, Entity, Intent, Snapshot } from
import { experienceText, statPointsText, updateExperienceMeter } from './progression';
import { InputActions, isEditing, type InputAction } from './input-actions';
import { hasOpenMenu, registerMenu } from './menu-focus';
import { carryStatus } from './character-stats';
type Config = { worldId: string; kind: string; development: boolean; worlds: { id: string; url: string }[]; playerSpeed: number; gatherRange: number; attackRange: number };
const $ = <T extends HTMLElement = HTMLElement>(id: string) => document.getElementById(id) as T;
@@ -204,6 +205,13 @@ function updateHUD(s: Snapshot) {
$('character-experience').textContent = experienceText(c);
updateExperienceMeter($<HTMLProgressElement>('experience-meter'), c);
$('stat-point-bank').textContent = statPointsText(c);
const carry = carryStatus(c);
$('carry-weight').textContent = carry.weight;
// Keep the explanation visible even when the bag is closed. The server owns
// the movement factor; do not reproduce encumbrance tuning in the browser.
if ($('carry-movement').textContent !== carry.movement) $('carry-movement').textContent = carry.movement;
$('carry-manage').classList.toggle('encumbered', carry.impaired);
$('carry-manage').title = `${carry.help} Open bag to manage carried items.`.trim();
const titleCount = c.titles?.length ?? 0;
$('title-count').textContent = `${titleCount} title${titleCount === 1 ? '' : 's'}`;
$('health-number').textContent = `${Math.max(0, Math.ceil(c.entity.hp))} / ${Math.ceil(c.entity.maxHp)}`;
@@ -232,6 +240,12 @@ function updateHUD(s: Snapshot) {
if (s.message && s.message !== lastNotice) { notice(s.message); lastNotice = s.message; }
}
async function boot() {
$('carry-manage').onclick = () => {
if ($('inventory').hidden) $('inventory-toggle').click();
const bag = $('inventory').querySelector<HTMLButtonElement>('[data-view="bag"]');
bag?.click();
bag?.focus();
};
$<HTMLAnchorElement>('login').href = `/auth/login?return=${encodeURIComponent(location.pathname + location.search)}`;
createIcons({ icons: { Crosshair, Settings2, X, Flame, LogOut, Hourglass, Swords, Pickaxe, HeartPulse, Gem, Backpack, ChevronUp, ChevronDown, ChevronLeft, ChevronRight, ArrowRight, RefreshCw } });
view = new WorldView($<HTMLCanvasElement>('world'));
+5
View File
@@ -10,6 +10,11 @@
@media(max-width:800px) and (min-height:521px){.movement:not([hidden]){bottom:255px}.inventory{bottom:258px;max-height:calc(100dvh - 350px)}.notice{bottom:375px}}
@media(max-height:520px){.movement:not([hidden]){bottom:178px}}
.carry-manage{display:grid;gap:3px;width:100%;margin-top:10px;padding:7px 8px;text-align:left;justify-content:start;font-size:11px;line-height:1.3}
.carry-manage small{color:#cbd7c2;font-size:10px}
.carry-manage.encumbered{color:#ffdc9b;background:#45321e;border-color:#c39152}
@media(max-width:800px) and (min-height:521px){.movement:not([hidden]){bottom:335px}}
@media(max-height:520px){.movement:not([hidden]){bottom:258px}.carry-manage{padding:4px 6px;margin-top:6px}}
#target-health{white-space:normal;line-height:1.5;max-width:min(550px,80vw)}
.crafting-workbench{display:grid;gap:12px;font-size:12px;line-height:1.5}.crafting-workbench h3{margin:8px 0 0}.crafting-workbench form{display:grid;gap:8px}.crafting-workbench .recipe{display:grid;grid-template-columns:minmax(0,1fr) 68px;gap:6px}.crafting-workbench .recipe button{grid-column:1/-1;justify-self:end}.crafting-workbench details{border-top:1px solid var(--progression-border);padding:10px 0;overflow-wrap:anywhere}.crafting-workbench summary{cursor:pointer}.crafting-workbench details p{margin:8px 0}.crafting-workbench [role=status]{color:#d6e4b6}
+6
View File
@@ -1,5 +1,11 @@
# Creator detour: rounded fantasy models
**Playtest direction revised:** the user rejected the current character styling
and requested anatomical body/face controls and a Spore-like creature part builder.
See [Modular creators](../planning/MODULAR-CREATORS.md) for the confirmed controls,
connection/joint contract, equipment dependencies, and proposed slices. The tools
described below remain the implemented version-1 prototype, not the final design.
September 11 playable handoff. The user chose softer, rounded fantasy shapes.
This is a focused creator detour before revised milestone 4's reliability and
persistence work. It completes part of the presentation/customization foundation,
+5
View File
@@ -235,6 +235,11 @@ with softer rounded fantasy shapes. See [Creator workshop](../docs/CREATOR-WORKS
for the implemented procedural creators and handoff. This does not renumber the
nine milestones or complete the full rigs/equipment/animation/audio scope.
The subsequent playtest reported blocked player movement and revised the visual
direction to anatomical region/face controls and a Spore-like modular mob builder.
[Modular creators](MODULAR-CREATORS.md) records the complete requested part list,
connection profiles/joint limits, version compatibility, and proposed review slices.
Milestones 1–3 have implementation handoffs above. Milestone 4 now includes the
storage work that must precede expanding worlds; it is no longer only a rules
discussion. The [reliability issue register and persistence plan](RELIABILITY-AND-PERSISTENCE.md)
+164
View File
@@ -0,0 +1,164 @@
# Modular characters and creature builder
September 11 follow-up to the first creator playtest. This records the user's
revised direction, not a claim that these controls or rigs are implemented.
The first [creator workshop](../docs/CREATOR-WORKSHOP.md) remains a version-1
prototype. Its rounded preset characters did not meet the desired visual style.
## Visual direction
Use the supplied head, torso, leg, and arm references as anatomical/proportion and
topology references. Build recognizable, proportioned fantasy bodies with a shaped
face, torso, elbows, knees, hands, and feet. The reference wireframes are modeling
guidance, not a request to display wireframes on finished characters. Final surface
detail, shading, and stylization should be reviewed on one base character before
expanding the library. Hair styles from the first scope remain confirmed.
Character appearance belongs to the character. Revival, travel, and restart retain
it; replacement starts a new character. Only cosmetic entitlements carry across
characters at account level. Body customization must not change player hitboxes,
reach, movement speed, or any other authoritative gameplay attribute.
## Confirmed character controls
| Region | Requested controls |
| --- | --- |
| Hair | Several selectable styles; retain color customization |
| Head | Independent length, width, and depth |
| Eyes | Location and color |
| Eyebrows | On/off, bushy/thin |
| Nose | Location and scale within reasonable bounds |
| Mouth | Location and style |
| Chest | Male/female forms |
| Hips | Adjustable body region |
| Arms | Adjustable body region |
| Legs | Adjustable body region |
| Feet | Adjustable body region |
Recommended first editor: choose a region on the preview or in a clearly labeled
list; show only that region's controls. Use proportion sliders, feature selectors,
reset-region/reset-all, front/side/back views, and an orbit preview. Pair left/right
features by default. Exact ranges, additional limb controls, and asymmetric player
editing remain to be decided; do not silently treat them as confirmed requirements.
Use a modest fitted base outfit while reviewing body forms.
## Confirmed creature controls
The requested direction is a Spore-like part builder, beyond four fixed creature
presets. It should support these parts and variations:
| Part | Requested options |
| --- | --- |
| Heads | One or more heads, each with its own features |
| Face | Eyes; vertical/horizontal mouths; inset/outset and large/small noses |
| Hair and horns | Hair parts and one or more horns; editable placement including X/Y |
| Necks | One or more necks connecting heads to the body |
| Body | Upper and lower body regions |
| Arms/hands | Optional arms; claw styles and finger count |
| Legs | Optional legs; biped, triped, quadruped, and higher counts |
| Feet | Hoof, animal, and human styles |
| Wings | Attachable wings |
| Tails | One or more tails |
Recommended interaction: select a body part, see compatible attachment locations,
add a part from a palette, then position/rotate/scale it within that attachment's
bounds. Offer mirror-pair placement, duplicate branch, undo/redo, and a visible
hierarchy. Multiple heads and unusual limb arrangements are part of the target
scope, not a promise that the initial prototype can animate every arrangement.
Mob visuals stay separate from existing stats, behavior, attacks, loot, spawns,
and biome rules. Adding a horn or wing must not implicitly add damage or flight.
Publishing and spawning continue through audited admin actions with server IDs.
Scenery creation for trees, rocks, and plants remains on the overall creator list.
## Shared connection and rig contract
Recommended implementation: fixed humanoid skeleton/topology for players, and a
validated part hierarchy for creatures. Both use connection profiles. A profile
defines the parent socket and child anchor, compatible part categories, local
rest position/orientation, scale bounds, joint axes, and minimum/maximum rotation
per axis. The editor must distinguish rest-pose editing from animation posing.
Use stable profile/part-definition IDs assigned by the server when published.
Player body sliders should deform a consistent mesh and update bone/attachment
placement together. Preserve topology and named bones across male/female chest
forms and proportions, so equipment and animation do not require a different
rig for every saved look. Avoid simply scaling separate spheres at each region.
Creature parts need connection seams, skin weights, bone chains, and locomotion
roles as well as rotation limits. Joint limits make assembly more predictable;
they do not automatically solve mesh deformation, foot placement, wing motion,
or animation for arbitrary anatomies. Start with a few supported locomotion
templates and validate each additional arrangement before describing it as ready.
The backend validates the complete recipe: supported version and part/profile
references, finite bounded transforms, valid ordered joint ranges, compatible
attachments, one root, no cycles or dangling parents, and explicit part/bone/depth
budgets. Numeric limits are provisional engineering choices to measure, not new
tested-capacity claims. Preview and save must apply the same restrictions.
## Equipment and export
Add named equipment anchors for head/face, neck/ears, shoulders/chest, hands,
waist/hips, legs/feet, back, and weapon/offhand grips. Preserve the existing slot
contract, including eight ring slots. Rigged clothes/armor deform with the body;
rigid accessories attach to anchors. Attachment sockets alone do not make fitted
armor fit: compatible deformation, body-region hiding, and clipping checks are
also required. Test extreme allowed proportions and joint poses with sample gear.
The current builder merges geometry by material for static rendering. Keep that
optimization for static scenery, but preserve the skeleton, skin weights, and
part/attachment metadata for deformable bodies. A future rigged GLB export must
retain its bones and bindings. Round-trip validation is required before replacing
the current static export. Animation, sounds, asset storage/CDN, and LOD work
remain visible dependencies in the main roadmap.
## Proposed playable slices
1. **Movement feedback repair.** The affected character's server snapshot shows
carry weight 297.1, capacity 100, and movement factor 0: the existing encumbrance
rule blocks all movement. Show persistent weight and blocked/slowed feedback
with direct bag access. Verify recovery after dropping weight, including
keyboard, click-to-move, and touch controls during manual playtesting. Preserve
server-side movement, weight, time, and lifecycle rules.
2. **Base humanoid review.** Build one proportioned base with male/female chest
forms, consistent topology, named bones, and a neutral outfit. Review front,
side, and joint-bend previews against the references before adding variants.
3. **Character customization.** Add the confirmed region and face controls,
versioned save/load, world/housing display, and compatibility with old looks.
Include basic equipment-fit previews to validate the shape/rig contract.
4. **Creature assembly prototype.** Add the part palette, socket profiles,
hierarchy, joint limits, and symmetry tools. Validate a biped and quadruped
first, then multiple heads, odd limb counts, wings, and tails as separate
reviewed additions. Record unsupported animation combinations explicitly.
5. **Presentation integration.** Complete production locomotion/action animation,
visible equipped gear, sound hooks, rigged exports, and performance work under
the existing presentation milestone. This is not completed by an editor demo.
Commit and push each playable slice for the user's manual test. Routine Playwright
authoring remains deferred; focused regression checks and required repository
checks still apply to fixes. The storage/reliability milestone remains required
before expanding worlds; these creator slices do not replace it or renumber the
main nine-step plan. The point at which the creator detour returns to that work
should be agreed after the base humanoid review.
## Compatibility and acceptance
- Keep version-1 appearances and published visual presets renderable. Introduce
a new recipe version; never silently reinterpret an old preset as a new anatomy.
- Existing characters can opt into a new base appearance without losing items,
progression, identity, or cosmetic entitlements. Failed saves retain the old look.
- Closing, saving, or canceling a creator must restore the surrounding interface;
gameplay input stays blocked only while a relevant menu is actually open.
- Check world and housing rendering, reconnect, travel, revival, replacement,
invalid recipes, bounded geometry cost, and disposal of replaced preview assets.
- Review silhouettes, facial feature placement, seams and joint bends visually.
Do not claim the new style is accepted based only on a passing build.
## Decisions still open
- Final shading and detail level of the humanoid; exact per-region slider ranges.
- Supported player asymmetry and full hand/finger editing, if desired.
- Creature part/bone budgets, socket libraries, and supported locomotion templates.
- Whether armor is fitted through shared morphs, authored size variants, or both.
- Scope of the first playable creature builder before returning to persistence.
+5
View File
@@ -22,6 +22,11 @@ for new mobs/resources with GLB export. The user requested this detour before
returning to revised milestone 4. Original 4.5's skeletal rigs, visible equipment,
animations, and sound remain pending; account cosmetics remain revised milestone 7.
**Creator playtest revision:** [Modular creators](MODULAR-CREATORS.md) records the
requested anatomical player controls, male/female chest forms, modular creature
parts, connection profiles and joint limits. It supersedes the initial character
styling direction; the version-1 workshop is still the implemented prototype.
Draft for discussion, 2026-09-08. This document organizes requested work; it does
not authorize gameplay implementation or finalize the open decisions below.
Existing behavior is described in `docs/ARCHITECTURE.md` and `docs/PROGRESSION.md`.