Skip to content

Commit

Permalink
Increment score in checkForWin rather than endGame
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb531 committed Sep 5, 2021
1 parent e9bf976 commit 89e647e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
4 changes: 1 addition & 3 deletions app/scripts/models/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ class Game extends Emitter {

// End the game without resetting the grid
endGame() {
if (this.winner) {
this.winner.score += 1;
}
this.inProgress = false;
this.currentPlayer = null;
this.pendingChip = null;
Expand Down Expand Up @@ -189,6 +186,7 @@ class Game extends Emitter {
chip.winning = true;
});
this.winner = this.grid.lastPlacedChip.player;
this.winner.score += 1;
this.emit('game:declare-winner', this.winner);
this.endGame();
}
Expand Down
10 changes: 0 additions & 10 deletions test/game/end-game.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,4 @@ describe('game', function () {
expect(game.columnHistory).to.have.length(0);
});

it('should increment winner\'s score when ending', function () {
const game = new Game();
game.setPlayers({ gameType: '2P' });
game.startGame();
game.winner = game.players[0];
expect(game.winner.score).to.equal(0);
game.endGame();
expect(game.winner.score).to.equal(1);
});

});

0 comments on commit 89e647e

Please sign in to comment.