1 import { ChessRules
} from "@/base_rules";
2 import { ArrayFun
} from "@/utils/array";
4 export class RugbyRules
extends ChessRules
{
5 static get HasFlags() {
9 static get PawnSpecs() {
13 { promotions: [V
.PAWN
] }
19 getPotentialMovesFrom(sq
) {
20 // There are only pawns:
21 return this.getPotentialPawnMoves(sq
);
24 getPotentialPawnMoves(sq
) {
25 const moves
= super.getPotentialPawnMoves(sq
);
26 // Add king movements, without capturing
29 ? [ [-1,-1], [-1,1], [0,1], [0,-1], [1,-1], [1,0], [1,1] ]
30 : [ [1,-1], [1,1], [0,1], [0,-1], [-1,-1], [-1,0], [-1,1] ];
31 let addMoves
= this.getSlideNJumpMoves(sq
, steps
, "oneStep");
32 return moves
.concat(addMoves
.filter(m
=> m
.vanish
.length
== 1));
35 static GenRandInitFen() {
36 // Non-randomized variant. En-passant possible:
37 return "pppppppp/8/8/8/8/8/8/PPPPPPPP w 0 -";
55 const color
= V
.GetOppCol(this.turn
);
56 const lastRank
= (color
== "w" ? 0 : V
.size
.x
- 1);
57 if (ArrayFun
.range(8).some(i
=> this.getColor(lastRank
, i
) == color
))
58 // The opposing edge is reached!
59 return color
== "w" ? "1-0" : "0-1";
60 if (this.atLeastOneMove()) return "*";
61 // Stalemate (will probably never happen)