Attempt to fix Eightpieces
[vchess.git] / client / src / variants / Vchess.js
CommitLineData
c0121280
BA
1import { ChessRules } from "@/base_rules";
2
3export class VchessRules extends ChessRules {
7e8a7ea1 4
c0121280
BA
5 static get PawnSpecs() {
6 return Object.assign(
7 {},
8 ChessRules.PawnSpecs,
9 { captureBackward: true }
10 );
11 }
12
1d67d961
BA
13 isAttackedByPawn(sq, color) {
14 return this.isAttackedBySlideNJump(
4313762d 15 sq, color, V.PAWN, V.steps[V.BISHOP], 1);
1d67d961
BA
16 }
17
c0121280
BA
18 getNotation(move) {
19 let notation = super.getNotation(move);
b2b5a729
BA
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 }
c0121280
BA
30 return notation;
31 }
7e8a7ea1 32
c0121280 33};