Adaptive Music v0.8.3 multiplayer and floating music controls
Validate and generate manual release / package (push) Waiting to run
Validate and generate manual release / package (push) Waiting to run
This commit is contained in:
1 parent
acc8cbafc6
commit
fbc265b526
33 files changed
+1673
-131
No files matched your search
@@ -1,7 +1,8 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { NativeProvider } from '../../src/providers/native/provider.mjs';
|
||||
import { primaryGM, startNativeRuntime } from '../../src/foundry/runtime.mjs';
|
||||
import { startNativeRuntime } from '../../src/foundry/runtime.mjs';
|
||||
import {activeMusicGM,isMusicListener} from '../../src/foundry/authority.mjs';
|
||||
const collection = items => { const m=new Map(items.map(x=>[x.id,x])); m[Symbol.iterator]=function*(){yield* this.values();}; return m; };
|
||||
function fixture() {
|
||||
const calls=[];
|
||||
@@ -50,14 +51,19 @@ test('scene-linked playlist conflict and lost authority fail before mutation',as
|
||||
provider.sceneConflict=()=>false;
|
||||
await assert.rejects(provider.stopOwned({...ctx,check(){throw new Error('lost');}}));assert.equal(calls.length,0);
|
||||
});
|
||||
test('GM election deterministic and no GM means none',()=>{
|
||||
assert.equal(primaryGM([{id:'z',active:true,isGM:true},{id:'a',active:true,isGM:true},{id:'0',active:false,isGM:true}]),'a');
|
||||
assert.equal(primaryGM([]),undefined);
|
||||
test('only one active full GM has authority and assistants are listeners',()=>{
|
||||
const gm={id:'a',active:true,role:4,isGM:true};
|
||||
const assistant={id:'b',active:true,role:3,isGM:true};
|
||||
assert.equal(activeMusicGM([assistant,gm,{active:false,role:4}]),gm);
|
||||
assert.equal(activeMusicGM([assistant]),undefined);
|
||||
assert.equal(activeMusicGM([gm,{id:'z',active:true,role:4}]),undefined);
|
||||
assert.equal(activeMusicGM([{...gm,isBanned:true}]),undefined);
|
||||
assert.equal(isMusicListener(assistant),true);
|
||||
});
|
||||
test('Foundry bootstrap registers local settings/hooks and disposes without ambient or actor access',async()=>{
|
||||
const callbacks=new Map();let index=0,registered=0;
|
||||
const Hooks={on(e,cb){callbacks.set(++index,cb);return index;},off(e,id){callbacks.delete(id);}};
|
||||
const game={ready:true,user:{id:'gm'},users:[{id:'gm',isGM:true,active:true}],playlists:collection([]),scenes:[],combats:[],
|
||||
const game={ready:true,user:{id:'gm'},users:[{id:'gm',role:4,active:true}],playlists:collection([]),scenes:[],combats:[],
|
||||
settings:{register(){registered++;},get(){return null;}}};
|
||||
const runtime=startNativeRuntime({game,Hooks,campaign:'c',session:'s',ownedPlaylistIds:[]});
|
||||
await runtime.refresh();assert.equal(registered,1);assert.ok(callbacks.size>0);runtime.dispose();assert.equal(callbacks.size,0);
|
||||
@@ -70,7 +76,7 @@ test('Foundry runtime uses committed unlinked combatant scenes and coalesces ini
|
||||
const encounter={id:'fight',scene:null,active:true,started:false,
|
||||
combatants:[{id:'token',sceneId:'A',getFlag:()=>undefined}],getFlag:()=>({boss:true})};
|
||||
const combats=collection([encounter]);
|
||||
const game={ready:true,user:{id:'gm'},users:[{id:'gm',isGM:true,active:true}],playlists:collection([]),scenes:[scene],combats,
|
||||
const game={ready:true,user:{id:'gm'},users:[{id:'gm',role:4,active:true}],playlists:collection([]),scenes:[scene],combats,
|
||||
settings:{register(){},get(){return null;}}};
|
||||
const maProvider={supports:()=>true,resolve:async ref=>ref,apply:async ref=>calls.push(ref.id),stopOwned:async()=>{},snapshot:async()=>({}),
|
||||
restore:async()=>calls.push('restored')};
|
||||
|
||||
Reference in new issue
Block a user