Mercurial > hg > rlgwebd
comparison rlgterm.js @ 94:597e9477b8ae
RLG-Web: Allow games to be taken over.
Make it possible to reconnect to a game if the user has left the page
without saving.
| author | John "Elwin" Edwards <elwin@sdf.org> |
|---|---|
| date | Wed, 11 Jul 2012 10:30:33 -0700 |
| parents | 104409bf5f03 |
| children | 7bb634f6995c |
comparison
equal
deleted
inserted
replaced
| 93:104409bf5f03 | 94:597e9477b8ae |
|---|---|
| 560 if (reply.stat[gname] == "s") | 560 if (reply.stat[gname] == "s") |
| 561 acttext = "Resume your game"; | 561 acttext = "Resume your game"; |
| 562 else if (reply.stat[gname] == "0") | 562 else if (reply.stat[gname] == "0") |
| 563 acttext = "Start a game"; | 563 acttext = "Start a game"; |
| 564 else if (reply.stat[gname] == "p") | 564 else if (reply.stat[gname] == "p") |
| 565 acttext = "Game in progress"; | 565 acttext = "Reconnect"; |
| 566 else if (reply.stat[gname] == "d") | 566 else if (reply.stat[gname] == "d") |
| 567 acttext = "Game in progress (dgl)"; | 567 acttext = "Game in progress (dgl)"; |
| 568 else | 568 else |
| 569 continue; | 569 continue; |
| 570 var button = document.createElement("span"); | 570 var button = document.createElement("span"); |
| 571 button.appendChild(document.createTextNode(acttext)); | 571 button.appendChild(document.createTextNode(acttext)); |
| 572 if ("s0".indexOf(reply.stat[gname]) >= 0) { | 572 if ("s0p".indexOf(reply.stat[gname]) >= 0) { |
| 573 button.onclick = makeStarter(gname); | 573 button.onclick = makeStarter(gname); |
| 574 button.className = "ibutton"; | 574 button.className = "ibutton"; |
| 575 } | 575 } |
| 576 var actdiv = document.createElement("div"); | 576 var actdiv = document.createElement("div"); |
| 577 actdiv.appendChild(button); | 577 actdiv.appendChild(button); |
| 626 setmode("play"); | 626 setmode("play"); |
| 627 getData(); | 627 getData(); |
| 628 } | 628 } |
| 629 else if (reply.t == 'E') { | 629 else if (reply.t == 'E') { |
| 630 debug(1, "Could not start game: " + reply.s); | 630 debug(1, "Could not start game: " + reply.s); |
| 631 message("Your game could not be started: " + reply.s); | |
| 632 if (reply.c == 1) { | 631 if (reply.c == 1) { |
| 633 logout(); | 632 logout(); |
| 633 message("The server forgot about you, please log in again."); | |
| 634 } | |
| 635 else if (reply.c == 4) { | |
| 636 message("You can't play that game because it is currently being " + | |
| 637 "played over SSH."); | |
| 638 } | |
| 639 else if (reply.c == 7) { | |
| 640 message("The game is being saved, try again in a few seconds."); | |
| 641 } | |
| 642 else { | |
| 643 message("The server says it can't start your game because \"" + | |
| 644 reply.s + "\". This is probably a bug."); | |
| 634 } | 645 } |
| 635 } | 646 } |
| 636 }; | 647 }; |
| 637 req.open('POST', '/play', true); | 648 req.open('POST', '/play', true); |
| 638 req.send(JSON.stringify(smsg)); | 649 req.send(JSON.stringify(smsg)); |
