Comparing version 1.6.3 to 1.6.4
@@ -1142,2 +1142,4 @@ "use strict"; | ||
var thatTurn = exports.getOppositePlayer(getTurn_1.getTurn(game)); | ||
var thisPlayersCurrentPosition = game.playerPositions[thisTurn]; | ||
var thatPlayersCurrentPosition = game.playerPositions[thatTurn]; | ||
var thisPlayersShortestPath = exports.shortestPath(game, thisTurn); | ||
@@ -1153,11 +1155,18 @@ var thatPlayersShortestPath = exports.shortestPath(game, thatTurn); | ||
return false; | ||
if (!overlapsPath(thisPlayersShortestPath, wallMove) && | ||
!overlapsPath(thatPlayersShortestPath, wallMove)) { | ||
if ( | ||
/** | ||
* shortestPath returns a list of moves, so it does not include the | ||
* initial position. We need the initial position here to check if a | ||
* wall blocks the first step of a path. To simplify this, consider | ||
* changing shortestPath to include the initial position in the path. | ||
*/ | ||
!overlapsPath(__spreadArray([thisPlayersCurrentPosition], thisPlayersShortestPath), wallMove) && | ||
!overlapsPath(__spreadArray([thatPlayersCurrentPosition], thatPlayersShortestPath), wallMove)) { | ||
return true; | ||
} | ||
var gameWithUnvalidatedMove = exports.unvalidatedMove(game, wallMove); | ||
var thisTurn = getTurn_1.getTurn(game); | ||
var thatTurn = exports.getOppositePlayer(getTurn_1.getTurn(game)); | ||
var thisShortestPath = exports.shortestPath(gameWithUnvalidatedMove, thisTurn); | ||
var thatShortestPath = exports.shortestPath(gameWithUnvalidatedMove, thatTurn); | ||
var thisTurnAfterMove = getTurn_1.getTurn(game); | ||
var thatTurnAfterMove = exports.getOppositePlayer(getTurn_1.getTurn(game)); | ||
var thisShortestPath = exports.shortestPath(gameWithUnvalidatedMove, thisTurnAfterMove); | ||
var thatShortestPath = exports.shortestPath(gameWithUnvalidatedMove, thatTurnAfterMove); | ||
return Boolean(thisShortestPath && thatShortestPath); | ||
@@ -1164,0 +1173,0 @@ }); |
{ | ||
"name": "quoridor", | ||
"version": "1.6.3", | ||
"version": "1.6.4", | ||
"description": "A JavaScipt Quoridor library for move validation etc.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
118196
2509