From 2a1160daa6d7993e65b8cb5eb2591aba0f8b46f9 Mon Sep 17 00:00:00 2001 From: Alex Kulcsar <38046796+alex-kulcsar@users.noreply.github.com> Date: Sat, 17 Feb 2024 10:25:20 -0500 Subject: [PATCH] Correct player indexing after adding Player Zero. --- main.ts | 5 ----- state.ts | 6 ++++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/main.ts b/main.ts index 1d979f8..9c9b11a 100644 --- a/main.ts +++ b/main.ts @@ -26,8 +26,6 @@ * - [ ] Add subclass of action menu for starting a turn with appropriate default actions. * - Trade * - Build/Mortgage - * - [X] Show ownership of a property with an overlay. - * - Bottom of tile, player name and color. * - [ ] Player select a space mechanism. * - [ ] Allow for restraints (*e.g.*, select only a property, select from one side of the board). * - [ ] Game select a random space mechanism. @@ -36,9 +34,6 @@ * - [ ] Production version cleanup. * - [ ] Remove viewing of action queue. * - [ ] Remove template board images from assets. - * - [X] Refactor player array in game state. - * - Player zero will be used when selecting a location on the board. - * - [X] When redeeming "Get out of jail free" card, place it at the bottom of the deck. */ /** diff --git a/state.ts b/state.ts index 2d787d4..6dacf95 100644 --- a/state.ts +++ b/state.ts @@ -112,7 +112,7 @@ class GameState { } public set CurrPlayer(value: number) { - if (value > 0 && value <= this.players.length) { + if (value > 0 && value < this.players.length) { this.currPlayer = value } } @@ -134,6 +134,7 @@ class GameState { } public get NumPlayers(): number { + // Player zero is for selecting return this.players.length - 1 } @@ -665,6 +666,7 @@ class GameState { protected initPlayerArray(): void { this.players = [] + // Player zero is for selecting a location on the board. let p: Player = new Player(0) p.Avatar = 0 this.players.push(p) @@ -672,7 +674,7 @@ class GameState { protected initPlayers(numPlayers: number): void { this.initPlayerArray() - for (let i: number = 0; i < numPlayers; i++) { + for (let i: number = 1; i <= numPlayers; i++) { let p: Player = new Player(i) if (this.speedDie || this.boardIndex > 0) { p.Bank = GameState.STARTING_BALANCES[1]