feat: integrate platform room entry, UI migration and erqiwang documentation
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import {test} from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {createTemplateGame} from '../../YouleNexus/assets/games/template/template-game.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();
|
||||
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')});
|
||||
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.at(-1),'closed');assert.throws(()=>actions.exit());
|
||||
});
|
||||
Reference in New Issue
Block a user