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