import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import { createHash } from 'node:crypto';
const source = new URL('./IVXGameModes.ts', import.meta.url);
assert.equal(createHash('sha256').update(await readFile(source)).digest('hex'), '3cc8dedfd634963b16d0c41cd1ef6062b910a4b2a403ffe0e008b765486e844a', 'SDK source hash differs from the verified commit');
const { IVXGameModes, IVXGameMode } = await import(source.href);
IVXGameModes.resetInstance();
const lobby = IVXGameModes.getInstance();
lobby.selectMode(IVXGameMode.LOCAL_MULTIPLAYER, 2);
assert.equal(lobby.canStartMatch, false);
assert.throws(() => lobby.startMatch(), error => error.code === -1);
lobby.addPlayer('Example player A', true);
lobby.addPlayer('Example player B', true);
assert.throws(() => lobby.addPlayer('Example player C'), error => error.message === 'Lobby full (max 2).');
lobby.setPlayerReady(0, true);
assert.equal(lobby.canStartMatch, false);
lobby.setPlayerReady(1, true);
assert.equal(lobby.canStartMatch, true);
assert.ok(lobby.startMatch());
const result = lobby.endMatch();
assert.equal(result.players.length, 2);
assert.equal(lobby.matchId, null);
console.log(JSON.stringify({sourceCommit:'f4329a486c98fe5712dbe9ac7f5c30d1b4f1952c', mode:result.mode, players:result.players.length, prematureStartRejected:true, overflowRejected:true, matchCompleted:true, scope:'Local SDK state only; no server, genuine participants, rewards or product activation.'}, null, 2));
