✨ (viewer) Enable loading game directly from json file

This commit is contained in:
coyotte508 2021-10-14 22:23:29 +02:00
commit fc00a499c5
3 changed files with 11 additions and 2 deletions

2
viewer/.gitignore vendored
View file

@ -19,3 +19,5 @@ pnpm-debug.log*
*.njsproj
*.sln
*.sw?
.env

View file

@ -1,6 +1,7 @@
import { move as execMove, Move, setup, stripSecret } from 'container-engine';
import { GameState, move as execMove, Move, setup, stripSecret } from 'container-engine';
import { moveAI } from 'container-engine/src/engine';
import { cloneDeep } from 'lodash';
import AbstractJudge from '../../engine/src/fixtures/Abstract-judge-7215.json';
import launch from './launch';
function launchSelfContained(selector = '#app') {
@ -14,12 +15,17 @@ function launchSelfContained(selector = '#app') {
gameState.players[i].name = `Player ${i + 1}`;
}
const playerIndex = 1;
let playerIndex = 1;
for (const player of gameState.players) {
if (player.id != playerIndex) player.isAI = true;
}
if (process.env.VUE_APP_loadGame) {
gameState = AbstractJudge as GameState;
playerIndex = AbstractJudge.currentPlayers[0];
}
emitter.on('move', async (move: Move) => {
console.log('move received', move);
gameState = execMove(gameState, move, playerIndex);

View file

@ -11,6 +11,7 @@
"allowSyntheticDefaultImports": true,
"noImplicitAny": false,
"sourceMap": true,
"resolveJsonModule": true,
"baseUrl": ".",
"types": ["webpack-env", "mocha", "chai"],
"paths": {