projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Almost finished problems logic. TODO: showProblem() part
[vchess.git]
/
public
/
javascripts
/
variants
/
Checkered.js
diff --git
a/public/javascripts/variants/Checkered.js
b/public/javascripts/variants/Checkered.js
index
2d62d4b
..
585d20f
100644
(file)
--- a/
public/javascripts/variants/Checkered.js
+++ b/
public/javascripts/variants/Checkered.js
@@
-19,18
+19,34
@@
class CheckeredRules extends ChessRules
}
static fen2board(f)
{
}
static fen2board(f)
{
+ // Tolerate upper-case versions of checkered pieces (why not?)
const checkered_pieces = {
's': 'p',
const checkered_pieces = {
's': 'p',
+ 'S': 'p',
't': 'q',
't': 'q',
+ 'T': 'q',
'u': 'r',
'u': 'r',
+ 'U': 'r',
'c': 'b',
'c': 'b',
+ 'C': 'b',
'o': 'n',
'o': 'n',
+ 'O': 'n',
};
if (Object.keys(checkered_pieces).includes(f))
return 'c'+checkered_pieces[f];
return ChessRules.fen2board(f);
}
};
if (Object.keys(checkered_pieces).includes(f))
return 'c'+checkered_pieces[f];
return ChessRules.fen2board(f);
}
+ static get PIECES() {
+ return ChessRules.PIECES.concat(['s','t','u','c','o']);
+ }
+
+ static IsGoodFlags(flags)
+ {
+ // 4 for castle + 16 for pawns
+ return !!flags.match(/^[01]{20,20}$/);
+ }
+
setFlags(fen)
{
super.setFlags(fen); //castleFlags
setFlags(fen)
{
super.setFlags(fen); //castleFlags
@@
-108,9
+124,7
@@
class CheckeredRules extends ChessRules
canIplay(side, [x,y])
{
canIplay(side, [x,y])
{
- return ((side=='w' && this.moves.length%2==0)
- || (side=='b' && this.moves.length%2==1))
- && [side,'c'].includes(this.getColor(x,y));
+ return (side == this.turn && [side,'c'].includes(this.getColor(x,y)));
}
// Does m2 un-do m1 ? (to disallow undoing checkered moves)
}
// Does m2 un-do m1 ? (to disallow undoing checkered moves)
@@
-194,11
+208,12
@@
class CheckeredRules extends ChessRules
checkGameEnd()
{
const color = this.turn;
checkGameEnd()
{
const color = this.turn;
- this.moves.length++; //artifically change turn, for checkered pawns (TODO)
+ // Artifically change turn, for checkered pawns
+ this.turn = this.getOppCol(this.turn);
const res = this.isAttacked(this.kingPos[color], [this.getOppCol(color),'c'])
? (color == "w" ? "0-1" : "1-0")
: "1/2";
const res = this.isAttacked(this.kingPos[color], [this.getOppCol(color),'c'])
? (color == "w" ? "0-1" : "1-0")
: "1/2";
- this.
moves.length--
;
+ this.
turn = this.getOppCol(this.turn)
;
return res;
}
return res;
}