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. */
|
||||
/* Whether the game is being played or just watched. */
|
||||
playing: false,
|
||||
/* If watching, the name of the player. */
|
||||
playername: null,
|
||||
/* Whether the Stop button was pushed. */
|
||||
leaving: false,
|
||||
/* WebSocket for communication */
|
||||
sock: null
|
||||
};
|
||||
|
|
@ -656,6 +660,7 @@ function startwatching(tag) {
|
|||
termemu.toAltBuf();
|
||||
var pname = msgObject.p;
|
||||
var gname = games[msgObject.g].name;
|
||||
session.playername = pname;
|
||||
message("You are now watching " + pname + " play " + gname + ".");
|
||||
}
|
||||
else if (msgObject.t == 'd') {
|
||||
|
|
@ -725,12 +730,23 @@ function gameover() {
|
|||
if (!session.connect)
|
||||
return;
|
||||
/* TODO IFACE2 If the end was unexpected, tell player the game was saved. */
|
||||
if (session.playing)
|
||||
if (session.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.playing = false;
|
||||
session.leaving = false;
|
||||
termemu.toNormBuf();
|
||||
if ("lcred" in sessionStorage)
|
||||
setmode("choose");
|
||||
|
|
@ -745,11 +761,11 @@ function logout() {
|
|||
setmode("login");
|
||||
}
|
||||
|
||||
/* TODO determine whether this is needed */
|
||||
function stop() {
|
||||
if (!session.connect)
|
||||
return;
|
||||
if (session.sock) {
|
||||
session.leaving = true;
|
||||
session.sock.close();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue