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