[Paco-Sako] At least forbid to castle when under direct check
[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,
16 color,
17 V.PAWN,
18 V.steps[V.BISHOP],
19 "oneStep"
20 );
21 }
22
23 getNotation(move) {
24 let notation = super.getNotation(move);
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 }
35 return notation;
36 }
37
38 };