projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix a non-deleted challenge bug
[vchess.git]
/
client
/
src
/
base_rules.js
diff --git
a/client/src/base_rules.js
b/client/src/base_rules.js
index
087b4f5
..
15609eb
100644
(file)
--- a/
client/src/base_rules.js
+++ b/
client/src/base_rules.js
@@
-50,13
+50,13
@@
export const ChessRules = class ChessRules
// Turn "wb" into "B" (for FEN)
static board2fen(b)
{
// Turn "wb" into "B" (for FEN)
static board2fen(b)
{
- return
b[0]=='w' ? b[1].toUpperCase() : b[1]
;
+ return
(b[0]=='w' ? b[1].toUpperCase() : b[1])
;
}
// Turn "p" into "bp" (for board)
static fen2board(f)
{
}
// Turn "p" into "bp" (for board)
static fen2board(f)
{
- return
f.charCodeAt()<=90 ? "w"+f.toLowerCase() : "b"+f
;
+ return
(f.charCodeAt()<=90 ? "w"+f.toLowerCase() : "b"+f)
;
}
// Check if FEN describe a position
}
// Check if FEN describe a position
@@
-409,8
+409,13
@@
export const ChessRules = class ChessRules
//////////////////
// INITIALIZATION
//////////////////
// INITIALIZATION
- // Fen string fully describes the game state
constructor(fen)
constructor(fen)
+ {
+ this.re_init(fen);
+ }
+
+ // Fen string fully describes the game state
+ re_init(fen)
{
const fenParsed = V.ParseFen(fen);
this.board = V.GetBoard(fenParsed.position);
{
const fenParsed = V.ParseFen(fen);
this.board = V.GetBoard(fenParsed.position);
@@
-1057,8
+1062,6
@@
export const ChessRules = class ChessRules
move.flags = JSON.stringify(this.aggregateFlags()); //save flags (for undo)
if (V.HasEnpassant)
this.epSquares.push( this.getEpSquare(move) );
move.flags = JSON.stringify(this.aggregateFlags()); //save flags (for undo)
if (V.HasEnpassant)
this.epSquares.push( this.getEpSquare(move) );
- if (!move.color)
- move.color = this.turn; //for interface
V.PlayOnBoard(this.board, move);
this.turn = V.GetOppCol(this.turn);
this.movesCount++;
V.PlayOnBoard(this.board, move);
this.turn = V.GetOppCol(this.turn);
this.movesCount++;