Skip to content

Commit

Permalink
Correct player indexing after adding Player Zero.
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-kulcsar committed Feb 17, 2024
1 parent 1509e7a commit 2a1160d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 0 additions & 5 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
*/

/**
Expand Down
6 changes: 4 additions & 2 deletions state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -134,6 +134,7 @@ class GameState {
}

public get NumPlayers(): number {
// Player zero is for selecting
return this.players.length - 1
}

Expand Down Expand Up @@ -665,14 +666,15 @@ 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)
}

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]
Expand Down

0 comments on commit 2a1160d

Please sign in to comment.