Project released Home Blocks as absent for native registration

This commit is contained in:
unimatrixgit 2026-11-29 23:06:28 +01:00
commit e94131d237
2 changed files with 9 additions and 2 deletions

View file

@ -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)){

View file

@ -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']);