projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix Koopa promotions after stunning pieces
[vchess.git]
/
client
/
src
/
variants
/
Koopa.js
diff --git
a/client/src/variants/Koopa.js
b/client/src/variants/Koopa.js
index
f24e5b2
..
c7b0859
100644
(file)
--- a/
client/src/variants/Koopa.js
+++ b/
client/src/variants/Koopa.js
@@
-49,11
+49,9
@@
export class KoopaRules extends ChessRules {
}
getStunnedFen() {
}
getStunnedFen() {
- return (
- Object.keys(this.stunned)
- .map(square => square + this.stunned[square])
- .join(",")
- );
+ const squares = Object.keys(this.stunned);
+ if (squares.length == 0) return "-";
+ return squares.map(square => square + this.stunned[square]).join(",");
}
// Base GenRandInitFen() is fine because en-passant indicator will
}
// Base GenRandInitFen() is fine because en-passant indicator will
@@
-80,7
+78,7
@@
export class KoopaRules extends ChessRules {
this.INIT_COL_KING["w"] = k;
break;
default: {
this.INIT_COL_KING["w"] = k;
break;
default: {
- const num = parseInt(fenRows[i].charAt(j));
+ const num = parseInt(fenRows[i].charAt(j)
, 10
);
if (!isNaN(num)) k += num - 1;
}
}
if (!isNaN(num)) k += num - 1;
}
}
@@
-100,7
+98,7
@@
export class KoopaRules extends ChessRules {
.map(s => {
return {
square: s.substr(0, 2),
.map(s => {
return {
square: s.substr(0, 2),
- state: parseInt(s[2])
+ state: parseInt(s[2]
, 10
)
};
});
}
};
});
}
@@
-186,7
+184,10
@@
export class KoopaRules extends ChessRules {
m.appear[0].x = i;
m.appear[0].y = j;
// Is it a pawn on last rank?
m.appear[0].x = i;
m.appear[0].y = j;
// Is it a pawn on last rank?
- if ((color == 'w' && i == 0) || (color == 'b' && i == 7)) {
+ if (
+ m.appear[0].p == V.PAWN &&
+ ((color == 'w' && i == 0) || (color == 'b' && i == 7))
+ ) {
m.appear[0].p = V.ROOK;
for (let ppiece of [V.KNIGHT, V.BISHOP, V.QUEEN]) {
let mp = JSON.parse(JSON.stringify(m));
m.appear[0].p = V.ROOK;
for (let ppiece of [V.KNIGHT, V.BISHOP, V.QUEEN]) {
let mp = JSON.parse(JSON.stringify(m));