1 import ChessRules
from "/base_rules.js";
3 export default class DobutsuRules
extends ChessRules
{
18 const pawnShift
= this.getPawnShift(color
|| 'w');
19 // NOTE: classs change according to playerColor (orientation)
20 const mySide
= (this.playerColor
== color
);
23 "class": (mySide
? "" : "rev-") + "chick",
24 both: [{steps: [[pawnShift
, 0]], range: 1}]
27 "class": (mySide
? "" : "rev-") + "hen",
31 [pawnShift
, 1], [pawnShift
, -1],
32 [0, 1], [0, -1], [1, 0], [-1, 0]
39 "class": (mySide
? "" : "rev-") + "elephant",
40 both: [{steps: [[-1, 1], [-1, -1], [1, 1], [1, -1]], range: 1}]
43 "class": (mySide
? "" : "rev-") + "giraffe",
44 both: [{steps: [[0, 1], [0, -1], [1, 0], [-1, 0]], range: 1}]
47 "class": (mySide
? "" : "rev-") + "lion",
49 steps: [[-1, 1], [-1, -1], [1, 1], [1, -1],
50 [0, 1], [0, -1], [1, 0], [-1, 0]],
57 static get ReserveArray() {
58 return ['p', 'h', 'e', 'g'];
61 updateReserve(color
, piece
, count
) {
63 super.updateReserve(color
, piece
, count
);
67 o
.options
= {crazyhouse: true, taking: true};
71 get pawnPromotions() {
75 genRandInitBaseFen() {
77 fen: "gke/1p1/1P1/EKG",
86 getCurrentScore(move_s
) {
87 const res
= super.getCurrentScore(move_s
);
90 for (let lastRank
of [0, 3]) {
91 const color
= (lastRank
== 0 ? 'w' : 'b');
92 for (let j
=0; j
< this.size
.y
; j
++) {
94 this.board
[lastRank
][j
] == color
+ 'k' &&
95 !this.underAttack([lastRank
, j
], [C
.GetOppTurn(color
)])
97 return (color
== 'w' ? "1-0" : "0-1");