Skip to content

Commit

Permalink
fix: decrease pieces on capture
Browse files Browse the repository at this point in the history
  • Loading branch information
kacperwyczawski committed Aug 20, 2024
1 parent def0111 commit df6fde5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/game/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ export default class Game {
throw new Error();
}

if (this.board.cellAt(point).piece) {
this.previousPlayer.pieces--;
}

this.board.cellAt(point).piece = this.board.cellAt(
this.#selectedPoint,
).piece;
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ function updateValue(element: HTMLElement, newValue: string) {
}

function renderGame() {
updateValue(q(`#${game.currentPlayer.color} .pieces`), game.currentPlayer.pieces.toString());
updateValue(q(`#${game.previousPlayer.color} .pieces`), game.previousPlayer.pieces.toString());
updateValue(q(`#${game.previousPlayer.color} .gold`), game.previousPlayer.gold.toString());
updateValue(q(`#${game.previousPlayer.color} .gold-per-turn`), game.previousPlayer.goldPerTurn.toString());
Expand Down

0 comments on commit df6fde5

Please sign in to comment.