}
},
"game.clocks": function(newState) {
+ if (this.game.moves.length < 2)
+ {
+ // 1st move not completed yet: freeze time
+ this.virtualClocks = newState.map(s => ppt(s));
+ return;
+ }
const currentTurn = this.vr.turn;
const colorIdx = ["w","b"].indexOf(currentTurn);
let countdown = newState[colorIdx] -
return obj;
}, {});
// Send move ("newmove" event) to opponent(s) (if ours)
- let addTime = undefined;
+ let addTime = 0;
if (move.color == this.game.mycolor)
{
- const elapsed = Date.now() - this.game.initime[colorIdx];
- // elapsed time is measured in milliseconds
- addTime = this.game.increment - elapsed/1000;
+ if (this.game.moves.length >= 2) //after first move
+ {
+ const elapsed = Date.now() - this.game.initime[colorIdx];
+ // elapsed time is measured in milliseconds
+ addTime = this.game.increment - elapsed/1000;
+ }
this.st.conn.send(JSON.stringify({
code: "newmove",
target: this.game.oppid,
<template lang="pug">
main
+ input#modalInfo.modal(type="checkbox")
+ div(role="dialog" aria-labelledby="infoMessage")
+ .card.smallpad.small-modal.text-center
+ label.modal-close(for="modalInfo")
+ h3#infoMessage.section
+ p New game started: #[a(href="/game/" + {{ newGameId }})]
input#modalNewgame.modal(type="checkbox")
div(role="dialog" aria-labelledby="titleFenedit")
.card.smallpad
games: [],
challenges: [],
people: [], //(all) online players
+ newGameId: 0,
newchallenge: {
fen: "",
vid: 0,
this.startNewGame(data.gameInfo);
else
{
- // TODO: notify with game link but do not redirect
+ this.newGameId = data.gameInfo.gameId;
+ let modalBox = document.getElementById("modalInfo");
+ modalBox.checked = true;
+ setTimeout(() => { modalBox.checked = false; }, 2500);
}
break;
}