3707ac87b33fb2960e2c4dedfd603674161ce55f
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() {
34 FenUtil
.setupPieces(['r', 'b', 'q', 'q', 'b', 'r'], {diffCol: ['b']});
42 s
.b
.map(p
=> piece2pawn
[p
]).join("") +
44 s
.w
.map(p
=> piece2pawn
[p
].toUpperCase()).join("") + "/" +
45 s
.w
.join("").toUpperCase()
47 return { fen: fen
, o: {} };
50 // Triangles are rotated from opponent viewpoint (=> suffix "_inv")
52 const allSpecs
= super.pieces(color
, x
, y
);
56 'b': Object
.assign({}, allSpecs
['b'],
57 {"class": "bishop" + (this.playerColor
!= color
? "_inv" : "")}),
62 steps: [[0, 1], [0, -1], [1, 0], [-1, 0]],
72 [0, 1], [0, -1], [1, 0], [-1, 0],
73 [1, 1], [1, -1], [-1, 1], [-1, -1]
80 "class": "babybishop" + (this.playerColor
!= color
? "_inv" : ""),
83 steps: [[1, 1], [1, -1], [-1, 1], [-1, -1]],
103 // Try both colors (to detect potential suicides)
105 for (let c
of ['w', 'b']) {
106 const oppCol
= C
.GetOppCol(c
);
107 const goal
= (c
== 'w' ? 0 : 5);
108 won
[c
] = this.board
[goal
].some((b
,j
) => {
110 this.getColor(goal
, j
) == c
&&
111 !this.findCapturesOn(
116 segments: this.options
["cylinder"]
122 if (won
['w'] && won
['b'])
123 return "?"; //no idea who won, not relevant anyway :)
124 return (won
['w'] ? "1-0" : (won
['b'] ? "0-1" : "*"));