X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FGame.vue;h=ec1962ee4d744620004938f7e22ebb9b97faa9cc;hp=6ea6cdd96c354f8a459cb0c777840fa0f10c85ab;hb=dfeb96ea90e880a2557cbb5953dbb7258c912283;hpb=602d6befd30793111d3fda6e733f73e08d8b7a30 diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 6ea6cdd9..ec1962ee 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -320,6 +320,8 @@ export default { } else if (this.drawOffer == "") //no effect if drawOffer == "sent" { + if (this.game.mycolor != this.vr.turn) + return alert(this.st.tr["Draw offer only in your turn"]); if (!confirm(this.st.tr["Offer draw?"])) return; this.drawOffer = "sent"; @@ -327,7 +329,7 @@ export default { if (sid != this.st.user.sid) this.st.conn.send(JSON.stringify({code:"drawoffer", target:sid})); }); - GameStorage.update(this.gameRef.id, {drawOffer: true}); + GameStorage.update(this.gameRef.id, {drawOffer: this.game.mycolor}); } }, abortGame: function() { @@ -396,8 +398,6 @@ export default { } if (L >= 1) game.initime[L%2] = game.moves[L-1].played; - if (game.drawOffer) - this.drawOffer = "received"; } // Now that we used idx and played, re-format moves as for live games game.moves = game.moves.map( (m) => { @@ -432,6 +432,22 @@ export default { } } } + + + + // TODO: (and also when receiving / sending a move ?) +// if (!!game.drawOffer) +// { +// if (game.drawOffer == "w") +// { +// if (myIdx == 0) +// { +// this.drawOffer = "sent"; + + + + + this.game = Object.assign({}, game, // NOTE: assign mycolor here, since BaseGame could also be VS computer