Fix draw logic for corr games
[vchess.git] / client / src / views / Game.vue
1 <template lang="pug">
2 main
3 input#modalChat.modal(type="checkbox" @click="resetChatColor")
4 div#chatWrap(role="dialog" data-checkbox="modalChat" aria-labelledby="inputChat")
5 #chat.card
6 label.modal-close(for="modalChat")
7 #participants
8 span {{ Object.keys(people).length + " " + st.tr["participant(s):"] }}
9 span(v-for="p in Object.values(people)" v-if="!!p.name")
10 | {{ p.name }}
11 span.anonymous(v-if="Object.values(people).some(p => !p.name)")
12 | + @nonymous
13 Chat(:players="game.players" :pastChats="game.chats"
14 :newChat="newChat" @mychat="processChat")
15 .row
16 #aboveBoard.col-sm-12.col-md-9.col-md-offset-3.col-lg-10.col-lg-offset-2
17 span.variant-info {{ game.vname }}
18 button#chatBtn(onClick="doClick('modalChat')") Chat
19 #actions(v-if="game.score=='*'")
20 button(@click="clickDraw" :class="{['draw-' + drawOffer]: true}")
21 | {{ st.tr["Draw"] }}
22 button(v-if="!!game.mycolor" @click="abortGame") {{ st.tr["Abort"] }}
23 button(v-if="!!game.mycolor" @click="resign") {{ st.tr["Resign"] }}
24 #playersInfo
25 p
26 span.name(:class="{connected: isConnected(0)}")
27 | {{ game.players[0].name || "@nonymous" }}
28 span.time(v-if="game.score=='*'") {{ virtualClocks[0] }}
29 span.split-names -
30 span.name(:class="{connected: isConnected(1)}")
31 | {{ game.players[1].name || "@nonymous" }}
32 span.time(v-if="game.score=='*'") {{ virtualClocks[1] }}
33 BaseGame(:game="game" :vr="vr" ref="basegame"
34 @newmove="processMove" @gameover="gameOver")
35 </template>
36
37 <script>
38 import BaseGame from "@/components/BaseGame.vue";
39 import Chat from "@/components/Chat.vue";
40 import { store } from "@/store";
41 import { GameStorage } from "@/utils/gameStorage";
42 import { ppt } from "@/utils/datetime";
43 import { extractTime } from "@/utils/timeControl";
44 import { ArrayFun } from "@/utils/array";
45 import { processModalClick } from "@/utils/modalClick";
46 import { getScoreMessage } from "@/utils/scoring";
47
48 export default {
49 name: 'my-game',
50 components: {
51 BaseGame,
52 Chat,
53 },
54 // gameRef: to find the game in (potentially remote) storage
55 data: function() {
56 return {
57 st: store.state,
58 gameRef: { //given in URL (rid = remote ID)
59 id: "",
60 rid: ""
61 },
62 game: { //passed to BaseGame
63 players:[{name:""},{name:""}],
64 rendered: false,
65 },
66 virtualClocks: [0, 0], //initialized with true game.clocks
67 vr: null, //"variant rules" object initialized from FEN
68 drawOffer: "",
69 people: {}, //players + observers
70 lastate: undefined, //used if opponent send lastate before game is ready
71 repeat: {}, //detect position repetition
72 newChat: "",
73 };
74 },
75 watch: {
76 "$route": function(to, from) {
77 this.gameRef.id = to.params["id"];
78 this.gameRef.rid = to.query["rid"];
79 this.loadGame();
80 },
81 "game.clocks": function(newState) {
82 if (this.game.moves.length < 2 || this.game.score != "*")
83 {
84 // 1st move not completed yet, or game over: freeze time
85 this.virtualClocks = newState.map(s => ppt(s));
86 return;
87 }
88 const currentTurn = this.vr.turn;
89 const colorIdx = ["w","b"].indexOf(currentTurn);
90 let countdown = newState[colorIdx] -
91 (Date.now() - this.game.initime[colorIdx])/1000;
92 this.virtualClocks = [0,1].map(i => {
93 const removeTime = i == colorIdx
94 ? (Date.now() - this.game.initime[colorIdx])/1000
95 : 0;
96 return ppt(newState[i] - removeTime);
97 });
98 let clockUpdate = setInterval(() => {
99 if (countdown < 0 || this.vr.turn != currentTurn || this.game.score != "*")
100 {
101 clearInterval(clockUpdate);
102 if (countdown < 0)
103 this.gameOver(this.vr.turn=="w" ? "0-1" : "1-0", this.st.tr["Time"]);
104 }
105 else
106 this.$set(this.virtualClocks, colorIdx, ppt(Math.max(0, --countdown)));
107 }, 1000);
108 },
109 },
110 // NOTE: some redundant code with Hall.vue (related to people array)
111 created: function() {
112 // Always add myself to players' list
113 const my = this.st.user;
114 this.$set(this.people, my.sid, {id:my.id, name:my.name});
115 this.gameRef.id = this.$route.params["id"];
116 this.gameRef.rid = this.$route.query["rid"]; //may be undefined
117 // Define socket .onmessage() and .onclose() events:
118 this.st.conn.onmessage = this.socketMessageListener;
119 const socketCloseListener = () => {
120 store.socketCloseListener(); //reinitialize connexion (in store.js)
121 this.st.conn.addEventListener('message', this.socketMessageListener);
122 this.st.conn.addEventListener('close', socketCloseListener);
123 };
124 this.st.conn.onclose = socketCloseListener;
125 // Socket init required before loading remote game:
126 const socketInit = (callback) => {
127 if (!!this.st.conn && this.st.conn.readyState == 1) //1 == OPEN state
128 callback();
129 else //socket not ready yet (initial loading)
130 this.st.conn.onopen = callback;
131 };
132 if (!this.gameRef.rid) //game stored locally or on server
133 this.loadGame(null, () => socketInit(this.roomInit));
134 else //game stored remotely: need socket to retrieve it
135 {
136 // NOTE: the callback "roomInit" will be lost, so we don't provide it.
137 // --> It will be given when receiving "fullgame" socket event.
138 // A more general approach would be to store it somewhere.
139 socketInit(this.loadGame);
140 }
141 },
142 mounted: function() {
143 document.getElementById("chatWrap").addEventListener(
144 "click", processModalClick);
145 },
146 methods: {
147 // O.1] Ask server for room composition:
148 roomInit: function() {
149 // Notify the room only now that I connected, because
150 // messages might be lost otherwise (if game loading is slow)
151 this.st.conn.send(JSON.stringify({code:"connect"}));
152 this.st.conn.send(JSON.stringify({code:"pollclients"}));
153 },
154 isConnected: function(index) {
155 const name = this.game.players[index].name;
156 if (this.st.user.name == name)
157 return true;
158 return Object.values(this.people).some(p => p.name == name);
159 },
160 socketMessageListener: function(msg) {
161 const data = JSON.parse(msg.data);
162 switch (data.code)
163 {
164 case "duplicate":
165 alert(this.st.tr["Warning: multi-tabs not supported"]);
166 break;
167 // 0.2] Receive clients list (just socket IDs)
168 case "pollclients":
169 {
170 data.sockIds.forEach(sid => {
171 if (!!this.people[sid])
172 return;
173 this.$set(this.people, sid, {id:0, name:""});
174 // Ask only identity
175 this.st.conn.send(JSON.stringify({code:"askidentity", target:sid}));
176 });
177 break;
178 }
179 case "askidentity":
180 {
181 // Request for identification: reply if I'm not anonymous
182 if (this.st.user.id > 0)
183 {
184 this.st.conn.send(JSON.stringify({code:"identity",
185 user: {
186 // NOTE: decompose to avoid revealing email
187 name: this.st.user.name,
188 sid: this.st.user.sid,
189 id: this.st.user.id,
190 },
191 target:data.from}));
192 }
193 break;
194 }
195 case "identity":
196 {
197 this.$set(this.people, data.user.sid,
198 {id: data.user.id, name: data.user.name});
199 // Ask potentially missed last state, if opponent and I play
200 if (!!this.game.mycolor
201 && this.game.type == "live" && this.game.score == "*"
202 && this.game.players.some(p => p.sid == data.user.sid))
203 {
204 this.st.conn.send(JSON.stringify({code:"asklastate", target:data.user.sid}));
205 }
206 break;
207 }
208 case "asklastate":
209 {
210 // Sending last state if I played a move or score != "*"
211 if ((this.game.moves.length > 0 && this.vr.turn != this.game.mycolor)
212 || this.game.score != "*" || this.drawOffer == "sent")
213 {
214 // Send our "last state" informations to opponent
215 const L = this.game.moves.length;
216 const myIdx = ["w","b"].indexOf(this.game.mycolor);
217 this.st.conn.send(JSON.stringify({
218 code: "lastate",
219 target: data.from,
220 state:
221 {
222 // NOTE: lastMove (when defined) includes addTime
223 lastMove: (L>0 ? this.game.moves[L-1] : undefined),
224 // Since we played a move (or abort or resign),
225 // only drawOffer=="sent" is possible
226 drawSent: this.drawOffer == "sent",
227 score: this.game.score,
228 movesCount: L,
229 initime: this.game.initime[1-myIdx], //relevant only if I played
230 }
231 }));
232 }
233 break;
234 }
235 case "askgame":
236 // Send current (live) game if I play in (not an observer),
237 // and not asked by opponent (!)
238 if (this.game.type == "live"
239 && this.game.players.some(p => p.sid == this.st.user.sid)
240 && this.game.players.every(p => p.sid != data.from))
241 {
242 const myGame =
243 {
244 // Minimal game informations:
245 id: this.game.id,
246 players: this.game.players,
247 vid: this.game.vid,
248 timeControl: this.game.timeControl,
249 score: this.game.score,
250 };
251 this.st.conn.send(JSON.stringify({code:"game",
252 game:myGame, target:data.from}));
253 }
254 break;
255 case "newmove":
256 if (!!data.move.cancelDrawOffer) //opponent refuses draw
257 {
258 this.drawOffer = "";
259 if (this.game.type == "live") //corr games: reset by player who played
260 GameStorage.update(this.gameRef.id, {drawOffer: ""});
261 }
262 this.$set(this.game, "moveToPlay", data.move);
263 break;
264 case "newchat":
265 this.newChat = data.chat;
266 if (!document.getElementById("modalChat").checked)
267 document.getElementById("chatBtn").style.backgroundColor = "#c5fefe";
268 break;
269 case "lastate": //got opponent infos about last move
270 {
271 this.lastate = data.state;
272 if (this.game.rendered) //game is rendered (Board component)
273 this.processLastate();
274 //else: will be processed when game is ready
275 break;
276 }
277 case "resign":
278 this.gameOver(data.side=="b" ? "1-0" : "0-1", "Resign");
279 break;
280 case "abort":
281 this.gameOver("?", "Abort");
282 break;
283 case "draw":
284 this.gameOver("1/2", data.message);
285 break;
286 case "drawoffer":
287 // NOTE: observers don't know who offered draw
288 this.drawOffer = "received";
289 break;
290 case "askfullgame":
291 this.st.conn.send(JSON.stringify({code:"fullgame",
292 game:this.game, target:data.from}));
293 break;
294 case "fullgame":
295 // Callback "roomInit" to poll clients only after game is loaded
296 this.loadGame(data.game, this.roomInit);
297 break;
298 case "connect":
299 {
300 this.$set(this.people, data.from, {name:"", id:0});
301 this.st.conn.send(JSON.stringify({code:"askidentity", target:data.from}));
302 break;
303 }
304 case "disconnect":
305 this.$delete(this.people, data.from);
306 break;
307 }
308 },
309 // lastate was received, but maybe game wasn't ready yet:
310 processLastate: function() {
311 const data = this.lastate;
312 this.lastate = undefined; //security...
313 const L = this.game.moves.length;
314 if (data.movesCount > L)
315 {
316 // Just got last move from him
317 this.$set(this.game, "moveToPlay", Object.assign({}, data.lastMove, {initime: data.initime}));
318 }
319 if (data.drawSent)
320 this.drawOffer = "received";
321 if (data.score != "*")
322 {
323 this.drawOffer = "";
324 if (this.game.score == "*")
325 this.gameOver(data.score);
326 }
327 },
328 clickDraw: function() {
329 if (!this.game.mycolor)
330 return; //I'm just spectator
331 if (["received","threerep"].includes(this.drawOffer))
332 {
333 if (!confirm(this.st.tr["Accept draw?"]))
334 return;
335 const message = (this.drawOffer == "received"
336 ? "Mutual agreement"
337 : "Three repetitions");
338 Object.keys(this.people).forEach(sid => {
339 if (sid != this.st.user.sid)
340 {
341 this.st.conn.send(JSON.stringify({code:"draw",
342 message:message, target:sid}));
343 }
344 });
345 this.gameOver("1/2", message);
346 }
347 else if (this.drawOffer == "") //no effect if drawOffer == "sent"
348 {
349 if (this.game.mycolor != this.vr.turn)
350 return alert(this.st.tr["Draw offer only in your turn"]);
351 if (!confirm(this.st.tr["Offer draw?"]))
352 return;
353 this.drawOffer = "sent";
354 Object.keys(this.people).forEach(sid => {
355 if (sid != this.st.user.sid)
356 this.st.conn.send(JSON.stringify({code:"drawoffer", target:sid}));
357 });
358 GameStorage.update(this.gameRef.id, {drawOffer: this.game.mycolor});
359 }
360 },
361 abortGame: function() {
362 if (!this.game.mycolor || !confirm(this.st.tr["Terminate game?"]))
363 return;
364 this.gameOver("?", "Abort");
365 Object.keys(this.people).forEach(sid => {
366 if (sid != this.st.user.sid)
367 {
368 this.st.conn.send(JSON.stringify({
369 code: "abort",
370 target: sid,
371 }));
372 }
373 });
374 },
375 resign: function(e) {
376 if (!this.game.mycolor || !confirm(this.st.tr["Resign the game?"]))
377 return;
378 Object.keys(this.people).forEach(sid => {
379 if (sid != this.st.user.sid)
380 {
381 this.st.conn.send(JSON.stringify({code:"resign",
382 side:this.game.mycolor, target:sid}));
383 }
384 });
385 this.gameOver(this.game.mycolor=="w" ? "0-1" : "1-0", "Resign");
386 },
387 // 3 cases for loading a game:
388 // - from indexedDB (running or completed live game I play)
389 // - from server (one correspondance game I play[ed] or not)
390 // - from remote peer (one live game I don't play, finished or not)
391 loadGame: function(game, callback) {
392 const afterRetrieval = async (game) => {
393 const vModule = await import("@/variants/" + game.vname + ".js");
394 window.V = vModule.VariantRules;
395 this.vr = new V(game.fen);
396 const gtype = (game.timeControl.indexOf('d') >= 0 ? "corr" : "live");
397 const tc = extractTime(game.timeControl);
398 if (gtype == "corr")
399 {
400 if (game.players[0].color == "b")
401 {
402 // Adopt the same convention for live and corr games: [0] = white
403 [ game.players[0], game.players[1] ] =
404 [ game.players[1], game.players[0] ];
405 }
406 // corr game: needs to compute the clocks + initime
407 // NOTE: clocks in seconds, initime in milliseconds
408 game.clocks = [tc.mainTime, tc.mainTime];
409 game.moves.sort((m1,m2) => m1.idx - m2.idx); //in case of
410 if (game.score == "*") //otherwise no need to bother with time
411 {
412 game.initime = [0, 0];
413 const L = game.moves.length;
414 if (L >= 3)
415 {
416 let addTime = [0, 0];
417 for (let i=2; i<L; i++)
418 {
419 addTime[i%2] += tc.increment -
420 (game.moves[i].played - game.moves[i-1].played) / 1000;
421 }
422 for (let i=0; i<=1; i++)
423 game.clocks[i] += addTime[i];
424 }
425 if (L >= 1)
426 game.initime[L%2] = game.moves[L-1].played;
427 }
428 // Now that we used idx and played, re-format moves as for live games
429 game.moves = game.moves.map( (m) => {
430 const s = m.squares;
431 return {
432 appear: s.appear,
433 vanish: s.vanish,
434 start: s.start,
435 end: s.end,
436 };
437 });
438 // Also sort chat messages (if any)
439 game.chats.sort( (c1,c2) => { return c2.added - c1.added; });
440 }
441 const myIdx = game.players.findIndex(p => {
442 return p.sid == this.st.user.sid || p.uid == this.st.user.id;
443 });
444 if (gtype == "live" && game.clocks[0] < 0) //game unstarted
445 {
446 game.clocks = [tc.mainTime, tc.mainTime];
447 if (game.score == "*")
448 {
449 game.initime[0] = Date.now();
450 if (myIdx >= 0)
451 {
452 // I play in this live game; corr games don't have clocks+initime
453 GameStorage.update(game.id,
454 {
455 clocks: game.clocks,
456 initime: game.initime,
457 });
458 }
459 }
460 }
461 if (!!game.drawOffer)
462 {
463 if (game.drawOffer == "t") //three repetitions
464 this.drawOffer = "threerep";
465 else
466 {
467 if (myIdx < 0)
468 this.drawOffer = "received"; //by any of the players
469 else
470 {
471 // I play in this game:
472 if ((game.drawOffer == "w" && myIdx==0) || (game.drawOffer=="b" && myIdx==1))
473 this.drawOffer = "sent";
474 else //all other cases
475 this.drawOffer = "received";
476 }
477 }
478 }
479 if (!!game.scoreMsg)
480 game.scoreMsg = this.st.tr[game.scoreMsg]; //stored in english
481 this.game = Object.assign({},
482 game,
483 // NOTE: assign mycolor here, since BaseGame could also be VS computer
484 {
485 type: gtype,
486 increment: tc.increment,
487 mycolor: [undefined,"w","b"][myIdx+1],
488 // opponent sid not strictly required (or available), but easier
489 // at least oppsid or oppid is available anyway:
490 oppsid: (myIdx < 0 ? undefined : game.players[1-myIdx].sid),
491 oppid: (myIdx < 0 ? undefined : game.players[1-myIdx].uid),
492 }
493 );
494 this.$nextTick(() => {
495 this.game.rendered = true;
496 // Did lastate arrive before game was rendered?
497 if (!!this.lastate)
498 this.processLastate();
499 });
500 this.repeat = {}; //reset: scan past moves' FEN:
501 let repIdx = 0;
502 // NOTE: vr_tmp to obtain FEN strings is redundant with BaseGame
503 let vr_tmp = new V(game.fenStart);
504 game.moves.forEach(m => {
505 vr_tmp.play(m);
506 const fenObj = V.ParseFen( vr_tmp.getFen() );
507 repIdx = fenObj.position + "_" + fenObj.turn;
508 if (!!fenObj.flags)
509 repIdx += "_" + fenObj.flags;
510 this.repeat[repIdx] = (!!this.repeat[repIdx]
511 ? this.repeat[repIdx]+1
512 : 1);
513 });
514 if (this.repeat[repIdx] >= 3)
515 this.drawOffer = "threerep";
516 callback();
517 };
518 if (!!game)
519 return afterRetrieval(game);
520 if (!!this.gameRef.rid)
521 {
522 // Remote live game: forgetting about callback func... (TODO: design)
523 this.st.conn.send(JSON.stringify(
524 {code:"askfullgame", target:this.gameRef.rid}));
525 }
526 else
527 {
528 // Local or corr game
529 GameStorage.get(this.gameRef.id, afterRetrieval);
530 }
531 },
532 // Post-process a move (which was just played)
533 processMove: function(move) {
534 // Update storage (corr or live) if I play in the game
535 const colorIdx = ["w","b"].indexOf(move.color);
536 const nextIdx = ["w","b"].indexOf(this.vr.turn);
537 // https://stackoverflow.com/a/38750895
538 if (!!this.game.mycolor)
539 {
540 const allowed_fields = ["appear", "vanish", "start", "end"];
541 // NOTE: 'var' to see this variable outside this block
542 var filtered_move = Object.keys(move)
543 .filter(key => allowed_fields.includes(key))
544 .reduce((obj, key) => {
545 obj[key] = move[key];
546 return obj;
547 }, {});
548 }
549 // Send move ("newmove" event) to people in the room (if our turn)
550 let addTime = 0;
551 if (move.color == this.game.mycolor)
552 {
553 if (this.drawOffer == "received") //I refuse draw
554 this.drawOffer = "";
555 if (this.game.moves.length >= 2) //after first move
556 {
557 const elapsed = Date.now() - this.game.initime[colorIdx];
558 // elapsed time is measured in milliseconds
559 addTime = this.game.increment - elapsed/1000;
560 }
561 const sendMove = Object.assign({},
562 filtered_move,
563 {
564 addTime: addTime,
565 cancelDrawOffer: this.drawOffer=="",
566 });
567 Object.keys(this.people).forEach(sid => {
568 if (sid != this.st.user.sid)
569 {
570 this.st.conn.send(JSON.stringify({
571 code: "newmove",
572 target: sid,
573 move: sendMove,
574 }));
575 }
576 });
577 // (Add)Time indication: useful in case of lastate infos requested
578 move.addTime = addTime;
579 }
580 else
581 addTime = move.addTime; //supposed transmitted
582 // Update current game object:
583 this.game.moves.push(move);
584 this.game.fen = move.fen;
585 this.$set(this.game.clocks, colorIdx, this.game.clocks[colorIdx] + addTime);
586 // move.initime is set only when I receive a "lastate" move from opponent
587 this.game.initime[nextIdx] = move.initime || Date.now();
588 // If repetition detected, consider that a draw offer was received:
589 const fenObj = V.ParseFen(move.fen);
590 let repIdx = fenObj.position + "_" + fenObj.turn;
591 if (!!fenObj.flags)
592 repIdx += "_" + fenObj.flags;
593 this.repeat[repIdx] = (!!this.repeat[repIdx]
594 ? this.repeat[repIdx]+1
595 : 1);
596 if (this.repeat[repIdx] >= 3)
597 this.drawOffer = "threerep";
598 else if (this.drawOffer == "threerep")
599 this.drawOffer = "";
600 // Since corr games are stored at only one location, update should be
601 // done only by one player for each move:
602 if (!!this.game.mycolor &&
603 (this.game.type == "live" || move.color == this.game.mycolor))
604 {
605 let drawCode = "";
606 switch (this.drawOffer)
607 {
608 case "threerep":
609 drawCode = "t";
610 break;
611 case "sent":
612 drawCode = this.game.mycolor;
613 break;
614 case "received":
615 drawCode = this.vr.turn;
616 break;
617 }
618 if (this.game.type == "corr")
619 {
620 GameStorage.update(this.gameRef.id,
621 {
622 fen: move.fen,
623 move:
624 {
625 squares: filtered_move,
626 played: Date.now(),
627 idx: this.game.moves.length - 1,
628 },
629 drawOffer: drawCode || "n", //"n" for "None" to force reset (otherwise it's ignored)
630 });
631 }
632 else //live
633 {
634 GameStorage.update(this.gameRef.id,
635 {
636 fen: move.fen,
637 move: filtered_move,
638 clocks: this.game.clocks,
639 initime: this.game.initime,
640 drawOffer: drawCode,
641 });
642 }
643 }
644 },
645 resetChatColor: function() {
646 // TODO: this is called twice, once on opening an once on closing
647 document.getElementById("chatBtn").style.backgroundColor = "#e2e2e2";
648 },
649 processChat: function(chat) {
650 this.st.conn.send(JSON.stringify({code:"newchat", chat:chat}));
651 // NOTE: anonymous chats in corr games are not stored on server (TODO?)
652 if (this.game.type == "corr" && this.st.user.id > 0)
653 GameStorage.update(this.gameRef.id, {chat: chat});
654 },
655 gameOver: function(score, scoreMsg) {
656 this.game.score = score;
657 this.game.scoreMsg = this.st.tr[(!!scoreMsg
658 ? scoreMsg
659 : getScoreMessage(score))];
660 const myIdx = this.game.players.findIndex(p => {
661 return p.sid == this.st.user.sid || p.uid == this.st.user.id;
662 });
663 if (myIdx >= 0) //OK, I play in this game
664 {
665 GameStorage.update(this.gameRef.id,
666 {score: score, scoreMsg: scoreMsg});
667 }
668 },
669 },
670 };
671 </script>
672
673 <style lang="sass" scoped>
674 .connected
675 background-color: lightgreen
676
677 #participants
678 margin-left: 5px
679
680 .anonymous
681 color: grey
682 font-style: italic
683
684 @media screen and (min-width: 768px)
685 #actions
686 width: 300px
687 @media screen and (max-width: 767px)
688 .game
689 width: 100%
690
691 #actions
692 display: inline-block
693 margin-top: 10px
694 button
695 display: inline-block
696 margin: 0
697
698 @media screen and (max-width: 767px)
699 #aboveBoard
700 text-align: center
701 @media screen and (min-width: 768px)
702 #aboveBoard
703 margin-left: 30%
704
705 .variant-info
706 font-weight: bold
707 padding-right: 10px
708
709 .name
710 font-size: 1.5rem
711 padding: 1px
712
713 .time
714 font-size: 2rem
715 display: inline-block
716 margin-left: 10px
717
718 .split-names
719 display: inline-block
720 margin: 0 15px
721
722 #chat
723 padding-top: 20px
724 max-width: 600px
725 border: none;
726
727 #chatBtn
728 margin: 0 10px 0 0
729
730 .draw-sent, .draw-sent:hover
731 background-color: lightyellow
732
733 .draw-received, .draw-received:hover
734 background-color: lightgreen
735
736 .draw-threerep, .draw-threerep:hover
737 background-color: #e4d1fc
738 </style>