mancala/tests/game_rules/GRClearBoardAtEnd.test.ts

47 lines
1.5 KiB
TypeScript
Raw Normal View History

2022-05-08 16:57:59 +03:00
import {
GAME_STEP_LAST_STONE_IN_BANK,
GRLastStoneInBank
} from '../../src/common/game_rules/GRLastStoneInBank';
import {
GAME_STEP_LAST_STONE_IN_EMPTY_PIT,
GRLastStoneInEmptyPit
} from '../../src/common/game_rules/GRLastStoneInEmptyPit';
import {
GAME_STEP_BOARD_CLEARED,
GRClearBoardAtEnd
} from '../../src/common/game_rules/GRClearBoardAtEnd';
2022-05-04 15:04:59 +03:00
import { Board } from '../../src/core/Board';
2022-05-08 16:57:59 +03:00
import { GAME_STEP_GAME_MOVE, MancalaGame } from '../../src/core/MancalaGame';
import { GameStep } from '../../src/core/HistoryItem';
import { createGame } from '../TestUtil';
2022-05-04 15:04:59 +03:00
describe('GRClearBoardAtEnd Test', () => {
test('test GRClearBoardAtEnd 1', () => {
const game = createGame();
game.board.fillPlayer1Pits(0);
game.board.fillPlayer2Pits(0);
game.board.player1Pits[5].stoneCount = 1;
game.board.player2Pits[5].stoneCount = 1;
game.moveByPlayerPit('0', 5);
expect(game.board.player1Bank.stoneCount).toBe(2);
expect(game.board.player2Bank.stoneCount).toBe(0);
expect(
game.board.player1Pits
.map((pit) => pit.stoneCount)
.reduce((sum, stoneCount) => sum + stoneCount, 0)
).toBe(0);
expect(
game.board.player2Pits
.map((pit) => pit.stoneCount)
.reduce((sum, stoneCount) => sum + stoneCount, 0)
).toBe(0);
2022-05-08 16:59:58 +03:00
expect(game.history[0].gameSteps).toStrictEqual([
new GameStep(6, GAME_STEP_GAME_MOVE),
new GameStep(6, GAME_STEP_LAST_STONE_IN_BANK),
new GameStep(6, GAME_STEP_BOARD_CLEARED, {
pitIndexesThatHasStone: [12]
})
]);
2022-05-04 15:04:59 +03:00
});
});