Add durable recipe discovery and profession crafting
This commit is contained in:
@@ -11,7 +11,7 @@ function button(label:string,key:string,fn:()=>void,disabled=false){const b=node
|
||||
function request(op:string,target:string,slot=''){sendIntent(op,target,0,0,slot);}
|
||||
function render(){
|
||||
for(const b of nav.querySelectorAll('button'))b.setAttribute('aria-pressed',String(b.dataset.section===selected));
|
||||
const next=JSON.stringify([selected,latest.entity.state,latest.remainingSeconds>0,latest.statPoints,latest.pendingVitalChoices,latest.allocatedStats,latest.stats,latest.items,latest.equipment,latest.inventory,latest.carryWeight,latest.gathering,latest.gatheringEffects,latest.consumables]);
|
||||
const next=JSON.stringify([selected,latest.entity.state,latest.remainingSeconds>0,latest.statPoints,latest.pendingVitalChoices,latest.allocatedStats,latest.stats,latest.items,latest.equipment,latest.inventory,latest.craftedStacks,latest.carryWeight,latest.gathering,latest.gatheringEffects,latest.consumables]);
|
||||
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();
|
||||
@@ -32,7 +32,7 @@ function render(){
|
||||
if(slot==='ring'){const label=node('label','Ring slot'),select=node('select');select.dataset.focusKey=`ring-${item.id}`;select.setAttribute('aria-label',`Ring slot for ${item.name}`);for(let n=1;n<=8;n++)select.append(new Option(`Ring ${n}${c.equipment?.[`ring${n}`]?' · Occupied':' · Empty'}`,`ring${n}`));select.value=rings.get(item.id)??equipmentSlots.find(s=>s.startsWith('ring')&&!c.equipment?.[s])??'ring1';slot=select.value;select.onchange=()=>{slot=select.value;rings.set(item.id,slot)};label.append(select);actions.append(label);}
|
||||
actions.append(button('Equip',`equip-${item.id}`,()=>request('equip',item.id,slot),!active()||!item.equippable),button('Drop',`drop-${item.id}`,()=>request('drop',item.id),!active()));card.append(actions);grid.append(card);
|
||||
}
|
||||
for(const [key,count] of Object.entries(c.inventory??{}))if(count>0){const card=node('article','','stack-card');card.append(node('span',`${c.stackNames?.[key]??statLabel(key)} × ${count}`),button('Drop one',`drop-stack-${key}`,()=>request('drop',key),!active()));const consumable=c.consumables?.find(v=>v.id===key);if(consumable)card.append(node('p',`${consumable.description} · ${consumable.seconds}s`),modifiersView(consumable.modifiers),button('Use',`consume-${key}`,()=>request('consume',key),!active()));grid.append(card);}
|
||||
for(const [key,count] of Object.entries(c.inventory??{}))if(count>0){const card=node('article','','stack-card');card.append(node('span',`${c.stackNames?.[key]??statLabel(key)} × ${count}`),button('Drop one',`drop-stack-${key}`,()=>request('drop',key),!active()));const consumable=c.consumables?.find(v=>v.id===key);if(consumable)card.append(node('p',`${consumable.description} · ${consumable.seconds}s`),modifiersView(consumable.modifiers),button('Use',`consume-${key}`,()=>request('consume',key),!active()));for(const batch of c.craftedStacks??[])if(batch.item===key)card.append(node('small',`${batch.quantity} crafted by ${batch.provenance.crafterName} in ${batch.provenance.worldId}`));grid.append(card);}
|
||||
if(!grid.children.length)grid.append(node('p','Your bag is empty.'));body.append(grid);
|
||||
}
|
||||
for(const d of body.querySelectorAll<HTMLDetailsElement>('details'))d.open=opened.has(d.dataset.key);
|
||||
|
||||
Reference in New Issue
Block a user