projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add 'pacoplay mode' to Paco-Sako
[vchess.git]
/
client
/
src
/
variants
/
Absorption.js
diff --git
a/client/src/variants/Absorption.js
b/client/src/variants/Absorption.js
index
7a9ff3c
..
293238d
100644
(file)
--- a/
client/src/variants/Absorption.js
+++ b/
client/src/variants/Absorption.js
@@
-1,6
+1,7
@@
import { ChessRules } from "@/base_rules";
export class AbsorptionRules extends ChessRules {
import { ChessRules } from "@/base_rules";
export class AbsorptionRules extends ChessRules {
+
getPpath(b) {
if ([V.BN, V.RN, V.QN].includes(b[1])) return "Absorption/" + b;
return b;
getPpath(b) {
if ([V.BN, V.RN, V.QN].includes(b[1])) return "Absorption/" + b;
return b;
@@
-49,8
+50,8
@@
export class AbsorptionRules extends ChessRules {
// p1 or p2 already have knight + other piece
return (p1 == V.KNIGHT ? p2 : p1);
}
// p1 or p2 already have knight + other piece
return (p1 == V.KNIGHT ? p2 : p1);
}
+ if ([p1, p2].includes(V.QN)) return V.QN;
for (let p of [p1, p2]) {
for (let p of [p1, p2]) {
- if (p == V.QN) return V.QN;
if ([V.BN, V.RN].includes(p))
return V.MergeComposed[[p1, p2].sort().join("")];
}
if ([V.BN, V.RN].includes(p))
return V.MergeComposed[[p1, p2].sort().join("")];
}
@@
-80,11
+81,23
@@
export class AbsorptionRules extends ChessRules {
default:
moves = super.getPotentialMovesFrom(sq);
}
default:
moves = super.getPotentialMovesFrom(sq);
}
+ // Filter out capturing promotions (except one),
+ // because they are all the same.
+ moves = moves.filter(m => {
+ return (
+ m.vanish.length == 1 ||
+ m.vanish[0].p != V.PAWN ||
+ [V.PAWN, V.QUEEN].includes(m.appear[0].p)
+ );
+ });
moves.forEach(m => {
moves.forEach(m => {
- if (m.vanish.length == 2) {
+ if (
+ m.vanish.length == 2 &&
+ m.appear.length == 1 &&
+ piece != m.vanish[1].p
+ ) {
// Augment pieces abilities in case of captures
// Augment pieces abilities in case of captures
- const piece2 = m.vanish[1].p;
- if (piece != piece2) m.appear[0].p = V.Fusion(piece, piece2);
+ m.appear[0].p = V.Fusion(piece, m.vanish[1].p);
}
});
return moves;
}
});
return moves;
@@
-103,7
+116,7
@@
export class AbsorptionRules extends ChessRules {
return (
this.isAttackedBySlideNJump(sq, color, V.BN, V.steps[V.BISHOP]) ||
this.isAttackedBySlideNJump(
return (
this.isAttackedBySlideNJump(sq, color, V.BN, V.steps[V.BISHOP]) ||
this.isAttackedBySlideNJump(
- sq, color, V.BN, V.steps[V.KNIGHT],
"oneStep"
)
+ sq, color, V.BN, V.steps[V.KNIGHT],
1
)
);
}
);
}
@@
-111,7
+124,7
@@
export class AbsorptionRules extends ChessRules {
return (
this.isAttackedBySlideNJump(sq, color, V.RN, V.steps[V.ROOK]) ||
this.isAttackedBySlideNJump(
return (
this.isAttackedBySlideNJump(sq, color, V.RN, V.steps[V.ROOK]) ||
this.isAttackedBySlideNJump(
- sq, color, V.RN, V.steps[V.KNIGHT],
"oneStep"
)
+ sq, color, V.RN, V.steps[V.KNIGHT],
1
)
);
}
);
}
@@
-120,7
+133,7
@@
export class AbsorptionRules extends ChessRules {
this.isAttackedBySlideNJump(
sq, color, V.QN, V.steps[V.BISHOP].concat(V.steps[V.ROOK])) ||
this.isAttackedBySlideNJump(
this.isAttackedBySlideNJump(
sq, color, V.QN, V.steps[V.BISHOP].concat(V.steps[V.ROOK])) ||
this.isAttackedBySlideNJump(
- sq, color, V.QN, V.steps[V.KNIGHT],
"oneStep"
)
+ sq, color, V.QN, V.steps[V.KNIGHT],
1
)
);
}
);
}
@@
-138,4
+151,5
@@
export class AbsorptionRules extends ChessRules {
notation += "=" + move.appear[0].p.toUpperCase();
return notation;
}
notation += "=" + move.appear[0].p.toUpperCase();
return notation;
}
+
};
};