X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FTeleport.js;h=f5422c73e0fb8e7e199dcb19ebf2d931a8bb8410;hp=93648c483b9147a4a3af42743265b443a223ce7c;hb=ad030c7d24804fbfa06158e93d89a3f101d2c8b3;hpb=c6624915379363caa432719a6d76a32e09d7136d diff --git a/client/src/variants/Teleport.js b/client/src/variants/Teleport.js index 93648c48..f5422c73 100644 --- a/client/src/variants/Teleport.js +++ b/client/src/variants/Teleport.js @@ -3,8 +3,27 @@ import { randInt } from "@/utils/alea"; export class TeleportRules extends ChessRules { hoverHighlight(x, y) { - // TODO: only highlight if the move is legal - return (this.subTurn == 2 && this.board[x][y] == V.EMPTY); + if (this.subTurn == 1 || this.board[x][y] != V.EMPTY) + return false; + // Only highlight if the move is legal + const color = this.turn; + const tMove = new Move({ + appear: [ + new PiPo({ + x: x, + y: y, + c: color, + // The dropped piece nature has no importance: + p: V.KNIGHT + }) + ], + vanish: [], + start: { x: -1, y: -1 } + }); + this.play(tMove); + const moveOk = !this.underCheck(color); + this.undo(tMove); + return moveOk; } setOtherVariables(fen) {