Commit | Line | Data |
---|---|---|
c0121280 BA |
1 | import { ChessRules } from "@/base_rules"; |
2 | ||
3 | export 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( | |
15 | sq, | |
16 | color, | |
17 | V.PAWN, | |
18 | V.steps[V.BISHOP], | |
19 | "oneStep" | |
20 | ); | |
21 | } | |
22 | ||
c0121280 BA |
23 | getNotation(move) { |
24 | let notation = super.getNotation(move); | |
b2b5a729 BA |
25 | // If pawn captures backward, add an indication 'b' |
26 | if ( | |
27 | move.appear[0].p == V.PAWN && | |
28 | ( | |
29 | (move.appear[0].c == 'w' && (move.end.x - move.start.x > 0)) || | |
30 | (move.appear[0].c == 'b' && (move.end.x - move.start.x < 0)) | |
31 | ) | |
32 | ) { | |
33 | notation += 'b'; | |
34 | } | |
c0121280 BA |
35 | return notation; |
36 | } | |
7e8a7ea1 | 37 | |
c0121280 | 38 | }; |