From 0254cfdf4a2eef74250bfb6d8f4d782a0a068cec Mon Sep 17 00:00:00 2001 From: jhalitaksoy Date: Sun, 4 Jul 2021 01:52:10 +0300 Subject: [PATCH] added who won text --- src/mancala.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/mancala.ts b/src/mancala.ts index 5eee132..5cea747 100644 --- a/src/mancala.ts +++ b/src/mancala.ts @@ -74,7 +74,7 @@ export class Game { //check if it was 0 before if (stopHole.ballCount == 1) { const ownStore = getOwnStore(circle) - const opponentHole = getOpponentHoleByIndex(stopIndex%circle.length, circle) + const opponentHole = getOpponentHoleByIndex(stopIndex%16, circle) if (opponentHole.ballCount > 0) { ownStore.ballCount++ @@ -144,9 +144,9 @@ export class Game { const player2BallCount = this.board.player2Store.ballCount if(player1BallCount < player2BallCount){ - return this.getPlayerKeyByName("player1") - }else if(player1BallCount > player2BallCount) { return this.getPlayerKeyByName("player2") + }else if(player1BallCount > player2BallCount) { + return this.getPlayerKeyByName("player1") }else{ return undefined } @@ -166,6 +166,10 @@ export function createGame(player1: string, player2: string) { // [new Hole(4), new Hole(4), new Hole(4), new Hole(4), new Hole(4), new Hole(1)], // [new Hole(1), new Hole(0), new Hole(0), new Hole(0), new Hole(1), new Hole(0)], // new Store(0), new Store(0)) + // const board = new Board( + // [new Hole(1), new Hole(1), new Hole(1), new Hole(1), new Hole(1), new Hole(1)], + // [new Hole(1), new Hole(1), new Hole(1), new Hole(1), new Hole(1), new Hole(1)], + // new Store(0), new Store(0)) return new Game(player1, player2, board, "player1", "playing") }