X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FExtinction.js;h=e25713782f679ef0773f794a47c8f7071206410a;hp=3fa5327608e50fe2e36c5305e699ada37526924b;hb=32f6285ee325a14286562a53baefc647201df2af;hpb=11482348f50058d235adb89bfc174a1da7c6abc4 diff --git a/client/src/variants/Extinction.js b/client/src/variants/Extinction.js index 3fa53276..e2571378 100644 --- a/client/src/variants/Extinction.js +++ b/client/src/variants/Extinction.js @@ -1,6 +1,14 @@ import { ChessRules } from "@/base_rules"; -export const VariantRules = class ExtinctionRules extends ChessRules { +export class ExtinctionRules extends ChessRules { + static get PawnSpecs() { + return Object.assign( + {}, + ChessRules.PawnSpecs, + { promotions: ChessRules.PawnSpecs.promotions.concat([V.KING]) } + ); + } + static IsGoodPosition(position) { if (!ChessRules.IsGoodPosition(position)) return false; @@ -43,43 +51,6 @@ export const VariantRules = class ExtinctionRules extends ChessRules { }; } - getPotentialPawnMoves([x, y]) { - let moves = super.getPotentialPawnMoves([x, y]); - // Add potential promotions into king - const color = this.turn; - const shift = color == "w" ? -1 : 1; - const lastRank = color == "w" ? 0 : V.size.x - 1; - - if (x + shift == lastRank) { - // Normal move - if (this.board[x + shift][y] == V.EMPTY) - moves.push( - this.getBasicMove([x, y], [x + shift, y], { c: color, p: V.KING }) - ); - // Captures - if ( - y > 0 && - this.board[x + shift][y - 1] != V.EMPTY && - this.canTake([x, y], [x + shift, y - 1]) - ) { - moves.push( - this.getBasicMove([x, y], [x + shift, y - 1], { c: color, p: V.KING }) - ); - } - if ( - y < V.size.y - 1 && - this.board[x + shift][y + 1] != V.EMPTY && - this.canTake([x, y], [x + shift, y + 1]) - ) { - moves.push( - this.getBasicMove([x, y], [x + shift, y + 1], { c: color, p: V.KING }) - ); - } - } - - return moves; - } - // TODO: verify this assertion atLeastOneMove() { return true; //always at least one possible move