projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixes, improvements
[vchess.git]
/
client
/
src
/
views
/
Game.vue
diff --git
a/client/src/views/Game.vue
b/client/src/views/Game.vue
index
a5db146
..
e221561
100644
(file)
--- a/
client/src/views/Game.vue
+++ b/
client/src/views/Game.vue
@@
-1,7
+1,7
@@
<template lang="pug">
main
input#modalChat.modal(type="checkbox" @click="resetChatColor()")
<template lang="pug">
main
input#modalChat.modal(type="checkbox" @click="resetChatColor()")
- div#chatWrap(role="dialog" data-checkbox="modalChat"
aria-labelledby="inputChat"
)
+ div#chatWrap(role="dialog" data-checkbox="modalChat")
#chat.card
label.modal-close(for="modalChat")
#participants
#chat.card
label.modal-close(for="modalChat")
#participants
@@
-14,7
+14,8
@@
main
:newChat="newChat" @mychat="processChat")
.row
#aboveBoard.col-sm-12.col-md-9.col-md-offset-3.col-lg-10.col-lg-offset-2
:newChat="newChat" @mychat="processChat")
.row
#aboveBoard.col-sm-12.col-md-9.col-md-offset-3.col-lg-10.col-lg-offset-2
- span.variant-info {{ game.vname }}
+ span.variant-cadence {{ game.cadence }}
+ span.variant-name {{ game.vname }}
button#chatBtn(onClick="doClick('modalChat')") Chat
#actions(v-if="game.score=='*'")
button(@click="clickDraw()" :class="{['draw-' + drawOffer]: true}")
button#chatBtn(onClick="doClick('modalChat')") Chat
#actions(v-if="game.score=='*'")
button(@click="clickDraw()" :class="{['draw-' + drawOffer]: true}")
@@
-30,8
+31,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
+134,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
+344,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)
if (!document.getElementById("modalChat").checked)
- document.getElementById("chatBtn").
style.backgroundColor = "#c5fefe"
;
+ document.getElementById("chatBtn").
classList.add("somethingnew")
;
break;
break;
- }
}
},
socketCloseListener: function() {
}
},
socketCloseListener: function() {
@@
-540,7
+541,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
+557,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);
@@
-661,7
+668,7
@@
export default {
},
resetChatColor: function() {
// TODO: this is called twice, once on opening an once on closing
},
resetChatColor: function() {
// TODO: this is called twice, once on opening an once on closing
- document.getElementById("chatBtn").
style.backgroundColor = "#e2e2e2"
;
+ document.getElementById("chatBtn").
classList.remove("somethingnew")
;
},
processChat: function(chat) {
this.send("newchat", {data:chat});
},
processChat: function(chat) {
this.send("newchat", {data:chat});
@@
-681,6
+688,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});
}
},
},
}
},
},
@@
-698,6
+707,9
@@
export default {
color: grey
font-style: italic
color: grey
font-style: italic
+#playersInfo > p
+ margin: 0
+
@media screen and (min-width: 768px)
#actions
width: 300px
@media screen and (min-width: 768px)
#actions
width: 300px
@@
-707,7
+719,7
@@
export default {
#actions
display: inline-block
#actions
display: inline-block
- margin
-top: 10px
+ margin
: 0
button
display: inline-block
margin: 0
button
display: inline-block
margin: 0
@@
-719,7
+731,10
@@
export default {
#aboveBoard
margin-left: 30%
#aboveBoard
margin-left: 30%
-.variant-info
+.variant-cadence
+ padding-right: 10px
+
+.variant-name
font-weight: bold
padding-right: 10px
font-weight: bold
padding-right: 10px
@@
-738,7
+753,7
@@
export default {
#chat
padding-top: 20px
#chat
padding-top: 20px
- max-width:
600
px
+ max-width:
767
px
border: none;
#chatBtn
border: none;
#chatBtn
@@
-752,4
+767,7
@@
export default {
.draw-threerep, .draw-threerep:hover
background-color: #e4d1fc
.draw-threerep, .draw-threerep:hover
background-color: #e4d1fc
+
+.somethingnew
+ background-color: #c5fefe
</style>
</style>