From: Benjamin Auder Date: Sat, 9 Jan 2021 21:36:47 +0000 (+0100) Subject: Fix Dobutsu, start draft of Relayup X-Git-Url: https://git.auder.net/variants/Chakart/pieces/current/doc/html/left.jpg?a=commitdiff_plain;h=ecb8f91b8b8ea909baabc8077baf1ca92b4b6664;p=vchess.git Fix Dobutsu, start draft of Relayup --- diff --git a/client/src/variants/Dobutsu.js b/client/src/variants/Dobutsu.js index a5c03868..4d151c3d 100644 --- a/client/src/variants/Dobutsu.js +++ b/client/src/variants/Dobutsu.js @@ -177,6 +177,7 @@ export class DobutsuRules extends ChessRules { } switch (this.getPiece(sq[0], sq[1])) { case V.PAWN: return this.getPotentialPawnMoves(sq); + case V.HEN: return this.getPotentialHenMoves(sq); case V.ELEPHANT: return this.getPotentialElephantMoves(sq); case V.GIRAFFE: return this.getPotentialGiraffeMoves(sq); case V.KING: return super.getPotentialKingMoves(sq); @@ -198,6 +199,13 @@ export class DobutsuRules extends ChessRules { } } + getPotentialHenMoves([x, y]) { + const c = this.turn; + const forward = (c == 'w' ? -1 : 1); + const steps = V.steps[V.ROOK].concat([[forward, 1], [forward, -1]]); + return super.getSlideNJumpMoves(sq, steps, "oneStep"); + } + getPotentialElephantMoves(sq) { return super.getSlideNJumpMoves(sq, V.steps[V.BISHOP], "oneStep"); } diff --git a/client/src/variants/Progressive2.js b/client/src/variants/Progressive2.js index d0c15e61..8df8eeae 100644 --- a/client/src/variants/Progressive2.js +++ b/client/src/variants/Progressive2.js @@ -17,6 +17,10 @@ export class Progressive2Rules extends Progressive1Rules { return false; } + static get HasEnpassant() { + return false; + } + postPlay(move) { const c = move.turn[0]; const piece = move.vanish[0].p; diff --git a/client/src/variants/Relayup.js b/client/src/variants/Relayup.js new file mode 100644 index 00000000..4b85fde1 --- /dev/null +++ b/client/src/variants/Relayup.js @@ -0,0 +1,59 @@ +import { ChessRules } from "@/base_rules"; + +// Pawns relayed by one square at a time (but with relaying pioece movements) +// diff from https://www.chessvariants.com/rules/relay-chess ==> new name +export class RelayupRules extends ChessRules { + + static get PawnSpecs() { + return Object.assign( + {}, + ChessRules.PawnSpecs, + { twoSquares: false } + ); + } + + static get HasFlags() { + return false; + } + + static get HasEnpassant() { + return false; + } + + getPotentialMovesFrom([x, y]) { + let moves = super.getPotentialMovesFrom([x, y]); + + // Expand possible moves if guarded by friendly pieces: + // --> Pawns cannot be promoted through a relaying move (thus 8th rank forbidden) + // TODO + + return moves; + } + + getNotation(move) { + // Translate final and initial square + const initSquare = V.CoordsToSquare(move.start); + const finalSquare = V.CoordsToSquare(move.end); + const piece = this.getPiece(move.start.x, move.start.y); + + // Since pieces and pawns could move like knight, + // indicate start and end squares + let notation = + piece.toUpperCase() + + initSquare + + (move.vanish.length > move.appear.length ? "x" : "") + + finalSquare + + if ( + piece == V.PAWN && + move.appear.length > 0 && + move.appear[0].p != V.PAWN + ) { + // Promotion + notation += "=" + move.appear[0].p.toUpperCase(); + } + + return notation; + } + +};