ajanata/PretendYoureXyzzy — pull request #60 by uecasm (2013-11-14 11:25:15+00:00)
Title: Add /hand command to resync hand

In the event that a player's client gets out of sync with the server (particularly involving the cards in the hand or in play), this allows the player to enter "/hand" in game chat to re-fetch the correct cards. (Note that despite the name it also affects played cards, not just the hand. If you'd prefer a different command name to reflect this, that's fine. One suggestion might be "/refresh".)

Intended for cases such as just after some other player has joined or left the game (since that tends to weird out the displayed cards), or if a client has missed some messages and the player ends up with too few or too many cards in their hand, or gets "you don't have that card" errors when they try to play.

This is a little redundant, as much the same effect can be achieved simply by refreshing the page. However this seems like a tidier solution (and players can be reluctant to reload the page in case they lose their score or get kicked out of the game, even though normally that doesn't happen). It's also friendlier to the server to just get a few Ajax calls instead of having to re-serve the entire HTML/CSS/JS bundle.

(It would be *slightly* cleaner if it cleared away the previous cards only once the Ajax query returned, but the implementation as is allowed re-use of an existing handler rather than having to create a new one. However it might be possible to move the clear operation to the common handler anyway -- I think the other case this is used it would still be safe. I haven't made this change because I haven't tested that theory.)