Compare commits

..
41 changed files with 96 additions and 1166 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 623 B

View file

@ -1,485 +0,0 @@
// The Search for Leto II. DM amounts use bank minor units. Item rewards use the native claim receipt.
const rows=[
{
"id": "POL-LETO-WHISPER",
"title": "A Whisper at Vaerkring",
"objective": "Find Ishaq the Fedaykin runner in the Guild lobby and hear why the twins' guardians are asking questions.",
"metric": "leto-contact-runner",
"target": 1,
"requires": [],
"requiresAny": [],
"branch": "leto-search",
"season": "S01",
"revision": 1,
"optional": false,
"verifiedOnly": true,
"xpType": "pol",
"issuer": "stilgar",
"issuerName": "Sietch Tabr",
"xp": 150,
"amountMinor": 15000,
"npcRole": "leto_runner",
"executionRequirements": {
"website": false,
"minecraft": {
"server": "lobby",
"dimension": "NORMAL",
"world": "Vaerkring"
}
},
"dialogue": {
"version": 1,
"introduction": "Word moves faster than water in the Guild lobby. A runner of the Fedaykin is looking for someone who can walk the worlds without drawing a Navigator's eye.",
"context": "Find Ishaq the Fedaykin runner in the Guild lobby and hear why the twins' guardians are asking questions.",
"turnIn": "Stilgar's people have lost the trail of Leto, son of Muad'Dib. Your map is delivered when you next play on a planet. Start at Sietch Tabr on Arrakis."
},
"itemReward": "leto/sietch-map-roll"
},
{
"id": "POL-LETO-TABR",
"title": "Home of the Twins",
"objective": "Enter Sietch Tabr through its south gate at X 792, Z 1480 in Arrakduin, then speak with the Sietch Steward.",
"metric": "leto-contact-steward",
"target": 1,
"requires": [
"POL-LETO-WHISPER"
],
"requiresAny": [],
"branch": "leto-search",
"season": "S01",
"revision": 1,
"optional": false,
"verifiedOnly": true,
"xpType": "pol",
"issuer": "stilgar",
"issuerName": "Sietch Tabr",
"xp": 200,
"amountMinor": 15000,
"npcRole": "leto_steward",
"executionRequirements": {
"website": false,
"minecraft": {
"server": "arrakis",
"dimension": "NORMAL",
"world": "Arrakduin"
}
},
"dialogue": {
"version": 1,
"introduction": "Sietch Tabr is where Leto and Ghanima were born and raised among the Fremen. The Steward says the boy walked out of the sietch and has not been seen.",
"context": "Enter Sietch Tabr through its south gate at X 792, Z 1480 in Arrakduin, then speak with the Sietch Steward.",
"turnIn": "The Steward gives you a water ring: proof that Tabr vouches for you."
},
"itemReward": "leto/tabr-water-ring"
},
{
"id": "POL-LETO-WATER",
"title": "The Price of Water",
"objective": "Gather 12 water bottles on Arrakis and deliver them to the Keeper of the Water Basin; the sietch owes a water debt to whoever helps it.",
"metric": "leto-gather-water",
"target": 12,
"requires": [
"POL-LETO-TABR"
],
"requiresAny": [],
"branch": "leto-search",
"season": "S01",
"revision": 1,
"optional": false,
"verifiedOnly": true,
"xpType": "pol",
"issuer": "stilgar",
"issuerName": "Sietch Tabr",
"xp": 250,
"amountMinor": 20000,
"npcRole": "leto_waterkeeper",
"executionRequirements": {
"website": false,
"minecraft": {
"server": "arrakis",
"dimension": "NORMAL",
"world": "Arrakduin"
}
},
"dialogue": {
"version": 1,
"introduction": "No Fremen speaks freely until water is settled. The Keeper counts every drop in the basin.",
"context": "Gather 12 water bottles on Arrakis and deliver them to the Keeper of the Water Basin; the sietch owes a water debt to whoever helps it.",
"turnIn": "The debt is paid. The Keeper points you to the old rumours of Jacurutu, the forbidden sietch."
},
"itemReward": null
},
{
"id": "POL-LETO-JACURUTU",
"title": "Where the Worms Sleep",
"objective": "Harvest 16 raw spice in the open sand and bring it to the Ecologist; the spice trance is needed to read what the desert remembers.",
"metric": "leto-gather-spice",
"target": 16,
"requires": [
"POL-LETO-WATER"
],
"requiresAny": [],
"branch": "leto-search",
"season": "S01",
"revision": 1,
"optional": false,
"verifiedOnly": true,
"xpType": "pol",
"issuer": "stilgar",
"issuerName": "Sietch Tabr",
"xp": 300,
"amountMinor": 25000,
"npcRole": "leto_ecologist",
"executionRequirements": {
"website": false,
"minecraft": {
"server": "arrakis",
"dimension": "NORMAL",
"world": "Arrakduin"
}
},
"dialogue": {
"version": 1,
"introduction": "Chani's old laboratory still studies the sand. The Ecologist believes the boy's tracks end near a sandtrout nursery.",
"context": "Harvest 16 raw spice in the open sand and bring it to the Ecologist; the spice trance is needed to read what the desert remembers.",
"turnIn": "The Ecologist presses a sandtrout token into your hand: living proof the sand-trail is real."
},
"itemReward": "leto/sandtrout-token"
},
{
"id": "POL-LETO-CALADAN",
"title": "The Sea Remembers",
"objective": "Travel to Caladan and find the House Archivist. Atreides records may name where a hidden heir would go.",
"metric": "leto-contact-archivist",
"target": 1,
"requires": [
"POL-LETO-JACURUTU"
],
"requiresAny": [],
"branch": "leto-search",
"season": "S01",
"revision": 1,
"optional": false,
"verifiedOnly": true,
"xpType": "pol",
"issuer": "stilgar",
"issuerName": "Sietch Tabr",
"xp": 350,
"amountMinor": 25000,
"npcRole": "leto_archivist",
"executionRequirements": {
"website": false,
"minecraft": {
"server": "caladan",
"dimension": "NORMAL",
"world": "Kaladam"
}
},
"dialogue": {
"version": 1,
"introduction": "On Caladan the Atreides line is written in stone and salt. The Archivist keeps what the sea has not taken.",
"context": "Travel to Caladan and find the House Archivist. Atreides records may name where a hidden heir would go.",
"turnIn": "Records confirm Leto had Atreides contacts beyond Arrakis. The thread leads to the Harkonnen pits."
},
"itemReward": null
},
{
"id": "POL-LETO-KELP",
"title": "Salt and Rope",
"objective": "Gather 32 kelp on Caladan; the Archivist trades records for honest work.",
"metric": "leto-gather-kelp",
"target": 32,
"requires": [
"POL-LETO-CALADAN"
],
"requiresAny": [],
"branch": "leto-search",
"season": "S01",
"revision": 1,
"optional": false,
"verifiedOnly": true,
"xpType": "pol",
"issuer": "stilgar",
"issuerName": "Sietch Tabr",
"xp": 350,
"amountMinor": 25000,
"npcRole": "leto_archivist",
"executionRequirements": {
"website": false,
"minecraft": {
"server": "caladan",
"dimension": "NORMAL",
"world": "Kaladam"
}
},
"dialogue": {
"version": 1,
"introduction": "The Archivist will not part with the sealed ledger until a fisher's debt is cleared.",
"context": "Gather 32 kelp on Caladan; the Archivist trades records for honest work.",
"turnIn": "The ledger is yours: it names a man who survived the pits of Giedi Prime."
},
"itemReward": null
},
{
"id": "POL-LETO-PITS",
"title": "Chains of Giedi Prime",
"objective": "Slip into Giedi Prime and find the Pit Informer. A former pit slave knows the Harkonnen cells.",
"metric": "leto-contact-informer",
"target": 1,
"requires": [
"POL-LETO-KELP"
],
"requiresAny": [],
"branch": "leto-search",
"season": "S01",
"revision": 1,
"optional": false,
"verifiedOnly": true,
"xpType": "pol",
"issuer": "stilgar",
"issuerName": "Sietch Tabr",
"xp": 450,
"amountMinor": 30000,
"npcRole": "leto_informer",
"executionRequirements": {
"website": false,
"minecraft": {
"server": "giedi-prime",
"dimension": "NORMAL",
"world": "Giedermark"
}
},
"dialogue": {
"version": 1,
"introduction": "Giedi Prime remembers its slaves. The Informer speaks only to those who show the ledger's mark.",
"context": "Slip into Giedi Prime and find the Pit Informer. A former pit slave knows the Harkonnen cells.",
"turnIn": "The Informer confirms Tleilaxu agents passed through, carrying something that smells of spice and iron."
},
"itemReward": "leto/spice-vision-vial"
},
{
"id": "POL-LETO-FURNACE",
"title": "Out of the Furnace",
"objective": "Enter Giedermark's Nether and obtain 6 ancient debris. The Informer needs it to bribe a Harkonnen quartermaster.",
"metric": "leto-gather-debris",
"target": 6,
"requires": [
"POL-LETO-PITS"
],
"requiresAny": [],
"branch": "leto-search",
"season": "S01",
"revision": 1,
"optional": false,
"verifiedOnly": true,
"xpType": "pol",
"issuer": "stilgar",
"issuerName": "Sietch Tabr",
"xp": 500,
"amountMinor": 35000,
"npcRole": "leto_informer",
"executionRequirements": {
"website": false,
"minecraft": {
"server": "giedi-prime",
"dimension": "NETHER",
"world": "Giedermark Nether"
}
},
"dialogue": {
"version": 1,
"introduction": "The Harkonnen deep forges burn hotter than any desert. The quartermaster wants metal that cannot be traced.",
"context": "Enter Giedermark's Nether and obtain 6 ancient debris. The Informer needs it to bribe a Harkonnen quartermaster.",
"turnIn": "The quartermaster hands over a travel pass for the Imperial court."
},
"itemReward": "leto/tabr-fedaykin-knife"
},
{
"id": "POL-LETO-COURT",
"title": "Veils at Kaitain",
"objective": "Travel to Kaitain and find the Court Archivist at the Imperial palace. Someone at court sold the twins' movements.",
"metric": "leto-contact-courtier",
"target": 1,
"requires": [
"POL-LETO-FURNACE"
],
"requiresAny": [],
"branch": "leto-search",
"season": "S01",
"revision": 1,
"optional": false,
"verifiedOnly": true,
"xpType": "pol",
"issuer": "stilgar",
"issuerName": "Sietch Tabr",
"xp": 500,
"amountMinor": 30000,
"npcRole": "leto_courtier",
"executionRequirements": {
"website": false,
"minecraft": {
"server": "kaitain",
"dimension": "NORMAL",
"world": "Kaiterhof"
}
},
"dialogue": {
"version": 1,
"introduction": "The Corrino court wears its secrets in silk. The Archivist remembers who bribed whom.",
"context": "Travel to Kaitain and find the Court Archivist at the Imperial palace. Someone at court sold the twins' movements.",
"turnIn": "The Archivist names the intermediary: a Guild fixer working for the Tleilaxu."
},
"itemReward": "leto/tabr-stillsuit-cowl"
},
{
"id": "POL-LETO-IRON",
"title": "Imperial Ledgers",
"objective": "Smelt 16 iron ingots on Kaitain to pay for a bribe on your own account.",
"metric": "leto-gather-iron",
"target": 16,
"requires": [
"POL-LETO-COURT"
],
"requiresAny": [],
"branch": "leto-search",
"season": "S01",
"revision": 1,
"optional": false,
"verifiedOnly": true,
"xpType": "pol",
"issuer": "stilgar",
"issuerName": "Sietch Tabr",
"xp": 550,
"amountMinor": 30000,
"npcRole": "leto_courtier",
"executionRequirements": {
"website": false,
"minecraft": {
"server": "kaitain",
"dimension": "NORMAL",
"world": "Kaiterhof"
}
},
"dialogue": {
"version": 1,
"introduction": "Nothing at court is free, not even silence.",
"context": "Smelt 16 iron ingots on Kaitain to pay for a bribe on your own account.",
"turnIn": "The fixer's last known meeting place is on Ordos."
},
"itemReward": null
},
{
"id": "POL-LETO-ORDOS",
"title": "Cold Hands on Ordos",
"objective": "Reach Sigmadraken IV and obtain 2 diamonds to buy the fixer's ledger.",
"metric": "leto-gather-diamond",
"target": 2,
"requires": [
"POL-LETO-IRON"
],
"requiresAny": [],
"branch": "leto-search",
"season": "S01",
"revision": 1,
"optional": false,
"verifiedOnly": true,
"xpType": "pol",
"issuer": "stilgar",
"issuerName": "Sietch Tabr",
"xp": 600,
"amountMinor": 35000,
"npcRole": "leto_tleilaxu_ghola",
"executionRequirements": {
"website": false,
"minecraft": {
"server": "sigma-draconis-iv",
"dimension": "NORMAL",
"world": "Sigmadraken IV"
}
},
"dialogue": {
"version": 1,
"introduction": "The fixer is a Tleilaxu go-between; Ordos is cold and quiet, and information is the only currency here.",
"context": "Reach Sigmadraken IV and obtain 2 diamonds to buy the fixer's ledger.",
"turnIn": "The fixer gives you a name and a Guild heighliner schedule."
},
"itemReward": null
},
{
"id": "POL-LETO-GUILD",
"title": "A Navigator's Price",
"objective": "Descend to the End of Sigmadraken IV and find the Guild Navigator's agent. The Guild knows every ship that left Arrakis.",
"metric": "leto-contact-navigator",
"target": 1,
"requires": [
"POL-LETO-ORDOS"
],
"requiresAny": [],
"branch": "leto-search",
"season": "S01",
"revision": 1,
"optional": false,
"verifiedOnly": true,
"xpType": "pol",
"issuer": "stilgar",
"issuerName": "Sietch Tabr",
"xp": 700,
"amountMinor": 40000,
"npcRole": "leto_navigator",
"executionRequirements": {
"website": false,
"minecraft": {
"server": "sigma-draconis-iv",
"dimension": "END",
"world": "Sigmadraken IV End"
}
},
"dialogue": {
"version": 1,
"introduction": "A Guild Navigator folds space and sees every course. The price of his word is high, and the Guild keeps neutral appearances.",
"context": "Descend to the End of Sigmadraken IV and find the Guild Navigator's agent. The Guild knows every ship that left Arrakis.",
"turnIn": "He gives you one coordinate: the dune sea south of Sietch Tabr."
},
"itemReward": "leto/jacurutu-sand-compass"
},
{
"id": "POL-LETO-RETURN",
"title": "The Sea That Walks",
"objective": "Return to Sietch Tabr and tell the Steward what you learned along the Golden Path.",
"metric": "leto-contact-finale",
"target": 1,
"requires": [
"POL-LETO-GUILD"
],
"requiresAny": [],
"branch": "leto-search",
"season": "S01",
"revision": 1,
"optional": false,
"verifiedOnly": true,
"xpType": "pol",
"issuer": "stilgar",
"issuerName": "Sietch Tabr",
"xp": 1500,
"amountMinor": 75000,
"npcRole": "leto_stilgar",
"executionRequirements": {
"website": false,
"minecraft": {
"server": "arrakis",
"dimension": "NORMAL",
"world": "Arrakduin"
}
},
"dialogue": {
"version": 1,
"introduction": "Everything has led back to the sand. The trail of Leto II leads to the old sietch, and the boy already knows you are coming.",
"context": "Return to Sietch Tabr and tell the Steward what you learned along the Golden Path.",
"turnIn": "You have found the trace of a boy who will become more than a man. The Search is over, but the Golden Path is long."
},
"itemReward": "leto/golden-path-seal"
}
];
export const LETO_QUESTS=Object.freeze(rows.map(q=>Object.freeze({...q,requires:Object.freeze(q.requires),requiresAny:Object.freeze([]),executionRequirements:Object.freeze({website:false,minecraft:Object.freeze(q.executionRequirements.minecraft)}),dialogue:Object.freeze(q.dialogue)})));
export const LETO_BRANCH=Object.freeze({id:'leto-search',office:null,title:'The Search for Leto II',issuer:'stilgar',issuerName:'Sietch Tabr',theme:'Thirteen steps, eight worlds, one boy · Reputation XP',xpType:'pol',quests:LETO_QUESTS,decisions:[]});
export const LETO_CATEGORY=Object.freeze({"id": "golden-path", "title": "The Golden Path", "tagline": "Seek the son of Muad'Dib across every world.", "accent": "#e0b04a", "icon": "quests/golden-path", "branches": ["leto-search"]});

View file

@ -2,27 +2,6 @@
// 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';
@ -50,7 +29,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,lane:list[0]?.lane,title:titles.get(id)||String(id).toUpperCase(),quests:list,done,total:list.length,complete:done===list.length};
return {id,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

@ -2,22 +2,17 @@
.mj-banner{display:flex;gap:.8rem;align-items:center;justify-content:space-between;padding:.7rem 1rem;border:1px solid var(--accent,#d7a548);border-radius:.5rem;background:rgba(215,165,72,.12)}
.mj-current{display:grid;gap:.25rem;padding:.7rem 1rem;border-left:4px solid var(--accent,#d7a548);background:rgba(255,255,255,.04);border-radius:.4rem}
.mj-current progress,.mj-objectives progress{width:100%;height:.6rem}
.mj-layout{display:grid;grid-template-columns:minmax(0,1fr);gap:1rem}
.mj-arcs{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,19rem),1fr));gap:.75rem;align-items:start;min-width:0}
.mj-layout{display:grid;grid-template-columns:minmax(14rem,22rem) 1fr;gap:1rem;align-items:start}
@media(max-width:46rem){.mj-layout{grid-template-columns:1fr}}
.mj-arcs{display:grid;gap:.5rem}
.mj-arc{border:1px solid rgba(255,255,255,.14);border-radius:.5rem;padding:.25rem .5rem}
.mj-arc summary{display:flex;justify-content:space-between;gap:.5rem;cursor:pointer;padding:.4rem .2rem;font-weight:600}
.mj .mj-arc .mj-mission-table-frame{overflow:visible;border:0}
.mj-mission-table{width:100%;border-collapse:collapse;table-layout:fixed;margin-bottom:.3rem}
.mj-mission-table th,.mj-mission-table td{text-align:left;overflow-wrap:anywhere;border-bottom:1px solid rgba(255,255,255,.1)}
.mj-mission-table th{padding:.35rem .5rem;font-size:.8rem;color:#c9b991}
.mj-mission-table th:last-child{width:35%}
.mj-mission-status{padding:.35rem .5rem;font-size:.82rem}
.mj-arc ol{list-style:none;margin:0;padding:0 0 .3rem;display:grid;gap:.2rem}
.mj-mission{display:flex;flex-wrap:wrap;justify-content:space-between;gap:.2rem .6rem;width:100%;text-align:left;padding:.45rem .6rem;border-radius:.35rem;border:1px solid transparent;background:transparent;color:inherit;cursor:pointer}
.mj-mission[aria-pressed=true]{border-color:var(--accent,#d7a548);background:rgba(215,165,72,.1)}
.mj-mission-table tr[data-status=done]{opacity:.65}.mj-mission-table tr[data-status=done] .mj-mission-status::before{content:"\2713\00a0"}
.mj-mission-table tr[data-status=locked]{opacity:.5}.mj-mission-table tr[data-status=locked] .mj-mission-status::before{content:"\1F512\00a0"}
.mj-mission-table tr[data-status=ready] .mj-mission-status,.mj-mission-table tr[data-status=active] .mj-mission-status{color:var(--accent,#d7a548);font-weight:600}
.mj-mission[data-status=done]{opacity:.65}.mj-mission[data-status=done] span::before{content:"\2713\00a0"}
.mj-mission[data-status=locked]{opacity:.5}.mj-mission[data-status=locked] span::before{content:"\1F512\00a0"}
.mj-mission[data-status=ready] small:first-of-type,.mj-mission[data-status=active] small:first-of-type{color:var(--accent,#d7a548);font-weight:600}
.mj-tracked{width:100%;font-style:italic}
.mj-detail{display:grid;gap:.5rem;padding:1rem;border:1px solid rgba(255,255,255,.14);border-radius:.5rem}
.mj-detail h3,.mj-detail h4{margin:.2rem 0}

View file

@ -1,7 +1,7 @@
import {element as el} from './cp-v2-page-template.mjs';
import {actions,briefing,currentObjective,JOURNAL_LANES,nextInArc,objectives,rewards,pickSelection} from './cp-v2-mission-journal-model.mjs';
import {actions,briefing,currentObjective,nextInArc,objectives,rewards,pickSelection} from './cp-v2-mission-journal-model.mjs';
import {categoryFor,categoryHero,groupJournalArcs,bannerUrl,iconUrl,ensureStyles,storyLanes} from './cp-v2-quest-categories.mjs';
import {categoryFor,categoryHero,groupJournalArcs,bannerUrl,iconUrl,ensureStyles} 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,15 +22,9 @@ 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');
const layout=el('div',undefined,'mj-layout'),nav=el('nav',undefined,'mj-arcs');nav.setAttribute('aria-label','Story arcs');
ensureStyles();
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)){
for(const arc of groupJournalArcs(journal.arcs)){
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;
@ -38,39 +32,27 @@ export function renderMissionJournal(body,{journal,selected,tracked,banners=[],b
head.onclick=event=>{if(!arc.quests.some(q=>q.id===selected)){event.preventDefault();onSelect(pickSelection({all:arc.quests},{tracked}));}};
group.append(head,el('p',arc.category.tagline,'mj-arc-tagline'),bar(arc.total?arc.done/arc.total*100:0,arc.category.title+' progress'));
if(arc.ready)group.append(el('small',arc.ready+' reward'+(arc.ready===1?'':'s')+' ready','mj-arc-ready'));
const table=el('table',undefined,'mj-mission-table');
table.setAttribute('aria-label',arc.category.title+' missions');
const thead=el('thead'),titles=el('tr');
for(const label of ['Mission','Status']){
const column=el('th',label);column.scope='col';titles.append(column);
}
thead.append(titles);table.append(thead);
const rows=el('tbody');
const list=el('ol');
for(const q of arc.quests){
const row=el('tr'),mission=el('td'),status=el('td',q.statusLabel,'mj-mission-status');
status.id='mission-status-'+q.id;
const pick=button('',()=>onSelect(q.id));pick.className='mj-mission';row.dataset.status=q.status;
pick.setAttribute('aria-pressed',String(q.id===selected));pick.setAttribute('aria-describedby',status.id);
pick.append(el('span',q.title));if(q.id===tracked&&q.status!=='done')pick.append(el('small','Tracked','mj-tracked'));
mission.append(pick);row.append(mission,status);rows.append(row);
}
const tableFrame=el('div',undefined,'table-wrap mj-mission-table-frame');
table.append(rows);tableFrame.append(table);group.append(tableFrame);nav.append(group);
const item=el('li'),pick=button('',()=>onSelect(q.id));pick.className='mj-mission';pick.dataset.status=q.status;pick.setAttribute('aria-pressed',String(q.id===selected));
pick.append(el('span',q.title),el('small',q.statusLabel));if(q.id===tracked&&q.status!=='done')pick.append(el('small','Tracked','mj-tracked'));
item.append(pick);list.append(item);
}
group.append(list);nav.append(group);
}
layout.append(nav);
const q=journal.all.find(x=>x.id===selected),pane=el('section',undefined,'mj-detail');pane.setAttribute('aria-label','Selected mission');
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'));if(q.lane)pane.append(el('small',JOURNAL_LANES[q.lane].label+' mission'));pane.append(el('p',briefing(q),'mj-briefing'));
pane.append(el('h3',q.title),el('span',q.statusLabel,'mj-status'),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:q.lane??xpType})){prizes.append(el('dt',r.label),el('dd',r.value));}
for(const r of rewards(q,{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})){
@ -79,5 +61,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,...sections);root.append(layout);body.append(root);
layout.append(pane);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,combineJournalData,completions,JOURNAL_LANES,journalId,nextInArc,pickSelection} from './cp-v2-mission-journal-model.mjs';
import {advanceTracked,buildJournal,completions,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,43 +18,26 @@ 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,combined=false,preferredLane=null}={}){
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}={}){
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:'+(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 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 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={},base=apiBase){
const response=await fetcher(base+path,{credentials:'same-origin',cache:'no-store',signal:controller.signal,...options});
async function api(path,options={}){
const response=await fetcher(apiBase+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';
@ -64,14 +47,14 @@ 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 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();}
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();}
catch(error){if(active){uncertain=true;message(error.message+' Reload the journal to confirm the recorded result.');}}
finally{busy=false;if(active)render();}
}
function render(){
connectorObserver?.disconnect();
const arcScroll=body.querySelector?.('.mj-arcs')?.scrollTop??0;
body.replaceChildren();if(!data)return;
if(!journalMode){const reload=button('Reload journal',load);reload.className='progression-reload';reload.disabled=busy;body.append(reload);}
if(view==='history'){renderProgressionHistory(body,data,{page,busy,onPrevious:()=>{page--;load();},onNext:()=>{page++;load();}});return;}
@ -79,37 +62,33 @@ 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 [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(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(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');
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();});}});
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();},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 arcNav=body.querySelector?.('.mj-arcs');if(arcNav)arcNav.scrollTop=arcScroll;
return;
}
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);
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);
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).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);}
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);}
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&&(!combined||q.lane===shown.lane))?.branch||branch;selected=null;render();};onBranches(availableBranches,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)?.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);
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&&(!combined||q.lane===shown.lane))).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)).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.definitionId??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.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=row.verificationSource??data.sources?.sources?.find(s=>s.metrics?.includes(row.metric));
const source=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)],[(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);
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);
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'});
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==='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,6 +29,7 @@ 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,4 @@
import {polQuestDialogue,polQuestContact} from './cp-v2-pol-dialogue.mjs';
import {LETO_BRANCH,LETO_QUESTS} from './cp-v2-leto-quests.mjs';
import {FAITH_QUEST_BRANCHES} from './cp-v2-faith-quests.mjs';
import {ELYTRA_BRANCH} from './cp-v2-elytra-quests.mjs';
import {WAR_QUEST_BRANCH} from './cp-v2-war-quests.mjs';
@ -1110,10 +1109,9 @@ export const POL_QUEST_BRANCHES=freeze([
BOUNTY_BRANCH,
SPICE_UPGRADE_BRANCH,
ELYTRA_BRANCH,
WAR_QUEST_BRANCH,
LETO_BRANCH
WAR_QUEST_BRANCH
]);
const gameplayMetrics=new Set(['pol-verified-report','pol-counterintelligence','pol-evidence-dossier','pol-covert-intelligence','pol-beneficiary-investigation','pol-diplomatic-dispatch','pol-diplomatic-agreement','pol-imperial-intelligence','pol-trade-intelligence','pol-confidential-diplomacy','pol-political-intelligence','pol-confidential-agreement','pol-smuggler-introduction','pol-sabotage','pol-water-supply','pol-procurement','pol-strategic-procurement','pol-settled-acquisition','pol-spice-transport','pol-sietch-service','pol-verified-route','pol-verified-manifest','pol-route-service','pol-sealed-cargo','pol-restricted-delivery','pol-alternate-route','pol-opposed-delivery','pol-ghost-cargo','pol-escort','pol-interdiction','pol-cargo-recovery','pol-protection','pol-commissioned-recovery','pol-discreet-logistics','pol-protected-delivery']);
const withDialogue=d=>Object.freeze({...d,npcRole:polQuestContact(d),dialogue:polQuestDialogue(d)});
export const POL_QUEST_DEFINITIONS=Object.freeze(POL_QUEST_BRANCHES.flatMap(b=>b===LETO_BRANCH?LETO_QUESTS:b.quests.map((q,index)=>withDialogue({...q,issuer:q.issuer||b.issuer||({smugglers:"esmar_tuek",clan:"gurney_halleck",company:"roma_atani"})[b.id],issuerName:q.issuerName||b.issuerName||({smugglers:"Esmar Tuek",clan:"Gurney Halleck",company:"Roma Atani"})[b.id],objective:q.objective,xp:q.xp??150+index*50,executionRequirements:Object.freeze({website:true,minecraft:gameplayMetrics.has(q.metric)||['elytra','war-service','fremen-husbandry','bounty-jobs','spice-upgrading'].includes(q.branch)})}))));
export const POL_QUEST_DEFINITIONS=Object.freeze(POL_QUEST_BRANCHES.flatMap(b=>b.quests.map((q,index)=>withDialogue({...q,issuer:q.issuer||b.issuer||({smugglers:"esmar_tuek",clan:"gurney_halleck",company:"roma_atani"})[b.id],issuerName:q.issuerName||b.issuerName||({smugglers:"Esmar Tuek",clan:"Gurney Halleck",company:"Roma Atani"})[b.id],objective:q.objective,xp:q.xp??150+index*50,executionRequirements:Object.freeze({website:true,minecraft:gameplayMetrics.has(q.metric)||['elytra','war-service','fremen-husbandry','bounty-jobs','spice-upgrading'].includes(q.branch)})}))));
export function polBranch(id){return POL_QUEST_BRANCHES.find(b=>b.id===id||b.office===id)||null;}

View file

@ -4,8 +4,6 @@ export const POL_SUPPLY_TASKS=Object.freeze([
{id:'POL-FREMEN-01',kind:'supply_water',metric:'pol-water-supply',item:'jerboa_water_vial',quantity:6,label:'Water Vials',server:'arrakis',role:'stilgar',contact:'Stilgar',faction:'fremen'},
{id:'POL-FREMEN-03',kind:'supply_sietch',metric:'pol-sietch-service',item:'farmers_bucket',quantity:1,label:"Farmer’s Bucket",server:'arrakis',role:'stilgar',contact:'Stilgar',faction:'fremen'},
{id:'POL-COMPANY-01',kind:'supply_company',metric:'pol-procurement',item:'spice',quantity:8,label:'raw Spice',server:'sigma-draconis-iv',role:'roma_atani',contact:'Roma Atani'},
{id:'POL-ORDOS-02',faction:'ordos',kind:'supply_ordos',metric:'pol-strategic-procurement',item:'refined_spice',quantity:4,label:'Refined Spice',server:'sigma-draconis-iv',role:'roma_atani',contact:'Roma Atani'},
{id:'POL-LETO-WATER',kind:'leto_gather_water',metric:'leto-gather-water',item:'bottled_water',quantity:12,label:'Water Bottles',server:'arrakis',role:'leto_waterkeeper',contact:'Keeper of the Water Basin'},
{id:'POL-LETO-JACURUTU',kind:'leto_gather_spice',metric:'leto-gather-spice',item:'spice',quantity:16,label:'raw Spice',server:'arrakis',role:'leto_ecologist',contact:'Sietch Ecologist'}
{id:'POL-ORDOS-02',faction:'ordos',kind:'supply_ordos',metric:'pol-strategic-procurement',item:'refined_spice',quantity:4,label:'Refined Spice',server:'sigma-draconis-iv',role:'roma_atani',contact:'Roma Atani'}
].map(Object.freeze));
export const polSupplyTask=id=>POL_SUPPLY_TASKS.find(t=>t.id===id)||null;

View file

@ -1,5 +1,5 @@
import {MISSION_BRANCHES} from './cp-v2-progression-catalogue.mjs';
import {groupBranches,bannerUrl,iconUrl,ensureStyles,storyLanes} from './cp-v2-quest-categories.mjs';
import {groupBranches,bannerUrl,iconUrl,ensureStyles} 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}={}){
@ -17,7 +17,7 @@ export function createProgressionSidebar(host,{fetcher=fetch,onBranch=()=>{},onN
const right=host.closest('#content')?.parentElement?.querySelector('#sidebar-right');
if(!right)return {available:false,setJournal(){},setBranches(){},showBranches(){},setNavigation(){},dispose(){}};
const controller=new AbortController(),summary=el('section',undefined,'mentat-report'),directory=el('section',undefined,'category-block progression-directory-menu');directory.setAttribute('aria-label','Mission branches');
const journalMenu=el('section',undefined,'category-block progression-journal-menu');journalMenu.setAttribute('aria-label','Journal views');let currentKind='personal',currentView='missions';const href=(kind,view)=>(location.hash.split('?')[0]||'#quests/quests')+'?'+new URLSearchParams(kind==='all'?{view}:{xp:kind,view});const closeMenus=()=>{right.classList.remove('open');right.parentElement?.querySelector('#sidebar')?.classList.remove('open');document.querySelector('#mobile-menu')?.setAttribute('aria-expanded','false');};const open=(event,kind,view)=>{event.preventDefault();history.replaceState(null,'',href(kind,view));onNavigate(kind,view);closeMenus();};
const journalMenu=el('section',undefined,'category-block progression-journal-menu');journalMenu.setAttribute('aria-label','Journal views');let currentKind='personal',currentView='missions';const href=(kind,view)=>(location.hash.split('?')[0]||'#quests/quests')+'?'+new URLSearchParams({xp:kind,view});const closeMenus=()=>{right.classList.remove('open');right.parentElement?.querySelector('#sidebar')?.classList.remove('open');document.querySelector('#mobile-menu')?.setAttribute('aria-expanded','false');};const open=(event,kind,view)=>{event.preventDefault();history.replaceState(null,'',href(kind,view));onNavigate(kind,view);closeMenus();};
const journals=new Map(),failures=new Set(),pending=new Set();let alive=true,player=null,mentat=null,houseState='loading',branchRows=[],branchId=null;
const directoryBanner=right.querySelector(':scope > .side-hero'),bannerNext=directoryBanner?.nextSibling;right.prepend(summary);const left=right.parentElement?.querySelector('#sidebar');(left||right).append(journalMenu);if(left&&directoryBanner)left.append(directoryBanner);(left||right).append(directory);
const format=n=>Number.isSafeInteger(n)?n.toLocaleString('en-GB'):'—';
@ -40,29 +40,8 @@ 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(){
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;
}
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;}
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)=>{if(kind==='personal'||kind==='pol')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)=>{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(){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.'));}
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||report.available;if(!xpNav.hidden)for(const [kind,label]of [['personal','Personal level'],['pol','Reputation level']]){const b=button(label,()=>{xpKind=kind;selected=null;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.'));}
render();return()=>{dossier.dispose();connectorObserver?.disconnect();disposePersonal?.();report.dispose();root.remove();};
}

View file

@ -4,7 +4,8 @@
.quest-category-heading{display:flex;align-items:center;gap:.5rem;margin:.6rem 0 .25rem;padding:.35rem .5rem;border-radius:4px;background-size:cover;background-position:right center;color:#fff7e6;font-weight:600;text-shadow:0 1px 2px rgba(40,26,18,.9)}
.quest-category-heading img{width:20px;height:20px;image-rendering:pixelated}
@media(max-width:46rem){.quest-category-hero{padding-right:5rem}}
.mj .mj-arcs{max-height:calc(100vh - 16rem);min-height:15rem;overflow-y:auto;overscroll-behavior:contain;padding-right:.35rem}
@media(max-width:46rem){.mj .mj-arcs{max-height:42vh;min-height:10rem}.quest-category-hero{padding-right:5rem}}
.mj .mj-arc>summary.quest-category-heading{display:grid;grid-template-columns:24px minmax(0,1fr) auto;gap:.6rem;min-height:44px;padding:.55rem .65rem;margin:0;border-radius:.35rem}
.mj .mj-arc[open]>summary{box-shadow:inset 0 0 0 1px #b6995c}

View file

@ -1,6 +1,5 @@
// Themed story-arc categories over the quest branches. Presentation only: quest ids, rewards,
// prerequisites and progress are never changed. Mirrors DuneRealmsGUI/src/main/resources/quest-categories.json.
import {LETO_CATEGORY} from './cp-v2-leto-quests.mjs';
export const QUEST_CATEGORIES=Object.freeze([
{
"id": "arrival",
@ -147,30 +146,18 @@ export const QUEST_CATEGORIES=Object.freeze([
"branches": [
"war-service"
]
},
LETO_CATEGORY
}
].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])));
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 categoryFor=branchId=>byBranch.get(branchId)||OTHER_CATEGORY;
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=>baseBranch(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=>r.id===id)).filter(Boolean);
if(members.length)groups.push({category,rows:members});
}
return groups;

View file

@ -15,7 +15,7 @@ export const QUEST_GUIDANCE=Object.freeze({
'guild-travel':live('Book Spacing Guild passage in the lobby, remain online and arrive on your House world. The 100 DM fare is taken from your central personal bank account on arrival.','Lobby → Spacing Guild NPC / Imperial Codex → Spacing Guild','Confirmed destination arrival and settled passage payment'),
'citizen-introduction':live('Start this quest, then read the Imperial Citizen briefing and press I understand in your ingame mission journal. Refresh this quest after confirmation, then claim the reward. This is separate from choosing a House or completing your profile.','Imperial Codex → Mission journal → Personal Experience → Onboarding → Complete Imperial Citizen introduction → Read citizen briefing','Confirmed ingame Citizen briefing acknowledgement'),
'earned-minor':live('Receive the stated cumulative amount in DM from posted incoming bank transfers, quest rewards, wages, P&O spice payouts and Exchange sales during this season. Spending it later does not reduce your earned total. Transfers between your own accounts, refunds and pending payments do not count.','Central bank → Transactions; receive transfers, complete reward quests, earn wages or sell goods on the Exchange','Settled central-bank income, not your current balance'),
'bank-deposit':live('Deposit physical cash at an ATM to get a RIA ID, then redeem that ID to your personal bank account. Cash pickup and bank transfers do not count.','Ingame Rihla / ATM → redeem to bank','Settled ATM voucher redemption to your bank account'),
'bank-deposit':pending('Deposit physical cash into your personal central-bank account through the ingame ATM. A transfer between your own accounts is not a cash deposit.','Rihla / ATM ingame menu'),
'bank-transfer':live('Send a payment from an authorised personal bank account to another customer. Wait until it is posted; a queued payment or transfer between your own accounts does not count.','Website bank → Transfers','Posted standard or instant payment to another customer'),
'shop-purchase':live('Buy and pay for goods listed by another player on the Exchange. Browsing, publishing your own listing or withdrawing an unsold item does not count.','Ingame /exchange → Buy','Settled central-bank Exchange purchase'),
'spice-harvest':live('Personally harvest genuine raw spice from deposits on Arrakis. Buying, trading or selling spice does not count; selling your own harvest does not count it a second time.','Arrakis → Natural spice deposits','Verified native harvest receipt'),

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -33,28 +33,3 @@ export function createBankQuestActivities(central,bank,keys,{clock=Date.now}={})
return {pendingMetrics:rows.length?[]:['shop-purchase']};
};
}
const verifiedBankDeposits = `SELECT id,created_at FROM ria_cash_redemptions
WHERE owner_id=? AND player_uuid=? AND mode='bank' AND state='redeemed'
AND CAST(amount_minor AS DECIMAL(20,0))>0 AND created_at>=? AND created_at<?`;
export function createBankDepositQuestActivity(central,bank,keys,{clock=Date.now}={}){
const producer={};
const events=createPersonalActivityEvents(central,keys,{clock,authorizeProducer:async(actor,p)=>{
if(actor!==producer||p.metric!=='bank-deposit'||p.quantity!==1||p.reference!=='bank-deposit:'+p.eventId)return false;
const rows=await bank.query(verifiedBankDeposits+' AND id=?',[p.accountId,p.minecraftUuid,p.occurredAt,p.occurredAt+1,p.eventId]);
return rows.length===1;
}});
return async function collect(actor,season){
const links=await central.query('SELECT minecraft_uuid FROM site_game_links WHERE user_id=?',[actor.id]);
if(links.length!==1)return {pendingMetrics:['bank-deposit']};
const minecraftUuid=links[0].minecraft_uuid.toLowerCase();
// This receipt and its Postbank credit are committed in the same transaction.
const rows=await bank.query(verifiedBankDeposits+' ORDER BY created_at,id LIMIT 1',[actor.id,minecraftUuid,Number(season.starts_at),clock()+1]);
const receipt=rows[0];
if(!receipt)return {pendingMetrics:['bank-deposit']};
await events.record(producer,{eventId:receipt.id,accountId:actor.id,minecraftUuid,seasonId:season.season_id,
metric:'bank-deposit',quantity:1,occurredAt:Number(receipt.created_at),reference:'bank-deposit:'+receipt.id});
return {pendingMetrics:[]};
};
}

View file

@ -57,7 +57,7 @@ export function createGuildService(bank,{authority,resolve,allowArrakis=async()=
const ready=await readyForTravel(user,uuid),open=[],catalog=[];
for(const world of TRADE_WORLDS){
const t=await tariff(user,uuid,world.id,bank),journey=await allowJourney(sourceWorld,world.id,bank,false),source=ready&&journey&&t.fareMinor>0?await funds(bank,user,t.fareMinor):null;
const reason=!ready?'Complete your House Prologue first.':world.id===tradeWorld(sourceWorld)?'Already on this world.':tradeWorld(sourceWorld)!=='lobby'?'Board ordinary passages from the Guild Lobby.':!journey?'The Spacing Guild has embargoed this route.':t.fareMinor>0&&!source?'Not enough available Dunemarks.':'';
const reason=!ready?'Complete your House Prologue first.':world.id===tradeWorld(sourceWorld)?'Already on this world.':tradeWorld(sourceWorld)!=='lobby'?'Board ordinary passages from the Guild Lobby.':!journey?'The Spacing Guild has embargoed this route.':!boardingOpen(clock())?'Boarding opens at :00, :20 and :40 for five minutes.':t.fareMinor>0&&!source?'Not enough available Dunemarks.':'';
if(!reason)open.push(world.id);
catalog.push({server:world.id,name:world.name,available:!reason,reason,fareMinor:t.fareMinor,free:t.free,...(t.free?{freeReason:t.reason}:{bountyMinor:t.bountyMinor,reduced:t.reduced,trip:t.trip})});
}
@ -70,7 +70,7 @@ export function createGuildService(bank,{authority,resolve,allowArrakis=async()=
await expire();const user=await resolve(uuid);if(!user||!routes[user.faction])fail('Link your active website account and choose your House first.',403);
const ready=await readyForTravel(user,uuid),{price,offer}=await quotedFare(user),source=ready?await funds(bank,user,price):null,open=[],catalog=[];
for(const world of TRADE_WORLDS){const lawful=await allowed(user,world.id),journey=lawful&&await allowJourney(sourceWorld,world.id,bank,false);if(ready&&journey)open.push(world.id);
const reason=!ready?'Complete your House Prologue first.':world.id===tradeWorld(sourceWorld)?'Already on this world.':!lawful?'Your House has no Imperial passage for this destination.':!journey?'The Spacing Guild has embargoed this route.':!source?'Not enough available Dunemarks.':'';
const reason=!ready?'Complete your House Prologue first.':world.id===tradeWorld(sourceWorld)?'Already on this world.':!lawful?'Your House has no Imperial passage for this destination.':!journey?'The Spacing Guild has embargoed this route.':!boardingOpen(clock())?'Boarding opens at :00, :20 and :40 for five minutes.':!source?'Not enough available Dunemarks.':'';
catalog.push({server:world.id,name:world.name,available:!reason,reason,fareMinor:price});
}
return {ok:true,destination:routes[user.faction],destinations:[...new Set([routes[user.faction],...open])].filter(w=>open.includes(w)),routes:catalog,fareMinor:price,...(offer?{subsidyMinor:offer.amount}:{}),affordable:!!source,account:source?.account_number||null,...(!ready?{prologueRequired:true}:{})};

View file

@ -9,9 +9,7 @@ const donorRanks=new Set(['vip','patron_caravan','patron_guild','patron_grand','
const clean=value=>String(value||'').replace(/[&§%<>\x00-\x1f\x7f]/g,'').trim().slice(0,64);
export function publicIdentity({ranks=[],roots=[],positions=[]}={}){
const unique=kind=>[...new Map(roots.filter(r=>r.kind===kind&&!r.hidden).map(r=>[r.id,{name:clean(r.name),...(kind==='clan'?{tag:clean(r.tag).slice(0,6)}:{})}])).values()].filter(r=>r.name).slice(0,5);
const titles=[...new Set(positions.map(clean).filter(Boolean))];
const titleNames=new Set(titles.map(name=>name.toLowerCase()));
return {staff:currentStaffRanks(ranks),vip:ranks.some(r=>donorRanks.has(r)),positions:titles,clans:unique('clan'),companies:unique('company'),pols:unique('politics').filter(({name})=>!titleNames.has(name.toLowerCase()))};
return {staff:currentStaffRanks(ranks),vip:ranks.some(r=>donorRanks.has(r)),positions:[...new Set(positions.map(clean).filter(Boolean))],clans:unique('clan'),companies:unique('company'),pols:unique('politics')};
}
// Public labels only. Deed relations are reused without changing rosters or authority.
export async function readGamePublicIdentity(db,actor,{clock=Date.now}={}){
@ -33,15 +31,9 @@ export async function readGamePublicIdentity(db,actor,{clock=Date.now}={}){
const value=parent?await root(parent.parent_kind,parent.parent_id,seen):{kind,id,name:row.name,tag:row.tag};memo.set(key,value);return value;
}
const clans=await store.query('SELECT DISTINCT c.id FROM site_clans c JOIN site_clan_members m ON m.clan_id=c.id JOIN site_game_links l ON l.user_id=m.user_id AND l.minecraft_uuid=m.minecraft_uuid WHERE m.user_id=? AND c.active=1 ORDER BY c.id LIMIT 21',[actor.id]);
const companies=await store.query("SELECT id,name,status,direct_member FROM (SELECT c.id,c.name,c.status,c.ceo_account_id,EXISTS(SELECT 1 FROM site_company_members m WHERE m.company_id=c.id AND m.user_id=?) AS direct_member FROM corrino_companies c WHERE c.status IN ('active','converted-order')) AS companies WHERE direct_member=1 OR ceo_account_id=? ORDER BY id LIMIT 21",[actor.id,actor.id]);
const companies=await store.query("SELECT DISTINCT c.id FROM corrino_companies c LEFT JOIN site_company_members m ON m.company_id=c.id WHERE c.status IN ('active','converted-order') AND (m.user_id=? OR c.ceo_account_id=?) ORDER BY c.id LIMIT 21",[actor.id,actor.id]);
if(clans.length>20||companies.length>20)throw Error('Public membership registry requires review');
for(const [kind,rows]of [['clan',clans],['company',companies]])for(const row of rows){
const value=await root(kind,row.id);
if(value)roots.push(value);
if(kind==='company'&&row.status==='active'&&Number(row.direct_member)===1&&value?.kind==='politics'&&!value.hidden){
roots.push({kind,id:row.id,name:row.name});
}
}
for(const [kind,rows]of [['clan',clans],['company',companies]])for(const row of rows){const value=await root(kind,row.id);if(value)roots.push(value);}
for(const order of await store.query('SELECT DISTINCT o.parent_office FROM political_passive_orders o LEFT JOIN political_passive_order_members m ON m.order_id=o.id WHERE m.user_id=? OR o.leader_account_id=?',[actor.id,actor.id])){const value=await root('politics',order.parent_office);if(value)roots.push(value);}
for(const office of PUBLIC_OFFICES){const holder=await currentOfficeController(store,office.key,clock());if(holder?.userId===actor.id){positions.push(office.name);const value=await root('politics',office.key);if(value)roots.push(value);}}
const access=await accessFor(db,actor);return publicIdentity({ranks:access?.ranks||[],roots,positions});

Some files were not shown because too many files have changed in this diff Show more