Client: improve messages at the end of watching a game.
The messages differentiate between the user stopping watching and the watched game coming to an end.
This commit is contained in:
parent
583514764f
commit
4a4bb390e8
1 changed files with 20 additions and 4 deletions
24
rlgterm.js
24
rlgterm.js
|
|
@ -30,6 +30,10 @@ var session = {
|
||||||
/* Login name and key are now in sessionStorage. */
|
/* Login name and key are now in sessionStorage. */
|
||||||
/* Whether the game is being played or just watched. */
|
/* Whether the game is being played or just watched. */
|
||||||
playing: false,
|
playing: false,
|
||||||
|
/* If watching, the name of the player. */
|
||||||
|
playername: null,
|
||||||
|
/* Whether the Stop button was pushed. */
|
||||||
|
leaving: false,
|
||||||
/* WebSocket for communication */
|
/* WebSocket for communication */
|
||||||
sock: null
|
sock: null
|
||||||
};
|
};
|
||||||
|
|
@ -656,6 +660,7 @@ function startwatching(tag) {
|
||||||
termemu.toAltBuf();
|
termemu.toAltBuf();
|
||||||
var pname = msgObject.p;
|
var pname = msgObject.p;
|
||||||
var gname = games[msgObject.g].name;
|
var gname = games[msgObject.g].name;
|
||||||
|
session.playername = pname;
|
||||||
message("You are now watching " + pname + " play " + gname + ".");
|
message("You are now watching " + pname + " play " + gname + ".");
|
||||||
}
|
}
|
||||||
else if (msgObject.t == 'd') {
|
else if (msgObject.t == 'd') {
|
||||||
|
|
@ -725,12 +730,23 @@ function gameover() {
|
||||||
if (!session.connect)
|
if (!session.connect)
|
||||||
return;
|
return;
|
||||||
/* TODO IFACE2 If the end was unexpected, tell player the game was saved. */
|
/* TODO IFACE2 If the end was unexpected, tell player the game was saved. */
|
||||||
if (session.playing)
|
if (session.playing) {
|
||||||
message("Finished playing.");
|
message("Finished playing.");
|
||||||
else
|
}
|
||||||
message("Finished watching.");
|
else {
|
||||||
|
if (session.leaving) {
|
||||||
|
/* Client-initiated: the user stopped watching. */
|
||||||
|
message("Finished watching " + session.playername + ".");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Server-initiated: end of game. */
|
||||||
|
message(session.playername + " has finished playing.");
|
||||||
|
}
|
||||||
|
session.playername = null;
|
||||||
|
}
|
||||||
session.connect = false;
|
session.connect = false;
|
||||||
session.playing = false;
|
session.playing = false;
|
||||||
|
session.leaving = false;
|
||||||
termemu.toNormBuf();
|
termemu.toNormBuf();
|
||||||
if ("lcred" in sessionStorage)
|
if ("lcred" in sessionStorage)
|
||||||
setmode("choose");
|
setmode("choose");
|
||||||
|
|
@ -745,11 +761,11 @@ function logout() {
|
||||||
setmode("login");
|
setmode("login");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO determine whether this is needed */
|
|
||||||
function stop() {
|
function stop() {
|
||||||
if (!session.connect)
|
if (!session.connect)
|
||||||
return;
|
return;
|
||||||
if (session.sock) {
|
if (session.sock) {
|
||||||
|
session.leaving = true;
|
||||||
session.sock.close();
|
session.sock.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue