X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FShogi.js;h=9104ed92d70ea59b64b95ac72bbfbcd3f06170ce;hb=ded43c88fad60fd8f9bb46aabd67f3f2092f65f3;hp=521e46806310c6a71d183271f9250ab20058e700;hpb=b4f2488a58c5c92e1673cd64c6bba13afcafbf66;p=vchess.git diff --git a/client/src/variants/Shogi.js b/client/src/variants/Shogi.js index 521e4680..9104ed92 100644 --- a/client/src/variants/Shogi.js +++ b/client/src/variants/Shogi.js @@ -3,6 +3,7 @@ import { ArrayFun } from "@/utils/array"; import { sample, shuffle } from "@/utils/alea"; export class ShogiRules extends ChessRules { + static get HasFlags() { return false; } @@ -15,6 +16,10 @@ export class ShogiRules extends ChessRules { return true; } + get showFirstTurn() { + return true; + } + static get Notoodark() { return true; } @@ -176,26 +181,27 @@ export class ShogiRules extends ChessRules { setOtherVariables(fen) { super.setOtherVariables(fen); - const fenParsed = V.ParseFen(fen); // Also init reserves (used by the interface to show landable pieces) + const reserve = + V.ParseFen(fen).reserve.split("").map(x => parseInt(x, 10)); this.reserve = { w: { - [V.PAWN]: parseInt(fenParsed.reserve[0]), - [V.ROOK]: parseInt(fenParsed.reserve[1]), - [V.BISHOP]: parseInt(fenParsed.reserve[2]), - [V.GOLD_G]: parseInt(fenParsed.reserve[3]), - [V.SILVER_G]: parseInt(fenParsed.reserve[4]), - [V.KNIGHT]: parseInt(fenParsed.reserve[5]), - [V.LANCE]: parseInt(fenParsed.reserve[6]) + [V.PAWN]: reserve[0], + [V.ROOK]: reserve[1], + [V.BISHOP]: reserve[2], + [V.GOLD_G]: reserve[3], + [V.SILVER_G]: reserve[4], + [V.KNIGHT]: reserve[5], + [V.LANCE]: reserve[6] }, b: { - [V.PAWN]: parseInt(fenParsed.reserve[7]), - [V.ROOK]: parseInt(fenParsed.reserve[8]), - [V.BISHOP]: parseInt(fenParsed.reserve[9]), - [V.GOLD_G]: parseInt(fenParsed.reserve[10]), - [V.SILVER_G]: parseInt(fenParsed.reserve[11]), - [V.KNIGHT]: parseInt(fenParsed.reserve[12]), - [V.LANCE]: parseInt(fenParsed.reserve[13]) + [V.PAWN]: reserve[7], + [V.ROOK]: reserve[8], + [V.BISHOP]: reserve[9], + [V.GOLD_G]: reserve[10], + [V.SILVER_G]: reserve[11], + [V.KNIGHT]: reserve[12], + [V.LANCE]: reserve[13] } }; } @@ -306,7 +312,7 @@ export class ShogiRules extends ChessRules { case V.LANCE: return this.getPotentialLanceMoves([x, y]); case V.KING: - return this.getPotentialKingMoves([x, y]); + return super.getPotentialKingMoves([x, y]); case V.P_ROOK: return this.getPotentialDragonMoves([x, y]); case V.P_BISHOP: @@ -445,14 +451,6 @@ export class ShogiRules extends ChessRules { ); } - getPotentialKingMoves(sq) { - return this.getSlideNJumpMoves( - sq, - V.steps[V.ROOK].concat(V.steps[V.BISHOP]), - { oneStep: true } - ); - } - isAttacked(sq, color) { return ( this.isAttackedByPawn(sq, color) || @@ -655,4 +653,5 @@ export class ShogiRules extends ChessRules { ) ); } + };