bug fix stopIndex%circle.length
This commit is contained in:
parent
fabc2ce07d
commit
fb12557ed7
@ -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%16, circle)
|
||||
const opponentHole = getOpponentHoleByIndex(stopIndex%circle.length, circle)
|
||||
|
||||
if (opponentHole.ballCount > 0) {
|
||||
ownStore.ballCount++
|
||||
|
||||
@ -47,4 +47,15 @@ describe('mancala', function () {
|
||||
expect(game.state).toBe("ended")
|
||||
expect(game.getWonPlayer()).toBe("player2")
|
||||
})
|
||||
|
||||
it('too many ball test', function () {
|
||||
const board = new Board(
|
||||
[new Hole(1), new Hole(1), new Hole(1), new Hole(1), new Hole(1), new Hole(1)],
|
||||
[new Hole(0), new Hole(0), new Hole(0), new Hole(0), new Hole(0), new Hole(12)],
|
||||
new Store(0), new Store(0))
|
||||
const game = new Game(player1, player2, board, "player2", "playing")
|
||||
game.moveByIndex(5, "player2")
|
||||
expect(game.turn).toBe("player1")
|
||||
expect(game.state).toBe("playing")
|
||||
})
|
||||
})
|
||||
Loading…
Reference in New Issue
Block a user