Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

quoridor

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quoridor - npm Package Compare versions

Comparing version 2.6.0 to 2.6.1

lib/mutable/getValidWallMoveArray.d.ts

3

lib/immutable/utils.d.ts

@@ -52,2 +52,3 @@ import { DecrementableHorizontalWallCoordinate, DecrementableVerticalWallCoordinate, Game, HorizontallyDecrementablePawnPosition, HorizontallyDecrementableWallPosition, HorizontallyIncrementablePawnPosition, HorizontalPiecePosition, HorizontalWallCoordinate, IncrementableHorizontalWallCoordinate, IncrementableVerticalWallCoordinate, PawnMove, PawnPosition, Player, VerticallyDecrementablePawnPosition, VerticallyDecrementableWallPosition, VerticallyIncrementablePawnPosition, VerticalPiecePosition, VerticalWallCoordinate, WallMove, WallOrientation, WallPosition } from '../types';

export declare const getValidPawnMoveArray: (game: Game) => PawnPosition[];
export declare const overlapsWall: (game: Game, wallMove: WallMove) => boolean;
export declare const moveWallLeft: (wall: HorizontallyDecrementableWallPosition) => WallPosition;

@@ -57,2 +58,3 @@ export declare const moveWallDown: (wall: VerticallyDecrementableWallPosition) => WallPosition;

export declare const isWallAdjacentToAtLeastOnePawn: (game: Game, wall: WallPosition) => boolean;
export declare const doesWallMoveHaveSameDirectionAsAllPreviousWallMoves: (game: Game, wallMove: WallMove) => boolean;
export declare const isHorizontalWallCoordinate: (horizontalPosition: HorizontalPiecePosition | HorizontalWallCoordinate) => horizontalPosition is HorizontalWallCoordinate;

@@ -65,2 +67,3 @@ export declare const isVerticalWallCoordinate: (verticalPosition: VerticalPiecePosition | VerticalWallCoordinate) => verticalPosition is VerticalWallCoordinate;

export declare const overlapsPath: (path: PawnPosition[], wallMove: WallPosition) => boolean;
export declare const getNumberOfPlacedWalls: (game: Game) => number;
export declare const getValidWallMoveArray: (game: Game) => WallPosition[];

@@ -67,0 +70,0 @@ export declare const butlast: <T>(array: T[]) => T[];

32

lib/immutable/utils.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getValidWallMoveArray = exports.overlapsPath = exports.isVerticallyDecrementableWallPosition = exports.isHorizontallyDecrementableWallPosition = exports.isDecrementableVerticalWallCoordinate = exports.isDecrementableHorizontalWallCoordinate = exports.isVerticalWallCoordinate = exports.isHorizontalWallCoordinate = exports.isWallAdjacentToAtLeastOnePawn = exports.getNumberOfNeighborWalls = exports.moveWallDown = exports.moveWallLeft = exports.getValidPawnMoveArray = exports.getPositionFromNorthWestMove = exports.getPositionFromWestMove = exports.getPositionFromWestWestMove = exports.getPositionFromSouthWestMove = exports.getPositionFromSouthSouthMove = exports.getPositionFromSouthMove = exports.getPositionFromSouthEastMove = exports.getPositionFromEastEastMove = exports.getPositionFromEastMove = exports.getPositionFromNorthEastMove = exports.getPositionFromNorthNorthMove = exports.getPositionFromNorthMove = exports.isHorizontallyDecrementablePawnPosition = exports.horizontallyDecrementPawnPosition = exports.isHorizontallyIncrementablePawnPosition = exports.horizontallyIncrementPawnPosition = exports.isVerticallyDecrementablePawnPosition = exports.verticallyDecrementPawnPosition = exports.isVerticallyIncrementablePawnPosition = exports.verticallyIncrementPawnPosition = exports.doesHorizontalWallBlockPlayer = exports.getShortestPathWithNoObstacles = exports.isValidNormalMove = exports.isValidAStarMove = exports.hasWallBelow = exports.hasWallToTheRight = exports.getOppositePlayer = exports.isWallPosition = exports.doesWallMoveOverlapExistingWall = exports.isPawnMove = exports.isHorizontalWallMove = exports.decrementVerticalWallCoordinate = exports.decrementHorizontalWallCoordinate = exports.getWallOrientation = exports.getVerticalCoordinate = exports.getHorizontalCoordinate = exports.mirrorPositionHorizontally = void 0;
exports.rest = exports.last = exports.first = exports.butlast = void 0;
exports.isVerticallyDecrementableWallPosition = exports.isHorizontallyDecrementableWallPosition = exports.isDecrementableVerticalWallCoordinate = exports.isDecrementableHorizontalWallCoordinate = exports.isVerticalWallCoordinate = exports.isHorizontalWallCoordinate = exports.doesWallMoveHaveSameDirectionAsAllPreviousWallMoves = exports.isWallAdjacentToAtLeastOnePawn = exports.getNumberOfNeighborWalls = exports.moveWallDown = exports.moveWallLeft = exports.overlapsWall = exports.getValidPawnMoveArray = exports.getPositionFromNorthWestMove = exports.getPositionFromWestMove = exports.getPositionFromWestWestMove = exports.getPositionFromSouthWestMove = exports.getPositionFromSouthSouthMove = exports.getPositionFromSouthMove = exports.getPositionFromSouthEastMove = exports.getPositionFromEastEastMove = exports.getPositionFromEastMove = exports.getPositionFromNorthEastMove = exports.getPositionFromNorthNorthMove = exports.getPositionFromNorthMove = exports.isHorizontallyDecrementablePawnPosition = exports.horizontallyDecrementPawnPosition = exports.isHorizontallyIncrementablePawnPosition = exports.horizontallyIncrementPawnPosition = exports.isVerticallyDecrementablePawnPosition = exports.verticallyDecrementPawnPosition = exports.isVerticallyIncrementablePawnPosition = exports.verticallyIncrementPawnPosition = exports.doesHorizontalWallBlockPlayer = exports.getShortestPathWithNoObstacles = exports.isValidNormalMove = exports.isValidAStarMove = exports.hasWallBelow = exports.hasWallToTheRight = exports.getOppositePlayer = exports.isWallPosition = exports.doesWallMoveOverlapExistingWall = exports.isPawnMove = exports.isHorizontalWallMove = exports.decrementVerticalWallCoordinate = exports.decrementHorizontalWallCoordinate = exports.getWallOrientation = exports.getVerticalCoordinate = exports.getHorizontalCoordinate = exports.mirrorPositionHorizontally = void 0;
exports.rest = exports.last = exports.first = exports.butlast = exports.getValidWallMoveArray = exports.getNumberOfPlacedWalls = exports.overlapsPath = void 0;
var consts_1 = require("./consts");

@@ -691,16 +691,3 @@ var getShortestPath_1 = require("./getShortestPath");

}
var validPawnMoveArray = [
(0, exports.getPositionFromNorthMove)(currentPosition),
(0, exports.getPositionFromNorthNorthMove)(currentPosition),
(0, exports.getPositionFromNorthEastMove)(currentPosition),
(0, exports.getPositionFromEastMove)(currentPosition),
(0, exports.getPositionFromEastEastMove)(currentPosition),
(0, exports.getPositionFromSouthEastMove)(currentPosition),
(0, exports.getPositionFromSouthMove)(currentPosition),
(0, exports.getPositionFromSouthSouthMove)(currentPosition),
(0, exports.getPositionFromSouthWestMove)(currentPosition),
(0, exports.getPositionFromWestMove)(currentPosition),
(0, exports.getPositionFromWestWestMove)(currentPosition),
(0, exports.getPositionFromNorthWestMove)(currentPosition),
].filter(function (newPosition) {
var validPawnMoveArray = unvalidatedPawnMoveArray.filter(function (newPosition) {
return newPosition && (0, exports.isValidNormalMove)(game, currentPosition, newPosition);

@@ -712,3 +699,3 @@ });

var overlapsWall = function (game, wallMove) {
var numberOfPlacedWalls = getNumberOfPlacedWalls(game);
var numberOfPlacedWalls = (0, exports.getNumberOfPlacedWalls)(game);
if (numberOfPlacedWalls === 0)

@@ -741,2 +728,3 @@ return false;

};
exports.overlapsWall = overlapsWall;
var moveWallRight = function (wall) {

@@ -1153,2 +1141,3 @@ var x = wall.charAt(0);

};
exports.doesWallMoveHaveSameDirectionAsAllPreviousWallMoves = doesWallMoveHaveSameDirectionAsAllPreviousWallMoves;
var isHorizontalWallCoordinate = function (horizontalPosition) {

@@ -1264,2 +1253,3 @@ return consts_1.isHorizontalWallCoordinateMap[horizontalPosition];

};
exports.getNumberOfPlacedWalls = getNumberOfPlacedWalls;
var getValidWallMoveArray = function (game) {

@@ -1271,7 +1261,7 @@ var thisTurn = (0, getTurn_1.getTurn)(game);

var thatTurn = (0, exports.getOppositePlayer)(thisTurn);
var numberOfPlacedWalls = getNumberOfPlacedWalls(game);
var numberOfPlacedWalls = (0, exports.getNumberOfPlacedWalls)(game);
if (numberOfPlacedWalls <= 2) {
if (!consts_1.possiblyTrappedPositions[(numberOfPlacedWalls + 1)].has(game.playerPositions[1].position) &&
!consts_1.possiblyTrappedPositions[(numberOfPlacedWalls + 1)].has(game.playerPositions[2].position)) {
return consts_1.wallPositions.filter(function (wallMove) { return !overlapsWall(game, wallMove); });
return consts_1.wallPositions.filter(function (wallMove) { return !(0, exports.overlapsWall)(game, wallMove); });
}

@@ -1290,3 +1280,3 @@ // TODO: We could have a similar lookup map to see if a wall position is

return consts_1.wallPositions.filter(function (wallMove) {
if (overlapsWall(game, wallMove))
if ((0, exports.overlapsWall)(game, wallMove))
return false;

@@ -1297,3 +1287,3 @@ if (!(0, exports.overlapsPath)(thisPlayersShortestPath, wallMove) &&

}
if (doesWallMoveHaveSameDirectionAsAllPreviousWallMoves(game, wallMove)) {
if ((0, exports.doesWallMoveHaveSameDirectionAsAllPreviousWallMoves)(game, wallMove)) {
return true;

@@ -1300,0 +1290,0 @@ }

@@ -8,3 +8,3 @@ export { createNewGame } from './immutable/createNewGame';

export { getWinner } from './immutable/getWinner';
export { getValidMoveArray } from './immutable/getValidMoveArray';
export { getValidMoveArray } from './mutable/getValidMoveArray';
export { getTurn } from './immutable/getTurn';

@@ -11,0 +11,0 @@ export { undo } from './immutable/undo';

@@ -18,3 +18,3 @@ "use strict";

Object.defineProperty(exports, "getWinner", { enumerable: true, get: function () { return getWinner_1.getWinner; } });
var getValidMoveArray_1 = require("./immutable/getValidMoveArray");
var getValidMoveArray_1 = require("./mutable/getValidMoveArray");
Object.defineProperty(exports, "getValidMoveArray", { enumerable: true, get: function () { return getValidMoveArray_1.getValidMoveArray; } });

@@ -21,0 +21,0 @@ var getTurn_1 = require("./immutable/getTurn");

@@ -5,10 +5,11 @@ "use strict";

var isGameOver_1 = require("../immutable/isGameOver");
var utils_1 = require("../immutable/utils");
var getValidWallMoveArray_1 = require("./getValidWallMoveArray");
var getValidPawnMoveArray_1 = require("./getValidPawnMoveArray");
var getValidMoveArray = function (game) {
if ((0, isGameOver_1.isGameOver)(game))
return [];
var validPawnMoveArray = (0, utils_1.getValidPawnMoveArray)(game);
var validWallMoveArray = (0, utils_1.getValidWallMoveArray)(game);
var validPawnMoveArray = (0, getValidPawnMoveArray_1.getValidPawnMoveArray)(game);
var validWallMoveArray = (0, getValidWallMoveArray_1.getValidWallMoveArray)(game);
return validPawnMoveArray.concat(validWallMoveArray);
};
exports.getValidMoveArray = getValidMoveArray;

@@ -28,16 +28,3 @@ "use strict";

}
var validPawnMoveArray = [
(0, utils_1.getPositionFromNorthMove)(currentPosition),
(0, utils_1.getPositionFromNorthNorthMove)(currentPosition),
(0, utils_1.getPositionFromNorthEastMove)(currentPosition),
(0, utils_1.getPositionFromEastMove)(currentPosition),
(0, utils_1.getPositionFromEastEastMove)(currentPosition),
(0, utils_1.getPositionFromSouthEastMove)(currentPosition),
(0, utils_1.getPositionFromSouthMove)(currentPosition),
(0, utils_1.getPositionFromSouthSouthMove)(currentPosition),
(0, utils_1.getPositionFromSouthWestMove)(currentPosition),
(0, utils_1.getPositionFromWestMove)(currentPosition),
(0, utils_1.getPositionFromWestWestMove)(currentPosition),
(0, utils_1.getPositionFromNorthWestMove)(currentPosition),
].filter(function (newPosition) {
var validPawnMoveArray = unvalidatedPawnMoveArray.filter(function (newPosition) {
return newPosition && (0, utils_1.isValidNormalMove)(game, currentPosition, newPosition);

@@ -44,0 +31,0 @@ });

{
"name": "quoridor",
"version": "2.6.0",
"version": "2.6.1",
"description": "A JavaScipt Quoridor library for move validation etc.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc