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
] }
17 getPotentialMovesFrom(sq
) {
18 // There are only pawns:
19 return this.getPotentialPawnMoves(sq
);
22 getPotentialPawnMoves(sq
) {
23 const moves
= super.getPotentialPawnMoves(sq
);
24 // Add king movements, without capturing
27 ? [ [-1,-1], [-1,1], [0,1], [0,-1], [1,-1], [1,0], [1,1] ]
28 : [ [1,-1], [1,1], [0,1], [0,-1], [-1,-1], [-1,0], [-1,1] ];
29 let addMoves
= this.getSlideNJumpMoves(sq
, steps
, "oneStep");
30 return moves
.concat(addMoves
.filter(m
=> m
.vanish
.length
== 1));
33 static GenRandInitFen() {
34 // Non-randomized variant. En-passant possible:
35 return "pppppppp/8/8/8/8/8/8/PPPPPPPP w 0 -";
49 const color
= V
.GetOppCol(this.turn
);
50 const lastRank
= (color
== "w" ? 0 : V
.size
.x
- 1);
51 if (ArrayFun
.range(8).some(i
=> this.getColor(lastRank
, i
) == color
))
52 // The opposing edge is reached!
53 return color
== "w" ? "1-0" : "0-1";
54 if (this.atLeastOneMove()) return "*";
55 // Stalemate (will probably never happen)