onix-chess
Advanced tools
Comparing version 6.5.4 to 6.5.5
@@ -0,1 +1,2 @@ | ||
import { Squares, Colors } from '../types/Types'; | ||
import { GameResult } from './GameResult'; | ||
@@ -6,3 +7,2 @@ import { Position } from './Position'; | ||
import { IGameData, IMovePart, ITreePart, IChessPlayer, IChessOpening } from '../types/Interfaces'; | ||
import { Squares, Colors } from '../types/Types'; | ||
export declare enum ChessRatingType { | ||
@@ -130,3 +130,3 @@ None = 0, | ||
static plyToColor(ply: number): Colors.BW; | ||
static turnToPly(turn: number, color?: number): number; | ||
static turnToPly(turn: number, color?: Colors.BW): number; | ||
} |
@@ -5,2 +5,3 @@ "use strict"; | ||
const toSafeInteger_1 = require("lodash-es/toSafeInteger"); | ||
const shortid = require("shortid"); | ||
const isNumber_1 = require("lodash-es/isNumber"); | ||
@@ -16,3 +17,3 @@ const indexOf_1 = require("lodash-es/indexOf"); | ||
const FenString_1 = require("./FenString"); | ||
const shortid = require("shortid"); | ||
const Common_1 = require("./Common"); | ||
var ChessRatingType; | ||
@@ -64,6 +65,6 @@ (function (ChessRatingType) { | ||
this.owner = owner; | ||
this.tags = {}; | ||
this.tags = new Map(); | ||
} | ||
clear() { | ||
this.tags = {}; | ||
this.tags.clear(); | ||
} | ||
@@ -101,3 +102,3 @@ add(name, value) { | ||
else { | ||
this.tags[name] = value; | ||
this.tags.set(name, value); | ||
} | ||
@@ -187,3 +188,3 @@ } | ||
get StartPlyCount() { | ||
return (this.startPos) ? this.startPos.PlyCount : 1; | ||
return (this.startPos) ? this.startPos.PlyCount + 1 : 1; | ||
} | ||
@@ -564,16 +565,9 @@ get RawData() { | ||
static plyToTurn(ply) { | ||
return toSafeInteger_1.default(1 + (ply - 1) / 2); | ||
return Common_1.plyToTurn(ply); | ||
} | ||
static plyToColor(ply) { | ||
if (ply === 0) { | ||
return Color_1.Color.White; | ||
} | ||
return ((ply % 2) == 1) ? Color_1.Color.White : Color_1.Color.Black; | ||
return Common_1.plyToColor(ply); | ||
} | ||
static turnToPly(turn, color) { | ||
if (turn === 0) { | ||
return 0; | ||
} | ||
color = color || Color_1.Color.White; | ||
return (((turn - 1) * 2) + color + 1); | ||
return Common_1.turnToPly(turn, color); | ||
} | ||
@@ -580,0 +574,0 @@ } |
@@ -10,2 +10,3 @@ "use strict"; | ||
const Castling_1 = require("./Castling"); | ||
const Common_1 = require("./Common"); | ||
// Forsite to piece map | ||
@@ -190,3 +191,3 @@ const fenPieces = { | ||
pos.HalfMoveCount = def.halfMoves; | ||
pos.setMoveNo(def.moveNo); | ||
pos.PlyCount = Common_1.turnToPly(def.moveNo, pos.WhoMove) - 1; | ||
return true; | ||
@@ -193,0 +194,0 @@ } |
@@ -98,10 +98,6 @@ import { Colors, Pieces, Squares } from '../types/Types'; | ||
/** | ||
* Get move number | ||
* Return current halfmove humber | ||
*/ | ||
getMoveNo(): number; | ||
set PlyCount(val: number); | ||
/** | ||
* Set move number | ||
*/ | ||
setMoveNo(no: number): void; | ||
/** | ||
* Make the move on the board and update all the necessary | ||
@@ -108,0 +104,0 @@ * fields in the simpleMove structure so it can be undone. |
{ | ||
"name": "onix-chess", | ||
"version": "6.5.4", | ||
"version": "6.5.5", | ||
"description": "Onix chess library", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
import toSafeInteger from 'lodash-es/toSafeInteger'; | ||
import * as shortid from 'shortid'; | ||
import isNumber from 'lodash-es/isNumber'; | ||
@@ -6,2 +7,3 @@ import indexOf from 'lodash-es/indexOf'; | ||
import { Hashtable } from 'onix-core'; | ||
import { Squares, Colors } from '../types/Types'; | ||
import { Color } from './Color'; | ||
@@ -14,6 +16,5 @@ import { GameResult } from './GameResult'; | ||
import { SimpleMove } from './SimpleMove'; | ||
import { IChessUser, IChessGame, IGameData, IMovePart, ITreePart, IChessPlayer, IChessOpening } from '../types/Interfaces'; | ||
import { IGameData, IMovePart, ITreePart, IChessPlayer, IChessOpening } from '../types/Interfaces'; | ||
import { FenString } from './FenString'; | ||
import { Squares, Colors } from '../types/Types'; | ||
import shortid = require('shortid'); | ||
import { plyToColor, plyToTurn, turnToPly } from './Common'; | ||
@@ -66,3 +67,3 @@ export enum ChessRatingType { | ||
export class ChessTags { | ||
private tags: Hashtable<string> = {}; | ||
private tags: Map<string, string> = new Map<string, string>(); | ||
@@ -76,3 +77,3 @@ /** | ||
public clear() { | ||
this.tags = { }; | ||
this.tags.clear(); | ||
} | ||
@@ -110,3 +111,3 @@ | ||
} else { | ||
this.tags[name] = value; | ||
this.tags.set(name, value); | ||
} | ||
@@ -180,3 +181,3 @@ } | ||
public get StartPlyCount() { | ||
return (this.startPos) ? this.startPos.PlyCount : 1; | ||
return (this.startPos) ? this.startPos.PlyCount + 1 : 1; | ||
} | ||
@@ -664,21 +665,12 @@ | ||
public static plyToTurn(ply: number) { | ||
return toSafeInteger(1 + (ply - 1) / 2); | ||
return plyToTurn(ply); | ||
} | ||
public static plyToColor(ply: number) { | ||
if (ply === 0) { | ||
return Color.White; | ||
} | ||
return ((ply % 2) == 1) ? Color.White : Color.Black; | ||
return plyToColor(ply); | ||
} | ||
public static turnToPly(turn: number, color?: number) { | ||
if (turn === 0) { | ||
return 0; | ||
} | ||
color = color || Color.White; | ||
return (((turn - 1) * 2) + color + 1); | ||
public static turnToPly(turn: number, color?: Colors.BW) { | ||
return turnToPly(turn, color); | ||
} | ||
} |
@@ -10,2 +10,3 @@ import repeat from 'lodash-es/repeat'; | ||
import { Castling, CastlingSide, CastlingStr } from './Castling'; | ||
import { turnToPly } from './Common'; | ||
@@ -241,3 +242,3 @@ // Forsite to piece map | ||
pos.HalfMoveCount = def.halfMoves; | ||
pos.setMoveNo(def.moveNo); | ||
pos.PlyCount = turnToPly(def.moveNo, pos.WhoMove) - 1; | ||
@@ -244,0 +245,0 @@ return true; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
485514
90
9262