acey-deucey-game-engine
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -25,6 +25,10 @@ "use strict"; | ||
if (activePlayer.barPieces && proposedMove.isBar === false) { | ||
if (activePlayer.barPieces && !proposedMove.isBar) { | ||
return false; | ||
} | ||
if (!activePlayer.barPieces && proposedMove.isBar) { | ||
return false; | ||
} | ||
if ((isPlayerOne && proposedSpaceIndex > lastBoardSpace) || | ||
@@ -31,0 +35,0 @@ (!isPlayerOne && proposedSpaceIndex < firstBoardSpace) |
{ | ||
"name": "acey-deucey-game-engine", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "a game engine for the backgammon variant acey deucey", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -88,2 +88,3 @@ "use strict"; | ||
const gameState = getInitialGameState(); | ||
gameState.playerOne.barPieces = 1; | ||
const diceRoll = [5, 2]; | ||
@@ -105,2 +106,3 @@ | ||
gameState.isPlayerOne = false; | ||
gameState.playerTwo.barPieces = 1; | ||
const diceRoll = [5, 2]; | ||
@@ -107,0 +109,0 @@ |
@@ -295,3 +295,3 @@ "use strict"; | ||
t.test("player 1", t => { | ||
t.plan(2); | ||
t.plan(3); | ||
@@ -319,7 +319,16 @@ const gameState = getInitialGameState(); | ||
"the move is not valid when player 1 has a piece on the bar but does not move it" | ||
); | ||
); | ||
gameState.playerOne.barPieces = 0; | ||
gameState.playerOne.initialPieces = 15; | ||
t.equal( | ||
isValidMove(gameState, proposedMoveFromBar), | ||
false, | ||
"the move is not valid when player 1 has no bar piece" | ||
); | ||
}); | ||
t.test("player 2", t => { | ||
t.plan(2); | ||
t.plan(3); | ||
@@ -349,2 +358,11 @@ const gameState = getInitialGameState(); | ||
); | ||
gameState.playerTwo.barPieces = 0; | ||
gameState.playerTwo.initialPieces = 15; | ||
t.equal( | ||
isValidMove(gameState, proposedMoveFromBar), | ||
false, | ||
"the move is not valid when player 2 has no bar piece" | ||
); | ||
}); | ||
@@ -351,0 +369,0 @@ |
134463
2501