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 1.6.7 to 1.6.8

lib/makeUnvalidatedMove.d.ts

4

lib/createGameFromMoves.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createGameFromMoves = void 0;
var utils_1 = require("./utils");
var createNewGame_1 = require("./createNewGame");
var makeUnvalidatedMove_1 = require("./makeUnvalidatedMove");
var createGameFromMoves = function (moves) {
return moves.reduce(utils_1.unvalidatedMove, createNewGame_1.createNewGame());
return moves.reduce(makeUnvalidatedMove_1.makeUnvalidatedMove, createNewGame_1.createNewGame());
};
exports.createGameFromMoves = createGameFromMoves;

@@ -13,2 +13,3 @@ export { createNewGame } from './createNewGame';

export { isMove } from './isMove';
export { makeUnvalidatedMove } from './makeUnvalidatedMove';
/**

@@ -15,0 +16,0 @@ * Deprecated. This function has been renamed to getUnicodeRepresentation.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.undoLastMove = exports.isValidMove = exports.getAsciiRepresentation = exports.isMove = exports.redo = exports.undo = exports.getTurn = exports.getValidMoveArray = exports.getWinner = exports.isGameOver = exports.makeMove = exports.getUnicodeRepresentation = exports.isMoveValid = exports.createGameFromMoves = exports.createNewGame = void 0;
exports.undoLastMove = exports.isValidMove = exports.getAsciiRepresentation = exports.makeUnvalidatedMove = exports.isMove = exports.redo = exports.undo = exports.getTurn = exports.getValidMoveArray = exports.getWinner = exports.isGameOver = exports.makeMove = exports.getUnicodeRepresentation = exports.isMoveValid = exports.createGameFromMoves = exports.createNewGame = void 0;
var createNewGame_1 = require("./createNewGame");

@@ -28,2 +28,4 @@ Object.defineProperty(exports, "createNewGame", { enumerable: true, get: function () { return createNewGame_1.createNewGame; } });

Object.defineProperty(exports, "isMove", { enumerable: true, get: function () { return isMove_1.isMove; } });
var makeUnvalidatedMove_1 = require("./makeUnvalidatedMove");
Object.defineProperty(exports, "makeUnvalidatedMove", { enumerable: true, get: function () { return makeUnvalidatedMove_1.makeUnvalidatedMove; } });
var getUnicodeRepresentation_2 = require("./getUnicodeRepresentation");

@@ -30,0 +32,0 @@ var isMoveValid_2 = require("./isMoveValid");

@@ -5,2 +5,3 @@ "use strict";

var getTurn_1 = require("./getTurn");
var makeUnvalidatedMove_1 = require("./makeUnvalidatedMove");
var utils_1 = require("./utils");

@@ -15,3 +16,3 @@ var isMoveValid = function (game, move) {

return false; // Check that wall does not overlap other walls
var gameWithUnvalidatedMove = utils_1.unvalidatedMove(game, move);
var gameWithUnvalidatedMove = makeUnvalidatedMove_1.makeUnvalidatedMove(game, move);
if (utils_1.shortestPath(gameWithUnvalidatedMove, getTurn_1.getTurn(game)) &&

@@ -18,0 +19,0 @@ utils_1.shortestPath(gameWithUnvalidatedMove, utils_1.getOppositePlayer(getTurn_1.getTurn(game)))) {

@@ -5,8 +5,8 @@ "use strict";

var isMoveValid_1 = require("./isMoveValid");
var utils_1 = require("./utils");
var makeUnvalidatedMove_1 = require("./makeUnvalidatedMove");
var makeMove = function (game, move) {
if (!isMoveValid_1.isMoveValid(game, move))
return game;
return utils_1.unvalidatedMove(game, move);
return makeUnvalidatedMove_1.makeUnvalidatedMove(game, move);
};
exports.makeMove = makeMove;

@@ -13,3 +13,2 @@ import { Game, HorizontalPiecePosition, HorizontalWallPosition, Move, MoveObject, PawnMove, PawnPosition, Player, WallMove, WallOrientation, WallPosition } from './types';

export declare const getOppositePlayer: (player: Player) => 1 | 2;
export declare const unvalidatedMove: (game: Game, move: Move) => Game;
export declare const isValidNormalMove: (game: Game, currentPosition: PawnPosition, move: PawnMove) => boolean;

@@ -16,0 +15,0 @@ export declare const shortestPath: (game: Game, player: Player) => {

"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {

@@ -19,5 +8,6 @@ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)

Object.defineProperty(exports, "__esModule", { value: true });
exports.rest = exports.last = exports.first = exports.butlast = exports.getValidWallMoveArray = exports.getValidPawnMoveArray = exports.shortestPath = exports.isValidNormalMove = exports.unvalidatedMove = exports.getOppositePlayer = exports.isWallPosition = exports.doesWallMoveOverlapExistingWall = exports.moveObjectToMove = exports.getWallOrientation = exports.getVerticalCoordinate = exports.getHorizontalCoordinate = void 0;
exports.rest = exports.last = exports.first = exports.butlast = exports.getValidWallMoveArray = exports.getValidPawnMoveArray = exports.shortestPath = exports.isValidNormalMove = exports.getOppositePlayer = exports.isWallPosition = exports.doesWallMoveOverlapExistingWall = exports.moveObjectToMove = exports.getWallOrientation = exports.getVerticalCoordinate = exports.getHorizontalCoordinate = void 0;
var aStar_1 = require("./aStar");
var getTurn_1 = require("./getTurn");
var makeUnvalidatedMove_1 = require("./makeUnvalidatedMove");
var getHorizontalCoordinate = function (move) {

@@ -241,25 +231,2 @@ return move.charAt(0);

exports.getOppositePlayer = getOppositePlayer;
var unvalidatedMove = function (game, move) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
var currentPosition = game.playerPositions[getTurn_1.getTurn(game)];
if (exports.isWallPosition(move)) {
// If wall move
return __assign(__assign({}, game), { board: __assign(__assign({}, game.board), (_a = {}, _a[move] = true, _a)), wallMatrix: __assign(__assign({}, game.wallMatrix), (_b = {}, _b[exports.getHorizontalCoordinate(move)] = __assign(__assign({}, game.wallMatrix[exports.getHorizontalCoordinate(move)]), (_c = {}, _c[exports.getVerticalCoordinate(move)] = __assign(__assign({}, game.wallMatrix[exports.getHorizontalCoordinate(move)][exports.getVerticalCoordinate(move)]), (_d = {}, _d[exports.getWallOrientation(move)] = true, _d)), _c)), _b)), playerWallCounts: __assign(__assign({}, game.playerWallCounts), (_e = {}, _e[getTurn_1.getTurn(game)] = game.playerWallCounts[getTurn_1.getTurn(game)] - 1, _e)), playerPositions: __assign(__assign({}, game.playerPositions), (_f = {}, _f[getTurn_1.getTurn(game)] = __assign(__assign({}, game.playerPositions[getTurn_1.getTurn(game)]), { previousPosition: game.playerPositions[getTurn_1.getTurn(game)] }), _f)), pastMoves: __spreadArray(__spreadArray([], game.pastMoves), [move]), futureMoves: [] });
}
else {
var pieceMatrixWithRemovedPiece = __assign(__assign({}, game.pieceMatrix), (_g = {}, _g[currentPosition.x] = __assign(__assign({}, game.pieceMatrix[currentPosition.x]), (_h = {}, _h[currentPosition.y] = 0, _h)), _g));
return __assign(__assign({}, game), { board: Object.fromEntries(Object.entries(game.board).map(function (_a) {
var pos = _a[0], val = _a[1];
return [
pos,
pos === move ? getTurn_1.getTurn(game) : val === getTurn_1.getTurn(game) ? null : val,
];
})), playerPositions: __assign(__assign({}, game.playerPositions), (_j = {}, _j[getTurn_1.getTurn(game)] = {
x: exports.getHorizontalCoordinate(move),
y: exports.getVerticalCoordinate(move),
previousPosition: game.playerPositions[getTurn_1.getTurn(game)],
}, _j)), pastMoves: __spreadArray(__spreadArray([], game.pastMoves), [move]), futureMoves: [], pieceMatrix: __assign(__assign({}, pieceMatrixWithRemovedPiece), (_k = {}, _k[exports.getHorizontalCoordinate(move)] = __assign(__assign({}, pieceMatrixWithRemovedPiece[exports.getHorizontalCoordinate(move)]), (_l = {}, _l[exports.getVerticalCoordinate(move)] = getTurn_1.getTurn(game), _l)), _k)) });
}
};
exports.unvalidatedMove = unvalidatedMove;
var isSingleUpMove = function (currentPosition, move) {

@@ -1271,3 +1238,3 @@ if (exports.getVerticalCoordinate(currentPosition) - exports.getVerticalCoordinate(move) ===

}
var gameWithUnvalidatedMove = exports.unvalidatedMove(game, wallMove);
var gameWithUnvalidatedMove = makeUnvalidatedMove_1.makeUnvalidatedMove(game, wallMove);
var thisTurnAfterMove = getTurn_1.getTurn(game);

@@ -1274,0 +1241,0 @@ var thatTurnAfterMove = exports.getOppositePlayer(getTurn_1.getTurn(game));

{
"name": "quoridor",
"version": "1.6.7",
"version": "1.6.8",
"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