1 import { ChessRules
} from "@/base_rules";
2 import { ArrayFun
} from "@/utils/array";
4 export class RugbyRules
extends ChessRules
{
10 static get HasFlags() {
14 static get PawnSpecs() {
18 { promotions: [V
.PAWN
] }
24 getPotentialMovesFrom(sq
) {
25 // There are only pawns:
26 return this.getPotentialPawnMoves(sq
);
29 getPotentialPawnMoves(sq
) {
30 const moves
= super.getPotentialPawnMoves(sq
);
31 // Add king movements, without capturing
34 ? [ [-1,-1], [-1,1], [0,1], [0,-1], [1,-1], [1,0], [1,1] ]
35 : [ [1,-1], [1,1], [0,1], [0,-1], [-1,-1], [-1,0], [-1,1] ];
36 let addMoves
= this.getSlideNJumpMoves(sq
, steps
, 1);
37 return moves
.concat(addMoves
.filter(m
=> m
.vanish
.length
== 1));
40 static GenRandInitFen() {
41 // Non-randomized variant. En-passant possible:
42 return "pppppppp/8/8/8/8/8/8/PPPPPPPP w 0 -";
60 const color
= V
.GetOppCol(this.turn
);
61 const lastRank
= (color
== "w" ? 0 : V
.size
.x
- 1);
62 if (ArrayFun
.range(8).some(i
=> this.getColor(lastRank
, i
) == color
))
63 // The opposing edge is reached!
64 return color
== "w" ? "1-0" : "0-1";
65 if (this.atLeastOneMove()) return "*";
66 // Stalemate (will probably never happen)
71 return V
.CoordsToSquare(move.start
) + V
.CoordsToSquare(move.end
);