<template lang="pug">
.row
.col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
- input#modalAbort.modal(type="checkbox")
- div(role="dialog" aria-labelledby="abortBoxTitle")
- .card.smallpad.small-modal.text-center
- label.modal-close(for="modalAbort")
- h3#abortBoxTitle.section {{ st.tr["Terminate game?"] }}
- button(@click="abortGame") {{ st.tr["Sorry I have to go"] }}
- button(@click="abortGame") {{ st.tr["Game seems over"] }}
- button(@click="abortGame") {{ st.tr["Opponent is gone"] }}
BaseGame(:game="game" :vr="vr" ref="basegame"
@newmove="processMove" @gameover="gameOver")
div Names: {{ game.players[0].name }} - {{ game.players[1].name }}
div(v-if="game.score=='*'") Time: {{ virtualClocks[0] }} - {{ virtualClocks[1] }}
.button-group(v-if="game.mode!='analyze' && game.score=='*'")
button(@click="offerDraw") Draw
- button(@click="() => abortGame()") Abort
+ button(@click="abortGame") Abort
button(@click="resign") Resign
textarea(v-if="game.score=='*'" v-model="corrMsg")
Chat(:players="game.players")
this.gameRef.rid = this.$route.query["rid"]; //may be undefined
if (!this.gameRef.rid)
this.loadGame(); //local or corr: can load from now
- // TODO: mode analyse (/analyze/Atomic/rn
- // ... fen = query[], vname=params[] ...
// 0.1] Ask server for room composition:
const initialize = () => {
// Poll clients + load game if stored remotely
this.game.mycolor=="w" ? "1-0" : "0-1", "Resign");
break;
case "abort":
- this.$refs["basegame"].endGame("?", "Abort: " + data.msg);
+ this.$refs["basegame"].endGame("?", "Abort");
break;
case "draw":
this.$refs["basegame"].endGame("1/2", "Mutual agreement");
// TODO: ignore if preventDrawOffer is set; otherwise show modal box with option "prevent future offers"
// if accept: send message "draw"
},
- abortGame: function(event) {
- let modalBox = document.getElementById("modalAbort");
- if (!event)
- {
- // First call show options:
- modalBox.checked = true;
- }
- else
- {
- modalBox.checked = false; //decision made: box disappear
- const message = event.target.innerText;
- // Next line will trigger a "gameover" event, bubbling up till here
- this.$refs["basegame"].endGame("?", "Abort: " + message);
- const oppsid = this.getOppSid();
- if (!!oppsid)
+ abortGame: function() {
+ if (!confirm(this.st.tr["Terminate game?"]))
+ return;
+ // Next line will trigger a "gameover" event, bubbling up till here
+ this.$refs["basegame"].endGame("?", "Abort");
+ this.people.forEach(p => {
+ if (p.sid != this.st.user.sid)
{
this.st.conn.send(JSON.stringify({
code: "abort",
- msg: message,
- target: oppsid,
+ target: p.sid,
}));
}
- }
+ });
},
resign: function(e) {
if (!confirm("Resign the game?"))
[ game.players[1], game.players[0] ];
}
// corr game: needs to compute the clocks + initime
+ // NOTE: clocks in seconds, initime in milliseconds
game.clocks = [tc.mainTime, tc.mainTime];
game.initime = [0, 0];
const L = game.moves.length;
for (let i=2; i<L; i++)
{
addTime[i%2] += tc.increment -
- (game.moves[i].played - game.moves[i-1].played);
+ (game.moves[i].played - game.moves[i-1].played) / 1000;
}
for (let i=0; i<=1; i++)
game.clocks[i] += addTime[i];