Project released Home Blocks as absent for native registration
All checks were successful
DuneRealms Web CI / web (push) Successful in 3m31s
All checks were successful
DuneRealms Web CI / web (push) Successful in 3m31s
This commit is contained in:
parent
46d13ea03e
commit
e94131d237
2 changed files with 9 additions and 2 deletions
|
|
@ -17,6 +17,7 @@ import {projectMilitaryClans} from './war-military-projection.mjs';
|
|||
const digest=value=>createHash('sha256').update(JSON.stringify(value)).digest('hex');
|
||||
const bounded=(rows,max)=>{if(rows.length>max)throw Error('Native inventory exceeds supported batch');return rows;};
|
||||
export function nativeClanControllerIds(deed,authority){return [...new Set([deed.owner?.id,...(deed.root===deed.clan.id?[deed.heir?.id]:[]),...(authority.parentControllerIds||[])].filter(Boolean))].sort();}
|
||||
export function nativeHomeBlock(snapshot,revision){return snapshot?.source==='minecraft'&&snapshot.homeBlock?{...snapshot.homeBlock,revision:Number(revision),source:'minecraft'}:null;}
|
||||
// A consumer view of current deeds/keys, not a new organisation or permission store.
|
||||
// Initial creation and later edits/deletions use this same projection.
|
||||
export async function readGameNativeState(db,{clock=Date.now}={}){
|
||||
|
|
@ -74,7 +75,7 @@ export async function readGameNativeState(db,{clock=Date.now}={}){
|
|||
const snapshot=claim?JSON.parse(claim.snapshot_json):null;
|
||||
record.claimRevision=Number(claim?.revision||0);
|
||||
record.homeServer??=nativeServer(snapshot?.homeBlock?.worldName);
|
||||
record.homeBlock=snapshot?.source==='minecraft'?{...snapshot.homeBlock,revision:Number(claim.revision),source:'minecraft'}:null;
|
||||
record.homeBlock=nativeHomeBlock(snapshot,claim?.revision);
|
||||
record.claimTier=snapshot?.tier||null;record.claimedChunks=registeredClaimChunks(snapshot);record.usedChunks=record.claimedChunks.length;
|
||||
const relocation=snapshot?.relocation;
|
||||
if(relocation&&['cleanup','ready'].includes(relocation.phase)){
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
import test from 'node:test';import assert from 'node:assert/strict';
|
||||
import {createGameNativeStateAPI,nativeClanControllerIds} from '../node/game-native-state.mjs';
|
||||
import {createGameNativeStateAPI,nativeClanControllerIds,nativeHomeBlock} from '../node/game-native-state.mjs';
|
||||
import {fixture} from './rebellion-fixture.mjs';
|
||||
test('a released marker projects as null so native menus expose registration instead of a malformed Home Block',()=>{
|
||||
assert.equal(nativeHomeBlock({source:'minecraft',homeBlock:null},5),null);
|
||||
const home={id:'home',worldName:'arrakis',position:{x:1,y:70,z:2}};
|
||||
assert.deepEqual(nativeHomeBlock({source:'minecraft',homeBlock:home},6),{...home,revision:6,source:'minecraft'});
|
||||
assert.equal(nativeHomeBlock({source:'web-development',homeBlock:home},6),null);
|
||||
});
|
||||
test('native build controllers follow the current mother deed without changing the child roster',()=>{
|
||||
const child={clan:{id:'child'},root:'mother',owner:{id:'child-owner'},heir:{id:'child-heir'}};
|
||||
assert.deepEqual(nativeClanControllerIds(child,{parentControllerIds:['mother-owner','mother-heir','mother-owner']}),['child-owner','mother-heir','mother-owner']);
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff