Can now set the power a game should run as

When creating a game.json, you can set the top level key "power" to any
valid key of PowerENUM and the game will always run from that power's
perspective.
This commit is contained in:
Tyler Marques 2025-05-30 12:06:04 -07:00
parent 32cce1bce0
commit 8c2d778065
No known key found for this signature in database
GPG key ID: CB99EDCF41D3016F
3 changed files with 8 additions and 4 deletions

View file

@ -97,7 +97,7 @@ class GameState {
constructor(boardName: AvailableMaps) {
this.phaseIndex = 0
this.boardName = boardName
this.currentPower = getRandomPower()
this.currentPower = null;
this.gameId = 1
// State locks
this.isSpeaking = false
@ -156,6 +156,8 @@ class GameState {
playBtn.disabled = false;
speedSelector.disabled = false;
// Set the poewr if the game specifies it, else random.
this.currentPower = this.gameData.power !== undefined ? this.gameData.power : getRandomPower();
const momentsFilePath = `./games/${this.gameId}/moments.json`;

View file

@ -46,6 +46,9 @@ function initScene() {
// Load default game file if in debug mode
if (config.isDebugMode || isStreamingMode) {
gameState.loadGameFile(0);
// Initialize info panel
logger.updateInfoPanel();
}
// Initialize debug menu if in debug mode
@ -69,8 +72,6 @@ function initScene() {
// Kick off animation loop
animate();
// Initialize info panel
logger.updateInfoPanel();
}
function createCameraPan(): Group {

View file

@ -1,5 +1,5 @@
import { z } from 'zod';
import { PowerENUMSchema } from './map';
import { PowerENUM, PowerENUMSchema } from './map';
import { OrderFromString } from './unitOrders';
import { ProvinceENUMSchema } from './map';
@ -67,6 +67,7 @@ const PhaseSchema = z.object({
export const GameSchema = z.object({
map: z.string(),
id: z.string(),
power: PowerENUMSchema.optional(),
phases: z.array(PhaseSchema),
});