onix-chess
Advanced tools
Comparing version 6.6.2 to 6.7.0
@@ -12,3 +12,5 @@ "use strict"; | ||
const { sm } = move.Prev; | ||
lastMove = [Square_1.Square.name(sm.from), Square_1.Square.name(sm.to)]; | ||
if (sm) { | ||
lastMove = [Square_1.Square.name(sm.from), Square_1.Square.name(sm.to)]; | ||
} | ||
} | ||
@@ -15,0 +17,0 @@ return lastMove; |
@@ -98,9 +98,20 @@ import { Squares, Colors } from '../types/Types'; | ||
addMove(sm: SimpleMove, san?: string, fen?: string): Move; | ||
moveToKey(key: string): void; | ||
/** | ||
* Переместиться на указанную позицию в главной линии партии | ||
* @param hmNumber | ||
* Move to begin game | ||
*/ | ||
moveToPly(hmNumber: number): void; | ||
moveToKey(key: string): void; | ||
moveBegin(): void; | ||
/** | ||
* Move to first move | ||
*/ | ||
moveFirst(): void; | ||
/** | ||
* Move to last move | ||
*/ | ||
moveLast(): void; | ||
/** | ||
* Move to end position | ||
*/ | ||
moveEnd(): void; | ||
/** | ||
* Переместить текущую позицию на 1 вперед | ||
@@ -116,13 +127,6 @@ * @returns Boolean | ||
/** | ||
* Move to begin game | ||
* Переместиться на указанную позицию в главной линии партии | ||
* @param hmNumber | ||
*/ | ||
moveBegin(): void; | ||
/** | ||
* Move to first move | ||
*/ | ||
moveFirst(): void; | ||
/** | ||
* Move to last move | ||
*/ | ||
moveLast(): void; | ||
moveToPly(hmNumber: number): void; | ||
getResultName(mode: 'char' | 'short' | 'long' | 'html'): string; | ||
@@ -129,0 +133,0 @@ static plyToTurn(ply: number): number; |
@@ -260,3 +260,2 @@ "use strict"; | ||
this.moveList[this.currentMove.Prev.moveKey] = this.currentMove.Prev; | ||
this.moveList[this.currentMove.moveKey] = this.currentMove; | ||
// Set up start | ||
@@ -314,2 +313,5 @@ this.currentPos = new Position_1.Position(); | ||
} | ||
sm.eval = mv.eval; | ||
sm.judgments = mv.comments; | ||
sm.glyphs = mv.glyphs; | ||
} | ||
@@ -455,31 +457,6 @@ const move = this.addMove(sm, sm.san, mv.fen); | ||
newMove.fen = fen; | ||
this.currentMove.fen = fen; | ||
this.positionChanged(); | ||
return newMove; | ||
} | ||
/** | ||
* Переместиться на указанную позицию в главной линии партии | ||
* @param hmNumber | ||
*/ | ||
moveToPly(hmNumber) { | ||
this.supressEvents = true; | ||
if (hmNumber > this.CurrentPlyCount) { | ||
while (!this.CurrentMove.END_MARKER && (hmNumber > this.CurrentPlyCount)) { | ||
if (!this.moveForward()) { | ||
break; | ||
} | ||
} | ||
this.supressEvents = false; | ||
this.positionChanged(); | ||
} | ||
else if (hmNumber < this.CurrentPlyCount) { | ||
while (!this.CurrentMove.START_MARKER && (hmNumber < this.CurrentPlyCount)) { | ||
if (!this.moveBackward()) { | ||
break; | ||
} | ||
} | ||
this.supressEvents = false; | ||
this.positionChanged(); | ||
} | ||
this.supressEvents = false; | ||
} | ||
moveToKey(key) { | ||
@@ -499,2 +476,31 @@ this.supressEvents = true; | ||
/** | ||
* Move to begin game | ||
*/ | ||
moveBegin() { | ||
this.currentMove = this.CurrentMove.Begin; | ||
this.currentPos.copyFrom(this.startPos); | ||
// this.currentPos = new Position(this.currentMove.fen); | ||
} | ||
/** | ||
* Move to first move | ||
*/ | ||
moveFirst() { | ||
this.currentMove = this.CurrentMove.First; | ||
this.currentPos = new Position_1.Position(this.CurrentMove.fen); | ||
} | ||
/** | ||
* Move to last move | ||
*/ | ||
moveLast() { | ||
this.currentMove = this.CurrentMove.Last; | ||
this.currentPos = new Position_1.Position(this.currentMove.fen); | ||
} | ||
/** | ||
* Move to end position | ||
*/ | ||
moveEnd() { | ||
this.currentMove = this.CurrentMove.End; | ||
this.currentPos = new Position_1.Position(this.currentMove.fen); | ||
} | ||
/** | ||
* Переместить текущую позицию на 1 вперед | ||
@@ -507,4 +513,4 @@ * @returns Boolean | ||
} | ||
this.currentMove = this.currentMove.Next; | ||
this.currentPos.doSimpleMove(this.currentMove.sm); | ||
this.currentMove = this.currentMove.Next; | ||
this.positionChanged(); | ||
@@ -521,4 +527,9 @@ return true; | ||
} | ||
this.currentMove = this.currentMove.Prev; | ||
if (this.currentMove.START_MARKER) { | ||
if (this.currentMove.Prev.START_MARKER) { | ||
if (this.currentMove.inVariation()) { | ||
this.currentPos.undoSimpleMove(this.currentMove.sm); | ||
this.currentMove = this.currentMove.exitVariation(); | ||
this.positionChanged(); | ||
return true; | ||
} | ||
this.currentPos.copyFrom(this.startPos); | ||
@@ -529,2 +540,3 @@ } | ||
} | ||
this.currentMove = this.currentMove.Prev; | ||
this.positionChanged(); | ||
@@ -534,23 +546,27 @@ return true; | ||
/** | ||
* Move to begin game | ||
* Переместиться на указанную позицию в главной линии партии | ||
* @param hmNumber | ||
*/ | ||
moveBegin() { | ||
this.currentMove = this.CurrentMove.Begin; | ||
this.currentPos.copyFrom(this.startPos); | ||
// this.currentPos = new Position(this.currentMove.fen); | ||
moveToPly(hmNumber) { | ||
this.supressEvents = true; | ||
if (hmNumber > this.CurrentPlyCount) { | ||
while (!this.CurrentMove.END_MARKER && (hmNumber > this.CurrentPlyCount)) { | ||
if (!this.moveForward()) { | ||
break; | ||
} | ||
} | ||
this.supressEvents = false; | ||
this.positionChanged(); | ||
} | ||
else if (hmNumber < this.CurrentPlyCount) { | ||
while (!this.CurrentMove.START_MARKER && (hmNumber < this.CurrentPlyCount)) { | ||
if (!this.moveBackward()) { | ||
break; | ||
} | ||
} | ||
this.supressEvents = false; | ||
this.positionChanged(); | ||
} | ||
this.supressEvents = false; | ||
} | ||
/** | ||
* Move to first move | ||
*/ | ||
moveFirst() { | ||
this.currentMove = this.CurrentMove.First; | ||
this.currentPos = new Position_1.Position(this.CurrentMove.Prev.fen); | ||
} | ||
/** | ||
* Move to last move | ||
*/ | ||
moveLast() { | ||
this.currentMove = this.CurrentMove.End; | ||
this.currentPos = new Position_1.Position(this.currentMove.fen); | ||
} | ||
getResultName(mode) { | ||
@@ -557,0 +573,0 @@ if (mode === "char") { |
@@ -53,3 +53,7 @@ import { SimpleMove } from './SimpleMove'; | ||
*/ | ||
exitVariation(): Window | this; | ||
exitVariation(): Move; | ||
/** | ||
* Is position inside variation | ||
*/ | ||
inVariation(): boolean; | ||
truncate(): void; | ||
@@ -56,0 +60,0 @@ append(sm: SimpleMove): Move; |
@@ -131,6 +131,12 @@ "use strict"; | ||
if (this.parent) { | ||
return parent; | ||
return this.parent; | ||
} | ||
return this; | ||
} | ||
/** | ||
* Is position inside variation | ||
*/ | ||
inVariation() { | ||
return !!this.parent; | ||
} | ||
truncate() { | ||
@@ -137,0 +143,0 @@ this.vars = []; |
@@ -0,1 +1,2 @@ | ||
import { IEval, IGlyph, IJudgment } from '../types/Interfaces'; | ||
import { Colors, Pieces, Squares } from '../types/Types'; | ||
@@ -21,5 +22,7 @@ /** | ||
comments?: string; | ||
nag?: string; | ||
eval?: IEval; | ||
judgments?: IJudgment[]; | ||
glyphs?: IGlyph[]; | ||
permanent: boolean; | ||
toString(): string; | ||
} |
{ | ||
"name": "onix-chess", | ||
"version": "6.6.2", | ||
"version": "6.7.0", | ||
"description": "Onix chess library", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -21,3 +21,5 @@ import * as cg from 'chessground/types'; | ||
const { sm } = move.Prev!; | ||
lastMove = [<cg.Key>Square.name(sm!.from!), <cg.Key>Square.name(sm!.to!)]; | ||
if (sm) { | ||
lastMove = [<cg.Key>Square.name(sm.from!), <cg.Key>Square.name(sm.to!)]; | ||
} | ||
} | ||
@@ -24,0 +26,0 @@ |
@@ -317,3 +317,2 @@ import toSafeInteger from 'lodash-es/toSafeInteger'; | ||
this.moveList[this.currentMove.Prev.moveKey] = this.currentMove.Prev; | ||
this.moveList[this.currentMove.moveKey] = this.currentMove; | ||
@@ -380,2 +379,6 @@ // Set up start | ||
} | ||
sm.eval = mv.eval; | ||
sm.judgments = mv.comments; | ||
sm.glyphs = mv.glyphs; | ||
} | ||
@@ -538,2 +541,3 @@ | ||
newMove.fen = fen; | ||
this.currentMove.fen = fen; | ||
@@ -545,31 +549,2 @@ this.positionChanged(); | ||
/** | ||
* Переместиться на указанную позицию в главной линии партии | ||
* @param hmNumber | ||
*/ | ||
public moveToPly(hmNumber: number) { | ||
this.supressEvents = true; | ||
if (hmNumber > this.CurrentPlyCount) { | ||
while (!this.CurrentMove.END_MARKER && (hmNumber > this.CurrentPlyCount)) { | ||
if (!this.moveForward()) { | ||
break; | ||
} | ||
} | ||
this.supressEvents = false; | ||
this.positionChanged(); | ||
} else if (hmNumber < this.CurrentPlyCount) { | ||
while (!this.CurrentMove.START_MARKER && (hmNumber < this.CurrentPlyCount)) { | ||
if (!this.moveBackward()) { | ||
break; | ||
} | ||
} | ||
this.supressEvents = false; | ||
this.positionChanged(); | ||
} | ||
this.supressEvents = false; | ||
} | ||
public moveToKey(key: string) { | ||
@@ -590,2 +565,35 @@ this.supressEvents = true; | ||
/** | ||
* Move to begin game | ||
*/ | ||
public moveBegin() { | ||
this.currentMove = this.CurrentMove.Begin; | ||
this.currentPos.copyFrom(this.startPos); | ||
// this.currentPos = new Position(this.currentMove.fen); | ||
} | ||
/** | ||
* Move to first move | ||
*/ | ||
public moveFirst() { | ||
this.currentMove = this.CurrentMove.First; | ||
this.currentPos = new Position(this.CurrentMove.fen); | ||
} | ||
/** | ||
* Move to last move | ||
*/ | ||
public moveLast() { | ||
this.currentMove = this.CurrentMove.Last; | ||
this.currentPos = new Position(this.currentMove.fen); | ||
} | ||
/** | ||
* Move to end position | ||
*/ | ||
public moveEnd() { | ||
this.currentMove = this.CurrentMove.End; | ||
this.currentPos = new Position(this.currentMove.fen); | ||
} | ||
/** | ||
* Переместить текущую позицию на 1 вперед | ||
@@ -599,4 +607,5 @@ * @returns Boolean | ||
this.currentMove = this.currentMove.Next!; | ||
this.currentPos.doSimpleMove(this.currentMove.sm!); | ||
this.currentMove = this.currentMove.Next!; | ||
this.positionChanged(); | ||
@@ -616,4 +625,10 @@ | ||
this.currentMove = this.currentMove.Prev!; | ||
if (this.currentMove.START_MARKER) { | ||
if (this.currentMove.Prev!.START_MARKER) { | ||
if (this.currentMove.inVariation()) { | ||
this.currentPos.undoSimpleMove(this.currentMove.sm!); | ||
this.currentMove = this.currentMove.exitVariation(); | ||
this.positionChanged(); | ||
return true; | ||
} | ||
this.currentPos.copyFrom(this.startPos); | ||
@@ -623,2 +638,4 @@ } else { | ||
} | ||
this.currentMove = this.currentMove.Prev!; | ||
@@ -631,24 +648,28 @@ this.positionChanged(); | ||
/** | ||
* Move to begin game | ||
* Переместиться на указанную позицию в главной линии партии | ||
* @param hmNumber | ||
*/ | ||
public moveBegin() { | ||
this.currentMove = this.CurrentMove.Begin; | ||
this.currentPos.copyFrom(this.startPos); | ||
// this.currentPos = new Position(this.currentMove.fen); | ||
} | ||
public moveToPly(hmNumber: number) { | ||
this.supressEvents = true; | ||
if (hmNumber > this.CurrentPlyCount) { | ||
while (!this.CurrentMove.END_MARKER && (hmNumber > this.CurrentPlyCount)) { | ||
if (!this.moveForward()) { | ||
break; | ||
} | ||
} | ||
/** | ||
* Move to first move | ||
*/ | ||
public moveFirst() { | ||
this.currentMove = this.CurrentMove.First; | ||
this.currentPos = new Position(this.CurrentMove.Prev.fen); | ||
} | ||
this.supressEvents = false; | ||
this.positionChanged(); | ||
} else if (hmNumber < this.CurrentPlyCount) { | ||
while (!this.CurrentMove.START_MARKER && (hmNumber < this.CurrentPlyCount)) { | ||
if (!this.moveBackward()) { | ||
break; | ||
} | ||
} | ||
/** | ||
* Move to last move | ||
*/ | ||
public moveLast() { | ||
this.currentMove = this.CurrentMove.End; | ||
this.currentPos = new Position(this.currentMove.fen); | ||
this.supressEvents = false; | ||
this.positionChanged(); | ||
} | ||
this.supressEvents = false; | ||
} | ||
@@ -655,0 +676,0 @@ |
@@ -7,3 +7,3 @@ import * as shortid from 'shortid'; | ||
import { Squares, Colors, Pieces } from '../types/Types'; | ||
import { ITreePart, IMovePart } from '../types/Interfaces'; | ||
import { ITreePart, IMovePart, IEval, IJudgment, IGlyph } from '../types/Interfaces'; | ||
import { Position } from './Position'; | ||
@@ -177,3 +177,3 @@ | ||
if (this.parent) { | ||
return parent; | ||
return this.parent; | ||
} | ||
@@ -184,2 +184,9 @@ | ||
/** | ||
* Is position inside variation | ||
*/ | ||
public inVariation() { | ||
return !!this.parent; | ||
} | ||
public truncate() { | ||
@@ -186,0 +193,0 @@ this.vars = []; |
@@ -0,1 +1,2 @@ | ||
import { IEval, IGlyph, IJudgment } from '../types/Interfaces'; | ||
import { Colors, Pieces, Squares } from '../types/Types'; | ||
@@ -29,3 +30,6 @@ import { Color } from './Color'; | ||
public comments?: string; | ||
public nag?: string; | ||
public eval?: IEval; | ||
public judgments?: IJudgment[]; | ||
public glyphs?: IGlyph[]; | ||
public permanent: boolean = true; | ||
@@ -32,0 +36,0 @@ |
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 not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
490078
9368