#chat.card
label.modal-close(for="modalChat")
#participants
- span {{ Object.keys(people).length }} st.tr["participant(s):"]
+ span {{ Object.keys(people).length + " " + st.tr["participant(s):"] }}
span(v-for="p in Object.values(people)" v-if="!!p.name")
| {{ p.name }}
span.anonymous(v-if="Object.values(people).some(p => !p.name)")
| + @nonymous
Chat(:players="game.players" :pastChats="game.chats"
- @newchat-sent="finishSendChat" @newchat-received="processChat")
+ :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
people: {}, //players + observers
lastate: undefined, //used if opponent send lastate before game is ready
repeat: {}, //detect position repetition
+ newChat: "",
};
},
watch: {
break;
}
case "askgame":
- // Send current (live) game if not asked by opponent (!)
- if (this.game.players.some(p => p.sid == data.from))
- return;
- const myGame =
+ // Send current (live) game if I play in (not an observer),
+ // and not asked by opponent (!)
+ if (this.game.type == "live"
+ && this.game.players.some(p => p.sid == this.st.user.sid)
+ && this.game.players.every(p => p.sid != data.from))
{
- // Minimal game informations:
- id: this.game.id,
- players: this.game.players,
- vid: this.game.vid,
- timeControl: this.game.timeControl,
- };
- this.st.conn.send(JSON.stringify({code:"game",
- game:myGame, target:data.from}));
+ const myGame =
+ {
+ // Minimal game informations:
+ id: this.game.id,
+ players: this.game.players,
+ vid: this.game.vid,
+ timeControl: this.game.timeControl,
+ };
+ this.st.conn.send(JSON.stringify({code:"game",
+ game:myGame, target:data.from}));
+ }
break;
case "newmove":
if (!!data.move.cancelDrawOffer) //opponent refuses draw
this.drawOffer = "";
this.$set(this.game, "moveToPlay", data.move);
break;
+ case "newchat":
+ this.newChat = data.chat;
+ if (!document.getElementById("modalChat").checked)
+ document.getElementById("chatBtn").style.backgroundColor = "#c5fefe";
+ break;
case "lastate": //got opponent infos about last move
{
this.lastate = data;
// TODO: this is called twice, once on opening an once on closing
document.getElementById("chatBtn").style.backgroundColor = "#e2e2e2";
},
- finishSendChat: function(chat) {
+ processChat: function(chat) {
+ this.st.conn.send(JSON.stringify({code:"newchat", chat:chat}));
// NOTE: anonymous chats in corr games are not stored on server (TODO?)
if (this.game.type == "corr" && this.st.user.id > 0)
GameStorage.update(this.gameRef.id, {chat: chat});
},
- processChat: function() {
- if (!document.getElementById("modalChat").checked)
- document.getElementById("chatBtn").style.backgroundColor = "#c5fefe";
- },
gameOver: function(score, scoreMsg) {
this.game.score = score;
this.game.scoreMsg = this.st.tr[(!!scoreMsg
margin-top: 10px
button
display: inline-block
- width: 33%
margin: 0
@media screen and (max-width: 767px)