projects
/
xogo.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
55a15dc
)
Fix cannibal promotions
author
Benjamin Auder
<benjamin.auder@somewhere>
Tue, 16 Nov 2021 22:31:21 +0000
(23:31 +0100)
committer
Benjamin Auder
<benjamin.auder@somewhere>
Tue, 16 Nov 2021 22:31:21 +0000
(23:31 +0100)
base_rules.js
patch
|
blob
|
blame
|
history
diff --git
a/base_rules.js
b/base_rules.js
index
715f4e0
..
4808d0c
100644
(file)
--- a/
base_rules.js
+++ b/
base_rules.js
@@
-1543,11
+1543,19
@@
export default class ChessRules {
addPawnMoves([x1, y1], [x2, y2], moves, promotions) {
let finalPieces = ["p"];
const color = this.getColor(x1, y1);
addPawnMoves([x1, y1], [x2, y2], moves, promotions) {
let finalPieces = ["p"];
const color = this.getColor(x1, y1);
+ const oppCol = C.GetOppCol(color);
const lastRank = (color == "w" ? 0 : this.size.x - 1);
if (x2 == lastRank && (!this.options["rifle"] || this.board[x2][y2] == ""))
{
// promotions arg: special override for Hiddenqueen variant
const lastRank = (color == "w" ? 0 : this.size.x - 1);
if (x2 == lastRank && (!this.options["rifle"] || this.board[x2][y2] == ""))
{
// promotions arg: special override for Hiddenqueen variant
- if (promotions) finalPieces = promotions;
+ if (
+ this.options["cannibal"] &&
+ this.board[x2][y2] != "" &&
+ this.getColor(x2, y2) == oppCol
+ ) {
+ finalPieces = [this.getPieceType(x2, y2)];
+ }
+ else if (promotions) finalPieces = promotions;
else if (this.pawnSpecs.promotions)
finalPieces = this.pawnSpecs.promotions;
}
else if (this.pawnSpecs.promotions)
finalPieces = this.pawnSpecs.promotions;
}