New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@chess-fu/chess-game

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chess-fu/chess-game - npm Package Compare versions

Comparing version 0.1.3 to 1.1.1

60

dist/src/chessGame.js

@@ -69,5 +69,4 @@ "use strict";

}
ChessGame.prototype.init = function (saveHeader) {
if (!saveHeader)
this._headers = {};
ChessGame.prototype.init = function () {
this._headers = {};
this._history = [];

@@ -81,2 +80,4 @@ this._board = EMPTY_BOARD();

this._castles = EMPTY_STRING;
this._cacheValid = false;
this._gameResult = constants_1.ONGOING;
};

@@ -88,3 +89,4 @@ ChessGame.prototype.load = function (fen) {

if (fen !== constants_1.START_FEN) {
this._headers = __assign({}, this._headers, { SetUp: '1', FEN: fen });
this._headers.SetUp = '1';
this._headers.FEN = fen;
}

@@ -164,3 +166,3 @@ };

}
return this._headers;
return __assign({}, this._headers, { Result: this._gameResult });
};

@@ -214,28 +216,23 @@ ChessGame.prototype.history = function (options) {

};
ChessGame.prototype.updated = function (saveResult) {
if (!saveResult) {
delete this._headers.Result;
}
ChessGame.prototype.updated = function () {
this._gameResult = constants_1.ONGOING;
this._cacheValid = false;
};
ChessGame.prototype.updateCachedState = function () {
if (this._cacheValid)
return;
this._cacheValid = true;
this._checked = this.testForCheck(this._turn);
this._noValidMoves = !this.hasValidMoves(this._turn);
if (!this.isOngoing()) {
return;
}
if (this.isAutomaticDraw()) {
this._headers.Result = constants_1.DRAW;
}
else {
if (this._noValidMoves) {
if (this._checked) {
this._headers.Result = this._turn === constants_1.WHITE ? constants_1.BLACK_WINS : constants_1.WHITE_WINS;
if (this._cacheValid !== true) {
this._cacheValid = true;
this._checked = this.testForCheck(this._turn);
this._noValidMoves = !this.hasValidMoves(this._turn);
if (this.isAutomaticDraw()) {
this._gameResult = constants_1.DRAW;
}
else {
if (this._noValidMoves) {
if (this._checked) {
this._gameResult = this._turn === constants_1.WHITE ? constants_1.BLACK_WINS : constants_1.WHITE_WINS;
}
else {
this._gameResult = constants_1.DRAW;
}
}
else {
this._headers.Result = constants_1.DRAW;
}
}

@@ -679,11 +676,5 @@ }

ChessGame.prototype.getResult = function () {
switch (this._headers.Result || constants_1.ONGOING) {
case constants_1.WHITE_WINS: return constants_1.WHITE_WINS;
case constants_1.BLACK_WINS: return constants_1.BLACK_WINS;
case constants_1.DRAW: return constants_1.DRAW;
default: return constants_1.ONGOING;
}
return this._gameResult;
};
ChessGame.prototype.assertOngoing = function () {
this.updateCachedState();
if (!this.isOngoing()) {

@@ -751,2 +742,3 @@ throw new Error("Invalid operation, game is over: " + this.getResult() + ".");

this._headers.Result = constants_1.DRAW;
this._gameResult = constants_1.DRAW;
};

@@ -753,0 +745,0 @@ ChessGame.prototype.isDraw = function () {

@@ -17,6 +17,7 @@ import { Move, MoveOptions, Offset, Color, GameResult } from './chessTypes';

private _cacheValid;
private _gameResult;
private _checked;
private _noValidMoves;
constructor(fen?: string);
init(saveHeader?: boolean): void;
private init;
load(fen?: string): void;

@@ -23,0 +24,0 @@ loadPgn(pgnGame: string): void;

{
"name": "@chess-fu/chess-game",
"access": "public",
"version": "0.1.3",
"version": "1.1.1",
"description": "Chess game logic",

@@ -6,0 +6,0 @@ "author": "chess-fu.com",

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