From: Benjamin Auder Date: Tue, 19 Dec 2023 14:51:02 +0000 (+0100) Subject: Almost fixed Coregal X-Git-Url: https://git.auder.net/variants/img/pieces/doc/index.css?a=commitdiff_plain;h=c08a5e745db2b631bedf981d1ba685b312c7e3b5;p=xogo.git Almost fixed Coregal --- diff --git a/LICENSE b/LICENSE index bd404c0..692028c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ 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 diff --git a/base_rules.js b/base_rules.js index ae2ca80..0f950a2 100644 --- a/base_rules.js +++ b/base_rules.js @@ -1686,6 +1686,10 @@ export default class ChessRules { 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( @@ -1792,7 +1796,10 @@ export default class ChessRules { 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]; diff --git a/variants/Coregal/class.js b/variants/Coregal/class.js index 15a99e2..1d746d6 100644 --- a/variants/Coregal/class.js +++ b/variants/Coregal/class.js @@ -22,7 +22,7 @@ export default class CoregalRules extends ChessRules { 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) { @@ -33,7 +33,7 @@ export default class CoregalRules extends ChessRules { relPos[col][symb] = '1'; //right } else - flags += flags.charAt(i); + flags += s.flags.charAt(i); } } return { @@ -41,25 +41,27 @@ export default class CoregalRules extends ChessRules { 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': {