projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix notation and pieces setup for random asymmetric in Eightpieces
[vchess.git]
/
client
/
src
/
variants
/
Eightpieces.js
diff --git
a/client/src/variants/Eightpieces.js
b/client/src/variants/Eightpieces.js
index
81d69d8
..
42df93e
100644
(file)
--- a/
client/src/variants/Eightpieces.js
+++ b/
client/src/variants/Eightpieces.js
@@
-175,7
+175,8
@@
export class EightpiecesRules extends ChessRules {
if (c == 'b') {
// Check if white sentry is on the same color as ours.
// If yes: swap bishop and sentry positions.
if (c == 'b') {
// Check if white sentry is on the same color as ours.
// If yes: swap bishop and sentry positions.
- if ((pieces['w'].indexOf('s') - sentryPos) % 2 == 0)
+ // NOTE: test % 2 == 1 because there are 7 slashes.
+ if ((pieces['w'].indexOf('s') - sentryPos) % 2 == 1)
[bishopPos, sentryPos] = [sentryPos, bishopPos];
}
positions.splice(Math.max(randIndex, randIndex_tmp), 1);
[bishopPos, sentryPos] = [sentryPos, bishopPos];
}
positions.splice(Math.max(randIndex, randIndex_tmp), 1);
@@
-761,6
+762,7
@@
export class EightpiecesRules extends ChessRules {
super.isAttacked(sq, color) ||
this.isAttackedByLancer(sq, color) ||
this.isAttackedBySentry(sq, color)
super.isAttacked(sq, color) ||
this.isAttackedByLancer(sq, color) ||
this.isAttackedBySentry(sq, color)
+ // The jailer doesn't capture.
);
}
);
}
@@
-836,6
+838,7
@@
export class EightpiecesRules extends ChessRules {
// Helper to check sentries attacks:
selfAttack([x1, y1], [x2, y2]) {
const color = this.getColor(x1, y1);
// Helper to check sentries attacks:
selfAttack([x1, y1], [x2, y2]) {
const color = this.getColor(x1, y1);
+ const oppCol = V.GetOppCol(color);
const sliderAttack = (allowedSteps, lancer) => {
const deltaX = x2 - x1,
absDeltaX = Math.abs(deltaX);
const sliderAttack = (allowedSteps, lancer) => {
const deltaX = x2 - x1,
absDeltaX = Math.abs(deltaX);
@@
-854,7
+857,7
@@
export class EightpiecesRules extends ChessRules {
if (
// NOTE: no need to check OnBoard in this special case
(!lancer && this.board[sq[0]][sq[1]] != V.EMPTY) ||
if (
// NOTE: no need to check OnBoard in this special case
(!lancer && this.board[sq[0]][sq[1]] != V.EMPTY) ||
- (!!lancer && this.getColor(sq[0], sq[1])
!= color
)
+ (!!lancer && this.getColor(sq[0], sq[1])
== oppCol
)
) {
return false;
}
) {
return false;
}
@@
-1028,6
+1031,13
@@
export class EightpiecesRules extends ChessRules {
if (Object.keys(V.LANCER_DIRNAMES).includes(move.vanish[0].p))
// Lancer: add direction info
notation += "=" + V.LANCER_DIRNAMES[move.appear[0].p];
if (Object.keys(V.LANCER_DIRNAMES).includes(move.vanish[0].p))
// Lancer: add direction info
notation += "=" + V.LANCER_DIRNAMES[move.appear[0].p];
+ else if (
+ move.vanish[0].p == V.PAWN &&
+ Object.keys(V.LANCER_DIRNAMES).includes(move.appear[0].p)
+ ) {
+ // Fix promotions in lancer:
+ notation = notation.slice(0, -1) + "L:" + V.LANCER_DIRNAMES[move.appear[0].p];
+ }
return notation;
}
};
return notation;
}
};