projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Some refactoring in variants logic: more robust FEN handling (untested)
[vchess.git]
/
public
/
javascripts
/
variants
/
Extinction.js
diff --git
a/public/javascripts/variants/Extinction.js
b/public/javascripts/variants/Extinction.js
index
2b0aeca
..
49d61b2
100644
(file)
--- a/
public/javascripts/variants/Extinction.js
+++ b/
public/javascripts/variants/Extinction.js
@@
-1,27
+1,30
@@
class ExtinctionRules extends ChessRules
{
class ExtinctionRules extends ChessRules
{
-
init
Variables(fen)
+
setOther
Variables(fen)
{
{
- super.initVariables(fen);
+ super.setOtherVariables(fen);
+ const pos = V.ParseFen(fen).position;
+ // NOTE: no need for safety "|| []", because each piece type must be present
+ // (otherwise game is already over!)
this.material =
{
"w":
{
this.material =
{
"w":
{
- [V.KING]:
1
,
- [V.QUEEN]:
1
,
- [V.ROOK]:
2
,
- [V.KNIGHT]:
2
,
- [V.BISHOP]:
2
,
- [V.PAWN]:
8
+ [V.KING]:
pos.match(/K/g).length
,
+ [V.QUEEN]:
pos.match(/Q/g).length
,
+ [V.ROOK]:
pos.match(/R/g).length
,
+ [V.KNIGHT]:
pos.match(/N/g).length
,
+ [V.BISHOP]:
pos.match(/B/g).length
,
+ [V.PAWN]:
pos.match(/P/g).length
},
"b":
{
},
"b":
{
- [V.KING]:
1
,
- [V.QUEEN]:
1
,
- [V.ROOK]:
2
,
- [V.KNIGHT]:
2
,
- [V.BISHOP]:
2
,
- [V.PAWN]:
8
+ [V.KING]:
pos.match(/k/g).length
,
+ [V.QUEEN]:
pos.match(/q/g).length
,
+ [V.ROOK]:
pos.match(/r/g).length
,
+ [V.KNIGHT]:
pos.match(/n/g).length
,
+ [V.BISHOP]:
pos.match(/b/g).length
,
+ [V.PAWN]:
pos.match(/p/g).length
}
};
}
}
};
}
@@
-117,7
+120,7
@@
class ExtinctionRules extends ChessRules
checkGameEnd()
{
checkGameEnd()
{
- return
this.turn == "w" ? "0-1" : "1-0"
;
+ return
(this.turn == "w" ? "0-1" : "1-0")
;
}
evalPosition()
}
evalPosition()