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.2.2 to 1.2.3

lib/createNewGame.d.ts

278

lib/createGameFromMoves.d.ts

@@ -1,276 +0,2 @@

import { Game, Move } from './types';
export declare const createNewWallMatrix: () => {
a: {
1: {
h: boolean;
v: boolean;
};
2: {
h: boolean;
v: boolean;
};
3: {
h: boolean;
v: boolean;
};
4: {
h: boolean;
v: boolean;
};
5: {
h: boolean;
v: boolean;
};
6: {
h: boolean;
v: boolean;
};
7: {
h: boolean;
v: boolean;
};
8: {
h: boolean;
v: boolean;
};
};
b: {
1: {
h: boolean;
v: boolean;
};
2: {
h: boolean;
v: boolean;
};
3: {
h: boolean;
v: boolean;
};
4: {
h: boolean;
v: boolean;
};
5: {
h: boolean;
v: boolean;
};
6: {
h: boolean;
v: boolean;
};
7: {
h: boolean;
v: boolean;
};
8: {
h: boolean;
v: boolean;
};
};
c: {
1: {
h: boolean;
v: boolean;
};
2: {
h: boolean;
v: boolean;
};
3: {
h: boolean;
v: boolean;
};
4: {
h: boolean;
v: boolean;
};
5: {
h: boolean;
v: boolean;
};
6: {
h: boolean;
v: boolean;
};
7: {
h: boolean;
v: boolean;
};
8: {
h: boolean;
v: boolean;
};
};
d: {
1: {
h: boolean;
v: boolean;
};
2: {
h: boolean;
v: boolean;
};
3: {
h: boolean;
v: boolean;
};
4: {
h: boolean;
v: boolean;
};
5: {
h: boolean;
v: boolean;
};
6: {
h: boolean;
v: boolean;
};
7: {
h: boolean;
v: boolean;
};
8: {
h: boolean;
v: boolean;
};
};
e: {
1: {
h: boolean;
v: boolean;
};
2: {
h: boolean;
v: boolean;
};
3: {
h: boolean;
v: boolean;
};
4: {
h: boolean;
v: boolean;
};
5: {
h: boolean;
v: boolean;
};
6: {
h: boolean;
v: boolean;
};
7: {
h: boolean;
v: boolean;
};
8: {
h: boolean;
v: boolean;
};
};
f: {
1: {
h: boolean;
v: boolean;
};
2: {
h: boolean;
v: boolean;
};
3: {
h: boolean;
v: boolean;
};
4: {
h: boolean;
v: boolean;
};
5: {
h: boolean;
v: boolean;
};
6: {
h: boolean;
v: boolean;
};
7: {
h: boolean;
v: boolean;
};
8: {
h: boolean;
v: boolean;
};
};
g: {
1: {
h: boolean;
v: boolean;
};
2: {
h: boolean;
v: boolean;
};
3: {
h: boolean;
v: boolean;
};
4: {
h: boolean;
v: boolean;
};
5: {
h: boolean;
v: boolean;
};
6: {
h: boolean;
v: boolean;
};
7: {
h: boolean;
v: boolean;
};
8: {
h: boolean;
v: boolean;
};
};
h: {
1: {
h: boolean;
v: boolean;
};
2: {
h: boolean;
v: boolean;
};
3: {
h: boolean;
v: boolean;
};
4: {
h: boolean;
v: boolean;
};
5: {
h: boolean;
v: boolean;
};
6: {
h: boolean;
v: boolean;
};
7: {
h: boolean;
v: boolean;
};
8: {
h: boolean;
v: boolean;
};
};
};
export declare const createGameFromMoves: (moves: Move[]) => Game;
import { Move } from './types';
export declare const createGameFromMoves: (moves: Move[]) => import("./types").Game;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createGameFromMoves = exports.createNewWallMatrix = void 0;
exports.createGameFromMoves = void 0;
var utils_1 = require("./utils");
var createNewBoard_1 = require("./createNewBoard");
var createNewPieceMatrix = function () { return ({
a: { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0 },
b: { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0 },
c: { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0 },
d: { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0 },
e: { 1: 1, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 2 },
f: { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0 },
g: { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0 },
h: { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0 },
i: { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0 },
}); };
var createNewWallMatrix = function () { return ({
a: {
1: { h: false, v: false },
2: { h: false, v: false },
3: { h: false, v: false },
4: { h: false, v: false },
5: { h: false, v: false },
6: { h: false, v: false },
7: { h: false, v: false },
8: { h: false, v: false },
},
b: {
1: { h: false, v: false },
2: { h: false, v: false },
3: { h: false, v: false },
4: { h: false, v: false },
5: { h: false, v: false },
6: { h: false, v: false },
7: { h: false, v: false },
8: { h: false, v: false },
},
c: {
1: { h: false, v: false },
2: { h: false, v: false },
3: { h: false, v: false },
4: { h: false, v: false },
5: { h: false, v: false },
6: { h: false, v: false },
7: { h: false, v: false },
8: { h: false, v: false },
},
d: {
1: { h: false, v: false },
2: { h: false, v: false },
3: { h: false, v: false },
4: { h: false, v: false },
5: { h: false, v: false },
6: { h: false, v: false },
7: { h: false, v: false },
8: { h: false, v: false },
},
e: {
1: { h: false, v: false },
2: { h: false, v: false },
3: { h: false, v: false },
4: { h: false, v: false },
5: { h: false, v: false },
6: { h: false, v: false },
7: { h: false, v: false },
8: { h: false, v: false },
},
f: {
1: { h: false, v: false },
2: { h: false, v: false },
3: { h: false, v: false },
4: { h: false, v: false },
5: { h: false, v: false },
6: { h: false, v: false },
7: { h: false, v: false },
8: { h: false, v: false },
},
g: {
1: { h: false, v: false },
2: { h: false, v: false },
3: { h: false, v: false },
4: { h: false, v: false },
5: { h: false, v: false },
6: { h: false, v: false },
7: { h: false, v: false },
8: { h: false, v: false },
},
h: {
1: { h: false, v: false },
2: { h: false, v: false },
3: { h: false, v: false },
4: { h: false, v: false },
5: { h: false, v: false },
6: { h: false, v: false },
7: { h: false, v: false },
8: { h: false, v: false },
},
}); };
exports.createNewWallMatrix = createNewWallMatrix;
var createNewGame_1 = require("./createNewGame");
var createGameFromMoves = function (moves) {
var game = {
board: createNewBoard_1.createNewBoard(),
pieceMatrix: createNewPieceMatrix(),
wallMatrix: exports.createNewWallMatrix(),
history: [],
playerPositions: { 1: { x: 'e', y: 1 }, 2: { x: 'e', y: 9 } },
playerWallCounts: { 1: 10, 2: 10 },
};
return moves.reduce(function (game, move) {
return utils_1.unvalidatedMove(game, move);
}, game);
return moves.reduce(utils_1.unvalidatedMove, createNewGame_1.createNewGame());
};
exports.createGameFromMoves = createGameFromMoves;

@@ -0,1 +1,2 @@

export { createNewGame } from './createNewGame';
export { createGameFromMoves } from './createGameFromMoves';

@@ -2,0 +3,0 @@ export { isMoveValid } from './isMoveValid';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isValidMove = exports.getAsciiRepresentation = exports.getTurn = exports.getValidMoveArray = exports.getWinner = exports.isGameOver = exports.makeMove = exports.getUnicodeRepresentation = exports.isMoveValid = exports.createGameFromMoves = void 0;
exports.isValidMove = exports.getAsciiRepresentation = 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");
Object.defineProperty(exports, "createNewGame", { enumerable: true, get: function () { return createNewGame_1.createNewGame; } });
var createGameFromMoves_1 = require("./createGameFromMoves");

@@ -5,0 +7,0 @@ Object.defineProperty(exports, "createGameFromMoves", { enumerable: true, get: function () { return createGameFromMoves_1.createGameFromMoves; } });

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

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

@@ -11,9 +11,42 @@ # quoridor.js

### getUnicodeRepresentation: (game: Game) => string
### createNewGame: () => Game
Returns a string representation of the board game state using Unicode box-drawing characters.
Generates a new game.
```TypeScript
import { createNewGame, getUnicodeRepresentation } from 'quoridor';
const game = createNewGame();
console.log(getUnicodeRepresentation(game));
// ┌───╫───╫───╫───╫───╫───╫───╫───╫───╫───╫───┐
// │ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ │
// │ ┌───┬───┬───┬───┬───┬───┬───┬───┬───┐ │
// │ 9 │ │ │ │ │ 2 │ │ │ │ │ │
// │ ├───┼───┼───┼───┼───┼───┼───┼───┼───┤ │
// │ 8 │ │ │ │ │ │ │ │ │ │ │
// │ ├───┼───┼───┼───┼───┼───┼───┼───┼───┤ │
// │ 7 │ │ │ │ │ │ │ │ │ │ │
// │ ├───┼───┼───┼───┼───┼───┼───┼───┼───┤ │
// │ 6 │ │ │ │ │ │ │ │ │ │ │
// │ ├───┼───┼───┼───┼───┼───┼───┼───┼───┤ │
// │ 5 │ │ │ │ │ │ │ │ │ │ │
// │ ├───┼───┼───┼───┼───┼───┼───┼───┼───┤ │
// │ 4 │ │ │ │ │ │ │ │ │ │ │
// │ ├───┼───┼───┼───┼───┼───┼───┼───┼───┤ │
// │ 3 │ │ │ │ │ │ │ │ │ │ │
// │ ├───┼───┼───┼───┼───┼───┼───┼───┼───┤ │
// │ 2 │ │ │ │ │ │ │ │ │ │ │
// │ ├───┼───┼───┼───┼───┼───┼───┼───┼───┤ │
// │ 1 │ │ │ │ │ 1 │ │ │ │ │ │
// │ └───┴───┴───┴───┴───┴───┴───┴───┴───┘ │
// │ ║ A ║ B ║ C ║ D ║ E ║ F ║ G ║ H ║ I ║ │
// └───╫───╫───╫───╫───╫───╫───╫───╫───╫───╫───┘
```
### createGameFromMoves: (moves: Move[]) => Game
Generates a game from an array of moves. Does not validate the moves.
Generates a game from an array of moves. Does not verify that the moves are valid.

@@ -53,2 +86,39 @@ ```TypeScript

### getUnicodeRepresentation: (game: Game) => string
Returns a string representation of the board game state using Unicode box-drawing characters.
```TypeScript
import { createNewGame, getUnicodeRepresentation } from 'quoridor';
const unicodeRepresentation = getUnicodeRepresentation(createNewGame())
console.log(unicodeRepresentation);
// ┌───╫───╫───╫───╫───╫───╫───╫───╫───╫───╫───┐
// │ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ │
// │ ┌───┬───┬───┬───┬───┬───┬───┬───┬───┐ │
// │ 9 │ │ │ │ │ 2 │ │ │ │ │ │
// │ ├───┼───┼───┼───┼───┼───┼───┼───┼───┤ │
// │ 8 │ │ │ │ │ │ │ │ │ │ │
// │ ├───┼───┼───┼───┼───┼───┼───┼───┼───┤ │
// │ 7 │ │ │ │ │ │ │ │ │ │ │
// │ ├───┼───┼───┼───┼───┼───┼───┼───┼───┤ │
// │ 6 │ │ │ │ │ │ │ │ │ │ │
// │ ├───┼───┼───┼───┼───┼───┼───┼───┼───┤ │
// │ 5 │ │ │ │ │ │ │ │ │ │ │
// │ ├───┼───┼───┼───┼───┼───┼───┼───┼───┤ │
// │ 4 │ │ │ │ │ │ │ │ │ │ │
// │ ├───┼───┼───┼───┼───┼───┼───┼───┼───┤ │
// │ 3 │ │ │ │ │ │ │ │ │ │ │
// │ ├───┼───┼───┼───┼───┼───┼───┼───┼───┤ │
// │ 2 │ │ │ │ │ │ │ │ │ │ │
// │ ├───┼───┼───┼───┼───┼───┼───┼───┼───┤ │
// │ 1 │ │ │ │ │ 1 │ │ │ │ │ │
// │ └───┴───┴───┴───┴───┴───┴───┴───┴───┘ │
// │ ║ A ║ B ║ C ║ D ║ E ║ F ║ G ║ H ║ I ║ │
// └───╫───╫───╫───╫───╫───╫───╫───╫───╫───╫───┘
```
### isMoveValid: (game: Game, move: Move) => boolean

@@ -62,4 +132,5 @@

const game = createGameFromMoves(['e2', 'e8', 'd7v']);
const move = 'd7';
const moveIsValid = isMoveValid(game, 'd7');
const moveIsValid = isMoveValid(game, move);

@@ -66,0 +137,0 @@ console.log(moveIsValid);

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