From: Benjamin Auder Date: Tue, 17 Nov 2020 10:57:38 +0000 (+0100) Subject: Early draft of TitanChess X-Git-Url: https://git.auder.net/doc/html/packages.html?a=commitdiff_plain;h=b0d55a053a319e1972c52a3c851dff787f52e015;p=vchess.git Early draft of TitanChess --- diff --git a/client/src/variants/Titan.js b/client/src/variants/Titan.js new file mode 100644 index 00000000..9e147cd3 --- /dev/null +++ b/client/src/variants/Titan.js @@ -0,0 +1,50 @@ +import { ChessRules } from "@/base_rules"; + +export class TitanRules extends ChessRules { + // Idea: yellow = bishop, orange = knight (for white) + // and, red = bishop + purple = knight (black side) + // (avoid using a bigger board, or complicated drawings) + + // TODO: decode if piece + bishop or knight + getPiece() {} + + // Code: a/c = bishop + knight/bishop j/l for king, + // m/o for knight, s/t for queen, u/v for rook + static get AUGMENTED_PIECES() { + return { + // ... + }; + } + // or: + getExtraPiece(symbol) { + // TODO: switch ... case ... return b or n + } + + // TODO: hook after any move from 1st rank, + // if piece not in usual list, bishop or knight appears. + getPotentialMovesFrom(sq) { + let moves = super.getPotentialMovesFrom(sq); + const color = this.turn; + if ( + !ChessRules.PIECES.includes(this.board[sq[0]][sq[1]][1]) && + ((color == 'w' && sq[0] == 7) || (color == "b" && sq[0] == 0)) + ) { + // (or lookup table) + const newPiece = this.getExtraPiece(this.board[sq[0]][sq[1]][1]) + moves.forEach(m => { + m.appear.push( + new PiPo({ + p: newPiece, + c: color, + x: sq[0], + y: sq[1] + }) + ); + }); + } + return moves; + } + + // TODO: special case of move 1 = choose squares, knight first, then bishop + // (just click ?) +};