From: Benjamin Auder Date: Fri, 6 Jun 2025 17:55:48 +0000 (+0200) Subject: Work on Eightpieces X-Git-Url: https://git.auder.net/assets/js/%7B%7B%20asset('mixstore/images/doc/%7B%7B%20pkg.url%20%7D%7D?a=commitdiff_plain;h=refs%2Fheads%2Fmain;p=xogo.git Work on Eightpieces --- diff --git a/base_rules.js b/base_rules.js index de3fa44..26e8e49 100644 --- a/base_rules.js +++ b/base_rules.js @@ -1151,7 +1151,7 @@ export default class ChessRules { // Color of thing on square (i,j). '' if square is empty getColor(i, j) { if (typeof i == "string") - return i; //reserves + return i; //reserves : 'wb' return this.board[i][j].charAt(0); } @@ -1166,7 +1166,7 @@ export default class ChessRules { // Piece on i,j. '' if square is empty getPiece(i, j) { if (typeof j == "string") - return j; //reserves + return j; //reserves : 'bq' return this.board[i][j].charAt(1); } diff --git a/variants/Eightpieces/class.js b/variants/Eightpieces/class.js index eb68c76..c1edfb4 100644 --- a/variants/Eightpieces/class.js +++ b/variants/Eightpieces/class.js @@ -12,11 +12,6 @@ export default class EightpiecesRules extends ChessRules { }; } -// TODO: variable (setupOthers) for lancers directions (x,y) => dir ("0, 1, 2, ...") 0 = top 1 = north east... / white viewpoint - -//variable lancer_orient ... --> array size 8 x 8 (TODO?) - // - static get LANCER_STEP() { return { 'N': [-1, 0], @@ -30,6 +25,10 @@ export default class EightpiecesRules extends ChessRules { }; } + encodeSquare(x, y) { + return (x*this.size.y+y).toString(); + } + pieces(color, x, y) { let basePieces = super.pieces(color, x, y); const extension = { @@ -54,7 +53,7 @@ export default class EightpiecesRules extends ChessRules { both: [ { steps: [ V.LANCER_STEP [ - this.lancer_orient[(x*this.size.y+y).toString()] ] + this.lancer_orient[this.encodeSquare(x, y)] ] ] } ] @@ -62,30 +61,35 @@ export default class EightpiecesRules extends ChessRules { }; } + get pawnPromotions() { + // TODO: lancer orientation = backward vertical from promotion square? + return ['q', 'r', 'n', 'b', 'j', 's', 'l']; + } + // lorient : "{z1:NO,z2:SE, ...etc}" setOtherVariables(fenParsed) { super.setOtherVariables(fenParsed); this.lancer_orient = JSON.parse(fenParsed.lorient); } - //TODO: from here - - static ParseFen(fen) { - const fenParts = fen.split(" "); - return Object.assign( - ChessRules.ParseFen(fen), - { sentrypush: fenParts[5] } + getPartFen(o) { + return Object.assign({}, + super.getPartFen(o), + { + "lorient": o.init ? "TODO" : this.getLorientFen(), + "sentrypush": o.init ? "-" : this.getSentrypushFen() + } ); } - getFen() { - return super.getFen() + " " + this.getSentrypushFen(); + getLorientFen() { + // TODO: use this.lancer_orient to output {z1:NO,z2:SE, ...etc} + return ""; } - getFenForRepeat() { - return super.getFenForRepeat() + "_" + this.getSentrypushFen(); - } + + // TODO: from here --> L1500 in base -- moves generation getSentrypushFen() { const L = this.sentryPush.length; if (!this.sentryPush[L-1]) return "-"; @@ -97,6 +101,8 @@ export default class EightpiecesRules extends ChessRules { .join(""); } + + setOtherVariables(fen) { super.setOtherVariables(fen); // subTurn == 2 only when a sentry moved, and is about to push something @@ -188,6 +194,12 @@ export default class EightpiecesRules extends ChessRules { return super.canTake([x1, y1], [x2, y2]); } + + + + + + // Is piece on square (x,y) immobilized? isImmobilized([x, y]) { const color = this.getColor(x, y);