| 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 | |
| 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 | |
| 22 | getNotation(move) { |
| 23 | let notation = super.getNotation(move); |
| 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 | } |
| 34 | return notation; |
| 35 | } |
| 36 | }; |