New variant idea
[xogo.git] / variants / Allmate / class.js
index e46f384..9493e6c 100644 (file)
@@ -35,7 +35,7 @@ export default class AllmateRules extends ChessRules {
     if (move.appear.length > 0)
       this.curMove = move;
     const color = this.turn;
-    const oppCol = C.GetOppCol(this.turn);
+    const oppCol = C.GetOppTurn(this.turn);
     let mv = new Move({
       start: this.curMove.end,
       end: this.curMove.end,
@@ -58,8 +58,8 @@ export default class AllmateRules extends ChessRules {
 
   // is piece on square x,y mated by color?
   isMated(x, y, color) {
-    const myColor = C.GetOppCol(color);
-    if (!this.underCheck([x, y], color))
+    const myColor = C.GetOppTurn(color);
+    if (!super.underAttack([x, y], [color]))
       return false;
     for (let i=0; i<this.size.x; i++) {
       for (let j=0; j<this.size.y; j++) {
@@ -71,7 +71,7 @@ export default class AllmateRules extends ChessRules {
             if (i == x && j == y) {
               // The mated-candidate has moved itself
               testSquare = [move.end.x, move.end.y]; }
-            const res = this.underCheck(testSquare, color);
+            const res = this.underAttack(testSquare, [color]);
             this.undoOnBoard(move);
             if (!res)
               return false;
@@ -82,9 +82,8 @@ export default class AllmateRules extends ChessRules {
     return true;
   }
 
-  // No "under check" conditions in castling
-  getCastleMoves(sq) {
-    return super.getCastleMoves(sq, null, "castleInCheck");
+  underCheck() {
+    return false; //not relevant here
   }
 
   filterValid(moves) {