9fcfc98ed45f302be164287d392090253ff53181
1 import ChessRules
from "/base_rules.js";
2 import {ArrayFun
} from "/utils/array.js";
3 import {Random
} from "/utils/alea.js";
4 import {FenUtil
} from "/utils/setupPieces.js";
6 export default class AlapoRules
extends ChessRules
{
10 select: C
.Options
.select
,
11 styles: C
.Options
.styles
.filter(s
=> s
!= "teleport")
23 let board
= super.getSvgChessboard().slice(0, -6);
24 // Add lines to delimitate goals
26 <line x1="0" y1="10" x2="60" y2="10" stroke="black" stroke-width="0.1"/>
27 <line x1="0" y1="50" x2="60" y2="50" stroke="black" stroke-width="0.1"/>
32 genRandInitBaseFen() {
33 const s
= FenUtil
.setupPieces(
34 ['r', 'b', 'q', 'q', 'b', 'r'],
36 randomness: this.options
["randomness"],
47 s
.b
.map(p
=> piece2pawn
[p
]).join("") +
49 s
.w
.map(p
=> piece2pawn
[p
].toUpperCase()).join("") + "/" +
50 s
.w
.join("").toUpperCase()
52 return { fen: fen
, o: {} };
55 // Triangles are rotated from opponent viewpoint (=> suffix "_inv")
57 const allSpecs
= super.pieces(color
, x
, y
);
61 'b': Object
.assign({}, allSpecs
['b'],
62 {"class": "bishop" + (this.playerColor
!= color
? "_inv" : "")}),
67 steps: [[0, 1], [0, -1], [1, 0], [-1, 0]],
77 [0, 1], [0, -1], [1, 0], [-1, 0],
78 [1, 1], [1, -1], [-1, 1], [-1, -1]
85 "class": "babybishop" + (this.playerColor
!= color
? "_inv" : ""),
88 steps: [[1, 1], [1, -1], [-1, 1], [-1, -1]],
108 // Try both colors (to detect potential suicides)
110 for (let c
of ['w', 'b']) {
111 const oppCol
= C
.GetOppTurn(c
);
112 const goal
= (c
== 'w' ? 0 : 5);
113 won
[c
] = this.board
[goal
].some((b
,j
) => {
115 this.getColor(goal
, j
) == c
&&
116 !this.findCapturesOn(
121 segments: this.options
["cylinder"]
127 if (won
['w'] && won
['b'])
128 return "?"; //no idea who won, not relevant anyway :)
129 return (won
['w'] ? "1-0" : (won
['b'] ? "0-1" : "*"));