1 import { ChessRules
} from "@/base_rules";
3 export class FootballRules
extends ChessRules
{
4 static get HasFlags() {
8 static get PawnSpecs() {
12 { promotions: ChessRules
.PawnSpecs
.promotions
.concat([V
.KING
]) }
31 static IsGoodPosition(position
) {
32 if (position
.length
== 0) return false;
33 const rows
= position
.split("/");
34 if (rows
.length
!= V
.size
.x
) return false;
35 // Just check that at least one piece of each color is there:
36 let pieces
= { "w": 0, "b": 0 };
37 for (let row
of rows
) {
39 for (let i
= 0; i
< row
.length
; i
++) {
40 const lowerRi
= row
[i
].toLowerCase();
41 if (V
.PIECES
.includes(lowerRi
)) {
42 pieces
[row
[i
] == lowerRi
? "b" : "w"]++;
45 const num
= parseInt(row
[i
]);
46 if (isNaN(num
)) return false;
50 if (sumElts
!= V
.size
.y
) return false;
52 if (Object
.values(pieces
).some(v
=> v
== 0)) return false;
66 // No variables update because no royal king + no castling
73 const oppCol
= V
.GetOppCol(this.turn
);
74 const goal
= (oppCol
== 'w' ? 0 : 7);
75 if (this.board
[goal
].slice(3, 5).some(b
=> b
[0] == oppCol
))
76 return oppCol
== 'w' ? "1-0" : "0-1";
77 if (this.atLeastOneMove()) return "*";