projects
/
xogo.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix Antiking
[xogo.git]
/
variants
/
Chakart
/
class.js
diff --git
a/variants/Chakart/class.js
b/variants/Chakart/class.js
index
59e44b1
..
02dd16e
100644
(file)
--- a/
variants/Chakart/class.js
+++ b/
variants/Chakart/class.js
@@
-1,7
+1,7
@@
import ChessRules from "/base_rules.js";
import GiveawayRules from "/variants/Giveaway/class.js";
import ChessRules from "/base_rules.js";
import GiveawayRules from "/variants/Giveaway/class.js";
-import {
ArrayFun
} from "/utils/array.js";
-import {
Random
} from "/utils/alea.js";
+import {
ArrayFun
} from "/utils/array.js";
+import {
Random
} from "/utils/alea.js";
import PiPo from "/utils/PiPo.js";
import Move from "/utils/Move.js";
import PiPo from "/utils/PiPo.js";
import Move from "/utils/Move.js";
@@
-127,7
+127,8
@@
export default class ChakartRules extends ChessRules {
]
}
},
]
}
},
- specials, bowsered, super.pieces(color, x, y));
+ specials, bowsered, super.pieces(color, x, y)
+ );
}
genRandInitFen(seed) {
}
genRandInitFen(seed) {
@@
-269,7
+270,7
@@
export default class ChakartRules extends ChessRules {
case 'b':
case 'r':
// Explicitely listing types to avoid moving immobilized piece
case 'b':
case 'r':
// Explicitely listing types to avoid moving immobilized piece
- moves =
this
.getPotentialMovesOf(piece, [x, y]);
+ moves =
super
.getPotentialMovesOf(piece, [x, y]);
break;
}
}
break;
}
}
@@
-341,14
+342,14
@@
export default class ChakartRules extends ChessRules {
getKnightMovesFrom([x, y]) {
// Add egg on initial square:
getKnightMovesFrom([x, y]) {
// Add egg on initial square:
- return
this
.getPotentialMovesOf('n', [x, y]).map(m => {
+ return
super
.getPotentialMovesOf('n', [x, y]).map(m => {
m.appear.push(new PiPo({p: "e", c: "a", x: x, y: y}));
return m;
});
}
getQueenMovesFrom(sq) {
m.appear.push(new PiPo({p: "e", c: "a", x: x, y: y}));
return m;
});
}
getQueenMovesFrom(sq) {
- const normalMoves =
this
.getPotentialMovesOf('q', sq);
+ const normalMoves =
super
.getPotentialMovesOf('q', sq);
// If flag allows it, add 'invisible movements'
let invisibleMoves = [];
if (this.powerFlags[this.turn]['q']) {
// If flag allows it, add 'invisible movements'
let invisibleMoves = [];
if (this.powerFlags[this.turn]['q']) {
@@
-370,10
+371,10
@@
export default class ChakartRules extends ChessRules {
}
getKingMovesFrom([x, y]) {
}
getKingMovesFrom([x, y]) {
- let moves =
this
.getPotentialMovesOf('k', [x, y]);
+ let moves =
super
.getPotentialMovesOf('k', [x, y]);
// If flag allows it, add 'remote shell captures'
if (this.powerFlags[this.turn]['k']) {
// If flag allows it, add 'remote shell captures'
if (this.powerFlags[this.turn]['k']) {
- let shellCaptures =
this
.getPotentialMovesOf('y', [x, y]);
+ let shellCaptures =
super
.getPotentialMovesOf('y', [x, y]);
shellCaptures.forEach(sc => {
sc.shell = true; //easier play()
sc.choice = 'z'; //to display in showChoices()
shellCaptures.forEach(sc => {
sc.shell = true; //easier play()
sc.choice = 'z'; //to display in showChoices()
@@
-458,7
+459,11
@@
export default class ChakartRules extends ChessRules {
this.getColor(i, j) == oppCol
) {
const pieceIJ = this.getPiece(i, j);
this.getColor(i, j) == oppCol
) {
const pieceIJ = this.getPiece(i, j);
- if (pieceIJ == 'i') {
+ if (
+ pieceIJ == 'i' &&
+ // Ensure that current move doesn't erase invisible queen
+ move.appear.every(a => a.x != i || a.y != j)
+ ) {
move.vanish.push(new PiPo({x: i, y: j, c: oppCol, p: 'i'}));
move.appear.push(new PiPo({x: i, y: j, c: oppCol, p: 'q'}));
}
move.vanish.push(new PiPo({x: i, y: j, c: oppCol, p: 'i'}));
move.appear.push(new PiPo({x: i, y: j, c: oppCol, p: 'q'}));
}