import { processModalClick } from "@/utils/modalClick";
import { playMove, getFilteredMove } from "@/utils/playUndo";
import { ArrayFun } from "@/utils/array";
import { processModalClick } from "@/utils/modalClick";
import { playMove, getFilteredMove } from "@/utils/playUndo";
import { ArrayFun } from "@/utils/array";
},
// Notify something after a new move (to opponent and me on MyGames page)
notifyMyGames: function(thing, data) {
},
// Notify something after a new move (to opponent and me on MyGames page)
notifyMyGames: function(thing, data) {
// For self multi-connects tests:
this.newConnect[data.from[0]] = true;
this.send("askidentity", { target: data.from[0] });
// For self multi-connects tests:
this.newConnect[data.from[0]] = true;
this.send("askidentity", { target: data.from[0] });
this.people[data.from[0]].tmpIds[data.from[1]] = { focus: true };
this.$forceUpdate(); //TODO: shouldn't be required
}
this.people[data.from[0]].tmpIds[data.from[1]] = { focus: true };
this.$forceUpdate(); //TODO: shouldn't be required
}
-console.log("Receive move");
-console.log(data.data);
-//moveslist not updated when receiving a move? (see in baseGame)
+//console.log("Receive move");
+//console.log(data.data);
+//moveslist not updated when receiving a move? (see in BaseGame)
this.rematchId = gameInfo.id;
document.getElementById("modalRules").checked = false;
document.getElementById("modalScore").checked = false;
this.rematchId = gameInfo.id;
document.getElementById("modalRules").checked = false;
document.getElementById("modalScore").checked = false;
// Just got last move from him
this.$refs["basegame"].play(data.lastMove, "received");
this.processMove(data.lastMove);
// Just got last move from him
this.$refs["basegame"].play(data.lastMove, "received");
this.processMove(data.lastMove);
: "Three repetitions";
this.send("draw", { data: message });
this.gameOver("1/2", message);
: "Three repetitions";
this.send("draw", { data: message });
this.gameOver("1/2", message);
// No effect if drawOffer == "sent"
if (this.game.mycolor != this.vr.turn) {
alert(this.st.tr["Draw offer only in your turn"]);
// No effect if drawOffer == "sent"
if (this.game.mycolor != this.vr.turn) {
alert(this.st.tr["Draw offer only in your turn"]);
let gameInfo = {
id: getRandString(), //ignored if corr
fen: V.GenRandInitFen(this.game.randomness),
let gameInfo = {
id: getRandString(), //ignored if corr
fen: V.GenRandInitFen(this.game.randomness),
players: [this.game.players[1], this.game.players[0]],
vid: this.game.vid,
cadence: this.game.cadence
players: [this.game.players[1], this.game.players[0]],
vid: this.game.vid,
cadence: this.game.cadence
data: { gameInfo: gameInfo },
success: (response) => {
gameInfo.id = response.gameId;
data: { gameInfo: gameInfo },
success: (response) => {
gameInfo.id = response.gameId;
this.rematchOffer = "sent";
this.send("rematchoffer", { data: true });
if (this.game.type == "live") {
this.rematchOffer = "sent";
this.send("rematchoffer", { data: true });
if (this.game.type == "live") {
- } else this.updateCorrGame({ rematchOffer: this.game.mycolor });
- } else if (this.rematchOffer == "sent") {
+ }
+ else this.updateCorrGame({ rematchOffer: this.game.mycolor });
+ }
+ else if (this.rematchOffer == "sent") {
// Toggle rematch offer (on --> off)
this.rematchOffer = "";
this.send("rematchoffer", { data: false });
// Toggle rematch offer (on --> off)
this.rematchOffer = "";
this.send("rematchoffer", { data: false });
window.V = vModule[game.vname + "Rules"];
this.loadGame(game, callback);
});
window.V = vModule[game.vname + "Rules"];
this.loadGame(game, callback);
});
- require(
- "raw-loader!@/translations/rules/" +
- game.vname + "/" +
- this.st.lang + ".pug"
- )
- // Next two lines fix a weird issue after last update (2019-11)
- .replace(/\\n/g, " ")
- .replace(/\\"/g, '"')
- .replace('module.exports = "', "")
- .replace(/"$/, "")
- .replace(/(fen:)([^:]*):/g, replaceByDiag);
+ afterRawLoad(
+ require(
+ "raw-loader!@/translations/rules/" +
+ game.vname + "/" + this.st.lang + ".pug"
+ ).default
+ ).replace(/(fen:)([^:]*):/g, replaceByDiag);
},
// 3 cases for loading a game:
// - from indexedDB (running or completed live game I play)
// - from server (one correspondance game I play[ed] or not)
// - from remote peer (one live game I don't play, finished or not)
fetchGame: function(callback) {
},
// 3 cases for loading a game:
// - from indexedDB (running or completed live game I play)
// - from server (one correspondance game I play[ed] or not)
// - from remote peer (one live game I don't play, finished or not)
fetchGame: function(callback) {
- if (this.repeat[fenObj] >= 3) this.drawOffer = "threerep";
+ if (this.repeat[fenObj] >= 3) {
+ if (V.LoseOnRepetition)
+ this.gameOver(moveCol == "w" ? "0-1" : "1-0", "Repetition");
+ else this.drawOffer = "threerep";
+ }
else if (this.drawOffer == "threerep") this.drawOffer = "";
if (!!this.game.mycolor && !data.receiveMyMove) {
// NOTE: 'var' to see that variable outside this block
else if (this.drawOffer == "threerep") this.drawOffer = "";
if (!!this.game.mycolor && !data.receiveMyMove) {
// NOTE: 'var' to see that variable outside this block
let el = document.querySelector("#buttonsConfirm > .acceptBtn");
// We may play several moves in a row: in case of, remove listener:
let elClone = el.cloneNode(true);
let el = document.querySelector("#buttonsConfirm > .acceptBtn");
// We may play several moves in a row: in case of, remove listener:
let elClone = el.cloneNode(true);
// In corr games, callback to change page only after score is set:
gameOver: function(score, scoreMsg, callback) {
this.game.score = score;
// In corr games, callback to change page only after score is set:
gameOver: function(score, scoreMsg, callback) {
this.game.score = score;
this.game.scoreMsg = scoreMsg;
document.getElementById("modalRules").checked = false;
// Display result in a un-missable way:
this.game.scoreMsg = scoreMsg;
document.getElementById("modalRules").checked = false;
// Display result in a un-missable way: