Merge pull request 'Connect the Church’s seven-day diplomatic endorsement' (#584) from dev/MC:feature/church-diplomatic-endorsement-20261125 into main
All checks were successful
DuneRealms Web CI / web (push) Successful in 3m19s

This commit is contained in:
unimatrix 2026-11-25 01:42:51 +00:00
commit 6a676ac994
5 changed files with 66 additions and 4 deletions

View file

@ -9,7 +9,7 @@ export function mountPoliticalDecision(host,id,{fetcher=fetch}={}){
const account=field('Office funding account','select');let title,body,recipient,citation,search,find,startsAt,endsAt;
if(d.kind==='proclamation'){title=field('Title','input');title.maxLength=120;title.minLength=3;body=field('Official message','textarea');body.maxLength=6000;body.minLength=10;body.rows=6;}
else if(d.kind==='event'){title=field('Audience title','input');title.maxLength=100;body=field('Purpose and invitation','textarea');body.maxLength=2000;body.rows=4;startsAt=field('Start time (UTC)','input');endsAt=field('End time (UTC)','input');startsAt.type=endsAt.type='datetime-local';form.append(el('p','Schedule at least one minute ahead and no more than 30 days ahead. The audience must finish before your mandate ends and last at most 24 hours. It appears in the existing House calendar.'));}
else if(d.kind==='honour'){search=field('Find recipient by player name','input');search.maxLength=64;find=el('button','Find players');find.type='button';form.append(find);recipient=field('Recipient','select');citation=field('Citation','textarea');citation.maxLength=2000;citation.rows=4;form.append(el('p','Ceremonial profile recognition for 30 days. No office, rank, vote or permission is granted. Renewing replaces the displayed recognition.'));}
else if(d.kind==='honour'){search=field('Find recipient by player name','input');search.maxLength=64;find=el('button','Find players');find.type='button';form.append(find);recipient=field('Recipient','select');citation=field('Citation','textarea');citation.maxLength=2000;citation.rows=4;form.append(el('p','Ceremonial profile recognition for '+d.durationMs/86400000+' days. No office, rank, vote or permission is granted. Renewing replaces the displayed recognition.'));}
const reportHost=el('section');if(d.kind==='report')host.append(reportHost);
function drawReport(report){reportHost.replaceChildren();if(!report)return;const dm=value=>{const n=BigInt(value);return(n/100n).toLocaleString('en-GB')+'.'+String(n%100n).padStart(2,'0')+' DM';};reportHost.append(el('h4','Verified market report'),el('p','Snapshot: '+new Date(report.observedAt).toLocaleString()),el('p',report.scope),el('p',report.listedStacks+' listings · '+report.units+' units · '+dm(report.askingValueMinor)+' asking value'));const table=el('table'),head=el('tr');for(const text of ['Creation world','Listings','Units','Asking value'])head.append(el('th',text));table.append(head);for(const row of report.byWorld){const tr=el('tr');for(const text of [row.world.replaceAll('_',' '),row.listedStacks,row.units,dm(row.askingValueMinor)])tr.append(el('td',String(text)));table.append(tr);}reportHost.append(table);if(report.transport){reportHost.append(el('h4','Guild arrivals · last seven days'),el('p',report.transport.scope));for(const row of report.transport.arrivals)reportHost.append(el('p',row.world.replaceAll('_',' ')+': '+row.total));if(!report.transport.arrivals.length)reportHost.append(el('p','No confirmed arrivals in this period.'));}}
for(const b of [prepare,confirm,refresh])b.type='button';confirm.hidden=true;host.append(status,form,review,prepare,confirm,refresh);

View file

@ -14,6 +14,7 @@ export const MASTER_KEY_TEMPLATES=[
action('company.subsidiary','Subsidiary founding','company-subsidiary',[field('parentCompanyId','Mother company'),field('recipient','Recipient')]),
action('company.royal','Royal company charter','staff-company-royal',[field('companyId','Company'),reference])]},
{id:'politics',label:'POL & orders',actions:[
action('faith.diplomatic-endorsement','Church diplomatic endorsement','entity-state',[field('decisionId','Faith decision','select',{options:['NF-07']}),field('sourceAccount','Authorised Church funding account'),field('recipientId','Other active player UUID'),field('citation','Diplomatic citation','textarea'),field('requestId','Request UUID')],{version:1,webIssue:false,recordOnly:true,domainAdapter:'createPoliticalDecisions.execute / politicalHonours',executionStatus:'current-church-officeholder-only',effect:'Current Royal Church office holder, Reputation 15, fixed 2,500 DM Church-account fee and 250 Reputation points. Seven-day ceremonial diplomatic endorsement on the recipient profile; one decision per 72 hours across succession. No self-award, faith conversion, clan membership, appointment, vote, rank, permissions or bonus. Payment, recognition and ordinary instrument commit once; expiry and key revocation remove the display.'}),
action('politics.court-audience','Official court calendar audience','entity-state',[field('decisionId','Court decision','select',{options:['COR-01']}),field('sourceAccount','Authorised office funding account'),field('requestId','Request UUID'),field('title','Audience title'),field('description','Purpose and invitation','textarea'),field('startsAt','Start UTC timestamp','number'),field('endsAt','End UTC timestamp','number')],{version:1,webIssue:false,recordOnly:true,domainAdapter:'createPoliticalDecisions.execute / createRealmEventRecord',executionStatus:'current-corrino-office-calendar-consumer',effect:'Current Royal Corrino office holder, Reputation 10, fixed 1,000 DM office fee and 200 Reputation points. One decision per 24 hours across succession. Schedule at least one minute and at most 30 days ahead, for at most 24 hours and entirely within the source mandate. Existing political EVT calendar row, history, fee, Reputation and key commit on the same transaction. Exact retries never create or charge twice. No election, war, office, membership or travel changes.'}),
action('politics.market-report','Funded political market intelligence','entity-state',[field('decisionId','Registered aggregate report','select',{options:['ORD-03','SG-04']}),field('sourceAccount','Authorised office funding account'),field('requestId','Request UUID')],{version:1,webIssue:false,recordOnly:true,domainAdapter:'createPoliticalDecisions.execute / createPoliticalMarketReports',executionStatus:'current-elected-office-aggregate-report-consumer',effect:'Ordos level 25, 400 Reputation; Guild level 30, 500 Reputation. Fixed 2,500 DM office-account fee and 72-hour successor-safe cooldown. Snapshot only valid, currently available native Exchange item listings; respect embargo and immutable creation-world metadata. Guild additionally receives confirmed seven-day arrival counts. Never disclose passenger identities, private orders or balances. Native tables must share the verified transaction server; unavailable or oversized sources roll back without fees or XP. Snapshot, payment, Reputation and ordinary key commit once; retries return the original report.'}),
action('faith.house-referendum','House missionary-law referendum','entity-state',[field('decisionId','House decision','select',{options:['ATR-FAITH','HAR-FAITH','COR-FAITH','ORD-FAITH','FRE-FAITH']}),field('faith','Faith','select',{options:['veiled_concord','muad_dib']}),field('prohibited','Prohibit new conversions','boolean'),field('requestId','Referendum UUID')],{version:1,webIssue:false,recordOnly:true,domainAdapter:'createHouseFaithLaws.propose / reconcile / missionaryFaithOutlawed',executionStatus:'current-house-authority-personal-ballot-consumer',effect:'Current Royal elected House holder and Reputation 5. Frozen verified House electorate; 48-hour vote, majority quorum and strict majority. Seven-day office cooldown survives succession. An adopted law lasts at most seven days and ends with its source mandate; the latest signed law gates only new faith offers and acceptance on the registered clan homeworld. Existing allegiance and earned rewards remain unchanged. No fee, XP, election-clock change or personal vote transfer. Private scheduled settlement is idempotent; key revocation never restores an older law.'}),

View file

@ -7,6 +7,7 @@ export const POLITICAL_DECISIONS=Object.freeze([
{id:'COR-01',office:'corrino',title:'Imperial Court Audience',kind:'event',level:10,xp:200,feeMinor:100000,cooldownMs:24*3600000},
{id:'ORD-03',office:'ordos',title:'Market Intelligence',kind:'report',level:25,xp:400,feeMinor:250000,cooldownMs:72*3600000},
{id:'SG-04',office:'spacing_guild',title:'Commercial Intelligence',kind:'report',level:30,xp:500,feeMinor:250000,cooldownMs:72*3600000},
{id:'NF-07',office:'muad_dib',title:'Church’s Favour',kind:'honour',level:15,xp:250,feeMinor:250000,cooldownMs:72*3600000,durationMs:7*86400000},
...[
['ATR-PROCLAIM','atreides','Ducal Proclamation','house:atreides'],
['HAR-PROCLAIM','harkonnen','Baronial Directive','house:harkonnen'],
@ -16,7 +17,7 @@ export const POLITICAL_DECISIONS=Object.freeze([
['BG-04','veiled_concord','Political Prophecy','house:veiled_concord'],
['NF-04','muad_dib','The Word of Muad’Dib','house:muad_dib']
].map(([id,office,title,scope])=>({id,office,title,scope,kind:'proclamation',level:5,xp:50,feeMinor:50000,cooldownMs:24*3600000}))
].map(d=>Object.freeze({...d,durationMs:d.kind==='honour'?30*86400000:null})));
].map(d=>Object.freeze({...d,durationMs:d.durationMs??(d.kind==='honour'?30*86400000:null)})));
export const politicalDecision=id=>POLITICAL_DECISIONS.find(d=>d.id===id)||null;
export function proclamationDecisionId(kind,faction){return kind==='imperial'?'IMP-04':kind==='guild'?'SG-PROCLAIM':kind==='house'?({atreides:'ATR-PROCLAIM',harkonnen:'HAR-PROCLAIM',corrino:'COR-PROCLAIM',ordos:'ORD-PROCLAIM',veiled_concord:'BG-04',muad_dib:'NF-04'})[faction]||null:null;}
export const POLITICAL_DECISION_CATALOGUE=Object.freeze(POLITICAL_DECISIONS.map(d=>Object.freeze({...d,office:({emperor:'IMP',atreides:'ATR',harkonnen:'HAR',corrino:'COR',ordos:'ORD',veiled_concord:'BG',muad_dib:'NF',spacing_guild:'SG'})[d.office],cost:(d.feeMinor/100).toLocaleString('en-GB')+' / '+d.cooldownMs/3600000+'h',effect:d.kind==='event'?'Schedule an official audience in the existing House calendar. Fixed office funding, Reputation and cooldown; no election, membership or travel change.':d.kind==='report'?'Read a sealed aggregate of available Exchange stock. Guild reports also include seven-day confirmed arrival totals. No passenger identities, private orders or account balances. Fixed office funding and cooldown.':d.kind==='proclamation'?'Publish an official message in this office’s existing proclamation archive. Fixed office funding and cooldown; no membership or voting rights change.':'Thirty-day ceremonial profile recognition. No office, rank, vote or permission is granted.'})));
export const POLITICAL_DECISION_CATALOGUE=Object.freeze(POLITICAL_DECISIONS.map(d=>Object.freeze({...d,office:({emperor:'IMP',atreides:'ATR',harkonnen:'HAR',corrino:'COR',ordos:'ORD',veiled_concord:'BG',muad_dib:'NF',spacing_guild:'SG'})[d.office],cost:(d.feeMinor/100).toLocaleString('en-GB')+' / '+d.cooldownMs/3600000+'h',effect:d.kind==='event'?'Schedule an official audience in the existing House calendar. Fixed office funding, Reputation and cooldown; no election, membership or travel change.':d.kind==='report'?'Read a sealed aggregate of available Exchange stock. Guild reports also include seven-day confirmed arrival totals. No passenger identities, private orders or account balances. Fixed office funding and cooldown.':d.kind==='proclamation'?'Publish an official message in this office’s existing proclamation archive. Fixed office funding and cooldown; no membership or voting rights change.':'Ceremonial profile recognition for '+d.durationMs/86400000+' days. No office, rank, vote or permission is granted.'})));

View file

@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"sourceHash": "e7127c7368ecd0dd230ec195beed741782da6ac7631e48d8cc1fc0bcf6fd5b60",
"sourceHash": "e853baf3a4665685d7bd8b160c3b2f1b631fdfd8729f988a6334985a79276d45",
"actions": [
{
"id": "war.coalition-consent",
@ -431,6 +431,58 @@
"webIssue": false,
"recordOnly": false
},
{
"id": "faith.diplomatic-endorsement",
"label": "POL & orders · Church diplomatic endorsement",
"version": 1,
"keyType": "entity-state",
"fields": [
{
"name": "ticketId",
"label": "Ban / support ticket ID",
"type": "text",
"required": true,
"maxLength": 80
},
{
"name": "decisionId",
"label": "Faith decision",
"type": "select",
"required": true,
"options": [
"NF-07"
]
},
{
"name": "sourceAccount",
"label": "Authorised Church funding account",
"type": "text",
"required": true
},
{
"name": "recipientId",
"label": "Other active player UUID",
"type": "text",
"required": true
},
{
"name": "citation",
"label": "Diplomatic citation",
"type": "textarea",
"required": true
},
{
"name": "requestId",
"label": "Request UUID",
"type": "text",
"required": true
}
],
"effect": "Current Royal Church office holder, Reputation 15, fixed 2,500 DM Church-account fee and 250 Reputation points. Seven-day ceremonial diplomatic endorsement on the recipient profile; one decision per 72 hours across succession. No self-award, faith conversion, clan membership, appointment, vote, rank, permissions or bonus. Payment, recognition and ordinary instrument commit once; expiry and key revocation remove the display.",
"fixedTargets": [],
"webIssue": false,
"recordOnly": true
},
{
"id": "politics.court-audience",
"label": "POL & orders · Official court calendar audience",

View file

@ -27,6 +27,14 @@ async function fixture(office='emperor',extra={}){
}
test('catalogue prices, Reputation requirements and XP agree with connected policy',()=>{for(const d of POLITICAL_DECISIONS){const row=DECISION_CATALOGUE.find(r=>r.id===d.id);assert.equal(row.level,d.level);assert.equal(row.xp,d.xp);const [dm,hours]=row.cost.replaceAll(',','').split(' / ');assert.equal(Number(dm)*100,d.feeMinor);assert.equal(Number(hours.replace('h',''))*3600000,d.cooldownMs);}});
test('Church diplomatic favour lasts seven days, uses only Church funding and grants no office or self-award',async()=>{
const f=await fixture('muad_dib');try{
const input=f.input('NF-07');await assert.rejects(f.service.execute(f.people.Owner,{...input,recipientId:f.people.Owner.id}),/another active/);const receipt=await f.service.execute(f.people.Owner,input);assert.equal(receipt.expiresAt,1000+7*86400000);assert.equal(receipt.cooldownUntil,1000+72*3600000);assert.equal(receipt.feeMinor,'250000');
const honours=await politicalHonours(f.db,f.people.Other.id,1000);assert.equal(honours.length,1);assert.equal(honours[0].title,'Church’s Favour');assert.match(honours[0].seal,/new-faith/);assert.equal((await politicalHonours(f.db,f.people.Other.id,receipt.expiresAt)).length,0);await f.db.query('UPDATE organisation_keys SET revoked_at=1 WHERE id=?',[receipt.keyId]);assert.equal((await politicalHonours(f.db,f.people.Other.id,1000)).length,0);
assert.equal((await f.db.first('SELECT COUNT(*) n FROM political_office_terms')).n,1);assert.equal((await f.pol.first('SELECT total_xp FROM jarvis_progression_accounts WHERE account_id=?',[f.people.Owner.id])).total_xp,10250);
}finally{f.db.close();}
});
test('a funded court audience uses the existing political calendar atomically and cannot replay or outlive its mandate',async()=>{
const f=await fixture('corrino');try{
for(const sql of EVENT_SCHEMA)await f.db.query(sql);const input={decisionId:'COR-01',requestId:randomUUID(),sourceAccount:String(f.source.id),title:'Court audience',description:'Diplomatic audience for our House envoys.',startsAt:100000,endsAt:200000,confirmed:true};