+ // Can thing on square1 capture thing on square2?
+ canTake([x1, y1], [x2, y2]) {
+ return this.getColor(x1, y1) !== this.getColor(x2, y2);
+ }
+
+ canStepOver(i, j, p) {
+ // In some variants, objects on boards don't stop movement (Chakart)
+ return this.board[i][j] == "";
+ }
+
+ // For Madrasi:
+ // (redefined in Baroque etc, where Madrasi condition doesn't make sense)
+ isImmobilized([x, y]) {
+ if (!this.options["madrasi"])
+ return false;
+ const color = this.getColor(x, y);
+ const oppCol = C.GetOppCol(color);
+ const piece = this.getPieceType(x, y); //ok not cannibal king
+ const stepSpec = this.getStepSpec(color, x, y);
+ const attacks = stepSpec.attack || stepSpec.moves;
+ for (let a of attacks) {
+ outerLoop: for (let step of a.steps) {
+ let [i, j] = [x + step[0], y + step[1]];
+ let stepCounter = 1;
+ while (this.onBoard(i, j) && this.board[i][j] == "") {
+ if (a.range <= stepCounter++)
+ continue outerLoop;
+ i += step[0];
+ j = this.getY(j + step[1]);
+ }
+ if (
+ this.onBoard(i, j) &&
+ this.getColor(i, j) == oppCol &&
+ this.getPieceType(i, j) == piece
+ ) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+