projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix Pandemonium pieces' values
[vchess.git]
/
client
/
src
/
variants
/
Allmate2.js
diff --git
a/client/src/variants/Allmate2.js
b/client/src/variants/Allmate2.js
index
424ff61
..
f4abbe3
100644
(file)
--- a/
client/src/variants/Allmate2.js
+++ b/
client/src/variants/Allmate2.js
@@
-1,6
+1,7
@@
import { ChessRules, PiPo, Move } from "@/base_rules";
export class Allmate2Rules extends ChessRules {
import { ChessRules, PiPo, Move } from "@/base_rules";
export class Allmate2Rules extends ChessRules {
+
static get HasEnpassant() {
return false;
}
static get HasEnpassant() {
return false;
}
@@
-61,11
+62,16
@@
export class Allmate2Rules extends ChessRules {
oppMoves = this.getPotentialQueenMoves([i, j]);
break;
case V.KING:
oppMoves = this.getPotentialQueenMoves([i, j]);
break;
case V.KING:
- oppMoves = this.getPotentialKingMoves([i, j]);
+ // Do not allow castling to escape from check
+ oppMoves = super.getSlideNJumpMoves(
+ [i, j],
+ V.steps[V.ROOK].concat(V.steps[V.BISHOP]),
+ "oneStep"
+ );
break;
}
for (let om of oppMoves) {
break;
}
for (let om of oppMoves) {
- if (om.vanish.length == 2
&& om.appear.length == 1
)
+ if (om.vanish.length == 2)
// Skip captures: forbidden in this mode
continue;
V.PlayOnBoard(this.board, om);
// Skip captures: forbidden in this mode
continue;
V.PlayOnBoard(this.board, om);
@@
-85,6
+91,7
@@
export class Allmate2Rules extends ChessRules {
}
}
}
}
}
}
+ this.undo(m);
// 3) Add mate-captures:
Object.values(attacked).forEach(sq => {
// 3) Add mate-captures:
Object.values(attacked).forEach(sq => {
@@
-95,8
+102,6
@@
export class Allmate2Rules extends ChessRules {
p: this.getPiece(sq[0], sq[1])
}));
});
p: this.getPiece(sq[0], sq[1])
}));
});
-
- this.undo(m);
});
return moves;
});
return moves;
@@
-104,7
+109,7
@@
export class Allmate2Rules extends ChessRules {
// No "under check" conditions in castling
getCastleMoves(sq) {
// No "under check" conditions in castling
getCastleMoves(sq) {
- return super.getCastleMoves(sq, "castleInCheck");
+ return super.getCastleMoves(sq,
null,
"castleInCheck");
}
// TODO: allow pieces to "commit suicide"? (Currently yes except king)
}
// TODO: allow pieces to "commit suicide"? (Currently yes except king)
@@
-180,10
+185,10
@@
export class Allmate2Rules extends ChessRules {
this.kingPos[this.turn] = [-1, -1];
// Or maybe a rook?
else if (v.p == V.ROOK) {
this.kingPos[this.turn] = [-1, -1];
// Or maybe a rook?
else if (v.p == V.ROOK) {
- if (v.y < this.
INIT_COL_KING[v.c
])
+ if (v.y < this.
kingPos[v.c][1
])
this.castleFlags[v.c][0] = 8;
else
this.castleFlags[v.c][0] = 8;
else
- // v.y > this.
INIT_COL_KING[v.c
]
+ // v.y > this.
kingPos[v.c][1
]
this.castleFlags[v.c][1] = 8;
}
}
this.castleFlags[v.c][1] = 8;
}
}
@@
-207,8
+212,7
@@
export class Allmate2Rules extends ChessRules {
if (kp[0] < 0)
// King disappeared
return color == "w" ? "0-1" : "1-0";
if (kp[0] < 0)
// King disappeared
return color == "w" ? "0-1" : "1-0";
- if (this.atLeastOneMove())
- return "*";
+ if (this.atLeastOneMove()) return "*";
// Kings still there, no moves:
return "1/2";
}
// Kings still there, no moves:
return "1/2";
}
@@
-228,4
+232,5
@@
export class Allmate2Rules extends ChessRules {
}
return notation;
}
}
return notation;
}
+
};
};