fix getWonPlayerId
This commit is contained in:
parent
8ff703da15
commit
2550d3a36f
@ -198,17 +198,18 @@ export class MancalaGame {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getWonPlayerId(): string | null {
|
public getWonPlayerId(): string | undefined {
|
||||||
|
const player1StoneCount = this.board.player1Bank.stoneCount;
|
||||||
|
const player2StoneCount = this.board.player2Bank.stoneCount;
|
||||||
if (this.checkGameIsEnded()) {
|
if (this.checkGameIsEnded()) {
|
||||||
if (
|
if (player1StoneCount === player2StoneCount) {
|
||||||
this.board.player1Bank.stoneCount > this.board.player2Bank.stoneCount
|
return undefined;
|
||||||
) {
|
} else if (player1StoneCount > player2StoneCount) {
|
||||||
return this.player1Id;
|
return this.player1Id;
|
||||||
} else {
|
} else {
|
||||||
return this.player2Id;
|
return this.player2Id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static createFromMancalaGame(mancalaGame: MancalaGame): MancalaGame {
|
public static createFromMancalaGame(mancalaGame: MancalaGame): MancalaGame {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user