# HG changeset patch # User John "Elwin" Edwards # Date 1421787972 18000 # Node ID 674e8899703b5c62294079cbc43552e8650c27e0 # Parent bbfda4a4eb7fdfc6a1ea9e176d7c122b2449918c 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. diff -r bbfda4a4eb7f -r 674e8899703b rlgterm.js --- a/rlgterm.js Tue Jan 20 10:17:05 2015 -0500 +++ b/rlgterm.js Tue Jan 20 16:06:12 2015 -0500 @@ -30,6 +30,10 @@ /* 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 @@ 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 @@ 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 @@ setmode("login"); } -/* TODO determine whether this is needed */ function stop() { if (!session.connect) return; if (session.sock) { + session.leaving = true; session.sock.close(); return; }