projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixes
[vchess.git]
/
client
/
src
/
views
/
Game.vue
diff --git
a/client/src/views/Game.vue
b/client/src/views/Game.vue
index
b7cc1fc
..
7971aab
100644
(file)
--- a/
client/src/views/Game.vue
+++ b/
client/src/views/Game.vue
@@
-30,8
+30,7
@@
main
span.name(:class="{connected: isConnected(1)}")
| {{ game.players[1].name || "@nonymous" }}
span.time(v-if="game.score=='*'") {{ virtualClocks[1] }}
span.name(:class="{connected: isConnected(1)}")
| {{ game.players[1].name || "@nonymous" }}
span.time(v-if="game.score=='*'") {{ virtualClocks[1] }}
- BaseGame(:game="game" :vr="vr" ref="basegame"
- @newmove="processMove" @gameover="gameOver")
+ BaseGame(:game="game" :vr="vr" @newmove="processMove" @gameover="gameOver")
</template>
<script>
</template>
<script>
@@
-134,7
+133,11
@@
export default {
if (!!this.conn && this.conn.readyState == 1) //1 == OPEN state
callback();
else //socket not ready yet (initial loading)
if (!!this.conn && this.conn.readyState == 1) //1 == OPEN state
callback();
else //socket not ready yet (initial loading)
- this.conn.onopen = callback;
+ {
+ // NOTE: it's important to call callback without arguments,
+ // otherwise first arg is Websocket object and loadGame fails.
+ this.conn.onopen = () => { return callback() };
+ }
};
if (!this.gameRef.rid) //game stored locally or on server
this.loadGame(null, () => socketInit(this.roomInit));
};
if (!this.gameRef.rid) //game stored locally or on server
this.loadGame(null, () => socketInit(this.roomInit));
@@
-340,13
+343,10
@@
export default {
this.drawOffer = "received";
break;
case "newchat":
this.drawOffer = "received";
break;
case "newchat":
- {
- const chat = data.data;
- this.newChat = chat;
+ this.newChat = data.data;
if (!document.getElementById("modalChat").checked)
document.getElementById("chatBtn").style.backgroundColor = "#c5fefe";
break;
if (!document.getElementById("modalChat").checked)
document.getElementById("chatBtn").style.backgroundColor = "#c5fefe";
break;
- }
}
},
socketCloseListener: function() {
}
},
socketCloseListener: function() {
@@
-540,7
+540,8
@@
export default {
});
if (this.repeat[repIdx] >= 3)
this.drawOffer = "threerep";
});
if (this.repeat[repIdx] >= 3)
this.drawOffer = "threerep";
- callback();
+ if (!!callback)
+ callback();
};
if (!!game)
return afterRetrieval(game);
};
if (!!game)
return afterRetrieval(game);
@@
-555,8
+556,13
@@
export default {
GameStorage.get(this.gameRef.id, afterRetrieval);
}
},
GameStorage.get(this.gameRef.id, afterRetrieval);
}
},
- // Post-process a move (which was just played)
+ // Post-process a move (which was just played
in BaseGame
)
processMove: function(move) {
processMove: function(move) {
+ if (this.game.type == "corr" && move.color == this.game.mycolor)
+ {
+ if (!confirm(this.st.tr["Move played:"] + " " + move.notation + "\n" + this.st.tr["Are you sure?"]))
+ return this.$set(this.game, "moveToUndo", move);
+ }
// Update storage (corr or live) if I play in the game
const colorIdx = ["w","b"].indexOf(move.color);
const nextIdx = ["w","b"].indexOf(this.vr.turn);
// Update storage (corr or live) if I play in the game
const colorIdx = ["w","b"].indexOf(move.color);
const nextIdx = ["w","b"].indexOf(this.vr.turn);
@@
-681,6
+687,8
@@
export default {
{
GameStorage.update(this.gameRef.id,
{score: score, scoreMsg: scoreMsg});
{
GameStorage.update(this.gameRef.id,
{score: score, scoreMsg: scoreMsg});
+ // Notify the score to main Hall. TODO: only one player (currently double send)
+ this.send("result", {gid:this.game.id, score:score});
}
},
},
}
},
},