forked from unimatrix/web
Merge pull request 'Regal titles and clan council appointments' (#372) from design/regal-clan-titles into main
This commit is contained in:
commit
a9db25ce1c
11 changed files with 71 additions and 25 deletions
13
docs/design/CAMPAIGN-MAP-NOTES.md
Normal file
13
docs/design/CAMPAIGN-MAP-NOTES.md
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Campaign map and Company specialist — design notes
|
||||
|
||||
Agreed 17 November 2026. Future work, not part of the current clan identity publication.
|
||||
|
||||
- RTS influence at campaign level: each Home Block anchors a province; actual WorldGuard-format claim geometry remains the land source. Do not imply ownership of gaps between disconnected claims.
|
||||
- Province owner comes from the deed; hierarchy distinguishes mother and daughter clans. Campaign overlays show conquer/server-event progress.
|
||||
- Example victory condition: conquer 10 Home Blocks on the target world. Repeat-capture, eligibility and holding-period rules remain to be designed with the event.
|
||||
- Minecraft players perform the battles; the website projects recorded outcomes through the shared API. No second ownership store or website-only combat result.
|
||||
- Company specialist inspiration: Duncan Idaho as portrayed in Dune (1992). Reuse appointment and portrait components, adapting to commercial responsibilities. Exact Company title and privileges remain to be agreed.
|
||||
|
||||
Imperial Intervention is a server event, not an action funded or authorised by the player Emperor's political deed. Management entry: Emperor Actions → Start Dune II Event. EU4-style event setup defines target world, participants, victory objective and Imperial intervention settings. Province map presents progress. This is a design entry, not an instruction to launch an event now. Exact access policy and event mechanics are future work.
|
||||
|
||||
Correction: no per-event staff setup. Start Dune II Event launches a predefined automated scenario; selection, objectives, province tracking, intervention and completion follow preset rules. Emperor Actions is its management entry, not a manual staff setup form.
|
||||
|
|
@ -64,3 +64,9 @@ The owner appoints an arms specialist through the versioned, audited deed appoin
|
|||
Tradition names: Atreides Master-at-Arms; Harkonnen Arms Overseer; Corrino Master of the Guard; Ordos Arsenal Director; Fremen Warleader; Spacing Guild Security Master; Bene Gesserit Weapons Master. Guildmaster-Designate and Mother Superior-Designate replace Mentat as heir titles.
|
||||
|
||||
The political deed is the office instrument and determines current office/title. The office register is the historical record. readPoliticalIdentity exposes these as separate projections: active verified offices and register-backed recognitions. A historical honour cannot establish a current Emperor. Ter Electus reuses the existing same-office consecutive-three-term honour; it does not create a second counter or grant powers.
|
||||
|
||||
## Imperial Envoy
|
||||
|
||||
Kynes-inspired clan representative. Appointed by the Ruler through the same versioned deed flow as the other specialist; public portrait is outside family connectors. clanElectionAuthority delegates organisation election management only. It cannot grant ownership, kit access, bank access or another person's personal vote. The ordinary personal ballot APIs remain authenticated-voter-only. The future organisation election control flow must consume this capability rather than impersonating the owner.
|
||||
|
||||
Arms specialist also receives clan warfare management through clanWarAuthority. War and kit scopes do not confer deed ownership, bank mandates or political powers. Actual war actions must enforce this scope alongside campaign eligibility and clan charter rules; a capability alone cannot start an ineligible conquest.
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ const el=(tag,text)=>{const n=document.createElement(tag);if(text!==undefined)n.
|
|||
export function mountClanDeedSettings(host,clan){
|
||||
let data=null,busy=false;const status=el('p','Opening the registered deed…'),content=el('div');status.setAttribute('role','status');host.append(status,content);
|
||||
async function request(body){const r=await fetch('/api/clan-deeds/'+encodeURIComponent(clan.id),{credentials:'same-origin',cache:'no-store',...(body?{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(body)}:{})}),d=await r.json();if(!r.ok)throw Error(d.message||'Deed service unavailable.');return d;}
|
||||
async function load(){try{data=await request();content.replaceChildren(createDeedCard({clan,deed:data.deed,titles:clan.titles||{},established:formatDuneDate(clan.created_at)}));const page=el('a','Open public clan page ↗');page.href='https://www.dunerealms.com/clans/'+encodeURIComponent(clan.tag);page.target='_blank';page.rel='noopener';content.append(page);for(const role of ['heir','consort','arms'].filter(role=>role==='arms'?data.canAppointArms:data.canAppoint)){
|
||||
const form=el('form'),label=el('label',role==='arms'?(clan.titles?.arms||'Master-at-Arms'):role==='heir'?'Heir / successor':'Consort'),select=el('select'),empty=el('option','Not appointed');empty.value='';select.append(empty);select.setAttribute('aria-label','Appoint '+(role==='arms'?(clan.titles?.arms||'Master-at-Arms'):role));for(const p of (role==='consort'?data.consortCandidates:data.candidates)){const o=el('option',p.username);o.value=p.username;select.append(o);}select.value=data.deed[role]?.username||'';label.append(select);const check=el('input');check.type='checkbox';const consent=el('label',role==='arms'?' I confirm this kit-generator appointment. It grants no ownership or succession rights.':role==='heir'?' I confirm that the Heir receives the same clan management rights as the Ruler.':' I confirm this honorary appointment. It grants no extra management rights.');consent.prepend(check);const button=el('button','Save '+(role==='arms'?(clan.titles?.arms||'Master-at-Arms'):role==='heir'?'Heir':'Consort'));button.type='submit';button.disabled=true;check.onchange=()=>button.disabled=busy||!check.checked||role==='heir'&&!data.canAppointHeir;select.onchange=()=>{check.checked=false;button.disabled=true;};form.append(label,consent,button);if(role==='heir'&&!data.canAppointHeir)form.append(el('p','A Keyed or Royal charter unlocks the Heir appointment.'));form.onsubmit=async e=>{e.preventDefault();if(busy||!check.checked)return;busy=true;button.disabled=true;try{await request({role,candidate:select.value||null,version:data.deed.version,confirmed:true});await load();status.textContent='Dynastic appointment saved. Members and their ordinary ranks are unchanged.';}catch(error){status.textContent=error.message;}finally{busy=false;}};content.append(form);
|
||||
async function load(){try{data=await request();content.replaceChildren(createDeedCard({clan,deed:data.deed,titles:clan.titles||{},established:formatDuneDate(clan.created_at)}));const page=el('a','Open public clan page ↗');page.href='https://www.dunerealms.com/clans/'+encodeURIComponent(clan.tag);page.target='_blank';page.rel='noopener';content.append(page);for(const role of ['heir','consort','arms','envoy'].filter(role=>['arms','envoy'].includes(role)?data.canAppointArms:data.canAppoint)){
|
||||
const form=el('form'),label=el('label',role==='envoy'?'Imperial Envoy':role==='arms'?(clan.titles?.arms||'Master-at-Arms'):role==='heir'?'Heir / successor':'Consort'),select=el('select'),empty=el('option','Not appointed');empty.value='';select.append(empty);select.setAttribute('aria-label','Appoint '+(role==='envoy'?'Imperial Envoy':role==='arms'?(clan.titles?.arms||'Master-at-Arms'):role));for(const p of (role==='consort'?data.consortCandidates:data.candidates)){const o=el('option',p.username);o.value=p.username;select.append(o);}select.value=data.deed[role]?.username||'';label.append(select);const check=el('input');check.type='checkbox';const consent=el('label',role==='envoy'?' I confirm this clan-election appointment. Personal voting rights and ownership are not delegated.':role==='arms'?' I confirm this kit and warfare appointment. It grants no ownership, banking or succession rights.':role==='heir'?' I confirm that the Heir receives the same clan management rights as the Ruler.':' I confirm this honorary appointment. It grants no extra management rights.');consent.prepend(check);const button=el('button','Save '+(role==='envoy'?'Imperial Envoy':role==='arms'?(clan.titles?.arms||'Master-at-Arms'):role==='heir'?'Heir':'Consort'));button.type='submit';button.disabled=true;check.onchange=()=>button.disabled=busy||!check.checked||role==='heir'&&!data.canAppointHeir;select.onchange=()=>{check.checked=false;button.disabled=true;};form.append(label,consent,button);if(role==='heir'&&!data.canAppointHeir)form.append(el('p','A Keyed or Royal charter unlocks the Heir appointment.'));form.onsubmit=async e=>{e.preventDefault();if(busy||!check.checked)return;busy=true;button.disabled=true;try{await request({role,candidate:select.value||null,version:data.deed.version,confirmed:true});await load();status.textContent='Dynastic appointment saved. Members and their ordinary ranks are unchanged.';}catch(error){status.textContent=error.message;}finally{busy=false;}};content.append(form);
|
||||
}status.textContent='Ruler follows the registered owner. Heir and Consort are separate dynastic appointments.';}catch(error){status.textContent=error.message;}}
|
||||
void load();return content;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600;700&display=swap');
|
||||
.clan-dynasty{position:relative;isolation:isolate;padding:clamp(24px,5vw,64px);border:1px solid #ae9452;border-radius:18px;background:linear-gradient(#0e2724aa,#091d1aeb),url('https://www.dunerealms.com/assets/political-small-council-v1.png') center/cover;color:#eee2c4;overflow:hidden}.clan-dynasty-basic{background-image:linear-gradient(#0e2724aa,#091d1aeb),url('https://www.dunerealms.com/assets/guild.webp')}.clan-dynasty-royal{background-image:linear-gradient(#18242988,#111b24eb),url('https://www.dunerealms.com/assets/political-imperial-chamber-v1.png')}.clan-dynasty>header{text-align:center;display:grid;justify-items:center;gap:12px;margin-bottom:38px}.clan-dynasty>header img{object-fit:contain;filter:drop-shadow(0 8px 12px #0008)}.clan-dynasty h2{font:700 clamp(26px,4vw,42px) Georgia,serif;color:#f0d592;margin:0}.clan-dynasty small,.clan-deed-card small{color:#e3bf71;letter-spacing:.15em;font-size:11px}.clan-dynasty-tree{display:grid;grid-template-columns:repeat(2,minmax(0,260px));gap:65px 45px;justify-content:center;position:relative}.dynasty-player{position:relative;display:flex;flex-direction:column;align-items:center;text-align:center;gap:12px;padding:26px 18px;border:1px solid #b69a54;border-radius:12px;background:linear-gradient(140deg,#244039e8,#102721f5);box-shadow:0 15px 30px #0005;min-width:0}.dynasty-player a{font:700 clamp(17px,2vw,23px) Georgia,serif;color:#f3d995;overflow-wrap:anywhere}.dynasty-player strong{font-size:14px;color:#d8cfb7}.dynasty-portrait{display:grid;place-items:center;width:100px;height:100px;border:1px solid #c3a65b;border-radius:12px;background:#0a1c19;color:#cfb36f;box-shadow:0 0 22px #e2bb4b19}.dynasty-portrait img{width:80px;height:80px;border-radius:8px;image-rendering:pixelated}.dynasty-player-ruler:after{content:'';position:absolute;width:46px;height:1px;right:-46px;top:50%;background:#c9ad68}.dynasty-player-heir{grid-column:1/-1;justify-self:center;width:100%;max-width:260px;box-sizing:border-box}.dynasty-player-heir:before{content:'';position:absolute;height:66px;width:1px;background:#c9ad68;top:-66px;left:50%}.dynasty-vacant{border-style:dashed;background:#10251fbd}.clan-deed-card{display:grid;grid-template-columns:minmax(150px,240px) minmax(0,1fr);gap:32px;padding:30px;border:1px solid #a48d52;border-radius:16px;background:linear-gradient(130deg,#2c3025,#102821);color:#e9dfc7;align-items:center}.clan-deed-card h2{font:700 30px Georgia,serif;color:#f2d896}.clan-deed-picture{height:auto;aspect-ratio:1;width:100%;overflow:hidden;position:relative}.clan-deed-picture img{width:300%;height:100%;max-width:none;object-fit:cover;position:absolute;left:0}.clan-deed-card dl{display:grid;grid-template-columns:auto 1fr;gap:10px 24px}.clan-deed-card dd{margin:0;overflow-wrap:anywhere}.clan-deed-card dt{color:#d2b66c}.clan-deed-card>div:last-child{min-width:0}.clan-dynasty-tree,.clan-deed-card{box-sizing:border-box}@media(max-width:560px){.clan-dynasty-tree{gap:48px 18px}.clan-dynasty{padding:24px 14px}.dynasty-player{padding:18px 8px}.dynasty-player-ruler:after{width:19px;right:-19px}.dynasty-player-heir:before{height:49px;top:-49px}.dynasty-portrait{width:70px;height:70px}.dynasty-portrait img{width:58px;height:58px}.clan-deed-card{grid-template-columns:1fr;padding:22px}.clan-deed-picture{width:180px;justify-self:center;height:auto}.clan-deed-card h2{font-size:26px}}
|
||||
|
||||
/* Imperial register: heraldic protection, sealed corners and ornate card edges. */
|
||||
|
|
@ -9,3 +10,5 @@
|
|||
.organisation-settings-card .clan-deed-card{display:block;padding:20px;max-width:100%;box-sizing:border-box}.organisation-settings-card .clan-deed-picture{width:160px;height:160px;max-width:100%;margin:0 auto 22px}.organisation-settings-card .clan-deed-card h2{font-size:26px;line-height:1.25;overflow-wrap:break-word}.organisation-settings-card .clan-deed-card dl{grid-template-columns:minmax(60px,auto) minmax(0,1fr);gap:12px 16px;font-size:15px;line-height:1.6}.organisation-settings-card .clan-deed-card dd{min-width:0;word-break:normal;overflow-wrap:break-word}.organisation-settings-card .clan-deed-card small{letter-spacing:.06em;line-height:1.6}.organisation-settings-card .clan-deed-card~form{display:grid;gap:14px;margin-top:24px;padding-top:22px;border-top:1px solid #87734466}.organisation-settings-card .clan-deed-card~form label{display:grid;gap:10px}.organisation-settings-card .clan-deed-card~form label:has(>input[type=checkbox]){display:flex;align-items:flex-start;gap:10px;line-height:1.6}.organisation-settings-card .clan-deed-card~form input[type=checkbox]{width:18px!important;height:18px;flex:0 0 18px;margin-top:4px}.organisation-settings-card .clan-deed-card~form button{justify-self:start}.dynasty-player>a{line-height:1.45;font-size:clamp(17px,2vw,21px)}.dynasty-player>small:last-child{font-size:11px;letter-spacing:.04em;color:#b6c9b9}.clan-deed-card dd{line-height:1.6}.clan-deed-card h2{overflow-wrap:break-word}
|
||||
/* Household specialist, deliberately outside the family connector graph. */
|
||||
.clan-dynasty>.dynasty-specialist{position:relative;max-width:280px;margin:42px auto 0;border-style:double;border-width:3px;padding:24px;box-sizing:border-box;text-align:center}.dynasty-specialist::before,.dynasty-specialist::after{display:none}.dynasty-specialist>small{display:block;margin-bottom:16px}.dynasty-specialist .dynasty-portrait{margin:0 auto 18px}.dynasty-specialist>a{display:block}.dynasty-specialist>small:last-child{margin-top:12px;margin-bottom:0}
|
||||
|
||||
.clan-dynasty h2,.dynasty-player>a,.clan-deed-card h2,.clan-deed-card dd{font-family:'Cinzel','Palatino Linotype',serif;font-weight:600;text-decoration:none;letter-spacing:.025em}.dynasty-player>a{line-height:1.55;text-wrap:balance}.dynasty-player>a:hover{text-shadow:0 0 14px #e8c97666;color:#fff0bc}.clan-deed-card dd{line-height:1.7}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ function styles(){if(document.querySelector('link[data-clan-dynasty]'))return;co
|
|||
export function createDynastyTree({clan,deed,titles}){
|
||||
styles();const root=el('section',undefined,'clan-dynasty clan-dynasty-'+deed.kind),heading=el('header'),crest=el('img');crest.src=clan.emblem;crest.alt=clan.name+' crest';crest.width=crest.height=220;const shield=el('div',undefined,'dynasty-heraldic-shield');shield.append(crest);heading.append(shield,el('small','THE DYNASTY'),el('h2',clan.name));if(clan.colors)for(const key of ['primary','secondary','trim'])if(/^#[A-F0-9]{6}$/i.test(clan.colors[key]||''))root.style.setProperty('--clan-'+key,clan.colors[key]);root.append(heading);
|
||||
const tree=el('div',undefined,'clan-dynasty-tree');tree.setAttribute('aria-label','Dynastic appointments');
|
||||
for(const [role,title]of [['ruler',titles.owner],['consort',titles.consort||'Consort'],['heir',titles.heir],['arms',titles.arms||'Master-at-Arms']]){
|
||||
const person=deed[role],card=el('article',undefined,'dynasty-player dynasty-player-'+role),portrait=el('div',undefined,'dynasty-portrait');card.append(el('small',role==='arms'?'CLAN SPECIALIST':role==='ruler'?'RULER':role==='heir'?'HEIR':'CONSORT'));
|
||||
for(const [role,title]of [['ruler',titles.owner],['consort',titles.consort||'Consort'],['heir',titles.heir],['arms',titles.arms||'Master-at-Arms'],['envoy',titles.envoy||'Imperial Envoy']]){
|
||||
const person=deed[role],card=el('article',undefined,'dynasty-player dynasty-player-'+role),portrait=el('div',undefined,'dynasty-portrait');card.append(el('small',['arms','envoy'].includes(role)?'CLAN SPECIALIST':role==='ruler'?'RULER':role==='heir'?'HEIR':'CONSORT'));
|
||||
if(person){const face=el('img');face.src='https://cp.dunerealms.com/api/avatars/face/roster/'+encodeURIComponent(person.username);face.alt=person.username+' Minecraft face';face.width=face.height=96;face.loading='lazy';portrait.append(face);const link=el('a',dynasticAddress(person,clan,titles,role));link.href='https://www.dunerealms.com/people/'+encodeURIComponent(person.username);const handle=el('small','@'+person.username);card.append(portrait,link,handle);}
|
||||
else{portrait.append(el('span','✦'));card.classList.add('dynasty-vacant');card.append(portrait,el('strong','Not appointed'),el('span',title));}
|
||||
if(role==='arms'){card.classList.add('dynasty-specialist');root.append(card);}else tree.append(card);
|
||||
if(['arms','envoy'].includes(role)){card.classList.add('dynasty-specialist');root.append(card);}else tree.append(card);
|
||||
}root.insertBefore(tree,root.querySelector('.dynasty-specialist'));return root;
|
||||
}
|
||||
export function createDeedCard({clan,deed,titles,established}){
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
const houses={
|
||||
atreides:[['Lord / Lady','Ducal Heir','Ducal Consort'],['Duke / Duchess','Ducal Heir','Ducal Consort'],['Duke / Duchess','Ducal Heir','Ducal Consort']],
|
||||
harkonnen:[['Lord / Lady','Na-Baron / Na-Baroness','Baronial Consort'],['Baron / Baroness','Na-Baron / Na-Baroness','Baronial Consort'],['Baron / Baroness','Na-Baron / Na-Baroness','Baronial Consort']],
|
||||
corrino:[['Lord / Lady','Imperial Heir','Imperial Consort'],['Prince / Princess','Imperial Heir','Imperial Consort'],['Prince / Princess Imperial','Imperial Heir','Imperial Consort']],
|
||||
corrino:[['Lord / Lady','Imperial Heir','Imperial Consort'],['Prince / Princess','Imperial Heir','Imperial Consort'],['Prince Imperial / Princess Imperial','Imperial Heir','Imperial Consort']],
|
||||
ordos:[['Factor','Director-Designate','Consort'],['Director','Director-Designate','Consort'],['High Director','Director-Designate','Consort']],
|
||||
fremen:[['Sietch Elder','Chosen Successor','Consort'],['Naib','Chosen Successor','Consort'],['Naib of Naibs','Chosen Successor','Consort']],
|
||||
guild:[['Guild Agent','Guildmaster-Designate','Consort'],['Navigator','Guildmaster-Designate','Consort'],['Guildmaster','Guildmaster-Designate','Consort']],
|
||||
|
|
@ -14,5 +14,5 @@ export function clanTitles({home_world,homeWorld,charterKind='basic',institution
|
|||
const faction=key==='veiled_concord'?'bene':['spacing_guild','vaerkring'].includes(key)?'guild':clanFaction(home_world||homeWorld);
|
||||
const level=charterKind==='royal'?2:['original','keyed'].includes(charterKind)?1:0;
|
||||
const pair=(houses[faction]||[['Lord / Lady','Designated Successor','Consort'],['Lord / Lady','Designated Successor','Consort'],['Lord / Lady','Designated Successor','Consort']])[level];
|
||||
return {arms:({atreides:'Master-at-Arms',harkonnen:'Arms Overseer',corrino:'Master of the Guard',ordos:'Arsenal Director',fremen:'Warleader',guild:'Security Master',bene:'Weapons Master'})[faction]||'Master-at-Arms',owner:pair[0],heir:pair[1],consort:pair[2],officer:'Officer',member:'Member'};
|
||||
return {envoy:'Imperial Envoy',arms:({atreides:'Master-at-Arms',harkonnen:'Arms Overseer',corrino:'Master of the Guard',ordos:'Arsenal Director',fremen:'Warleader',guild:'Security Master',bene:'Weapons Master'})[faction]||'Master-at-Arms',owner:pair[0],heir:pair[1],consort:pair[2],officer:'Officer',member:'Member'};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ const first=value=>String(value||'').split(' / ')[0].trim();
|
|||
// Display only. Auth, ownership and permission checks never consume this text.
|
||||
export function dynasticAddress(person,clan,titles,role='ruler'){
|
||||
if(!person)return 'Not appointed';
|
||||
const name=String(person.characterName||person.displayName||person.username||'').trim();
|
||||
const name=String(person.characterName||person.displayName||person.username||'').replace(/_+/g,' ').replace(/\s+/g,' ').trim();
|
||||
if(!name)return 'Not appointed';
|
||||
const politics=role==='arms'?null:person.politicalIdentity;
|
||||
const politics=['arms','envoy'].includes(role)?null:person.politicalIdentity;
|
||||
const emperor=politics?.poldeeds?.status==='available'&&politics.poldeeds.records.some(r=>r.office==='emperor');
|
||||
const raw=role==='ruler'?titles?.owner:role==='heir'?titles?.heir:role==='arms'?titles?.arms:titles?.consort;
|
||||
const title=emperor?'Padishah Emperor':first(raw)||({ruler:'Ruler',heir:'Heir',consort:'Consort',arms:'Master-at-Arms'})[role];
|
||||
const raw=role==='ruler'?titles?.owner:role==='heir'?titles?.heir:role==='arms'?titles?.arms:role==='envoy'?titles?.envoy:titles?.consort;
|
||||
const title=emperor?'Padishah Emperor':first(raw)||({ruler:'Ruler',heir:'Heir',consort:'Consort',arms:'Master-at-Arms',envoy:'Imperial Envoy'})[role];
|
||||
const house=String(clan?.name||'').trim().replace(/^House\s+/i,'');
|
||||
const recognition=politics?.register?.status==='available'&&politics.register.recognitions.some(h=>h.title==='Ter Electus'&&(!emperor||h.office==='emperor'));
|
||||
return title+' '+name+(house?' of '+house:'')+(recognition?' · Ter Electus':'');
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ import {readPoliticalIdentity} from './political-identity.mjs';
|
|||
import {normalisePalette} from '../control-panel/public/organisation-palette-model.mjs';
|
||||
import {randomUUID} from 'node:crypto';
|
||||
import {readClanCharter} from './clan-charters.mjs';
|
||||
export const CLAN_DEED_SCHEMA=`CREATE TABLE IF NOT EXISTS site_clan_deeds (clan_id CHAR(36) PRIMARY KEY,parent_clan_id CHAR(36) NULL,heir_account_id CHAR(36) NULL,consort_account_id CHAR(36) NULL,heir_joined_at BIGINT NULL,consort_joined_at BIGINT NULL,arms_account_id CHAR(36) NULL,arms_joined_at BIGINT NULL,claims_use_mother INTEGER NOT NULL DEFAULT 0,primary_color CHAR(7) NULL,secondary_color CHAR(7) NULL,trim_color CHAR(7) NULL,version INTEGER NOT NULL DEFAULT 1,updated_at BIGINT NOT NULL,FOREIGN KEY(clan_id) REFERENCES site_clans(id),FOREIGN KEY(parent_clan_id) REFERENCES site_clans(id),FOREIGN KEY(heir_account_id) REFERENCES site_accounts(id),FOREIGN KEY(consort_account_id) REFERENCES site_accounts(id))`;
|
||||
export const CLAN_DEED_SCHEMA=`CREATE TABLE IF NOT EXISTS site_clan_deeds (clan_id CHAR(36) PRIMARY KEY,parent_clan_id CHAR(36) NULL,heir_account_id CHAR(36) NULL,consort_account_id CHAR(36) NULL,heir_joined_at BIGINT NULL,consort_joined_at BIGINT NULL,envoy_account_id CHAR(36) NULL,envoy_joined_at BIGINT NULL,arms_account_id CHAR(36) NULL,arms_joined_at BIGINT NULL,claims_use_mother INTEGER NOT NULL DEFAULT 0,primary_color CHAR(7) NULL,secondary_color CHAR(7) NULL,trim_color CHAR(7) NULL,version INTEGER NOT NULL DEFAULT 1,updated_at BIGINT NOT NULL,FOREIGN KEY(clan_id) REFERENCES site_clans(id),FOREIGN KEY(parent_clan_id) REFERENCES site_clans(id),FOREIGN KEY(heir_account_id) REFERENCES site_accounts(id),FOREIGN KEY(consort_account_id) REFERENCES site_accounts(id))`;
|
||||
export async function initializeClanDeeds(db,{mysql=true}={}){
|
||||
await db.prepare(CLAN_DEED_SCHEMA+(mysql?' ENGINE=InnoDB DEFAULT CHARSET=utf8mb4':'')).run();
|
||||
if(mysql)for(const [column,type]of Object.entries({arms_account_id:'CHAR(36) NULL',arms_joined_at:'BIGINT NULL',claims_use_mother:'INTEGER NOT NULL DEFAULT 0',primary_color:'CHAR(7) NULL',secondary_color:'CHAR(7) NULL',trim_color:'CHAR(7) NULL'})){const found=await db.prepare("SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='site_clan_deeds' AND COLUMN_NAME=?").bind(column).first();if(!found)try{await db.prepare('ALTER TABLE site_clan_deeds ADD COLUMN '+column+' '+type).run();}catch(error){if(error.errno!==1060&&error.code!=='ER_DUP_FIELDNAME')throw error;}}
|
||||
if(mysql)for(const [column,type]of Object.entries({envoy_account_id:'CHAR(36) NULL',envoy_joined_at:'BIGINT NULL',arms_account_id:'CHAR(36) NULL',arms_joined_at:'BIGINT NULL',claims_use_mother:'INTEGER NOT NULL DEFAULT 0',primary_color:'CHAR(7) NULL',secondary_color:'CHAR(7) NULL',trim_color:'CHAR(7) NULL'})){const found=await db.prepare("SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='site_clan_deeds' AND COLUMN_NAME=?").bind(column).first();if(!found)try{await db.prepare('ALTER TABLE site_clan_deeds ADD COLUMN '+column+' '+type).run();}catch(error){if(error.errno!==1060&&error.code!=='ER_DUP_FIELDNAME')throw error;}}
|
||||
await db.prepare('INSERT INTO site_clan_deeds(clan_id,updated_at) SELECT c.id,? FROM site_clans c WHERE c.active=1 AND NOT EXISTS(SELECT 1 FROM site_clan_deeds d WHERE d.clan_id=c.id)').bind(Date.now()).run();
|
||||
db.clanDeedsEnabled=true;
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@ export function clanHierarchyRoot(rows,id){
|
|||
throw new DeedError('The clan hierarchy is unavailable.');
|
||||
}
|
||||
export async function readClanDeed(db,clanId,{includePolitics=false}={}){
|
||||
const clan=await db.prepare('SELECT c.id,c.name,c.tag,c.description,c.home_world,c.owner_id,c.version,c.created_at,i.institution_key,d.parent_clan_id,d.heir_account_id,d.consort_account_id,d.heir_joined_at,d.consort_joined_at,d.arms_account_id,d.arms_joined_at,d.claims_use_mother,d.primary_color,d.secondary_color,d.trim_color,d.version deed_version FROM site_clans c LEFT JOIN site_clan_deeds d ON d.clan_id=c.id LEFT JOIN site_clan_institutions i ON i.clan_id=c.id WHERE c.id=? AND c.active=1').bind(clanId).first();
|
||||
const clan=await db.prepare('SELECT c.id,c.name,c.tag,c.description,c.home_world,c.owner_id,c.version,c.created_at,i.institution_key,d.parent_clan_id,d.heir_account_id,d.consort_account_id,d.heir_joined_at,d.consort_joined_at,d.envoy_account_id,d.envoy_joined_at,d.arms_account_id,d.arms_joined_at,d.claims_use_mother,d.primary_color,d.secondary_color,d.trim_color,d.version deed_version FROM site_clans c LEFT JOIN site_clan_deeds d ON d.clan_id=c.id LEFT JOIN site_clan_institutions i ON i.clan_id=c.id WHERE c.id=? AND c.active=1').bind(clanId).first();
|
||||
if(!clan)throw new DeedError('Clan not found.',404);
|
||||
const {results:hierarchy}=await db.prepare('SELECT c.id,d.parent_clan_id FROM site_clans c LEFT JOIN site_clan_deeds d ON d.clan_id=c.id WHERE c.active=1 LIMIT 501').all();if(hierarchy.length>500)throw new DeedError('The hierarchy requires a larger registry view.');
|
||||
const root=clanHierarchyRoot(hierarchy,clan.id),kind=await readClanCharter(db,clanId),eligible=new Set(hierarchy.filter(c=>clanHierarchyRoot(hierarchy,c.id)===root).map(c=>c.id));
|
||||
|
|
@ -24,8 +24,9 @@ export async function readClanDeed(db,clanId,{includePolitics=false}={}){
|
|||
const candidates=members.filter(m=>eligible.has(m.clan_id)),owner=candidates.find(m=>m.id===clan.owner_id),keyed=['original','royal'].includes(kind);
|
||||
const heir=keyed?candidates.find(m=>m.id===clan.heir_account_id&&m.id!==clan.owner_id&&Number(m.joined_at)===Number(clan.heir_joined_at))||null:null,consort=members.find(m=>m.id===clan.consort_account_id&&m.id!==clan.owner_id&&Number(m.joined_at)===Number(clan.consort_joined_at))||null;
|
||||
if(includePolitics)for(const person of [owner,heir,consort])if(person)person.politicalIdentity=await readPoliticalIdentity(db,person);
|
||||
const envoy=candidates.find(m=>m.id===clan.envoy_account_id&&Number(m.joined_at)===Number(clan.envoy_joined_at))||null;
|
||||
const arms=candidates.find(m=>m.id===clan.arms_account_id&&Number(m.joined_at)===Number(clan.arms_joined_at))||null;
|
||||
const colors=normalisePalette(clan.primary_color&&clan.secondary_color&&clan.trim_color?{primary:clan.primary_color,secondary:clan.secondary_color,trim:clan.trim_color}:undefined,clan.institution_key||clan.home_world);return {clan,root,kind,keyed,owner,heir,consort,arms,colors,candidates,consortCandidates:members,version:Number(clan.deed_version||1)};
|
||||
const colors=normalisePalette(clan.primary_color&&clan.secondary_color&&clan.trim_color?{primary:clan.primary_color,secondary:clan.secondary_color,trim:clan.trim_color}:undefined,clan.institution_key||clan.home_world);return {clan,root,kind,keyed,owner,heir,consort,arms,envoy,colors,candidates,consortCandidates:members,version:Number(clan.deed_version||1)};
|
||||
}
|
||||
export async function clanDeedAuthority(db,userId,clanId){
|
||||
try{const deed=await readClanDeed(db,clanId),mother=deed.root!==clanId?await readClanDeed(db,deed.root):deed;return {canManage:!deed.clan.institution_key&&(deed.owner?.id===userId||mother.owner?.id===userId||mother.heir?.id===userId),isOwner:deed.owner?.id===userId,deed};}catch(error){if(error instanceof DeedError)return {canManage:false,isOwner:false};throw error;}
|
||||
|
|
@ -38,7 +39,7 @@ export function clanDeedGuard(db,userId,clanId){return {async run(connection){
|
|||
}};}
|
||||
export function publicDeed(deed){
|
||||
const person=member=>member?{username:member.username,characterName:member.display_name?.trim()||member.username,clanId:member.clan_id,politicalIdentity:member.politicalIdentity}:null;
|
||||
return {clanId:deed.clan.id,kind:deed.kind,version:deed.version,ruler:person(deed.owner),heir:person(deed.heir),consort:person(deed.consort),arms:person(deed.arms),parentClanId:deed.clan.parent_clan_id||null};
|
||||
return {clanId:deed.clan.id,kind:deed.kind,version:deed.version,ruler:person(deed.owner),heir:person(deed.heir),consort:person(deed.consort),arms:person(deed.arms),envoy:person(deed.envoy),parentClanId:deed.clan.parent_clan_id||null};
|
||||
}
|
||||
export async function clanDeedOperators(db){
|
||||
if(!db.clanDeedsEnabled)return new Map();
|
||||
|
|
@ -47,23 +48,23 @@ export async function clanDeedOperators(db){
|
|||
for(const clan of clans){const root=map.get(clanHierarchyRoot(clans,clan.id)),operators=new Set([clan.owner_id,root.owner_id]);const heir=members.find(m=>m.user_id===root.heir_account_id&&Number(m.joined_at)===Number(root.heir_joined_at));if(heir&&['original','royal'].includes(root.charter_kind)&&clanHierarchyRoot(clans,heir.clan_id)===root.id)operators.add(heir.user_id);result.set(clan.id,[...operators]);}return result;
|
||||
}
|
||||
export async function appointClanDynasty(db,user,clanId,input){
|
||||
if(!input||Object.keys(input).some(k=>!['role','candidate','version','confirmed'].includes(k))||!['heir','consort','arms'].includes(input.role)||input.confirmed!==true||!Number.isSafeInteger(input.version)||input.version<1||input.candidate!==null&&typeof input.candidate!=='string')throw new DeedError('Choose and confirm a current appointment.',400);
|
||||
if(!input||Object.keys(input).some(k=>!['role','candidate','version','confirmed'].includes(k))||!['heir','consort','arms','envoy'].includes(input.role)||input.confirmed!==true||!Number.isSafeInteger(input.version)||input.version<1||input.candidate!==null&&typeof input.candidate!=='string')throw new DeedError('Choose and confirm a current appointment.',400);
|
||||
const initial=await readClanDeed(db,clanId);if(initial.owner?.id!==user.id)throw new DeedError('Only the registered Ruler can appoint a dynastic role.',403);
|
||||
if(initial.root!==clanId)throw new DeedError('Dynastic appointments are managed by the mother clan.',403);
|
||||
if(input.role==='heir'&&!initial.keyed)throw new DeedError('A Keyed or Royal charter is required for an Heir.',403);
|
||||
if(initial.clan.institution_key&&input.role!=='arms')throw new DeedError('Protected institution appointments follow their franchise.',403);
|
||||
if(initial.clan.institution_key&&!['arms','envoy'].includes(input.role))throw new DeedError('Protected institution appointments follow their franchise.',403);
|
||||
const chosen=input.candidate===null?null:(input.role==='consort'?initial.consortCandidates:initial.candidates).find(m=>m.username===input.candidate&&m.id!==user.id);if(input.candidate!==null&&!chosen)throw new DeedError('Choose an eligible current member for this dynastic role.',400);
|
||||
if(input.role!=='arms'&&chosen&&(input.role==='heir'?initial.consort?.id:initial.heir?.id)===chosen.id)throw new DeedError('Heir and Consort must be different people.',400);
|
||||
const column=({heir:'heir_account_id',consort:'consort_account_id',arms:'arms_account_id'})[input.role],now=Date.now();
|
||||
if(!['arms','envoy'].includes(input.role)&&chosen&&(input.role==='heir'?initial.consort?.id:initial.heir?.id)===chosen.id)throw new DeedError('Heir and Consort must be different people.',400);
|
||||
const column=({heir:'heir_account_id',consort:'consort_account_id',arms:'arms_account_id',envoy:'envoy_account_id'})[input.role],now=Date.now();
|
||||
// Lock the owner clan first. Every later deed/relationship writer uses the
|
||||
// same clan version lock; membership and appointments are re-read in this tx.
|
||||
await db.batch([{async run(connection){
|
||||
const scoped=connection?{prepare(sql){let values=[];return {bind(...args){values=args;return this;},async first(){return (await connection.execute(sql,values))[0][0]||null;},async all(){return {results:(await connection.execute(sql,values))[0]};}};}}:db;
|
||||
if(connection)await connection.execute('SELECT id FROM site_clans WHERE id=? FOR UPDATE',[clanId]);
|
||||
const current=await readClanDeed(scoped,clanId),candidate=chosen?(input.role==='consort'?current.consortCandidates:current.candidates).find(m=>m.id===chosen.id):null;
|
||||
if(current.owner?.id!==user.id||current.version!==input.version||current.root!==clanId||current.clan.institution_key&&input.role!=='arms'||input.role==='heir'&&!current.keyed||chosen&&!candidate)throw new DeedError('The deed or clan eligibility changed. Refresh first.');
|
||||
const other=input.role==='heir'?current.consort:current.heir;if(input.role!=='arms'&&candidate&&other?.id===candidate.id)throw new DeedError('The dynastic appointments changed. Refresh first.');
|
||||
const result=await db.prepare('UPDATE site_clan_deeds SET '+column+'=?,'+({heir:'heir_joined_at',consort:'consort_joined_at',arms:'arms_joined_at'})[input.role]+'=?,version=version+1,updated_at=? WHERE clan_id=? AND version=?').bind(candidate?.id||null,candidate?Number(candidate.joined_at):null,now,clanId,input.version).run(connection);if(result.meta.changes!==1)throw new DeedError('The deed changed. Refresh first.');return result;
|
||||
if(current.owner?.id!==user.id||current.version!==input.version||current.root!==clanId||current.clan.institution_key&&!['arms','envoy'].includes(input.role)||input.role==='heir'&&!current.keyed||chosen&&!candidate)throw new DeedError('The deed or clan eligibility changed. Refresh first.');
|
||||
const other=input.role==='heir'?current.consort:current.heir;if(!['arms','envoy'].includes(input.role)&&candidate&&other?.id===candidate.id)throw new DeedError('The dynastic appointments changed. Refresh first.');
|
||||
const result=await db.prepare('UPDATE site_clan_deeds SET '+column+'=?,'+({heir:'heir_joined_at',consort:'consort_joined_at',arms:'arms_joined_at',envoy:'envoy_joined_at'})[input.role]+'=?,version=version+1,updated_at=? WHERE clan_id=? AND version=?').bind(candidate?.id||null,candidate?Number(candidate.joined_at):null,now,clanId,input.version).run(connection);if(result.meta.changes!==1)throw new DeedError('The deed changed. Refresh first.');return result;
|
||||
}},db.prepare('INSERT INTO account_audit(id,actor_id,action,details,created_at) VALUES(?,?,?,?,?)').bind(randomUUID(),user.id,'clan-dynasty-appointment',JSON.stringify({clanId,role:input.role,candidate:chosen?.username||null}),now)]);
|
||||
return {ok:true};
|
||||
}
|
||||
|
|
@ -71,3 +72,13 @@ export async function clanKitAuthority(db,userId,clanId){
|
|||
const deed=await readClanDeed(db,clanId),management=await clanDeedAuthority(db,userId,clanId);
|
||||
return {canGenerate:management.canManage||deed.arms?.id===userId,progression:deed.kind,appointment:deed.arms?.id===userId?'arms':null};
|
||||
}
|
||||
// Organisation election authority only. Personal ballots always remain bound to
|
||||
// their authenticated voter; this projection is not an owner impersonation token.
|
||||
export async function clanElectionAuthority(db,userId,clanId){
|
||||
const deed=await readClanDeed(db,clanId),management=await clanDeedAuthority(db,userId,clanId);
|
||||
return {canManageClanElections:management.canManage||deed.envoy?.id===userId,canCastOthersPersonalVotes:false,appointment:deed.envoy?.id===userId?'envoy':null};
|
||||
}
|
||||
export async function clanWarAuthority(db,userId,clanId){
|
||||
const deed=await readClanDeed(db,clanId),management=await clanDeedAuthority(db,userId,clanId);
|
||||
return {canManageWar:management.canManage||deed.arms?.id===userId,appointment:deed.arms?.id===userId?'arms':null};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600;700&display=swap');
|
||||
*{box-sizing:border-box}body{margin:0;background:#0b221b;color:#eee6ce;font:15px/1.7 system-ui,sans-serif}a{color:#e4ca83}.citizen-profile{max-width:1240px;margin:36px auto 60px;padding:0 28px}.citizen-profile [hidden]{display:none!important}.profile-breadcrumb{margin-bottom:22px;font-size:13px;color:#b8c5b7}.profile-breadcrumb a{text-decoration:none}.profile-hero,.profile-panel{border:1px solid #7f8c61;border-radius:16px;padding:30px;margin-bottom:24px;background:linear-gradient(135deg,#1d4031,#102c23);box-shadow:0 8px 25px #0002}.profile-hero{border-top:3px solid #d2b76b;background:linear-gradient(105deg,#173e2bf2,#102e28e8),url('/assets/sietch.webp') center/cover}.citizen-profile .eyebrow{font-size:10px;font-weight:700;letter-spacing:.16em;color:#c4ad6d;margin:0 0 12px}.identity{display:flex;align-items:center;gap:26px;margin:22px 0}.identity>div{min-width:0}#avatar{width:112px;height:112px;flex-shrink:0;border-radius:13px;border:2px solid #c6ab64;object-fit:cover;image-rendering:pixelated;background:#0a241b}.citizen-profile h1,.citizen-profile h2,.citizen-profile h3{font-family:Georgia,serif;color:#efdcab;line-height:1.25;overflow-wrap:anywhere}.citizen-profile h1{font-size:38px;margin:0 0 6px}.citizen-profile h2{font-size:25px;margin:0 0 18px}.citizen-profile h3{font-size:18px}.citizen-profile p{margin-top:0}.muted,#handle,#status{color:#b9ccbd}#handle{margin-bottom:6px}.metadata{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:24px;margin-top:26px}.metadata>div{border-top:1px solid #8d9a6b55;padding-top:16px}.metadata small{display:block;color:#b5c6b5;font-size:12px;margin-bottom:5px}.metadata strong{overflow-wrap:anywhere}.chips{display:flex;gap:10px;flex-wrap:wrap}.chip{display:inline-block;border:1px solid #a89058;border-radius:20px;padding:5px 13px;background:#9b87481c;font-size:12px;text-decoration:none}.chip[data-staff=true]{border-color:#90b2bb;color:#b8d8e3;background:#456d7b30}.profile-columns{display:grid;grid-template-columns:minmax(0,1.1fr) minmax(0,1fr);gap:24px}.profile-prose{white-space:pre-line;overflow-wrap:anywhere;color:#d4dfce}.profile-functions{display:grid;gap:12px;margin-bottom:20px}.profile-function{padding:13px 16px;border:1px solid #71856677;border-left:3px solid #d1b66c;border-radius:8px;background:#0b281d}.profile-function strong{display:block;color:#e4cb8e}.profile-function span,.profile-function small{display:block;color:#b8cdbb;font-size:12px}.profile-award-groups{display:grid;gap:28px;margin-top:26px}.profile-awards{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:18px}.profile-seal{margin:0!important;min-width:0;padding:22px 16px;border:1px solid #7f8b645c;border-radius:12px;background:linear-gradient(145deg,#274936,#102d24);text-align:center;display:flex;flex-direction:column;align-items:center;gap:14px}.profile-seal img{width:128px;height:128px;max-width:100%;object-fit:contain;filter:drop-shadow(0 4px 7px #0005)}.profile-seal figcaption{font-size:13px;color:#e8d6a5;overflow-wrap:anywhere;line-height:1.5;width:100%}.profile-seal small{font-size:11px;color:#b4bd9f}.personal-seal-panel,.profile-order{display:flex;align-items:center;justify-content:space-between;gap:30px}.personal-seal-panel .profile-seal{min-width:210px}.profile-order{justify-content:flex-start;border-color:#c7a955;background:linear-gradient(115deg,#5d502936,#173b2c)}.profile-order>img{object-fit:contain;flex-shrink:0}.profile-community{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:18px}.profile-community>article{padding:20px;border:1px solid #6e886777;border-radius:10px;background:#0c281e}.profile-community strong{display:block;color:#e8d6a5;font-size:21px}.profile-community small{color:#b7cbb8}.profile-community a{font-size:12px}.citizen-profile a:focus-visible{outline:2px solid #e8cb7c;outline-offset:4px}
|
||||
|
||||
.profile-clan-emblem{display:block;width:110px;height:110px;object-fit:contain;margin:0 auto 18px;filter:drop-shadow(0 4px 8px #0005)}
|
||||
.profile-political-offices{border:3px double #c7a05a;background:linear-gradient(120deg,#4b252c,#261e22);box-shadow:inset 0 0 0 3px #d5ad6114}.profile-political-office-list{display:grid;gap:16px}.profile-political-office{display:flex;align-items:center;gap:24px;padding:20px;border:1px solid #b8975688;border-radius:10px;background:#f6eddd0a;min-width:0}.profile-political-office>img{width:96px;height:96px;object-fit:contain;flex-shrink:0;filter:drop-shadow(0 4px 8px #0005)}.profile-political-office small{color:#d4ba82;letter-spacing:.08em;text-transform:uppercase}.profile-political-office h3{margin:7px 0 10px}.profile-political-office strong{color:#edd7a0;font-size:13px}.profile-political-office p{margin:8px 0 0;font-size:12px}@media(max-width:520px){.profile-political-office{align-items:flex-start;flex-direction:column;gap:14px;padding:16px}.profile-political-office>img{width:80px;height:80px}}
|
||||
|
||||
#passport-title{line-height:1.2;font-size:clamp(1.6rem,3.7vw,2.8rem);overflow-wrap:break-word}.profile-header-clan-logo{display:block;width:88px;height:88px;object-fit:contain;filter:drop-shadow(0 4px 7px #0006)}.profile-holdings{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px}.profile-holding-box{padding:22px;min-width:0;border:1px solid #947b43;border-radius:13px;background:linear-gradient(120deg,#213d31ec,#102922f7)}.profile-holding-box h3{font-family:Georgia,serif;color:#e7cc86;margin-top:0}.profile-holding-link{display:flex;align-items:center;gap:14px;padding:10px 0;line-height:1.5;overflow-wrap:anywhere}.profile-holding-link img{width:48px;height:48px;object-fit:contain;flex:none}.profile-holding-box>small{display:block;color:#b7c9b8}@media(max-width:650px){.profile-holdings{grid-template-columns:1fr}}
|
||||
|
||||
#passport-title,.profile-holding-card h3,.profile-holding-card a{font-family:'Cinzel','Palatino Linotype',serif;font-weight:600;letter-spacing:.025em;text-wrap:balance}
|
||||
|
|
|
|||
|
|
@ -26,3 +26,5 @@ test('specialist titles follow all seven traditions',async()=>{
|
|||
for(const [home,arms] of [['kaladam','Master-at-Arms'],['giedermark','Arms Overseer'],['kaiterhof','Master of the Guard'],['sigmadraken_iv','Arsenal Director'],['arrakduin','Warleader']])assert.equal(clanTitles({home_world:home}).arms,arms);
|
||||
assert.equal(clanTitles({institution:'spacing_guild',charterKind:'royal'}).heir,'Guildmaster-Designate');assert.equal(clanTitles({institution:'veiled_concord',charterKind:'royal'}).arms,'Weapons Master');
|
||||
});
|
||||
|
||||
test('ceremonial names replace underscores without changing account identity',()=>{const person={username:'mr_blueray'};assert.equal(dynasticAddress(person,{name:'Unimatrix-Artreides'},{heir:'Ducal Heir'},'heir'),'Ducal Heir mr blueray of Unimatrix-Artreides');assert.equal(person.username,'mr_blueray');});
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ test('a Consort from an independent clan is honorary and never becomes a deed op
|
|||
|
||||
test('specialist kit rights do not grant clan management and expire on leaving and rejoining',async()=>{
|
||||
const f=await fixture();try{
|
||||
const {clanKitAuthority}=await import('../node/clan-deeds.mjs');await f.appoint('arms','Partner');
|
||||
assert.equal((await clanKitAuthority(f.db,f.users.Partner.id,f.root)).canGenerate,true);
|
||||
const {clanKitAuthority,clanWarAuthority}=await import('../node/clan-deeds.mjs');await f.appoint('arms','Partner');
|
||||
assert.equal((await clanKitAuthority(f.db,f.users.Partner.id,f.root)).canGenerate,true);assert.equal((await clanWarAuthority(f.db,f.users.Partner.id,f.root)).canManageWar,true);
|
||||
assert.equal((await clanDeedAuthority(f.db,f.users.Partner.id,f.root)).canManage,false);
|
||||
const data=await (await createPublicClans(f.db)(new Request('https://www.dunerealms.com/api/public/clans/ROOT'))).json();assert.equal(data.deed.arms.username,'Partner');
|
||||
await assert.rejects(f.appoint('arms','Unrelated',2),e=>e.status===400);
|
||||
|
|
@ -40,3 +40,11 @@ test('specialist kit rights do not grant clan management and expire on leaving a
|
|||
assert.equal((await clanKitAuthority(f.db,f.users.Partner.id,f.root)).canGenerate,false);
|
||||
}finally{f.close();}
|
||||
});
|
||||
|
||||
test('Imperial Envoy receives clan-election delegation without owner, kit or personal voting powers',async()=>{
|
||||
const f=await fixture();try{const {clanElectionAuthority,clanKitAuthority}=await import('../node/clan-deeds.mjs');await f.appoint('envoy','Partner');
|
||||
const rights=await clanElectionAuthority(f.db,f.users.Partner.id,f.root);assert.equal(rights.canManageClanElections,true);assert.equal(rights.canCastOthersPersonalVotes,false);assert.equal((await clanDeedAuthority(f.db,f.users.Partner.id,f.root)).canManage,false);assert.equal((await clanKitAuthority(f.db,f.users.Partner.id,f.root)).canGenerate,false);
|
||||
const data=await (await createPublicClans(f.db)(new Request('https://www.dunerealms.com/api/public/clans/ROOT'))).json();assert.equal(data.deed.envoy.username,'Partner');assert.equal(data.titles.envoy,'Imperial Envoy');
|
||||
await assert.rejects(f.appoint('envoy','Unrelated',2),e=>e.status===400);f.db.sqlite.prepare('UPDATE site_clan_members SET joined_at=2 WHERE user_id=?').run(f.users.Partner.id);assert.equal((await clanElectionAuthority(f.db,f.users.Partner.id,f.root)).canManageClanElections,false);
|
||||
}finally{f.close();}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff