projects
/
xogo.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
New variant idea
[xogo.git]
/
variants
/
Chakart
/
class.js
diff --git
a/variants/Chakart/class.js
b/variants/Chakart/class.js
index
6ddc37c
..
3454d8f
100644
(file)
--- a/
variants/Chakart/class.js
+++ b/
variants/Chakart/class.js
@@
-130,6
+130,12
@@
export default class ChakartRules extends ChessRules {
);
}
);
}
+ isKing(x, y, p) {
+ if (!p)
+ p = this.getPiece(x, y);
+ return ['k', 'l'].includes(p);
+ }
+
genRandInitBaseFen() {
const s = FenUtil.setupPieces(
['r', 'n', 'b', 'q', 'k', 'b', 'n', 'r'],
genRandInitBaseFen() {
const s = FenUtil.setupPieces(
['r', 'n', 'b', 'q', 'k', 'b', 'n', 'r'],
@@
-594,6
+600,10
@@
export default class ChakartRules extends ChessRules {
const coords = getRandomPiece(oldColor);
if (coords) {
const piece = this.getPiece(coords[0], coords[1]);
const coords = getRandomPiece(oldColor);
if (coords) {
const piece = this.getPiece(coords[0], coords[1]);
+ if (coords[0] == move.start.x && coords[1] == move.start.y) {
+ // Moving piece change color: fix coords
+ coords = [move.end.x, move.end.y];
+ }
em = new Move({
appear: [
new PiPo({x: coords[0], y: coords[1], c: newColor, p: piece})
em = new Move({
appear: [
new PiPo({x: coords[0], y: coords[1], c: newColor, p: piece})
@@
-626,19
+636,25
@@
export default class ChakartRules extends ChessRules {
});
break;
case "koopa":
});
break;
case "koopa":
- // Reverse move
+ // Reverse move
, if possible
em = new Move({
em = new Move({
- appear: [
- new PiPo({
- x: move.start.x, y: move.start.y, c: color, p: move.appear[0].p
- })
- ],
+ appear: [],
vanish: [
new PiPo({
x: move.end.x, y: move.end.y, c: color, p: move.appear[0].p
})
vanish: [
new PiPo({
x: move.end.x, y: move.end.y, c: color, p: move.appear[0].p
})
- ]
+ ],
+ end: {x: move.start.x, y: move.start.y} //may be irrelevant
});
});
+ em.koopa = true; //avoid applying effect
+ if (move.vanish.length == 0)
+ // After toadette+drop, just erase piece
+ break;
+ em.appear.push(
+ new PiPo({
+ x: move.start.x, y: move.start.y, c: color, p: move.appear[0].p
+ })
+ );
if (this.board[move.start.x][move.start.y] != "") {
// Pawn or knight let something on init square
em.vanish.push(new PiPo({
if (this.board[move.start.x][move.start.y] != "") {
// Pawn or knight let something on init square
em.vanish.push(new PiPo({
@@
-648,7
+664,6
@@
export default class ChakartRules extends ChessRules {
p: this.getPiece(move.start.x, move.start.y)
}));
}
p: this.getPiece(move.start.x, move.start.y)
}));
}
- em.koopa = true; //avoid applying effect
break;
case "chomp":
// Eat piece
break;
case "chomp":
// Eat piece