import {setGameInfo} from "./moooove"; import {clearBoard, resizeBoard} from "./Board"; type CrashGroup = { name: string; passed: number; status: string; total: number; }; type CommandOpts = { continue: boolean; record_on: string; timeout: number; }; type CrashCommand = { cause: string; cmd: string[]; code: number; key: string[]; opts: CommandOpts; status: string; stderr: string; stdout: string; }; type CrashReport = { commands: CrashCommand[]; groups: CrashGroup[]; player_1: string; player_2: string; }; type Move = { x: number; y: number; id: number; tile: { t: number[], c: number[], name: string, angle: string }; }; type Game = { seed: number; type: string; player0: string; player1: string; queens0: number[]; queens1: number[]; moves: Move[]; winner?: string; cause?: string; crashReport?: CrashReport; }; let games: Game[] = []; function main() { games = JSON.parse(document.getElementById("jsonData")!.textContent!) as Game[]; const crashes = JSON.parse(document.getElementById("errors")!.textContent!) as (CrashReport & { log: Game; })[]; const timeouts: CrashReport[] = []; crashes.forEach((c) => { const {log: gameLog, ...crashReportWithoutGame} = c; if (typeof (gameLog as unknown) === "string") { // Timeout case... timeouts.push(crashReportWithoutGame); return; } gameLog.crashReport = crashReportWithoutGame; games.push(gameLog); }); console.log(games); console.log(timeouts); console.log(crashes); } window.onload = ((e) => { main(); clearBoard(); setGameInfo(); resizeBoard(); const showDataButton = (document.getElementById('showData')); showDataButton.addEventListener( 'click', () => { (document.getElementById('jsonData')).classList.toggle("closed"); if (showDataButton.innerText.includes("Afficher")) showDataButton.innerText = "Cacher les données de parties"; else showDataButton.innerText = "Afficher les données de parties"; }); }); export {games, Move};