projects
/
xogo.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix complete rules of Cwda
[xogo.git]
/
variants
/
Coregal
/
class.js
diff --git
a/variants/Coregal/class.js
b/variants/Coregal/class.js
index
15a99e2
..
23f67c7
100644
(file)
--- a/
variants/Coregal/class.js
+++ b/
variants/Coregal/class.js
@@
-22,7
+22,7
@@
export default class CoregalRules extends ChessRules {
const col = (c == 0 ? 'w' : 'b');
let first = "";
for (let i=4*c; i<4*(c+1); i++) {
const col = (c == 0 ? 'w' : 'b');
let first = "";
for (let i=4*c; i<4*(c+1); i++) {
- const pos = parseInt(flags.charAt(i), 10);
+ const pos = parseInt(
s.
flags.charAt(i), 10);
const symb = s[col][pos];
if (['k', 'l'].includes(symb)) {
if (!first) {
const symb = s[col][pos];
if (['k', 'l'].includes(symb)) {
if (!first) {
@@
-33,7
+33,7
@@
export default class CoregalRules extends ChessRules {
relPos[col][symb] = '1'; //right
}
else
relPos[col][symb] = '1'; //right
}
else
- flags += flags.charAt(i);
+ flags +=
s.
flags.charAt(i);
}
}
return {
}
}
return {
@@
-41,25
+41,27
@@
export default class CoregalRules extends ChessRules {
s.w.join("").toUpperCase(),
o: {
flags: flags + flags, //duplicate: one for each royal piece
s.w.join("").toUpperCase(),
o: {
flags: flags + flags, //duplicate: one for each royal piece
- relPos: (
- relPos['w']['k'] + relPos['w']['l'] +
- relPos['b']['k'] + relPos['b']['l']
- )
+ relPos: this.getRelposFen(relPos)
}
};
}
getPartFen(o) {
return (Object.assign(
}
};
}
getPartFen(o) {
return (Object.assign(
- {"relpos": o.
relPos
},
+ {"relpos": o.
init ? o.relPos : this.getRelposFen()
},
super.getPartFen(o)
));
}
super.getPartFen(o)
));
}
+ getRelposFen(relPos) {
+ relPos = relPos || this.relPos;
+ return (
+ relPos['w']['k'] + relPos['w']['l'] +
+ relPos['b']['k'] + relPos['b']['l']
+ );
+ }
+
setOtherVariables(fenParsed, pieceArray) {
setOtherVariables(fenParsed, pieceArray) {
-
-//TODO: issue, relPos is set at init but doesn't persist --> see base_rules.js line 263
-console.log(fenParsed);
super.setOtherVariables(fenParsed, pieceArray);
this.relPos = {
'w': {
super.setOtherVariables(fenParsed, pieceArray);
this.relPos = {
'w': {
@@
-73,11
+75,12
@@
console.log(fenParsed);
};
}
};
}
- pieces() {
- let res = super.pieces();
+ pieces(
color, x, y
) {
+ let res = super.pieces(
color, x, y
);
res['l'] = JSON.parse(JSON.stringify(res['q']));
// TODO: CSS royal queen symbol (with cross?)
res['l']["class"] = "royal_queen";
res['l'] = JSON.parse(JSON.stringify(res['q']));
// TODO: CSS royal queen symbol (with cross?)
res['l']["class"] = "royal_queen";
+ res['='] = {"class": "castle"}; //for castle display
return res;
}
return res;
}
@@
-118,8
+121,10
@@
console.log(fenParsed);
this.relPos[c][p] == '0' ? [1, 2] : [2, 3], //0 == left
this.relPos[c][p] == '1' ? [6, 5] : [5, 4] //1 == right
];
this.relPos[c][p] == '0' ? [1, 2] : [2, 3], //0 == left
this.relPos[c][p] == '1' ? [6, 5] : [5, 4] //1 == right
];
-
cons
t moves =
+
le
t moves =
super.getCastleMoves([x, y], finalSquares, null, this.castleFlags[p][c]);
super.getCastleMoves([x, y], finalSquares, null, this.castleFlags[p][c]);
+ if (p == 'l')
+ moves.forEach(m => m.choice = '='); //required (for display)
return moves;
}
return moves;
}