feat: integrate room framework and isolated subgame bundles
Complete room UI and protocol integration, move game definitions and resources behind bundle entries, publish authoritative version XML, and document single-game builds. Include all current resource changes and experiment artifacts.
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import {test} from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {createTemplateGame} from '../../YouleNexus/assets/games/template/template-game.ts';
|
||||
import {GAME_DEFINITIONS} from '../fixtures/game-definitions.ts';
|
||||
test('template module attaches only when opened and releases its view and subscription',()=>{
|
||||
let unsubscribed=0;const commands:unknown[]=[];const views:unknown[]=[];
|
||||
const snapshot={connection:{phase:'logged-in'},self:{playerId:1,seat:0},room:{roomcode:'123456',roomtype:[],stage:0,needprepare:0,infinite:0},seats:[]};
|
||||
const game=createTemplateGame('g');const probe=game.entry.createModule();probe.dispose();
|
||||
const game=GAME_DEFINITIONS.Game_Surface_3.createGame('g');const probe=game.entry.createModule();probe.dispose();
|
||||
assert.throws(()=>game.mount({render:s=>views.push(s),close(){}}));
|
||||
const module=game.entry.createModule();
|
||||
module.attach({getSnapshot:()=>snapshot,subscribe:()=>()=>unsubscribed++,execute:(c:unknown)=>commands.push(c),seat:{toView:(n:number)=>n,toServer:(n:number)=>n},sendGameMessage(){}} as any);
|
||||
let actions:any;game.mount({render:(s,a)=>{views.push(s);actions=a;},close:()=>views.push('closed')});
|
||||
const module=game.entry.createModule();assert.equal(game.roomProjection,null);assert.equal(module.roomProjection,null);
|
||||
module.attach({capabilities:{room:{getSnapshot:()=>snapshot,subscribe:()=>()=>unsubscribed++,prepare:()=>commands.push({type:'room.prepare'}),requestExit:()=>commands.push({type:'room.exit'})}}} as any);
|
||||
let actions:any;game.mount({render:(s,a,projection)=>{assert.equal(projection,null);views.push(s);actions=a;},close:()=>views.push('closed')});
|
||||
actions.exit();actions.prepare();assert.deepEqual(commands,[{type:'room.exit'},{type:'room.prepare'}]);
|
||||
const deskinfo={nested:[1,2]};module.restore(deskinfo);assert.equal(game.restoredSnapshot,deskinfo);
|
||||
module.dispose();assert.equal(unsubscribed,1);assert.equal(views[views.length - 1],'closed');assert.throws(()=>actions.exit());
|
||||
|
||||
Reference in New Issue
Block a user