--- /dev/null
+newmove received on mygames page should be added to storage if gtype == "live"
+and, on game page "mconnect" events => send newmove to them (better than current setup)
+also, mygames page should ask lastate infos to connected players if any (where it's not my turn)
+(maybe in component GameList, if g.type == "live" ...)
},
// Retrieve all local games (running, completed, imported...)
- // light: do not retrieve moves or players or clocks (TODO: this is the only usage)
+ // light: do not retrieve moves or clocks (TODO: this is the only usage)
getAll: function(light, callback) {
dbOperation((err,db) => {
let objectStore = db.transaction("games").objectStore("games");
delete g.moves;
delete g.clocks;
delete g.initime;
- delete g.players;
}
games.push(g);
cursor.continue();
getNotation(move) {
let notation = super.getNotation(move);
// Add a capture mark (not describing what is captured...):
- if (move.vanish.length > 1 && move.appear[0].p != V.KING) {
- if (notation.match(/^[a-h]/))
- // Pawn capture: remove "bx" in bxc4 for example
- notation = notation.substr(2);
- else
- notation = notation.replace("x","") + "X";
+ if (move.vanish.length > 1 && move.appear.length == 1) {
+ if (notation.match(/^[a-h]x/))
+ // Pawn capture: remove initial "b" in bxc4 for example
+ notation = notation.substr(1);
+ notation = notation.replace("x","") + "X";
}
return notation;
}
import { store } from "@/store";
import { GameStorage } from "@/utils/gameStorage";
import { ppt } from "@/utils/datetime";
+import { ajax } from "@/utils/ajax";
import { extractTime } from "@/utils/timeControl";
import { getRandString } from "@/utils/alea";
import { processModalClick } from "@/utils/modalClick";
},
clearChat: function() {
// Nothing more to do if game is live (chats not recorded)
- if (this.game.mycolor && this.game.type == "corr") {
- ajax(
- "/chats",
- "DELETE",
- {gid: this.game.id},
- () => {
- // TODO: this.game.pastChats = [] could be enough here?
- this.$set(this.game, "pastChats", []);
- }
- );
+ if (this.game.type == "corr") {
+ if (this.game.mycolor)
+ ajax("/chats", "DELETE", {gid: this.game.id});
+ // TODO: this.game.chats = [] could be enough here?
+ this.$set(this.game, "chats", []);
}
},
socketMessageListener: function(msg) {
import { store } from "@/store";
import { GameStorage } from "@/utils/gameStorage";
import { ajax } from "@/utils/ajax";
+import params from "@/parameters";
+import { getRandString } from "@/utils/alea";
import GameList from "@/components/GameList.vue";
export default {
name: "my-my-games",
const showType = localStorage.getItem("type-myGames") || "live";
this.setDisplay(showType);
},
+ beforeDestroy: function() {
+ this.conn.send(JSON.stringify({code: "disconnect"}));
+ },
methods: {
setDisplay: function(type, e) {
this.display = type;
localStorage.setItem("type-myGames", type);
let elt = e ? e.target : document.getElementById(type + "Games");
elt.classList.add("active");
+ elt.classList.remove("somethingnew"); //in case of
if (elt.previousElementSibling)
elt.previousElementSibling.classList.remove("active");
else elt.nextElementSibling.classList.remove("active");
// NOTE: new move itself is not received, because it wouldn't be used.
let g = games.find(g => g.id == data.gid);
this.$set(g, "movesCount", g.movesCount + 1);
+ if (
+ (g.type == "live" && this.display == "corr") ||
+ (g.type == "corr" && this.display == "live")
+ ) {
+ document
+ .getElementById(g.type + "Games")
+ .classList.add("somethingnew");
+ }
}
},
socketCloseListener: function() {
table.game-list
max-height: 100%
+
+.somethingnew
+ background-color: #c5fefe !important
</style>
query += modifs + " WHERE id = " + id;
db.run(query);
}
+ // NOTE: move, chat and delchat are mutually exclusive
if (obj.move)
{
// Security: only update moves if index is right
"DELETE " +
"FROM Chats " +
"WHERE gid = " + id;
- db.run(query, cb);
+ db.run(query);
}
});
},
GameModel.getPlayers(gid, (err,players) => {
if (players.some(p => p.uid == req.userId))
{
- GameModel.update(gid, {delchat: true}, (err) => {
- res.json(err || {});
+ GameModel.update(gid, {delchat: true}, () => {
+ res.json({});
});
}
});
{
// Relay newmove info to myGames page
// NOTE: the move itself is not needed (for now at least)
- const newmoveForMygames = {
- gid: page.split("/")[2] //format is "/game/gid"
- };
+ const gid = page.split("/")[2]; //format is "/game/gid"
obj.data.players.forEach(pSid => {
if (clients[mygamesPg][pSid])
{
Object.keys(clients[mygamesPg][pSid]).forEach(x => {
send(
clients[mygamesPg][pSid][x],
- {code:"newmove", data:newmoveForMygames}
+ {code:"newmove", gid:gid}
);
});
}