nlupugla / WarpWars

0 stars 0 forks source link

Game state changing when it shouldn't be #7

Open nlupugla opened 9 years ago

nlupugla commented 9 years ago

It seems like sometimes simply clicking on a unit will change the game's state, causing the tiles that become painted to indicate legal moves to unpaint, also requiring the user to click on the unit again. If this happens with enough frequency, it becomes very difficult to move units at all.

Here is a list of functions that change the game's state in no particular order:

  1. Game.next_turn (advances the turn)
  2. Game.next_phase (advances the phase)
  3. Game.move (moves a unit, checking legality in the process)
  4. Game.place (places a unit in a given spot on the board without checking legality, called by move and deploy)
  5. Game.take (removes a unit from play)
  6. Game.deploy (put a new unit into play, checking legality in the process)
nlupugla commented 9 years ago

After some investigation, it seems that this bug is likely an effect of server lag. If the user clicks on a piece while the server is computing a function that would change the state of the game, that function may finish while the legal moves are painted, in which case the front end will update and the interface will reset to the unpainted state.

voynix commented 9 years ago

the question then becomes: whence comes the lag? if it's client-side, there's probably something stupid I'm doing that I can stop doing, which should be easy to fix; but if it's server-side things get a bit messier, since we're running Flask through gunicorn behind nginx so there's a lot of layers for weirdness to hide in there