add GrClearBoardAtEnd game rule
This commit is contained in:
parent
9902404ca8
commit
52e14c7e04
17
src/common/game_rules/GRClearBoardAtEnd.ts
Normal file
17
src/common/game_rules/GRClearBoardAtEnd.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { GameRule } from '../../core/GameRule';
|
||||||
|
import { MancalaGame } from '../../core/MancalaGame';
|
||||||
|
|
||||||
|
export class GRClearBoardAtEnd implements GameRule {
|
||||||
|
onGameMoveStart(game: MancalaGame, index: number): void {}
|
||||||
|
onGameMove(game: MancalaGame, index: number): void {}
|
||||||
|
onGameMoveEnd(game: MancalaGame, index: number): void {
|
||||||
|
if (game.getPlayer1StoneCountInPits() === 0) {
|
||||||
|
game.board.player1Bank.stoneCount += game.getPlayer2StoneCountInPits();
|
||||||
|
game.board.clearPlayer2Pits();
|
||||||
|
}
|
||||||
|
if (game.getPlayer2StoneCountInPits() === 0) {
|
||||||
|
game.board.player2Bank.stoneCount += game.getPlayer1StoneCountInPits();
|
||||||
|
game.board.clearPlayer1Pits();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user