projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Continue debug attempt for move update on server
[vchess.git]
/
client
/
src
/
views
/
Hall.vue
diff --git
a/client/src/views/Hall.vue
b/client/src/views/Hall.vue
index
0876a2d
..
2b0a148
100644
(file)
--- a/
client/src/views/Hall.vue
+++ b/
client/src/views/Hall.vue
@@
-55,7
+55,7
@@
main
placeholder="5+0, 1h+30s, 5d ..."
)
fieldset
placeholder="5+0, 1h+30s, 5d ..."
)
fieldset
- label(for="selectRandomLevel") {{ st.tr["Randomness"] }}
+ label(for="selectRandomLevel") {{ st.tr["Randomness"] }}
*
select#selectRandomLevel(v-model="newchallenge.randomness")
option(value="0") {{ st.tr["Deterministic"] }}
option(value="1") {{ st.tr["Symmetric random"] }}
select#selectRandomLevel(v-model="newchallenge.randomness")
option(value="0") {{ st.tr["Deterministic"] }}
option(value="1") {{ st.tr["Symmetric random"] }}
@@
-254,7
+254,7
@@
export default {
let names = {};
response.challenges.forEach(c => {
if (c.uid != this.st.user.id) names[c.uid] = "";
let names = {};
response.challenges.forEach(c => {
if (c.uid != this.st.user.id) names[c.uid] = "";
- else if (
!!
c.target && c.target != this.st.user.id)
+ else if (c.target && c.target != this.st.user.id)
names[c.target] = "";
});
const addChallenges = () => {
names[c.target] = "";
});
const addChallenges = () => {
@@
-407,6
+407,15
@@
export default {
processChat: function(chat) {
this.send("newchat", { data: chat });
},
processChat: function(chat) {
this.send("newchat", { data: chat });
},
+ getOppsid: function(c) {
+ let oppsid = c.from.sid; //may not be defined if corr + offline opp
+ if (!oppsid) {
+ oppsid = Object.keys(this.people).find(
+ sid => this.people[sid].id == c.from.id
+ );
+ }
+ return oppsid;
+ },
// Messaging center:
socketMessageListener: function(msg) {
if (!this.conn) return;
// Messaging center:
socketMessageListener: function(msg) {
if (!this.conn) return;
@@
-467,7
+476,10
@@
export default {
// Disconnect means no more tmpIds:
if (data.code == "disconnect") {
// Remove the live challenge sent by this player:
// Disconnect means no more tmpIds:
if (data.code == "disconnect") {
// Remove the live challenge sent by this player:
- ArrayFun.remove(this.challenges, c => c.from.sid == data.from);
+ ArrayFun.remove(
+ this.challenges,
+ c => c.type == "live" && c.from.sid == data.from
+ );
} else {
// Remove the matching live game if now unreachable
const gid = data.page.match(/[a-zA-Z0-9]+$/)[0];
} else {
// Remove the matching live game if now unreachable
const gid = data.page.match(/[a-zA-Z0-9]+$/)[0];
@@
-694,7
+706,7
@@
export default {
}
},
newChallenge: async function() {
}
},
newChallenge: async function() {
- if (
this.newchallenge.cadence.match(/^[0-9]+$/
))
+ if (
!!(this.newchallenge.cadence.match(/^[0-9]+$/)
))
this.newchallenge.cadence += "+0"; //assume minutes, no increment
const ctype = this.classifyObject(this.newchallenge);
// TODO: cadence still unchecked so ctype could be wrong...
this.newchallenge.cadence += "+0"; //assume minutes, no increment
const ctype = this.classifyObject(this.newchallenge);
// TODO: cadence still unchecked so ctype could be wrong...
@@
-797,7
+809,11
@@
export default {
};
this.launchGame(c);
} else {
};
this.launchGame(c);
} else {
- this.send("refusechallenge", { data: c.id, target: c.from.sid });
+ const oppsid = this.getOppsid(c);
+ if (oppsid)
+ this.send("refusechallenge", { data: c.id, target: oppsid });
+ if (c.type == "corr")
+ ajax("/challenges", "DELETE", { id: c.id });
}
this.send("deletechallenge", { data: c.id });
},
}
this.send("deletechallenge", { data: c.id });
},
@@
-836,9
+852,8
@@
export default {
}
else {
// My challenge
}
else {
// My challenge
- if (c.type == "corr")
{
+ if (c.type == "corr")
ajax("/challenges", "DELETE", { id: c.id });
ajax("/challenges", "DELETE", { id: c.id });
- }
this.send("deletechallenge", { data: c.id });
}
// In all cases, the challenge is consumed:
this.send("deletechallenge", { data: c.id });
}
// In all cases, the challenge is consumed:
@@
-857,13
+872,8
@@
export default {
vid: c.vid,
cadence: c.cadence
};
vid: c.vid,
cadence: c.cadence
};
- let oppsid = c.from.sid; //may not be defined if corr + offline opp
- if (!oppsid) {
- oppsid = Object.keys(this.people).find(
- sid => this.people[sid].id == c.from.id
- );
- }
const notifyNewgame = () => {
const notifyNewgame = () => {
+ const oppsid = this.getOppsid(c);
if (oppsid)
//opponent is online
this.send("startgame", { data: gameInfo, target: oppsid });
if (oppsid)
//opponent is online
this.send("startgame", { data: gameInfo, target: oppsid });