ISC license https://opensource.org/licenses/ISC
-Copyright (C) 2021-2022 Benjamin Auder
+Copyright (C) 2021-2024 Benjamin Auder
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
getPotentialMovesOf(piece, [x, y]) {
const color = this.getColor(x, y);
const stepSpec = this.getStepSpec(color, x, y, piece);
+
+ // TODO: pawns, coregal
+console.log(stepSpec);
+
let squares = [];
if (stepSpec.attack) {
squares = this.findDestSquares(
continue outerLoop;
const oldIJ = [i, j];
[i, j] = this.increment([i, j], step);
- if (Math.abs(j - oldIJ[1]) > 1 || Math.abs(i - oldIJ[0]) > 1) {
+ if (
+ Math.abs(i - oldIJ[0]) != Math.abs(step[0]) ||
+ Math.abs(j - oldIJ[1]) != Math.abs(step[1])
+ ) {
// Boundary between segments (cylinder or circular mode)
segments.push([[segStart[0], segStart[1]], oldIJ]);
segStart = [i, j];
const col = (c == 0 ? 'w' : 'b');
let first = "";
for (let i=4*c; i<4*(c+1); i++) {
- const pos = parseInt(flags.charAt(i), 10);
+ const pos = parseInt(s.flags.charAt(i), 10);
const symb = s[col][pos];
if (['k', 'l'].includes(symb)) {
if (!first) {
relPos[col][symb] = '1'; //right
}
else
- flags += flags.charAt(i);
+ flags += s.flags.charAt(i);
}
}
return {
s.w.join("").toUpperCase(),
o: {
flags: flags + flags, //duplicate: one for each royal piece
- relPos: (
- relPos['w']['k'] + relPos['w']['l'] +
- relPos['b']['k'] + relPos['b']['l']
- )
+ relPos: this.getRelposFen(relPos)
}
};
}
getPartFen(o) {
return (Object.assign(
- {"relpos": o.relPos},
+ {"relpos": o.init ? o.relPos : this.getRelposFen()},
super.getPartFen(o)
));
}
+ getRelposFen(relPos) {
+ relPos = relPos || this.relPos;
+ return (
+ relPos['w']['k'] + relPos['w']['l'] +
+ relPos['b']['k'] + relPos['b']['l']
+ );
+ }
+
setOtherVariables(fenParsed, pieceArray) {
-
-//TODO: issue, relPos is set at init but doesn't persist --> see base_rules.js line 263
-console.log(fenParsed);
super.setOtherVariables(fenParsed, pieceArray);
this.relPos = {
'w': {