Merge pull request #1 from jhalitaksoy/feature/game-id
feature : add id to MancalaGame
This commit is contained in:
commit
82dfe6fa96
@ -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()
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user