5250089e0832824936493c8ec8d3b72d4e8e7479
1 import { ChessRules
} from "@/base_rules";
3 export class EvolutionRules
extends ChessRules
{
5 getPotentialMovesFrom([x
, y
]) {
6 let moves
= super.getPotentialMovesFrom([x
, y
]);
7 const c
= this.getColor(x
, y
);
8 const piece
= this.getPiece(x
, y
);
10 [V
.BISHOP
, V
.ROOK
, V
.QUEEN
].includes(piece
) &&
11 (c
== 'w' && x
== 7) || (c
== 'b' && x
== 0)
13 // Move from first rank
14 const forward
= (c
== 'w' ? -1 : 1);
15 for (let shift
of [-2, 0, 2]) {
17 (piece
== V
.ROOK
&& shift
!= 0) ||
18 (piece
== V
.BISHOP
&& shift
== 0)
23 V
.OnBoard(x
+2*forward
, y
+shift
) &&
24 this.board
[x
+forward
][y
+shift
/2] != V
.EMPTY
&&
25 this.getColor(x
+2*forward
, y
+shift
) != c
27 moves
.push(this.getBasicMove([x
,y
], [x
+2*forward
,y
+shift
]));