fc4337294b1f1581ca5a594119897742d6f8dce8
[vchess.git] / client / src / variants / Vchess.js
1 import { ChessRules } from "@/base_rules";
2
3 export class VchessRules extends ChessRules {
4
5 static get PawnSpecs() {
6 return Object.assign(
7 {},
8 ChessRules.PawnSpecs,
9 { captureBackward: true }
10 );
11 }
12
13 isAttackedByPawn(sq, color) {
14 return this.isAttackedBySlideNJump(
15 sq, color, V.PAWN, V.steps[V.BISHOP], 1);
16 }
17
18 getNotation(move) {
19 let notation = super.getNotation(move);
20 // If pawn captures backward, add an indication 'b'
21 if (
22 move.appear[0].p == V.PAWN &&
23 (
24 (move.appear[0].c == 'w' && (move.end.x - move.start.x > 0)) ||
25 (move.appear[0].c == 'b' && (move.end.x - move.start.x < 0))
26 )
27 ) {
28 notation += 'b';
29 }
30 return notation;
31 }
32
33 };