buttonmen-dev / buttonmen

Buttonmen - an online dice game
Other
16 stars 24 forks source link

BMInterface::is_action_current() failures should return more useful API messages #1263

Open cgolubi1 opened 10 years ago

cgolubi1 commented 10 years ago

At the moment, if is_action_current() fails, there's not a very good corellation between why is_action_current() reported a failure, and what gets told to the player via the API. For instance, if i try to submit die values as a player who's not in a game, i get back "Dice sizes no longer need to be set".

I have two suggestions to improve this:

  1. If is_action_current() returns false, don't set a message, just pass along the one is_action_current() set. Some functions (e.g. react_to_auxiliary()) do this already, but submit_die_values() and submit_turn() clobber the message with a less informative one.
  2. Inside is_action_current(), do the last set of three checks one a time the way the first two are done, i.e. set a distinct message and fail after each check, rather than grouping them all and setting a generic message.
cgolubi1 commented 10 years ago

In the normal course of events, players should never see is_action_current() failures. But that means that people who see them are always in a situation where the failures are unexpected and need to be debugged, whether that's (a) a player using the normal UI whose page is stale and doesn't realise it, (b) someone writing their own API client who hasn't sorted the timestamp business yet, or (c) a dev trying to debug a problem. In each of those cases, i think it's more useful to know what actually went wrong.