Compare commits

..
Author SHA1 Message Date
unimatrixgit
3f1582e634 Classify resale stock as player goods rather than official publication
All checks were successful
DuneRealms Web CI / web (push) Successful in 5m39s
2026-12-06 19:26:32 +01:00
unimatrixgit
6e56432344 Add shared Exchange sorting, categories and atomic buy-and-relist 2026-12-06 19:23:55 +01:00
unimatrixgit
6783cd9034 Publish the immutable hydration HUD pack download route
All checks were successful
DuneRealms Web CI / web (push) Successful in 5m30s
2026-12-06 16:59:18 +01:00
unimatrixgit
f07e3e8c31 Filter web cookbook recipes by production world
All checks were successful
DuneRealms Web CI / web (push) Successful in 6m43s
2026-12-06 16:18:25 +01:00
unimatrixgit
26145f2154 Preserve canonical LF release source formatting 2026-12-06 16:14:22 +01:00
unimatrixgit
339026fe2e Publish Cooking & Baking news and advance Beta to 1.0.4.0 2026-12-06 16:14:04 +01:00
unimatrixgit
b70b274982 Publish the immutable Cooking Beta network pack route
All checks were successful
DuneRealms Web CI / web (push) Successful in 6m17s
2026-12-06 15:42:40 +01:00
unimatrixgit
c5560fe0ff Keep bottled recipes and the canonical native cookbook in sync 2026-12-06 15:01:38 +01:00
unimatrixgit
abaa1f41e0 Pin the shared cooking catalogue to its actual native source path 2026-12-06 14:50:53 +01:00
unimatrixgit
c319bb476f Keep original cookbook byte checks separate from new regional recipes 2026-12-06 14:45:07 +01:00
unimatrixgit
28ebc5e043 Publish regional food and drink recipes with authored icons and lore 2026-12-06 14:44:09 +01:00
unimatrixgit
6c525f8a64 Use an authorised shared lock for Exchange delivery reads
All checks were successful
DuneRealms Web CI / web (push) Successful in 6m38s
2026-12-06 13:50:23 +01:00
unimatrixgit
577d975787 Keep company labels under political ownership
All checks were successful
DuneRealms Web CI / web (push) Successful in 5m20s
2026-12-05 23:32:24 +01:00
unimatrixgit
03b7332653 Cover mixed journal actions and unavailable feeds
All checks were successful
DuneRealms Web CI / web (push) Successful in 5m14s
2026-12-05 21:56:12 +01:00
unimatrixgit
188f8fcd21 Show personal and reputation arcs in one quest journal 2026-12-05 21:54:03 +01:00
unimatrixgit
091720f9e4 Merge commit 'a61b9ec93f' into fix/reputation-journal-navigation-20261205
All checks were successful
DuneRealms Web CI / web (push) Successful in 5m19s
2026-12-05 21:25:43 +01:00
unimatrixgit
4254a96b42 Expose Reputation missions and lay out story arcs in tables 2026-12-05 21:25:42 +01:00
unimatrixgit
a61b9ec93f Allow the immutable Golden Path resource pack download
Some checks failed
DuneRealms Web CI / web (push) Has been cancelled
2026-12-05 20:54:42 +01:00
unimatrixgit
fe67c7820f Give players the Tabr entrance and reward delivery instructions
All checks were successful
DuneRealms Web CI / web (push) Successful in 5m26s
2026-12-05 19:35:24 +01:00
unimatrixgit
96c3f601bc Merge commit 'afa1feb' into feat/golden-path-finish-web-20261205 2026-12-05 19:23:09 +01:00
unimatrixgit
79cd02f99e Verify first bank deposit from settled ATM voucher redemption
All checks were successful
DuneRealms Web CI / web (push) Successful in 5m35s
2026-12-05 16:49:49 +01:00
unimatrixgit
afa1feb366 Pay approved Golden Path rewards through P&O 2026-12-05 15:33:59 +01:00
unimatrixgit
6d0f15082a Keep the Golden Path outside the original Reputation policy 2026-12-05 15:02:45 +01:00
unimatrixgit
1a011deb2b Bind Golden Path deliveries to exact Reputation quest claims 2026-12-05 15:01:24 +01:00
unimatrixgit
9641d1e855 Wire the Golden Path into the gated Reputation quest runtime 2026-12-05 14:55:02 +01:00
unimatrixgit
93489c6119 Prepare the Golden Path quest catalogue and evidence contract 2026-12-05 14:09:53 +01:00
172 changed files with 5634 additions and 645 deletions

View file

@ -0,0 +1,16 @@
import {identity} from '../node/auth.mjs';
import {validUuid} from '../node/game-link.mjs';
import {BankError} from '../node/postbank-service.mjs';
/** Browser authentication never substitutes a client-supplied game identity. */
export function createExchangePurchase(db,runtime,{origin='https://cp.dunerealms.com',identify=identity}={}){return async request=>{
const reply=(body,status=200)=>Response.json(body,{status,headers:{'Cache-Control':'private, no-store'}});
if(request.method!=='POST')return reply({message:'Method not allowed.'},405);
if(request.headers.get('origin')!==new URL(origin).origin)return reply({message:'Invalid request origin.'},403);
if(!/^application\/json(?:;|$)/i.test(request.headers.get('content-type')||''))return reply({message:'JSON required.'},415);
const user=await identify(request,db);if(!user)return reply({message:'Sign in first.'},401);
let input;try{const text=await request.text();if(Buffer.byteLength(text)>4096)return reply({message:'Purchase request too large.'},413);input=JSON.parse(text);}catch{return reply({message:'Invalid purchase request.'},400);}
const fields=['action','requestId','listingId','amount','priceMinor','confirmed',...(input?.action==='buy_resell'?['resalePriceMinor']:[])];
const price=v=>Number.isSafeInteger(v)&&v>=1&&v<=100000000;
if(!input||typeof input!=='object'||Array.isArray(input)||Object.keys(input).length!==fields.length||!fields.every(k=>Object.hasOwn(input,k))||!['buy','buy_resell'].includes(input.action)||!validUuid(input.requestId)||!/^[1-9]\d{0,17}$/.test(input.listingId)||!Number.isInteger(input.amount)||input.amount<1||input.amount>64||!price(input.priceMinor)||input.confirmed!==true||input.action==='buy_resell'&&(!price(input.resalePriceMinor)||input.resalePriceMinor<=input.priceMinor))return reply({message:'Review the item, quantity, purchase price and resale price.'},400);
try{return reply({ok:true,...await runtime.purchaseFor(user,input)});}catch(error){return reply({message:error instanceof BankError?error.message:'Purchase could not be confirmed. Retry with the same purchase reference.'},error instanceof BankError?error.status||409:503);}
};}

View file

@ -1,3 +1,4 @@
import {orderExchange,validExchangeSort,validExchangeCategory} from './public/exchange-order.mjs';
import {visibleTradeListings} from '../node/world-trade-listings.mjs';
import {identity} from '../node/auth.mjs';
export function createExchange(db,pool,settings={}){return async request=>{
@ -5,11 +6,12 @@ export function createExchange(db,pool,settings={}){return async request=>{
const user=await identity(request,db);if(!user)return reply({message:'Sign in first.'},401);
if(request.method!=='GET')return reply({message:'Method not allowed'},405);
const view=new URL(request.url).searchParams.get('view')||'all';if(!['all','mine'].includes(view))return reply({message:'Unknown listings view.'},400);
const params=new URL(request.url).searchParams,sort=params.get('sort')||'newest',category=params.get('category')||'all';if(!validExchangeSort(sort)||!validExchangeCategory(category))return reply({message:'Unknown Exchange sorting or category.'},400);
const paused=await db.prepare('SELECT setting_value FROM website_settings WHERE setting_key=?').bind('exchange_public_enabled').first();
if(paused?.setting_value==='false')return reply({message:'The exchange is temporarily paused.'},503);
try{
const link=await db.prepare('SELECT minecraft_uuid FROM site_game_links WHERE user_id=?').bind(user.id).first(),linked=!!link?.minecraft_uuid;
if(view==='mine'&&!linked)return reply({listings:[],view,linked:false,message:'Link your Minecraft account to view your listings.'});
const result=await pool.query({text:'SELECT id::text AS id,material,payload,display_name AS "displayName",category,origin,seller_name AS seller,quantity,price::text AS price FROM dune_exchange_listings'+(view==='mine'?' WHERE seller=$1':'')+' ORDER BY id DESC LIMIT 500',...(view==='mine'?{values:[link.minecraft_uuid]}:{}),query_timeout:5000});return reply({listings:await visibleTradeListings(db,result.rows,{mine:view==='mine',hqSecret:settings.GAME_LINK_SECRET}),view,linked});
const result=await pool.query({text:'SELECT id::text AS id,material,payload,display_name AS "displayName",category,origin,seller AS "sellerUuid",seller_name AS seller,quantity,price::text AS price FROM dune_exchange_listings'+(view==='mine'?' WHERE seller=$1':'')+' ORDER BY id DESC LIMIT 200001',...(view==='mine'?{values:[link.minecraft_uuid]}:{}),query_timeout:5000});if(result.rows.length>200000)return reply({message:'The Exchange register is too large to sort safely.'},503);return reply({listings:orderExchange(await visibleTradeListings(db,result.rows.map(({sellerUuid,...row})=>({...row,own:linked&&sellerUuid?.toLowerCase()===link.minecraft_uuid.toLowerCase()})),{mine:view==='mine',hqSecret:settings.GAME_LINK_SECRET}),{sort,category}),view,linked,sort,category});
}catch{return reply({message:'The exchange is temporarily unavailable.'},503);}
};}

View file

@ -12,7 +12,8 @@ export function createMarketBridge({pool,readToken,db=null,hqSecret=''}){
if(received.length!==expected.length||!timingSafeEqual(received,expected))return reply({error:'unauthorized'},401);
if(url.search)return reply({error:'invalid_request'},400);
try{
const result=await pool.query({text:'SELECT id::text AS id,material,payload,display_name AS "displayName",category,origin,seller_name AS seller,quantity,price::text AS price FROM dune_exchange_listings ORDER BY id DESC LIMIT 500',query_timeout:5000});
const result=await pool.query({text:'SELECT id::text AS id,material,payload,display_name AS "displayName",category,origin,seller_name AS seller,quantity,price::text AS price FROM dune_exchange_listings ORDER BY id DESC LIMIT 200001',query_timeout:5000});
if(result.rows.length>200000)return reply({error:'market_too_large'},503);
return reply({listings:await visibleTradeListings(db,result.rows,{hqSecret})});
}catch{return reply({error:'market_unavailable'},503);}
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 623 B

View file

@ -1,3 +1,5 @@
import {EXCHANGE_SORTS,EXCHANGE_CATEGORIES,compareExchange,exchangeCategory} from '../exchange-order.mjs';
import {purchaseControls} from '../exchange-purchase-view.mjs';
import {itemDesignTemplate} from '../item-design-model.mjs';
import {itemLoreCard} from '../item-lore-view.mjs';
import {itemPublicHref} from '../item-lore-model.mjs';
@ -17,9 +19,9 @@ export function mountExchangeDesign(host,{context='public',view='browse',fetcher
if(!document.querySelector('link[data-codex-exchange]')){const css=el('link');css.rel='stylesheet';css.href=new URL('./cp-v2-exchange-design.css',import.meta.url).href;css.dataset.codexExchange='';document.head.append(css);}
let disposeJarvis=()=>{},active=true,rows=[],kitRows=[],jarvisRows=[],auctionRows=[],campaignRows=[],politicalRows=[],currentEdition=null,category=context==='user'?'items':context==='public'&&TYPES.some(([id])=>id===new URLSearchParams(location.search).get('type'))?new URLSearchParams(location.search).get('type'):'all',page=0,examples=false,goodsState='loading',kitState=context==='public'?'loading':'hidden',jarvisState='loading';const controller=new AbortController();
const root=el('section',undefined,'codex-exchange'+(context==='public'?' codex-exchange-public':'')),hero=el('header',undefined,'codex-exchange-hero'),copy=el('div');copy.append(el('small',context==='public'?'SPACING GUILD · STARPORT EXCHANGE':'STARPORT · J.A.R.V.I.S.'),el('h2',context==='clan'?(organisationScope?.kind==='company'?'Company Exchange':organisationScope?.kind==='politics'?'Political House Exchange':'Household Exchange'):context==='user'?'Item Exchange':'Starport Exchange'),el('p','Find your next trade, calling or adventure.'));hero.append(image(context==='public'?'faction-guild.svg':'nav-exchange-v2.webp'),copy);root.append(hero);
const banner=el('p',context==='user'?'Minecraft goods use the existing listings service. Trading remains in game.':context==='clan'?'Opening the J.A.R.V.I.S. recruitment register…':'Browse live goods, kit designs and published recruitment opportunities.','codex-exchange-notice');root.append(banner);
const banner=el('p',context==='user'?'Browse and buy live Minecraft goods, collect purchases in game, or choose your resale price and relist.':context==='clan'?'Opening the J.A.R.V.I.S. recruitment register…':'Browse live goods, kit designs and published recruitment opportunities.','codex-exchange-notice');root.append(banner);
const browse=el('div'),layout=el('div',undefined,'codex-exchange-layout'),aside=el('aside',undefined,'codex-exchange-categories'),main=el('div',undefined,'codex-exchange-main'),tools=el('div',undefined,'codex-exchange-tools');
const search=field('Search','Items, opportunities, sellers or worlds');search.input.type='search';const sort=field('Sort',['Newest first','Price: low to high','Price: high to low','Title']);const quality=field('Quality',['All qualities','Common','Uncommon','Rare','Very Rare','Legendary','Mythic','Relic']);const stage=field('Edition',['All stages','Alpha','Beta','Live']);const season=field('Season',['All seasons','Current season','Earlier seasons']);const preview=el('label',undefined,'codex-exchange-preview'),toggle=el('input');toggle.type='checkbox';preview.append(toggle,el('span','Show design examples'));toggle.onchange=()=>{examples=toggle.checked;page=0;render();};tools.append(search.box,sort.box,quality.box,stage.box,season.box);if(context!=='user')tools.append(preview);const status=el('p','Loading live Minecraft listings…','codex-exchange-status');status.setAttribute('role','status');const cards=el('div',undefined,'codex-exchange-cards'),pager=el('div',undefined,'codex-exchange-pager');main.append(tools,status,cards,pager);layout.append(aside,main);browse.append(layout);
const search=field('Search','Items, opportunities, sellers or worlds');search.input.type='search';const sort=field('Sort',EXCHANGE_SORTS.map(([,label])=>label));EXCHANGE_SORTS.forEach(([id],i)=>sort.input.options[i].value=id);const goodsCategory=field('Item category',EXCHANGE_CATEGORIES.map(([,label])=>label));EXCHANGE_CATEGORIES.forEach(([id],i)=>goodsCategory.input.options[i].value=id);const quality=field('Quality',['All qualities','Common','Uncommon','Rare','Very Rare','Legendary','Mythic','Relic']);const stage=field('Edition',['All stages','Alpha','Beta','Live']);const season=field('Season',['All seasons','Current season','Earlier seasons']);const preview=el('label',undefined,'codex-exchange-preview'),toggle=el('input');toggle.type='checkbox';preview.append(toggle,el('span','Show design examples'));toggle.onchange=()=>{examples=toggle.checked;page=0;render();};tools.append(search.box,goodsCategory.box,sort.box,quality.box,stage.box,season.box);if(context!=='user')tools.append(preview);const status=el('p','Loading live Minecraft listings…','codex-exchange-status');status.setAttribute('role','status');const cards=el('div',undefined,'codex-exchange-cards'),pager=el('div',undefined,'codex-exchange-pager');main.append(tools,status,cards,pager);layout.append(aside,main);browse.append(layout);
const categories=context==='user'?TYPES.filter(([id])=>id==='items'):context==='clan'?TYPES.filter(([id])=>!id.startsWith('kits')):TYPES;const buttons=[];for(const [id,title,art]of categories){const node=button(title,()=>{category=id;page=0;if(context==='public'){const url=new URL(location.href);if(id==='all')url.searchParams.delete('type');else url.searchParams.set('type',id);history.replaceState(null,'',url);}render();});node.prepend(image(art));if(id.startsWith('kits-'))node.dataset.subcategory='true';node.setAttribute('aria-pressed',String(id===category));buttons.push([node,id]);aside.append(node);}
const legend=el('details',undefined,'codex-exchange-legend');if(context==='public')legend.open=true;legend.append(el('summary','J.A.R.V.I.S. symbols · What each listing means'),el('p','J.A.R.V.I.S. · '+JARVIS_EXPANSION));const icons=el('div');for(const [type,title,art,description]of TYPES.slice(1).filter(([id])=>!id.startsWith('kits-')&&(context==='public'||id!=='kits'))){const row=el('section');row.append(image(art),el('strong',title),el('span',description));icons.append(row);}legend.append(icons);browse.append(legend);
const mine=el('div');mine.append(el('h3','My listings'),empty(['Artwork','Title','Type','Applications','Promotion','Status','Action'],'J.A.R.V.I.S. listing records are not connected. No records or balances are inferred.'),button('Post a listing',()=>selectPost?.()));
@ -29,7 +31,7 @@ export function mountExchangeDesign(host,{context='public',view='browse',fetcher
const eligibility=el('p','Checking your deed…','codex-exchange-eligibility');if(context==='clan')root.append(eligibility);
let selectPost;const groups=[{id:'browse',title:'Browse',content:browse}];if(context!=='public'){groups.push({id:'mine',title:'My listings',content:mine},{id:'post',title:context==='user'?'Post an item':'Post a listing',content:post});if(context==='clan')groups.push({id:'applications',title:'Applications',content:applications},{id:'promotions',title:'Promotions',content:promotions});}const tabbed=organisationTabs(groups,{label:'Exchange sections',initial:view});selectPost=()=>tabbed.querySelector('[role=tab][aria-controls$="-post-panel"]')?.click();root.append(tabbed);
const footer=el('footer',undefined,'codex-exchange-logistics');footer.append(el('span',context==='public'?'Logistics by SPost':'Exchange logistics supplied by'),image('spost-logo-v1.svg'),el('small','part of'),image('corrino-group-v4.png'));root.append(footer);if(context==='public'){const egg=el('details',undefined,'jarvis-victory'),summary=el('summary','J.A.R.V.I.S. · Archive fragment'),figure=el('figure'),art=image('jarvis-victory-v1.png');art.alt='Minecraft-style Jem’Hadar warrior holding a command crystal. J.A.R.V.I.S. is victory. Victory is life.';art.width=960;art.height=640;figure.append(art,el('figcaption','J.A.R.V.I.S. is victory. Victory is life.'));egg.append(summary,figure);root.append(egg);}const cardDesigns=el('details',undefined,'codex-exchange-legend');cardDesigns.append(el('summary','Card design previews · items, kits, campaigns, jobs and more'),createCardGallery());root.append(cardDesigns);host.replaceChildren(root);
function render(){for(const [node,id]of buttons)node.setAttribute('aria-pressed',String(id===category));let matches=[...rows,...kitRows,...jarvisRows,...auctionRows,...campaignRows,...politicalRows,...(examples?SAMPLES.filter(row=>context!=='clan'||['recruitment','quests','events'].includes(row.type)):[])].filter(row=>(category==='all'||row.category===category||row.type===category&&!(category==='recruitment'&&row.organisationKind==='company')||row.kitCategory===category)&&[row.title,row.owner,row.world].join(' ').toLowerCase().includes(search.input.value.toLowerCase()));if(stage.input.selectedIndex>0)matches=matches.filter(row=>row.edition?.stage===stage.input.value.toLowerCase());if(season.input.selectedIndex>0)matches=matches.filter(row=>row.edition&&currentEdition&&(season.input.selectedIndex===1?row.edition.season===currentEdition.season:row.edition.season!==currentEdition.season));if(quality.input.selectedIndex>0)matches=matches.filter(row=>words(row.quality).toLowerCase()===quality.input.value.toLowerCase());matches.sort((a,b)=>sort.input.selectedIndex===1?a.price-b.price:sort.input.selectedIndex===2?b.price-a.price:sort.input.selectedIndex===3?a.title.localeCompare(b.title):Number(b.createdAt||b.created_at||b.id)-Number(a.createdAt||a.created_at||a.id)||0);page=Math.min(page,Math.max(0,Math.ceil(matches.length/8)-1));cards.replaceChildren();if(!matches.length)cards.append(el('p',season.input.selectedIndex||quality.input.selectedIndex||stage.input.selectedIndex?'No listings match these edition and quality filters. Goods without edition metadata are excluded.':'No matching listings. Design examples can be enabled separately.','codex-exchange-empty'));for(const row of matches.slice(page*8,page*8+8)){const sample=String(row.id).startsWith('preview-'),type=TYPES.find(([id])=>id===(row.category||row.type)),cardType=({'items':'item','kits':'kit','recruitment':'job','quests':'quest','events':'event','deeds':'deed','auctions':'auction','campaign':'campaign','political-job':'job'})[row.type]||'ad',art=row.type==='recruitment'&&row.organisationKind==='company'?'exchange-company-jobs-v1.png':row.type==='items'?'minecraft-items/'+String(row.material).toLowerCase()+'.png':row.type==='kits'?'minecraft-items/'+(row.quality==='legendary'?'netherite_chestplate':'leather_chestplate')+'.png':type?.[2]||'nav-exchange-v2.webp',facts=[row.world,...(row.type==='items'&&row.levyPercent>0?[row.levyPercent+'% House levy from seller proceeds']:[]),...(row.edition?[words(row.edition.stage)+' '+row.edition.version+' · '+row.edition.season]:[]),...(row.type==='items'?[row.quantity+' available']:row.type==='kits'?[words(row.quality)]:[])].filter(Boolean),card=createListingCard({item:row,type:cardType,featured:row.featured===true,title:row.title,owner:row.owner,subtitle:row.subtitle||row.owner,message:row.description||'',image:row.image||asset+art,facts:row.type==='auctions'?['Highest bid: '+(row.highestMinor/100).toFixed(2)+' DM','Closes: '+new Date(row.closesAt).toLocaleString('en-GB'),'3 hour office auction']:facts,price:['items','kits','deeds'].includes(row.type)?Number(row.price).toFixed(2)+' DM':null},{preview:sample,onOpen:()=>detail(row,sample)});card.classList.add('codex-exchange-card');cards.append(card);}pager.replaceChildren(button('← Previous',()=>{page--;render();},page===0),el('span',(page+1)+' / '+Math.max(1,Math.ceil(matches.length/8))),button('Next →',()=>{page++;render();},(page+1)*8>=matches.length));}
function render(){for(const [node,id]of buttons)node.setAttribute('aria-pressed',String(id===category));let matches=[...rows,...kitRows,...jarvisRows,...auctionRows,...campaignRows,...politicalRows,...(examples?SAMPLES.filter(row=>context!=='clan'||['recruitment','quests','events'].includes(row.type)):[])].filter(row=>(category==='all'||row.category===category||row.type===category&&!(category==='recruitment'&&row.organisationKind==='company')||row.kitCategory===category)&&[row.title,row.owner,row.world].join(' ').toLowerCase().includes(search.input.value.toLowerCase()));if(stage.input.selectedIndex>0)matches=matches.filter(row=>row.edition?.stage===stage.input.value.toLowerCase());if(season.input.selectedIndex>0)matches=matches.filter(row=>row.edition&&currentEdition&&(season.input.selectedIndex===1?row.edition.season===currentEdition.season:row.edition.season!==currentEdition.season));if(quality.input.selectedIndex>0)matches=matches.filter(row=>words(row.quality).toLowerCase()===quality.input.value.toLowerCase());if(goodsCategory.input.value!=='all')matches=matches.filter(row=>row.type==='items'&&exchangeCategory(row)===goodsCategory.input.value);matches.sort(compareExchange(sort.input.value));page=Math.min(page,Math.max(0,Math.ceil(matches.length/8)-1));cards.replaceChildren();if(!matches.length)cards.append(el('p',season.input.selectedIndex||quality.input.selectedIndex||stage.input.selectedIndex?'No listings match these edition and quality filters. Goods without edition metadata are excluded.':'No matching listings. Design examples can be enabled separately.','codex-exchange-empty'));for(const row of matches.slice(page*8,page*8+8)){const sample=String(row.id).startsWith('preview-'),type=TYPES.find(([id])=>id===(row.category||row.type)),cardType=({'items':'item','kits':'kit','recruitment':'job','quests':'quest','events':'event','deeds':'deed','auctions':'auction','campaign':'campaign','political-job':'job'})[row.type]||'ad',art=row.type==='recruitment'&&row.organisationKind==='company'?'exchange-company-jobs-v1.png':row.type==='items'?'minecraft-items/'+String(row.material).toLowerCase()+'.png':row.type==='kits'?'minecraft-items/'+(row.quality==='legendary'?'netherite_chestplate':'leather_chestplate')+'.png':type?.[2]||'nav-exchange-v2.webp',facts=[row.world,...(row.type==='items'&&row.levyPercent>0?[row.levyPercent+'% House levy from seller proceeds']:[]),...(row.edition?[words(row.edition.stage)+' '+row.edition.version+' · '+row.edition.season]:[]),...(row.type==='items'?[row.quantity+' available',...(row.equipmentMark!==undefined?['MK '+row.equipmentMark]:[]),...(row.quality?[words(row.quality)]:[]),...(row.own?['Your listing']:[])]:row.type==='kits'?[words(row.quality)]:[])].filter(Boolean),card=createListingCard({item:row,type:cardType,featured:row.featured===true,title:row.title,owner:row.owner,subtitle:row.subtitle||row.owner,message:row.description||'',image:row.image||asset+art,facts:row.type==='auctions'?['Highest bid: '+(row.highestMinor/100).toFixed(2)+' DM','Closes: '+new Date(row.closesAt).toLocaleString('en-GB'),'3 hour office auction']:facts,price:['items','kits','deeds'].includes(row.type)?Number(row.price).toFixed(2)+' DM':null},{preview:sample,onOpen:()=>detail(row,sample)});card.classList.add('codex-exchange-card');cards.append(card);}pager.replaceChildren(button('← Previous',()=>{page--;render();},page===0),el('span',(page+1)+' / '+Math.max(1,Math.ceil(matches.length/8))),button('Next →',()=>{page++;render();},(page+1)*8>=matches.length));}
function detail(row,sample){
const dialog=el('dialog',undefined,'codex-exchange-dialog'),bar=el('div',undefined,'exchange-detail-bar'),close=button('Close ×',()=>dialog.close()),copy=el('div',undefined,'exchange-detail-content'),returnFocus=document.activeElement;
close.setAttribute('aria-label','Close listing details');bar.append(el('h3',row.title),close);dialog.setAttribute('aria-label',row.title||'Listing details');dialog.append(bar,copy);
@ -43,7 +45,7 @@ export function mountExchangeDesign(host,{context='public',view='browse',fetcher
}else if(row.kitset)link('Review kit purchase →','https://cp.dunerealms.com/?kitset-listing='+encodeURIComponent(row.listingId)+'#market/commodity-listings');
else link('Review kit purchase →','https://cp.dunerealms.com/?kit-listing='+encodeURIComponent(row.listingId)+'#realm/kits-exchange');
}
if(!sample&&row.type==='items')copy.append(el('p','Purchase this listing through the ingame Exchange. Opening these details does not reserve or buy it.'));
if(!sample&&row.type==='items'){if(context==='public')link('Buy or relist this item →','https://cp.dunerealms.com/?exchange-listing='+encodeURIComponent(row.id)+'#market/commodity-listings');else if(row.own)copy.append(el('p','Your listing. Withdraw unsold stock through the in-game Exchange.'));else copy.append(purchaseControls(row,{fetcher,onPurchased:()=>void load()}));}
const href=!sample?itemPublicHref(row):null;if(href)link('Full item dashboard →',href);
}else{
copy.append(el('p',row.description||row.message||'Published listing details.'));
@ -57,8 +59,8 @@ export function mountExchangeDesign(host,{context='public',view='browse',fetcher
if(sample)copy.append(el('p','Design example. Applications and purchases are disabled.'));
dialog.onclose=()=>{dialog.remove();if(returnFocus?.isConnected)returnFocus.focus();};dialog.onclick=event=>{if(event.target!==dialog)return;const r=dialog.getBoundingClientRect();if(event.clientX<r.left||event.clientX>r.right||event.clientY<r.top||event.clientY>r.bottom)dialog.close();};root.append(dialog);dialog.showModal();close.focus();
}
search.input.oninput=()=>{page=0;render();};sort.input.onchange=quality.input.onchange=stage.input.onchange=season.input.onchange=()=>{page=0;render();};
async function load(){try{const response=await fetcher(context==='public'?'/api/exchange/listings':'/api/exchange/listings?view=all',{credentials:'same-origin',signal:controller.signal});if(!response.ok)throw Error('unavailable');const data=await response.json();const source=Array.isArray(data)?data:Array.isArray(data.listings)?data.listings:Array.isArray(data.items)?data.items:[];rows=source.filter(row=>Number.isFinite(Number(row.price))&&Number.isFinite(Number(row.quantity))&&/^[A-Za-z0-9_]+$/.test(row.material||'')&&/^\d+$/.test(String(row.id))).map(row=>({...row,type:'items',title:row.displayName||words(row.material),owner:row.seller||row.seller_name||'Player listing',world:words(row.origin),price:Number(row.price),quantity:Number(row.quantity)}));if(!active)return;goodsState='ready';updateStatus();render();}catch{if(!active)return;rows=[];goodsState='error';updateStatus();render();}}
search.input.oninput=()=>{page=0;render();};sort.input.onchange=goodsCategory.input.onchange=quality.input.onchange=stage.input.onchange=season.input.onchange=()=>{page=0;render();};
async function load(){try{const response=await fetcher(context==='public'?'/api/exchange/listings':'/api/exchange/listings?view=all',{credentials:'same-origin',signal:controller.signal});if(!response.ok)throw Error('unavailable');const data=await response.json();const source=Array.isArray(data)?data:Array.isArray(data.listings)?data.listings:Array.isArray(data.items)?data.items:[];rows=source.filter(row=>Number.isFinite(Number(row.price))&&Number.isFinite(Number(row.quantity))&&/^[A-Za-z0-9_]+$/.test(row.material||'')&&/^\d+$/.test(String(row.id))).map(row=>({...row,type:'items',title:row.displayName||words(row.material),owner:row.seller||row.seller_name||'Player listing',world:words(row.origin),price:Number(row.price),quantity:Number(row.quantity)}));if(!active)return;goodsState='ready';updateStatus();render();const selected=new URLSearchParams(location.search).get('exchange-listing'),found=selected&&rows.find(row=>String(row.id)===selected);if(found)detail(found,false);}catch{if(!active)return;rows=[];goodsState='error';updateStatus();render();}}
if(context==='clan')import('./cp-v2-jarvis-recruitment.mjs').then(({mountJarvisRecruitment})=>{if(active)disposeJarvis=mountJarvisRecruitment({mine,post,applications,promotions,banner,eligibility,scope:organisationScope||{kind:'clan'},fetcher,signal:controller.signal,onChanged:()=>void loadJarvis()});}).catch(()=>{if(active)banner.textContent='Recruitment services could not be opened.';});
if(context==='user')Promise.resolve().then(async()=>{const response=await fetcher('/api/exchange/listings?view=mine',{signal:controller.signal,credentials:'same-origin'});if(!response.ok)throw Error();const data=await response.json();if(!active)return;const records=Array.isArray(data.listings)?data.listings:[];const table=empty(['Item','World','Quantity','Each · DM'],'No active item listings. List goods through /exchange in game.');if(records.length){const body=table.querySelector('tbody');body.replaceChildren();for(const item of records){const row=el('tr');for(const value of [item.displayName||words(item.material),words(item.origin),String(item.quantity),String(item.price)])row.append(el('td',value));body.append(row);}}mine.replaceChildren(el('h3','My item listings'),table,el('p',data.linked===false?'Link your Minecraft account to see your listings.':'Existing Minecraft listings · manage in game through /exchange.'));}).catch(()=>{if(active)mine.replaceChildren(el('h3','My item listings'),el('p','Your listings are unavailable. Refresh to retry.'));});
Promise.resolve().then(async()=>{const response=await fetcher(context==='public'?'/api/kits/catalogue':'/api/kitsets/catalogue',{signal:controller.signal,cache:'no-store'});if(!response.ok)throw Error();const data=await response.json();if(!Array.isArray(data.listings))throw Error();kitRows=data.listings.filter(r=>/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(r.listingId)&&Number.isSafeInteger(r.priceCents)&&r.priceCents>0).map(row=>({...row,id:'kit-'+row.listingId,type:'kits',kitCategory:row.shopType==='clan'?'kits-clan':row.shopType==='company'?'kits-company':row.commerceKind==='server_sale'?'kits-legendary':['official_sale','faction_sale'].includes(row.commerceKind)?'kits-office':'kits-player',title:row.name,owner:row.ownerName||row.sellerName,world:'Kit catalogue',price:row.priceCents/100,description:(row.lore||[]).join(' · '),purchaseAvailable:row.purchaseAvailable===true||(row.purchaseAvailable===undefined&&row.commerceKind==='personal_sale')}));if(active){kitState='ready';updateStatus();render();const selected=new URLSearchParams(location.search).get('kitset-listing');const found=selected&&kitRows.find(r=>r.listingId===selected);if(found)detail(found,false);}}).catch(()=>{if(active){kitState='error';updateStatus();const note=el('p','Kit catalogue is unavailable. Minecraft listings remain separate.','codex-exchange-status');browse.prepend(note);}});

View file

@ -0,0 +1,485 @@
// 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,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

@ -2,17 +2,22 @@
.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(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-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-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-arc ol{list-style:none;margin:0;padding:0 0 .3rem;display:grid;gap:.2rem}
.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-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[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-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-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,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;
@ -32,27 +38,39 @@ 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 list=el('ol');
for(const q of arc.quests){
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);
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');
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);
}
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'),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})){
@ -61,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);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,14 +64,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 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();}
}
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;}
@ -62,33 +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();},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;
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,4 +1,5 @@
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';
@ -1109,9 +1110,10 @@ export const POL_QUEST_BRANCHES=freeze([
BOUNTY_BRANCH,
SPICE_UPGRADE_BRANCH,
ELYTRA_BRANCH,
WAR_QUEST_BRANCH
WAR_QUEST_BRANCH,
LETO_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.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===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 function polBranch(id){return POL_QUEST_BRANCHES.find(b=>b.id===id||b.office===id)||null;}

View file

@ -4,6 +4,8 @@ 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-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'}
].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} 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}={}){
@ -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({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(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 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,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||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.'));}
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

@ -4,8 +4,7 @@
.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}
.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}}
@media(max-width:46rem){.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,5 +1,6 @@
// 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",
@ -146,18 +147,30 @@ 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])));
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;

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':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-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-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

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