Show personal and reputation arcs in one quest journal

This commit is contained in:
unimatrixgit 2026-12-05 21:54:03 +01:00
commit 188f8fcd21
10 changed files with 124 additions and 42 deletions

View file

@ -2,6 +2,27 @@
// The server decides state, eligibility and rewards; nothing here grants anything.
export const STATUS_LABEL=Object.freeze({done:'Done',ready:'Ready to claim',active:'Active',available:'Available',locked:'Locked'});
export const JOURNAL_LANES=Object.freeze({
personal:{endpoint:'/api/progression',label:'Personal'},
pol:{endpoint:'/api/progression/pol',label:'Reputation'}
});
export const journalId=(lane,id)=>lane+':'+id;
/** Preserve each definition and source lane while making selection IDs unambiguous. */
export function combineJournalData(results){
const active=results.filter(([,data])=>data.state==='active');
return {
state:active.length?'active':'season-not-configured',
profiles:active.map(([lane,data])=>({lane,profile:data.profile,season:data.season})),
branches:active.flatMap(([lane,data])=>(data.branches||[]).map(b=>({...b,id:journalId(lane,b.id),lane}))),
quests:active.flatMap(([lane,data])=>(data.quests||[]).map(q=>({
...q,id:journalId(lane,q.id),definitionId:q.id,branch:journalId(lane,q.branch),lane,
requires:(q.requires||[]).map(id=>journalId(lane,id)),
requiresAny:(q.requiresAny||[]).map(id=>journalId(lane,id)),
verificationSource:data.sources?.sources?.find(source=>source.metrics?.includes(q.metric))
})))
};
}
export function questStatus(q){
if(q.state==='claimed')return 'done';
if(q.canClaim&&q.progress>=q.target)return 'ready';
@ -29,7 +50,7 @@ export function buildJournal(data,{arcTitles={}}={}){
return {...q,status,statusLabel:STATUS_LABEL[status],lockedBy:status==='locked'&&missing.length?'Complete '+names.get(missing[0])+' first.':null};
});
const done=list.filter(q=>q.status==='done').length;
return {id,title:titles.get(id)||String(id).toUpperCase(),quests:list,done,total:list.length,complete:done===list.length};
return {id,lane:list[0]?.lane,title:titles.get(id)||String(id).toUpperCase(),quests:list,done,total:list.length,complete:done===list.length};
});
return {arcs,all:arcs.flatMap(a=>a.quests)};
}

View file

@ -1,7 +1,7 @@
import {element as el} from './cp-v2-page-template.mjs';
import {actions,briefing,currentObjective,nextInArc,objectives,rewards,pickSelection} from './cp-v2-mission-journal-model.mjs';
import {actions,briefing,currentObjective,JOURNAL_LANES,nextInArc,objectives,rewards,pickSelection} from './cp-v2-mission-journal-model.mjs';
import {categoryFor,categoryHero,groupJournalArcs,bannerUrl,iconUrl,ensureStyles} from './cp-v2-quest-categories.mjs';
import {categoryFor,categoryHero,groupJournalArcs,bannerUrl,iconUrl,ensureStyles,storyLanes} from './cp-v2-quest-categories.mjs';
const bar=(percent,label)=>{const p=el('progress');p.max=100;p.value=percent;p.setAttribute('aria-label',label);return p;};
const button=(text,fn,disabled=false)=>{const b=el('button',text);b.type='button';b.disabled=disabled;b.onclick=fn;return b;};
@ -22,9 +22,15 @@ export function renderMissionJournal(body,{journal,selected,tracked,banners=[],b
else strip.append(el('small','Current objective'),el('span','No active mission. Pick one from the list.'));
root.append(strip);
const layout=el('div',undefined,'mj-layout'),nav=el('nav',undefined,'mj-arcs');nav.setAttribute('aria-label','Story arcs');
const layout=el('div',undefined,'mj-layout');
ensureStyles();
for(const arc of groupJournalArcs(journal.arcs)){
const sections=[];
for(const lane of storyLanes(journal.arcs)){
const section=el('section',undefined,'mj-story-lane');
const nav=el('nav',undefined,'mj-arcs');nav.setAttribute('aria-label',lane.title);
if(lane.lane){section.dataset.lane=lane.lane;section.append(el('h3',lane.title));}
section.append(nav);sections.push(section);
for(const arc of groupJournalArcs(lane.rows)){
const group=el('details',undefined,'mj-arc');group.dataset.categoryId=arc.category.id;group.open=arc.quests.some(q=>q.id===selected)||(!arc.complete&&arc.quests.some(q=>q.status==='active'||q.status==='ready'));
const head=el('summary',undefined,'quest-category-heading');head.style.backgroundImage='linear-gradient(90deg,rgba(24,34,25,.75),rgba(24,34,25,.15)),url("'+bannerUrl(arc.category)+'")';
const icon=el('img');icon.src=iconUrl(arc.category);icon.alt='';icon.width=icon.height=24;
@ -50,6 +56,7 @@ export function renderMissionJournal(body,{journal,selected,tracked,banners=[],b
}
const tableFrame=el('div',undefined,'table-wrap mj-mission-table-frame');
table.append(rows);tableFrame.append(table);group.append(tableFrame);nav.append(group);
}
}
@ -57,13 +64,13 @@ export function renderMissionJournal(body,{journal,selected,tracked,banners=[],b
if(!q)pane.append(el('p','No missions are available yet.'));
else{
pane.append(categoryHero(categoryFor(q.branch),el));
pane.append(el('h3',q.title),el('span',q.statusLabel,'mj-status'),el('p',briefing(q),'mj-briefing'));
pane.append(el('h3',q.title),el('span',q.statusLabel,'mj-status'));if(q.lane)pane.append(el('small',JOURNAL_LANES[q.lane].label+' mission'));pane.append(el('p',briefing(q),'mj-briefing'));
if(q.lockedBy)pane.append(el('p',q.lockedBy,'progression-notice'));
if(q.cooldownUntil>Date.now())pane.append(el('p','Next available: '+new Date(q.cooldownUntil).toLocaleString(),'progression-notice'));
pane.append(el('h4','Objectives'));const goals=el('ul',undefined,'mj-objectives');
for(const o of objectives(q)){const row=el('li');row.dataset.done=String(o.done);row.append(el('span',o.label),el('small',o.text),bar(o.percent,o.label));goals.append(row);}
pane.append(goals,el('h4','Rewards'));const prizes=el('dl',undefined,'mj-rewards');
for(const r of rewards(q,{xpType})){prizes.append(el('dt',r.label),el('dd',r.value));}
for(const r of rewards(q,{xpType:q.lane??xpType})){prizes.append(el('dt',r.label),el('dd',r.value));}
pane.append(prizes);
const row=el('div',undefined,'mj-actions');
for(const a of actions(q,{tracked})){
@ -72,5 +79,5 @@ export function renderMissionJournal(body,{journal,selected,tracked,banners=[],b
if(onSteps)row.append(button("Mission steps",()=>onSteps(q),busy));
pane.append(row);
}
layout.append(pane,nav);root.append(layout);body.append(root);
layout.append(pane,...sections);root.append(layout);body.append(root);
}

View file

@ -6,7 +6,7 @@ import {renderProgressionHistory} from './cp-v2-progression-history.mjs';
import {element as el} from './cp-v2-page-template.mjs';
import {MISSION_BRANCHES} from './cp-v2-progression-catalogue.mjs';
import {categoryFor,categoryHero,groupBranches,orderChapters} from './cp-v2-quest-categories.mjs';
import {advanceTracked,buildJournal,completions,nextInArc,pickSelection} from './cp-v2-mission-journal-model.mjs';
import {advanceTracked,buildJournal,combineJournalData,completions,JOURNAL_LANES,journalId,nextInArc,pickSelection} from './cp-v2-mission-journal-model.mjs';
import {renderMissionJournal} from './cp-v2-mission-journal.mjs';
const art='https://www.dunerealms.com/assets/';
@ -18,26 +18,43 @@ const date=n=>new Date(n).toLocaleString(undefined,{dateStyle:'medium',timeStyle
// The server supplies all state, eligibility and rewards. The browser sends only
// the selected definition and its displayed revision, never XP or counters.
export function mountPersonalProgression(host,{view='missions',fetcher=fetch,apiBase='/api/progression',onData=()=>{},onBranches=()=>{},externalBranches=false,onCareerNavigate=null,initialBranch='a',allowedBranches=null,artwork=null,journal=true}={}){
export function mountPersonalProgression(host,{view='missions',fetcher=fetch,apiBase='/api/progression',onData=()=>{},onBranches=()=>{},externalBranches=false,onCareerNavigate=null,initialBranch='a',allowedBranches=null,artwork=null,journal=true,combined=false,preferredLane=null}={}){
const controller=new AbortController(),status=el('p','Opening your mission journal…','progression-notice'),body=el('div');
status.setAttribute('role','status');host.replaceChildren(status,body);
let active=true,data=null,branch=initialBranch,selected=null,busy=false,uncertain=false,page=1,loadSequence=0,connectorObserver=null;
let requestedLane=combined&&Object.hasOwn(JOURNAL_LANES,preferredLane)?preferredLane:null,loadNotice='';
let requestedArc=typeof initialBranch==='string'&&initialBranch!=='a'?initialBranch:null;
const journalMode=journal!==false&&view==='missions';
if(journalMode&&!document.querySelector('link[data-mission-journal]')){const link=el('link');link.rel='stylesheet';link.href=new URL('./cp-v2-mission-journal.css',import.meta.url).href;link.dataset.missionJournal='true';document.head.append(link);}
const trackKey=()=>'dunerealms.tracked-mission:'+(data?.xpType==='pol'?'pol':'personal');let tracked=null,trackedLoaded=false,lastJournal=null,lastData=null,banners=[];
const rememberTrack=id=>{tracked=id;try{if(id)localStorage.setItem(trackKey(),id);else localStorage.removeItem(trackKey());}catch{}try{window.dispatchEvent(new CustomEvent('dunerealms:tracked-mission'));}catch{}};
const trackKey=()=>'dunerealms.tracked-mission:'+(combined?'combined':data?.xpType==='pol'?'pol':'personal');let tracked=null,trackedLoaded=false,lastJournal=null,lastData=null,banners=[];
const rememberTrack=id=>{tracked=id;try{if(id)localStorage.setItem(trackKey(),id);else localStorage.removeItem(trackKey());const q=combined&&data?.quests.find(row=>row.id===id);if(q)localStorage.setItem('dunerealms.tracked-mission:'+q.lane,q.definitionId);}catch{}try{window.dispatchEvent(new CustomEvent('dunerealms:tracked-mission'));}catch{}};
const track=id=>{rememberTrack(id);render();};
let detailOpen=false;const dossier=createProgressionDialog(host,{onClose:()=>{detailOpen=false;if(journalMode&&active)render();}});
const requestIds=new Map();
async function api(path,options={}){
const response=await fetcher(apiBase+path,{credentials:'same-origin',cache:'no-store',signal:controller.signal,...options});
async function api(path,options={},base=apiBase){
const response=await fetcher(base+path,{credentials:'same-origin',cache:'no-store',signal:controller.signal,...options});
const value=await response.json();if(!response.ok)throw Error(value.message||'The journal could not be loaded.');return value;
}
function message(text){if(active){status.hidden=false;status.textContent=text;}}
async function load(){
const sequence=++loadSequence;
try{
if(combined){
const lanes=Object.keys(JOURNAL_LANES);
const settled=await Promise.allSettled(lanes.map(lane=>api('',{},JOURNAL_LANES[lane].endpoint)));
if(!active||sequence!==loadSequence)return;
const available=[],unavailable=[];
settled.forEach((result,index)=>{
const lane=lanes[index];
if(result.status==='fulfilled'){available.push([lane,result.value]);onData(result.value,lane);}
else unavailable.push(JOURNAL_LANES[lane].label);
});
if(!available.length)throw Error('The mission journal could not be loaded.');
loadNotice=unavailable.length?unavailable.join(' and ')+' missions are temporarily unavailable.':'';
data=combineJournalData(available);uncertain=false;requestIds.clear();render();
if(data.state!=='active')message(loadNotice||'The next season has not opened yet.');else status.hidden=true;
return;
}
const fresh=await api(view==='history'?'/history?page='+page:'');if(!active||sequence!==loadSequence)return;
data=allowedBranches&&Array.isArray(fresh.quests)?{...fresh,quests:fresh.quests.filter(q=>allowedBranches.includes(q.branch)),branches:fresh.branches?.filter(b=>allowedBranches.includes(b.id))}:fresh;uncertain=false;requestIds.clear();if(view!=='history')onData(fresh);render();
message(view==='history'?'Your recorded J.A.R.V.I.S. activity.':data.state==='active'?'Only verified objectives can be claimed. Unconnected gameplay objectives remain pending.':'The next season has not opened yet.');status.hidden=data.state==='active'||view==='history';
@ -47,8 +64,9 @@ export function mountPersonalProgression(host,{view='missions',fetcher=fetch,api
if(busy||uncertain||!active)return;busy=true;render();
const claim=row.canClaim,path=claim?'/claim':'/start';
const id=requestIds.get(row.id)||crypto.randomUUID();requestIds.set(row.id,id);
const payload=claim?{definitionId:row.id,revision:row.revision,requestId:id,confirmed:true}:{definitionId:row.id,confirmed:true};
try{const result=await api(path,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(payload)});if(claim&&typeof result.nextQuestId==='string')selected=result.nextQuestId;await load();}
const definitionId=row.definitionId??row.id;
const payload=claim?{definitionId,revision:row.revision,requestId:id,confirmed:true}:{definitionId,confirmed:true};
try{const result=await api(path,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(payload)},combined?JOURNAL_LANES[row.lane].endpoint:apiBase);if(claim&&typeof result.nextQuestId==='string')selected=combined?journalId(row.lane,result.nextQuestId):result.nextQuestId;await load();}
catch(error){if(active){uncertain=true;message(error.message+' Reload the journal to confirm the recorded result.');}}
finally{busy=false;if(active)render();}
}
@ -61,32 +79,37 @@ export function mountPersonalProgression(host,{view='missions',fetcher=fetch,api
if(journalMode&&!detailOpen){
if(!trackedLoaded){trackedLoaded=true;try{tracked=localStorage.getItem(trackKey());}catch{tracked=null;}}
const model=buildJournal(data);
if(requestedArc!==null){const scope=requestedArc;requestedArc=null;const choices=model.all.filter(q=>scope.startsWith('category:')?categoryFor(q.branch).id===scope.slice(9):q.branch===scope);if(choices.length)selected=pickSelection({all:choices},{tracked});}
if(requestedArc!==null){const scope=requestedArc;requestedArc=null;const [type,lane,category]=scope.split(':');const choices=model.all.filter(q=>type==='category'?category?categoryFor(q.branch).id===category&&q.lane===lane:categoryFor(q.branch).id===lane:q.branch===scope);if(choices.length)selected=pickSelection({all:choices},{tracked});}
if(data!==lastData){banners=completions(lastJournal,model);lastData=data;lastJournal=model;const next=advanceTracked(model,tracked);if(next!==tracked)rememberTrack(next);}
if(requestedLane){const choices=model.all.filter(q=>q.lane===requestedLane);requestedLane=null;if(!selected&&choices.length)selected=pickSelection({all:choices});}
selected=pickSelection(model,{preferred:selected,tracked});
branch=model.all.find(q=>q.id===selected)?.branch||branch;
const stats=el('div',undefined,'progression-stats');stats.append(el('strong',(data.xpType==='pol'?'Reputation level ':'Personal level ')+data.profile.level+(data.season.levelCap===null?' · uncapped':' / '+data.season.levelCap)));body.append(stats);
onBranches(model.arcs.map(a=>({id:a.id,title:a.title})),branch);
renderMissionJournal(body,{journal:model,selected,tracked,banners,busy,xpType:data.xpType,notice:uncertain?status.textContent:''},{onSelect:id=>{selected=id;banners=[];render();body.querySelector?.('.mj-detail')?.scrollIntoView?.({block:'nearest'});},onTrack:track,onSteps:row=>{branch=row.branch;selected=row.id;detailOpen=true;render();},onAct:row=>{const arcNext=()=>nextInArc(buildJournal(data),row.id);act(row).then(()=>{if(!selected||selected===row.id)selected=arcNext()||selected;if(active)render();});}});
const stats=el('div',undefined,'progression-stats');
const profiles=combined?data.profiles:[{lane:data.xpType==='pol'?'pol':'personal',profile:data.profile,season:data.season}];
for(const {lane,profile,season} of profiles)if(profile&&season)stats.append(el('strong',JOURNAL_LANES[lane].label+' level '+profile.level+(season.levelCap===null?' · uncapped':' / '+season.levelCap)));
body.append(stats);
onBranches(model.arcs.map(a=>({id:a.id,title:a.title,lane:a.lane})),branch);
renderMissionJournal(body,{journal:model,selected,tracked,banners,busy,xpType:data.xpType,notice:uncertain?status.textContent:loadNotice},{onSelect:id=>{selected=id;banners=[];render();body.querySelector?.('.mj-detail')?.scrollIntoView?.({block:'nearest'});},onTrack:track,onSteps:row=>{branch=row.branch;selected=row.id;detailOpen=true;render();},onAct:row=>{const arcNext=()=>nextInArc(buildJournal(data),row.id);act(row).then(()=>{if(!selected||selected===row.id)selected=arcNext()||selected;if(active)render();});}});
return;
}
const stats=el('div',undefined,'progression-stats');stats.append(el('strong',(data.xpType==='pol'?'Reputation level ':'Personal level ')+data.profile.level+(data.season.levelCap===null?' · uncapped':' / '+data.season.levelCap)),el('span',data.profile.effectiveXP.toLocaleString()+(data.xpType==='pol'?' reputation':' seasonal XP')),el('span','Season ends '+date(data.season.endsAt)));
const progress=el('progress');progress.max=data.season.levelCap;progress.value=data.profile.level;progress.setAttribute('aria-label','Season level');if(data.season.levelCap!==null)stats.append(progress);body.append(stats);
const shown=combined?data.profiles.find(p=>p.lane===data.quests.find(q=>q.id===selected)?.lane)??data.profiles[0]:data;
const stats=el('div',undefined,'progression-stats');stats.append(el('strong',((shown.lane??data.xpType)==='pol'?'Reputation level ':'Personal level ')+shown.profile.level+(shown.season.levelCap===null?' · uncapped':' / '+shown.season.levelCap)),el('span',shown.profile.effectiveXP.toLocaleString()+((shown.lane??data.xpType)==='pol'?' reputation':' seasonal XP')),el('span','Season ends '+date(shown.season.endsAt)));
const progress=el('progress');progress.max=shown.season.levelCap;progress.value=shown.profile.level;progress.setAttribute('aria-label','Season level');if(shown.season.levelCap!==null)stats.append(progress);body.append(stats);
if(data.affiliations?.length){const affiliation=el('aside',undefined,'progression-intro');affiliation.append(el('strong','The Unmarked Caravan'),el('p','Your smuggler clan and company affiliations are secondary. Your ordinary affiliations stay in place.'));body.append(affiliation);}
const select=el('select');select.setAttribute('aria-label','Mission branch');
const availableBranches=data.branches||branches;for(const group of groupBranches(availableBranches.filter(b=>data.quests.some(q=>q.branch===b.id)))){const option=el('option',group.category.title);option.value=group.category.id;select.append(option);}
const availableBranches=(data.branches||branches).filter(b=>data.quests.some(q=>q.branch===b.id));const stepBranches=combined?availableBranches.filter(b=>b.lane===shown.lane):availableBranches;for(const group of groupBranches(stepBranches)){const option=el('option',group.category.title);option.value=group.category.id;select.append(option);}
if(!data.quests.some(q=>q.branch===branch))branch=data.quests[0]?.branch;
select.value=categoryFor(branch).id;select.onchange=()=>{branch=data.quests.find(q=>categoryFor(q.branch).id===select.value)?.branch||branch;selected=null;render();};onBranches(availableBranches.filter(b=>data.quests.some(q=>q.branch===b.id)),branch);body.append(categoryHero(categoryFor(branch),el));if(!externalBranches)body.append(select);
select.value=categoryFor(branch).id;select.onchange=()=>{branch=data.quests.find(q=>categoryFor(q.branch).id===select.value&&(!combined||q.lane===shown.lane))?.branch||branch;selected=null;render();};onBranches(availableBranches,branch);body.append(categoryHero(categoryFor(branch),el));if(!externalBranches)body.append(select);
if(branch==='e'&&typeof onCareerNavigate==='function'){const careers=el('section',undefined,'progression-toolbar');careers.append(el('h3','Reputation careers'),button('Official Spice Harvesting',()=>onCareerNavigate('spice-harvesting')),button('Smuggling Jobs',()=>onCareerNavigate('smugglers')),button('Bounty Jobs',()=>onCareerNavigate('bounty-jobs')));body.append(careers);}
const rows=orderChapters(data.quests.filter(q=>categoryFor(q.branch).id===categoryFor(branch).id)).map(q=>({...q,channel:questChannel(q.executionRequirements)}));selected=rows.find(q=>q.id===selected)?.id||null;
const rows=orderChapters(data.quests.filter(q=>categoryFor(q.branch).id===categoryFor(branch).id&&(!combined||q.lane===shown.lane))).map(q=>({...q,channel:questChannel(q.executionRequirements)}));selected=rows.find(q=>q.id===selected)?.id||null;
const layout=el('div',undefined,'progression-layout'),tree=el('div',undefined,'progression-tree');tree.setAttribute('aria-label','Mission tree');
for(const row of rows){const card=button('',()=>{selected=row.id;detailOpen=true;render();});card.className='progression-mission';card.dataset.missionId=row.id;card.dataset.channel=row.channel==='website'?'website':'shared';card.setAttribute('aria-pressed',String(row.id===selected));card.setAttribute('aria-haspopup','dialog');card.append(image(artwork||questArtwork(row.channel)),el('strong',row.title),el('span',labels[row.state]||'Awaiting verification','progression-badge'));tree.append(card);}
layout.append(tree);const row=rows.find(q=>q.id===selected);
if(row&&detailOpen){const pane=el('aside',undefined,'progression-detail');pane.setAttribute('aria-label','Selected mission');pane.append(image(artwork||questArtwork(row.channel)),el('small',row.id),el('h3',row.title),el('small',row.channel==='website'?'Website quest':'Website / Minecraft quest'));
if(row&&detailOpen){const pane=el('aside',undefined,'progression-detail');pane.setAttribute('aria-label','Selected mission');pane.append(image(artwork||questArtwork(row.channel)),el('small',row.definitionId??row.id),el('h3',row.title),el('small',row.channel==='website'?'Website quest':'Website / Minecraft quest'));
if(uncertain){const feedback=el('p',status.textContent,'progression-notice');feedback.setAttribute('role','alert');pane.append(feedback);}const guide=questGuidance(row);pane.append(el('h4','How to complete'),el('p',guide.objective),el('h4','Where'),el('p',guide.where));if(guide.connected===false&&row.state!=='claimed')pane.append(el('p',guide.verification,'progression-notice'));if(row.issuerName)pane.append(el('small','Questgiver · '+row.issuerName));if(row.recipe){pane.append(el('h4','Recipe · '+row.recipe.world));const table=el('table',undefined,'progression-recipe');table.setAttribute('aria-label','Elytra crafting recipe');for(const cells of row.recipe.grid){const tr=el('tr');for(const cell of cells)tr.append(el('td',cell));table.append(tr);}pane.append(table,el('p','Very Rare · MK XI · Craft on Arrakis'));}
const source=data.sources?.sources?.find(s=>s.metrics?.includes(row.metric));
const source=row.verificationSource??data.sources?.sources?.find(s=>s.metrics?.includes(row.metric));
const quantity=value=>row.metric?.endsWith('-minor')?(value/100).toLocaleString(undefined,{minimumFractionDigits:2,maximumFractionDigits:2})+' DM':value.toLocaleString();
const dl=el('dl');for(const [label,value]of [['Progress',quantity(row.progress)+' / '+quantity(row.target)],['Status',labels[row.state]||'Awaiting verification'],['Verification',questVerification(row,source)],[data.xpType==='pol'?'Reputation':'XP',row.xp===null?'Not configured':String(row.xp)],['Participation',row.optional?'Optional':'Required']])dl.append(el('dt',label),el('dd',value));if(Number.isSafeInteger(row.personalXP))dl.append(el('dt','Base Personal XP'),el('dd',String(row.personalXP)));if(Number.isSafeInteger(row.baseDMMinor))dl.append(el('dt','Base funded reward'),el('dd',(row.baseDMMinor/100).toLocaleString(undefined,{minimumFractionDigits:2,maximumFractionDigits:2})+' DM'));pane.append(dl);
const dl=el('dl');for(const [label,value]of [['Progress',quantity(row.progress)+' / '+quantity(row.target)],['Status',labels[row.state]||'Awaiting verification'],['Verification',questVerification(row,source)],[(row.lane??data.xpType)==='pol'?'Reputation':'XP',row.xp===null?'Not configured':String(row.xp)],['Participation',row.optional?'Optional':'Required']])dl.append(el('dt',label),el('dd',value));if(Number.isSafeInteger(row.personalXP))dl.append(el('dt','Base Personal XP'),el('dd',String(row.personalXP)));if(Number.isSafeInteger(row.baseDMMinor))dl.append(el('dt','Base funded reward'),el('dd',(row.baseDMMinor/100).toLocaleString(undefined,{minimumFractionDigits:2,maximumFractionDigits:2})+' DM'));pane.append(dl);
if(row.title==='Repair Your Starter Kit'){const parts=el('div',undefined,'progression-repair');for(const item of STARTER_REPAIR_PARTS){const part=el('figure');part.append(image(item.art),el('figcaption',item.name+' × '+item.quantity));parts.append(part);}pane.append(el('p','Your '+STARTER_KIT_POLICY.tier+' faction kit starts with '+STARTER_KIT_POLICY.remainingDurabilityBps/100+'% durability. Collect all four parts and return that damaged kit to receive one intact replacement. Verified Minecraft collection and surrender are required.'),parts);}
if(row.branch==='acquisitions')pane.append(el('p','Settled purchases and clan submissions or conquests count. Founding an organisation does not count.'));
if(row.cooldownUntil>Date.now())pane.append(el('p','Next available: '+date(row.cooldownUntil),'progression-notice'));const action=button(row.cooldownUntil>Date.now()?'Cooldown active':row.state==='claimed'?'Reward claimed':row.canClaim?'Claim reward':row.state==='active'?'Awaiting verified progress':row.canStart?'Start mission':'Complete the previous mission',()=>act(row));action.disabled=busy||uncertain||row.state==='claimed'||!row.canClaim&&(!row.canStart||row.state==='active');pane.append(action);

View file

@ -17,7 +17,7 @@ export function mountPlayWorkspace(host,workspace,id,options={}){
if(workspace==='clan'&&id==='clan-campaigns')return mountWarPlanning(host,{kind:'clan',scopeId:options.accountId||null});
if(workspace==='clan'&&id==='clan-war-exchange')return mountWarExchange(host,{kind:'clan',scopeId:options.accountId||null,fetcher:options.fetcher||fetch});
if(workspace==='clan'&&id==='clan-decisions')return mountProgressionDesign(host,{context:'clan',organisation:options.accountId?{id:options.accountId}:null,initialView:'decisions'});
if(workspace==='quests'||workspace==='clan'&&id==='clan-quests')return mountProgressionDesign(host,{organisation:workspace==='clan'&&options.accountId?{id:options.accountId}:null,context:workspace==='clan'?'clan':'personal',dashboard:workspace==='quests'&&id==='quest-dashboard'});
if(workspace==='quests'||workspace==='clan'&&id==='clan-quests')return mountProgressionDesign(host,{organisation:workspace==='clan'&&options.accountId?{id:options.accountId}:null,context:workspace==='clan'?'clan':'personal',dashboard:workspace==='quests'});
if(workspace==='events'||workspace==='clan'&&id==='clan-events')return mountRealmEvents(host,{kind:workspace==='clan'?'clan':null,fetcher:options.fetcher||fetch});
if(workspace==='clan'&&id==='clan-tailor')return mountKitsetBuilder(host,{fetcher:options.fetcher||fetch,ownerScope:{kind:'clan',id:options.accountId}});
if(workspace==='clan'&&id==='clan-elections')return mountElectionDesign(host,{context:'clan'});
@ -29,7 +29,6 @@ export function mountPlayWorkspace(host,workspace,id,options={}){
const operations={'clan-shop':'clan-shops','clan-tailor':'clan-kits','clan-bank':'clan-bank'};
if(operations[id])return mountNativeService(host,'clan-operations',{...options,singleHeading:true,initialTab:operations[id]});
}
if(workspace==='quests'&&id==='quests')return mountUserPage(host,'quests',options);
if(workspace==='kits'&&id==='kits-exchange')return mountUserPage(host,'kits-exchange',options);
const panel=el('section',undefined,'cp-play-placeholder');
panel.append(el('h2',workspace==='events'?'Events & gatherings':id==='clan-quests'?'Clan expeditions':'Clan campaigns'),el('p',workspace==='events'?'The event calendar will appear here when events are published.':id==='clan-quests'?'Shared clan quests and expedition tracking are not available yet. Your personal assignments remain in the Quests workspace.':'Clan campaign management is not available yet. Your existing clan roster, tailor, shop and correspondence remain available in the side menus.'),el('strong','Coming later'));

View file

@ -1,5 +1,5 @@
import {MISSION_BRANCHES} from './cp-v2-progression-catalogue.mjs';
import {groupBranches,bannerUrl,iconUrl,ensureStyles} from './cp-v2-quest-categories.mjs';
import {groupBranches,bannerUrl,iconUrl,ensureStyles,storyLanes} from './cp-v2-quest-categories.mjs';
import {element as el} from './cp-v2-page-template.mjs';
import {mentatFromDeeds,mentatFromCharacterChoice,systemPortrait,MENTAT_NAMES} from './cp-v2-mentat-portraits.mjs';
export function xpReport(data,{tracked=null}={}){
@ -40,8 +40,29 @@ export function createProgressionSidebar(host,{fetcher=fetch,onBranch=()=>{},onN
function menuIcon(key){const img=el('img');img.src=typeof globalThis.uniqueMenuIcon==='function'?globalThis.uniqueMenuIcon('quests/'+key):'https://www.dunerealms.com/assets/nav-account-v2.webp';img.alt='';img.width=img.height=24;return img;}
function menuHeading(label,count){const title=el('div',undefined,'category-heading');title.setAttribute('role','heading');title.setAttribute('aria-level','2');title.append(menuIcon('category/'+label),el('span',label,'category-name'),el('span',String(count),'category-count'));return title;}
function renderViews(){journalMenu.replaceChildren(menuHeading('Journal views',3));const links=el('div',undefined,'category-links');for(const [view,label]of [['missions','Missions'],['decisions','Decisions'],['history','History']]){const link=el('a',undefined,'navitem');link.append(menuIcon('view/'+view),el('span',label));link.href=href(currentKind,view);link.setAttribute('aria-current',view===currentView?'page':'false');link.onclick=event=>open(event,currentKind,view);links.append(link);}journalMenu.append(links);}
function renderBranches(){const groups=groupBranches(branchRows);directory.replaceChildren(menuHeading('Story arcs',groups.length));ensureStyles();const links=el('div',undefined,'category-links');for(const group of groups){const button=el('button',undefined,'navitem quest-arc-link');button.type='button';button.setAttribute('aria-current',group.rows.some(row=>row.id===branchId)?'page':'false');button.style.backgroundImage='linear-gradient(90deg,rgba(24,34,25,.75),rgba(24,34,25,.2)),url("'+bannerUrl(group.category)+'")';const icon=el('img');icon.src=iconUrl(group.category);icon.alt='';icon.width=icon.height=28;button.append(icon,el('span',group.category.title));button.onclick=()=>{onBranch('category:'+group.category.id);closeMenus();};links.append(button);}directory.append(links);directory.hidden=!groups.length;}
function renderBranches(){
directory.replaceChildren();ensureStyles();
const lanes=storyLanes(branchRows);
for(const lane of lanes){
const groups=groupBranches(lane.rows);
if(!groups.length)continue;
const section=el('section',undefined,'progression-story-lane');
if(lane.lane)section.dataset.lane=lane.lane;
section.append(menuHeading(lane.title,groups.length));
const links=el('div',undefined,'category-links');
for(const group of groups){
const button=el('button',undefined,'navitem quest-arc-link');button.type='button';
button.setAttribute('aria-current',group.rows.some(row=>row.id===branchId)?'page':'false');
button.style.backgroundImage='linear-gradient(90deg,rgba(24,34,25,.75),rgba(24,34,25,.2)),url("'+bannerUrl(group.category)+'")';
const icon=el('img');icon.src=iconUrl(group.category);icon.alt='';icon.width=icon.height=28;
button.append(icon,el('span',group.category.title));
button.onclick=()=>{onBranch('category:'+(lane.lane?lane.lane+':':'')+group.category.id);closeMenus();};
links.append(button);
}
section.append(links);directory.append(section);
}
directory.hidden=!directory.children.length;
}
async function read(path){const r=await fetcher(path,{credentials:'same-origin',cache:'no-store',signal:controller.signal});if(!r.ok)throw Error('Report unavailable');return r.json();}
function updateBranches(){const data=journals.get(currentKind);const rows=data?.branches||[...MISSION_BRANCHES.filter(b=>b.id!=='discoveries'),{id:'acquisitions',title:'Acquisitions'}];branchRows=data?.quests?rows.filter(b=>data.quests.some(q=>q.branch===b.id)):[];if(!branchRows.some(b=>b.id===branchId))branchId=branchRows[0]?.id;renderBranches();}
function ensureJournal(kind){if(journals.has(kind)||pending.has(kind))return;pending.add(kind);void read(kind==='pol'?'/api/progression/pol':'/api/progression').then(data=>setJournal(kind,data)).catch(()=>{if(alive){failures.add(kind);render();}}).finally(()=>pending.delete(kind));}

View file

@ -37,7 +37,7 @@ export function mountProgressionDesign(host,{context='personal',dashboard=false,
let connectorObserver=null,disposePersonal=null;const dossier=createProgressionDialog(root);
const hero=el('header',undefined,'progression-hero'),head=el('div');head.append(el('small',manage?'IMPERIAL BUREAU · J.A.R.V.I.S.':'REALM PROGRESSION'),el('h2',manage?'Progression definitions':dashboard?'Quest Dashboard':'Missions & Decisions'),el('p','Your objectives, authority and recorded achievements.'));hero.append(image('exchange-quests-v1.png'),head);if(manage||(context!=='personal'&&context!=='clan')||!applyShellHeading(host,{title:context==='clan'?'Clan Missions & Decisions':dashboard?'Quest Dashboard':'Missions & Decisions',description:'Your objectives, authority and recorded achievements.',artwork:'exchange-quests-v1.png'}))root.append(hero);root.append(notice);
const xpNav=el('nav',undefined,'progression-tabs progression-xp-types');xpNav.setAttribute('aria-label','XP type');const contextNav=el('nav',undefined,'progression-contexts'),gallery=el('section',undefined,'progression-gallery'),nav=el('nav',undefined,'progression-tabs'),content=el('section',undefined,'progression-content');nav.setAttribute('aria-label','Progression views');contextNav.setAttribute('aria-label','Progression contexts');
root.append(gallery,xpNav,nav,content);host.replaceChildren(root);if(['politics','clan'].includes(context))mountPoliticalConsultations(root);if(context==='politics')mountPoliticalAgreements(root);const report=!manage&&(context==='personal'||dashboard)?createProgressionSidebar(host,{onBranch:id=>{branch=id;if(tab==='missions')disposePersonal?.selectBranch?.(id);else{tab='missions';selected=null;render();}},onNavigate:(kind,view)=>{xpKind=kind;tab=view;selected=null;render();}}):{available:false,setJournal(){},setBranches(){},showBranches(){},setNavigation(){},dispose(){}};
root.append(gallery,xpNav,nav,content);host.replaceChildren(root);if(['politics','clan'].includes(context))mountPoliticalConsultations(root);if(context==='politics')mountPoliticalAgreements(root);const report=!manage&&(context==='personal'||dashboard)?createProgressionSidebar(host,{onBranch:id=>{branch=id;if(tab==='missions')disposePersonal?.selectBranch?.(id);else{tab='missions';selected=null;render();}},onNavigate:(kind,view)=>{if(kind==='personal'||kind==='pol')xpKind=kind;tab=view;selected=null;render();}}):{available:false,setJournal(){},setBranches(){},showBranches(){},setNavigation(){},dispose(){}};
function renderGallery(){gallery.replaceChildren();gallery.hidden=activeContext==='personal'||activeContext==='clan'||manage;gallery.className='progression-gallery'+(activeContext==='politics'&&officeCode==='IMP'?' progression-imperial':'');if(gallery.hidden)return;
const title=activeContext==='politics'?OFFICES.find(([id])=>id===officeCode)?.[1]:organisation?.name||CONTEXTS[activeContext][0];gallery.append(el('h3',title||'Your organisation'));
if(activeContext==='politics'&&officeCode==='IMP'){const throne=el('div',undefined,'progression-throne');throne.append(image('seals/emperor-v1.png'),el('strong','Padishah Emperor'),el('span','Officeholder avatar · preview'));gallery.append(throne);const seals=el('div',undefined,'progression-electors');for(const[name,file]of SEALS){const card=el('figure');card.append(image('seals/'+file),el('figcaption',name),el('span','Leader avatar · preview'));seals.append(card);}gallery.append(seals);return;}
@ -69,6 +69,6 @@ export function mountProgressionDesign(host,{context='personal',dashboard=false,
function renderDecisions(){if(activeContext==='politics')appendOfficeDecisionBanner(content,officeCode);if(activeContext==='politics'&&!manage){const live=el('div');content.append(live);disposePersonal=mountOfficeRebellionDecisions(live,{officeKey:organisation?.id||({IMP:'emperor',ATR:'atreides',HAR:'harkonnen',COR:'corrino',ORD:'ordos',FRE:'fremen',BG:'veiled_concord',NF:'muad_dib',SG:'spacing_guild',CLD:'clan_delegate'})[officeCode]});}const toolbar=el('div',undefined,'progression-toolbar'),search=el('input');search.type='search';search.placeholder='Search decisions';search.setAttribute('aria-label','Search decisions');search.value=query;search.oninput=()=>{query=search.value;renderDecisionsList();};toolbar.append(search);if(activeContext==='personal'&&xpKind==='pol'){const chooser=field('Questgiver',POL_QUEST_BRANCHES.map(b=>b.title));chooser.querySelector('select').selectedIndex=POL_QUEST_BRANCHES.findIndex(b=>b.id===polDecisionBranch);chooser.onchange=e=>{polDecisionBranch=POL_QUEST_BRANCHES[e.target.selectedIndex].id;selected=null;render();};toolbar.append(chooser);}if((dashboard&&activeContext==='politics')||manage){const chooser=field('Office catalogue',OFFICES.map(([,name])=>name));chooser.querySelector('select').selectedIndex=OFFICES.findIndex(([id])=>id===officeCode);chooser.onchange=e=>{officeCode=OFFICES[e.target.selectedIndex][0];selected=null;render();};toolbar.append(chooser);}content.append(toolbar);const listHost=el('div');content.append(listHost);
function renderDecisionsList(){listHost.replaceChildren();let rows=activeContext==='politics'||manage?[...DECISION_CATALOGUE.filter(d=>d.office===officeCode),...officeDecisionPreviews(officeCode)]:activeContext==='personal'&&xpKind==='pol'?(POL_QUEST_BRANCHES.find(b=>b.id===polDecisionBranch)?.decisions||[]):activeContext==='personal'?[{id:'P-MARK',title:'Equipment Mark eligibility',effect:'Level, materials and equipment restrictions remain necessary.',level:0,xp:0,cost:'Pending configuration'},{id:'P-RARITY',title:'Rarity enhancement eligibility',effect:'Use the existing rarity and Legendary upgrade policy.',level:0,xp:0,cost:'Pending configuration'},{id:'P-SEASON',title:'Seasonal completion entitlement',effect:'One non-tradable completion kit after all mandatory objectives.',level:0,xp:0,cost:'Earned entitlement'}]:[];rows=rows.filter(r=>(r.title+' '+r.effect).toLowerCase().includes(query.toLowerCase()));if(!rows.length){listHost.append(el('p','No decision definitions available for this selection. No authority is inferred.'));return;}selected=rows.find(r=>r.id===selected)?.id||rows[0].id;const layout=el('div',undefined,'progression-layout'),cards=el('div',undefined,'progression-decisions');for(const row of rows){const card=button('',()=>{selected=row.id;dossier.show(details(row,true),{title:lore(row.title),returnFocus:card});},'progression-decision');card.setAttribute('aria-haspopup','dialog');card.setAttribute('aria-pressed',String(row.id===selected));const art=activeContext==='politics'?POL_PLANNING_ART[officeCode]:activeContext==='personal'&&xpKind==='pol'?POL_PLANNING_ART[POL_QUEST_BRANCHES.find(b=>b.id===polDecisionBranch)?.office]:null;card.append(image(art?.banner||'exchange-political-positions-v1.png'),...(art?[planningImage(art.seal,art.title+' seal','pol-decision-seal')]:[]),el('small',row.id),el('strong',row.title),el('span',row.executionStatus==='clan-faith-controller'?'Invite a clan':row.executionStatus==='house-faith-controller'?'Review House referendum':row.executionStatus==='world-trade-controller'?'Review trade decision':politicalDecision(row.id)?'Review funded decision':row.id==='IMP-10'?'Manage House passage':faithBlessing(row.id)?'Prepare clan blessing':row.executionStatus==='war-exchange-controller'?'Manage war agreement':'View proposal · execution unavailable'));cards.append(card);if(deepLink?.id===row.id){deepLink=null;queueMicrotask(()=>{if(card.isConnected)card.click();});}}layout.append(cards);listHost.append(layout);}renderDecisionsList();
}
function render(){dossier.close();connectorObserver?.disconnect();disposePersonal?.();disposePersonal=null;notice.textContent=activeContext==='personal'&&!manage?(xpKind==='pol'?'Reputation missions use verified J.A.R.V.I.S. records and their system questgivers. Decision execution awaits configuration.':'Personal missions use verified J.A.R.V.I.S. records. Decision and organisation integrations remain in preview.'):'Connected decisions open a review and confirmation. Other proposals remain unavailable until their consumers are connected.';root.dataset.context=activeContext;notice.hidden=activeContext==='personal'&&!manage;nav.hidden=report.available&&activeContext==='personal'&&!manage;report.setNavigation(xpKind,tab);report.showBranches(activeContext==='personal');xpNav.replaceChildren();xpNav.hidden=activeContext!=='personal'||manage;if(!xpNav.hidden)for(const [kind,label]of [['personal','Personal missions'],['pol','Reputation missions']]){const b=button(label,()=>{xpKind=kind;tab='missions';selected=null;history.replaceState(null,'',location.hash.split('?')[0]+'?'+new URLSearchParams({xp:kind,view:tab}));render();});b.setAttribute('aria-pressed',String(kind===xpKind));xpNav.append(b);}contextNav.replaceChildren();for(const[id,[label]]of Object.entries(CONTEXTS)){const b=button(label,()=>{activeContext=id;selected=null;query='';render();});b.setAttribute('aria-pressed',String(id===activeContext));contextNav.append(b);}renderGallery();nav.replaceChildren();for(const[id,label]of [['missions',manage?'Mission Definitions':'Missions'],['decisions',manage?'Decision Definitions':'Decisions'],...(manage?[['rewards','Progression & Rewards']]:[]),['history','History']]){const b=button(label,()=>{tab=id;selected=null;render();});b.setAttribute('aria-pressed',String(tab===id));nav.append(b);}content.replaceChildren();if(activeContext==='clan'&&!manage){notice.hidden=true;disposePersonal=mountClanRebellions(content,{clanId:organisation?.id||null,embedded:true,view:tab,onDecisions:()=>{tab='decisions';render();}});return;}if(activeContext==='personal'&&!manage&&['missions','history'].includes(tab))disposePersonal=mountPersonalProgression(content,{view:tab,apiBase:xpKind==='pol'?'/api/progression/pol':'/api/progression',externalBranches:report.available,initialBranch:branch,onCareerNavigate:id=>{xpKind='pol';tab='missions';branch=id;selected=null;render();},onData:data=>report.setJournal(xpKind,data),onBranches:(rows,id)=>{branch=id;report.setBranches(rows,id);}});else if(tab==='missions')renderMissions();else if(tab==='decisions')renderDecisions();else if(tab==='rewards'){content.append(el('h3','Progression & Rewards'),field('Season cap',['70 · proposed']),field('Milestone announcements',['Halfway and completion only']),el('p','Rewards, XP curves, repair recipes and signing editions await backend review. No configuration writes enabled.'));}else content.append(el('h3','J.A.R.V.I.S. History'),el('p','Verified completion, claims, decisions and any staff overrides will appear here after integration. No sample audit records are shown.'));}
function render(){const combined=activeContext==='personal'&&!manage&&tab==='missions';dossier.close();connectorObserver?.disconnect();disposePersonal?.();disposePersonal=null;notice.textContent=activeContext==='personal'&&!manage?(xpKind==='pol'?'Reputation missions use verified J.A.R.V.I.S. records and their system questgivers. Decision execution awaits configuration.':'Personal missions use verified J.A.R.V.I.S. records. Decision and organisation integrations remain in preview.'):'Connected decisions open a review and confirmation. Other proposals remain unavailable until their consumers are connected.';root.dataset.context=activeContext;notice.hidden=activeContext==='personal'&&!manage;nav.hidden=report.available&&activeContext==='personal'&&!manage;report.setNavigation(combined?'all':xpKind,tab);report.showBranches(activeContext==='personal');xpNav.replaceChildren();xpNav.hidden=combined||activeContext!=='personal'||manage;if(!xpNav.hidden)for(const [kind,label]of [['personal','Personal'],['pol','Reputation']]){const b=button(label,()=>{xpKind=kind;selected=null;history.replaceState(null,'',location.hash.split('?')[0]+'?'+new URLSearchParams({xp:kind,view:tab}));render();});b.setAttribute('aria-pressed',String(kind===xpKind));xpNav.append(b);}contextNav.replaceChildren();for(const[id,[label]]of Object.entries(CONTEXTS)){const b=button(label,()=>{activeContext=id;selected=null;query='';render();});b.setAttribute('aria-pressed',String(id===activeContext));contextNav.append(b);}renderGallery();nav.replaceChildren();for(const[id,label]of [['missions',manage?'Mission Definitions':'Missions'],['decisions',manage?'Decision Definitions':'Decisions'],...(manage?[['rewards','Progression & Rewards']]:[]),['history','History']]){const b=button(label,()=>{tab=id;selected=null;render();});b.setAttribute('aria-pressed',String(tab===id));nav.append(b);}content.replaceChildren();if(activeContext==='clan'&&!manage){notice.hidden=true;disposePersonal=mountClanRebellions(content,{clanId:organisation?.id||null,embedded:true,view:tab,onDecisions:()=>{tab='decisions';render();}});return;}if(activeContext==='personal'&&!manage&&['missions','history'].includes(tab))disposePersonal=mountPersonalProgression(content,{view:tab,combined,preferredLane:routeParams.get('xp'),apiBase:xpKind==='pol'?'/api/progression/pol':'/api/progression',externalBranches:report.available,initialBranch:branch,onCareerNavigate:id=>{xpKind='pol';tab='missions';branch=id;selected=null;render();},onData:(data,lane)=>report.setJournal(lane??xpKind,data),onBranches:(rows,id)=>{branch=id;report.setBranches(rows,id);}});else if(tab==='missions')renderMissions();else if(tab==='decisions')renderDecisions();else if(tab==='rewards'){content.append(el('h3','Progression & Rewards'),field('Season cap',['70 · proposed']),field('Milestone announcements',['Halfway and completion only']),el('p','Rewards, XP curves, repair recipes and signing editions await backend review. No configuration writes enabled.'));}else content.append(el('h3','J.A.R.V.I.S. History'),el('p','Verified completion, claims, decisions and any staff overrides will appear here after integration. No sample audit records are shown.'));}
render();return()=>{dossier.dispose();connectorObserver?.disconnect();disposePersonal?.();report.dispose();root.remove();};
}

View file

@ -152,14 +152,25 @@ export const QUEST_CATEGORIES=Object.freeze([
].map(c=>Object.freeze({...c,branches:Object.freeze([...c.branches])})));
export const OTHER_CATEGORY=Object.freeze({id:'other',title:'Other Work',tagline:'Quests outside the main story arcs.',accent:'#8f7a5a',icon:'quests/other',branches:Object.freeze([])});
const byBranch=new Map(QUEST_CATEGORIES.flatMap(c=>c.branches.map(b=>[b,c])));
export const categoryFor=branchId=>byBranch.get(branchId)||OTHER_CATEGORY;
const baseBranch=id=>typeof id==='string'?id.replace(/^(?:personal|pol):/,''):id;
export const categoryFor=branchId=>byBranch.get(baseBranch(branchId))||OTHER_CATEGORY;
export const STORY_LANES=Object.freeze({
personal:'Personal Story Arcs',
pol:'Reputation Story Arcs'
});
export function storyLanes(rows){
if(!rows.some(row=>row.lane))return [{lane:null,title:'Story arcs',rows}];
return Object.entries(STORY_LANES)
.map(([lane,title])=>({lane,title,rows:rows.filter(row=>row.lane===lane)}))
.filter(group=>group.rows.length);
}
export const bannerUrl=category=>new URL('./art/quests/'+category.id+'-banner.png',import.meta.url).href;
export const iconUrl=category=>new URL('./art/quests/'+category.id+'-icon.png',import.meta.url).href;
/** Branch rows [{id,title}] regrouped by category in catalogue order; unmapped branches land in "Other Work" last. */
export function groupBranches(rows){
const groups=[];
for(const category of [...QUEST_CATEGORIES,OTHER_CATEGORY]){
const members=category===OTHER_CATEGORY?rows.filter(r=>categoryFor(r.id)===OTHER_CATEGORY):category.branches.map(id=>rows.find(r=>r.id===id)).filter(Boolean);
const members=category===OTHER_CATEGORY?rows.filter(r=>categoryFor(r.id)===OTHER_CATEGORY):category.branches.map(id=>rows.find(r=>baseBranch(r.id)===id)).filter(Boolean);
if(members.length)groups.push({category,rows:members});
}
return groups;

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
(()=>{const frame=document.getElementById('clan-workspace');if(!frame)return;frame.setAttribute('scrolling','no');frame.addEventListener('load',()=>frame.contentWindow?.postMessage({type:'dune-embed-measure'},'https://cp.dunerealms.com'));const cp='https://cp.dunerealms.com',legacy={'clans':'clan/clan-directory','clan-portal':'clan/clan-overview','clan-kits':'clan/clan-tailor','clan-shops':'clan/clan-shop','clan-bank':'clan/clan-bank','clan-settings':'clan/clan-settings','clan-quests':'clan/clan-quests'};
(()=>{const frame=document.getElementById('clan-workspace');if(!frame)return;frame.setAttribute('scrolling','no');frame.addEventListener('load',()=>frame.contentWindow?.postMessage({type:'dune-embed-measure'},'https://cp.dunerealms.com'));const cp='https://cp.dunerealms.com',legacy={'quests/quest-dashboard':'quests/quests','quest-dashboard':'quests/quests','realm/quests':'quests/quests','clans':'clan/clan-directory','clan-portal':'clan/clan-overview','clan-kits':'clan/clan-tailor','clan-shops':'clan/clan-shop','clan-bank':'clan/clan-bank','clan-settings':'clan/clan-settings','clan-quests':'clan/clan-quests'};
const valid=value=>/^(?:clan\/(?:clan-(?:overview|roster|requests|settings|directory|boards|events|elections|advertising|mail|bank|shop|listings|post-listing|tailor|quests|decisions|campaigns|claims|subhouses|patronage))|quests\/quests|kits\/kits-exchange|events\/events-calendar)(?:\/[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12})?$/.test(value);
function show(){const [raw,query]=location.hash.slice(1).split('?'),route=valid(raw)?raw:legacy[raw]||'clan/clan-overview',incoming=new URLSearchParams(query),params=new URLSearchParams();if(route==='quests/quests'){const xp=incoming.get('xp'),view=incoming.get('view');if(['personal','pol'].includes(xp))params.set('xp',xp);if(['missions','decisions','history'].includes(view))params.set('view',view);}const url=cp+'/clan-cp#'+route+(params.size?'?'+params:'');if(frame.src!==url)frame.src=url;}window.addEventListener('hashchange',show);
window.addEventListener('message',event=>{if(event.origin!==cp||event.source!==frame.contentWindow)return;if(event.data?.type==='dune-embed-size'&&Number.isFinite(event.data.height)&&event.data.height>=100&&event.data.height<=200000)frame.style.height=Math.ceil(event.data.height)+'px';if(event.data?.type==='dune-clan-route'){const selected=typeof event.data.accountId==='string'&&/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(event.data.accountId)?'/'+event.data.accountId:'',route=event.data.workspace+'/'+event.data.page+selected;if(valid(route)&&location.hash.slice(1).split('?')[0]!==route)history.replaceState(null,'','#'+route);}});show();})();

View file

@ -22,7 +22,7 @@ test('ordinary player Mentats use the existing bound House choice without invent
});
const branchButtons=directory=>directory.children.flatMap(child=>child.children||[]).filter(node=>typeof node.onclick==='function');
const branchButtons=node=>typeof node.onclick==='function'?[node]:node.children.flatMap(branchButtons);
test('mission branches and directory persist through decisions/history and stay scoped to the selected journal',async()=>{
const {createProgressionSidebar}=await import('../control-panel/public/cp-v2/cp-v2-progression-sidebar.mjs');
class Node{constructor(){this.children=[];this.style={};this.attributes={};this.classList={remove(){}};this.isConnected=true;}append(...nodes){this.children.push(...nodes);}prepend(...nodes){this.children.unshift(...nodes);}insertBefore(node){this.children.push(node);}replaceChildren(...nodes){this.children=nodes;}setAttribute(k,v){this.attributes[k]=v;}remove(){}querySelector(){return null;}}