X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FBoard.vue;h=0d531a6b4594de3f731bc35a1e2bd46128de915c;hb=3a2a7b5fd3c6bfd0752838094c27e1fb6172d109;hp=f2fd44c3be74963a7db27c255b8cad26452bbbe8;hpb=fabb53f2e009b79c2c87ea7683e45b3202d4a934;p=vchess.git diff --git a/client/src/components/Board.vue b/client/src/components/Board.vue index f2fd44c3..0d531a6b 100644 --- a/client/src/components/Board.vue +++ b/client/src/components/Board.vue @@ -25,6 +25,7 @@ export default { selectedPiece: null, //moving piece (or clicked piece) start: null, //pixels coordinates + id of starting square (click or drag) click: "", + clickTime: 0, settings: store.state.settings }; }, @@ -112,7 +113,12 @@ export default { attrs: { src: "/images/pieces/" + - this.vr.getPpath(this.vr.board[ci][cj], this.userColor, this.score) + + this.vr.getPpath( + this.vr.board[ci][cj], + // Extra args useful for some variants: + this.userColor, + this.score, + this.orientation) + ".svg" } }) @@ -275,9 +281,10 @@ export default { if (!!this.vr.reserve) elementArray.push(reserveBottom); const boardElt = document.querySelector(".game"); if (this.choices.length > 0 && !!boardElt) { - //no choices to show at first drawing + // No choices to show at first drawing const squareWidth = boardElt.offsetWidth / sizeY; const offset = [boardElt.offsetTop, boardElt.offsetLeft]; + // TODO: multi-rows if more than V.size.y pieces (as inEightpieces) const choices = h( "div", { @@ -297,6 +304,9 @@ export default { // A "choice" is a move const applyMove = (e) => { e.stopPropagation(); + // Force a delay between move is shown and clicked + // (otherwise a "double-click" bug might occur) + if (Date.now() - this.clickTime < 200) return; this.play(m); this.choices = []; }; @@ -321,7 +331,10 @@ export default { attrs: { src: "/images/pieces/" + - this.vr.getPpath(m.appear[0].c + m.appear[0].p) + + this.vr.getPPpath( + m.appear[0].c + m.appear[0].p, + // Extra arg useful for some variants: + this.orientation) + ".svg" }, class: { "choice-piece": true }, @@ -440,8 +453,10 @@ export default { let endSquare = getSquareFromId(landing.id); let moves = this.findMatchingMoves(endSquare); this.possibleMoves = []; - if (moves.length > 1) this.choices = moves; - else if (moves.length == 1) this.play(moves[0]); + if (moves.length > 1) { + this.clickTime = Date.now(); + this.choices = moves; + } else if (moves.length == 1) this.play(moves[0]); // else: forbidden move attempt }, findMatchingMoves: function(endSquare) {