diff --git a/src/common/CommonMancalaGame.ts b/src/common/CommonMancalaGame.ts index 29c7c4d..ea612fb 100644 --- a/src/common/CommonMancalaGame.ts +++ b/src/common/CommonMancalaGame.ts @@ -5,8 +5,8 @@ import { GRLastStoneInBank } from './game_rules/GRLastStoneInBank'; import { GRLastStoneInEmptyPit } from './game_rules/GRLastStoneInEmptyPit'; export class CommonMancalaGame extends MancalaGame { - constructor(player1Id: string, player2Id: string) { - super(new CommonBoard(), player1Id, player2Id, player1Id, [ + constructor(id: string, player1Id: string, player2Id: string) { + super(id, new CommonBoard(), player1Id, player2Id, player1Id, [ new GRLastStoneInEmptyPit(), new GRLastStoneInBank(), new GRClearBoardAtEnd() diff --git a/src/core/MancalaGame.ts b/src/core/MancalaGame.ts index e83ab6b..b73647b 100644 --- a/src/core/MancalaGame.ts +++ b/src/core/MancalaGame.ts @@ -4,6 +4,7 @@ import { GameRule } from './GameRule'; export type GameState = 'initial' | 'playing' | 'ended'; export class MancalaGame { + id: string; board: Board; player1Id: string; player2Id: string; @@ -12,6 +13,7 @@ export class MancalaGame { gameRules: GameRule[]; constructor( + id: string, board: Board, player1Id: string, player2Id: string, @@ -19,6 +21,7 @@ export class MancalaGame { gameRules: GameRule[], state: GameState = 'initial' ) { + this.id = id; this.board = board; this.player1Id = player1Id; this.player2Id = player2Id; @@ -193,6 +196,7 @@ export class MancalaGame { public static createFromMancalaGame(mancalaGame: MancalaGame): MancalaGame { return new MancalaGame( + mancalaGame.id, new Board( mancalaGame.board.playerPitCount, mancalaGame.board.initialStoneCountInPits, diff --git a/tests/MancalaGame.test.ts b/tests/MancalaGame.test.ts index 11088e4..22c6894 100644 --- a/tests/MancalaGame.test.ts +++ b/tests/MancalaGame.test.ts @@ -8,7 +8,7 @@ function createGame(): MancalaGame { const board = new Board(6, 4); const player1Id = '0'; const player2Id = '1'; - const game = new MancalaGame(board, player1Id, player2Id, player1Id, [ + const game = new MancalaGame('0', board, player1Id, player2Id, player1Id, [ new GRLastStoneInEmptyPit(), new GRLastStoneInBank(), new GRClearBoardAtEnd() diff --git a/tests/game_rules/GRClearBoardAtEnd.test.ts b/tests/game_rules/GRClearBoardAtEnd.test.ts index 65aa1c9..30f8109 100644 --- a/tests/game_rules/GRClearBoardAtEnd.test.ts +++ b/tests/game_rules/GRClearBoardAtEnd.test.ts @@ -8,7 +8,7 @@ function createGame(): MancalaGame { const board = new Board(6, 4); const player1Id = '0'; const player2Id = '1'; - const game = new MancalaGame(board, player1Id, player2Id, player1Id, [ + const game = new MancalaGame('0', board, player1Id, player2Id, player1Id, [ new GRLastStoneInEmptyPit(), new GRLastStoneInBank(), new GRClearBoardAtEnd()