import { ChessRules, PiPo } from "@/base_rules";
-export const VariantRules = class MagneticRules extends ChessRules {
+export class MagneticRules extends ChessRules {
static get HasEnpassant() {
return false;
}
cmove.appear[i].p = piece;
moves.push(cmove);
}
- // Swap appear[i] and appear[0] for moves presentation (TODO: this is awkward)
+ // Swap appear[i] and appear[0] for moves presentation
+ // (TODO: this is awkward)
moves.forEach(m => {
let tmp = m.appear[0];
m.appear[0] = m.appear[i];
psq.x == oppFirstRank &&
this.castleFlags[oppCol].includes(psq.y)
) {
- this.castleFlags[oppCol][psq.y == this.castleFlags[oppCol][0] ? 0 : 1] = 8;
+ const flagIdx = (psq.y == this.castleFlags[oppCol][0] ? 0 : 1);
+ this.castleFlags[oppCol][flagIdx] = 8;
}
});
}
// King disappeared
return color == "w" ? "0-1" : "1-0";
if (this.atLeastOneMove())
- // game not over
+ // Game not over
return "*";
return "1/2"; //no moves but kings still there
}