Adaptive Music v0.8.1 combat automation fixes
Validate and generate manual release / package (push) Waiting to run

This commit is contained in:
Jason committed 2026-12-05 13:37:05 -05:00
1 parent 95b0427aa1
commit 357c904d1b
26 files changed
+1387 -138

No files matched your search

+35
View File
@@ -62,3 +62,38 @@ test('Foundry bootstrap registers local settings/hooks and disposes without ambi
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);
});
test('Foundry runtime uses committed unlinked combatant scenes and coalesces initiative changes',async()=>{
const callbacks=new Map(), calls=[];
const Hooks={on(event,callback){callbacks.set(event,callback);return event;},off(event){callbacks.delete(event);}};
const ref=id=>({provider:'ma',id});
const scene={id:'A',active:true,getFlag:()=>({ambient:ref('ambient'),combat:ref('battle'),boss:ref('boss')})};
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,
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')};
const runtime=startNativeRuntime({game,Hooks,campaign:'c',session:'s',ownedPlaylistIds:[],maProvider});
await runtime.refresh();
assert.equal(runtime.musicMode,'ambient');
assert.equal(callbacks.has('combatStart'),false);
combats.delete(encounter.id);
callbacks.get('deleteCombat')(encounter);
await runtime.controller.tail;
assert.deepEqual(calls,['ambient']);
combats.set(encounter.id,encounter);
encounter.started=true;
callbacks.get('updateCombat')(encounter,{round:1,turn:0});
await runtime.controller.tail;
assert.equal(runtime.musicMode,'boss');
callbacks.get('updateCombat')(encounter,{turn:1});
await runtime.controller.tail;
assert.deepEqual(calls,['ambient','boss']);
combats.delete(encounter.id);
callbacks.get('deleteCombat')(encounter);
await runtime.controller.tail;
assert.deepEqual(calls,['ambient','boss','restored']);
assert.equal(runtime.musicMode,'ambient');
runtime.dispose();
});