boardgameio / boardgame.io

State Management and Multiplayer Networking for Turn-Based Games
https://boardgame.io
MIT License
10.03k stars 709 forks source link

Moves from debug panel are disallowed when playing with local master #810

Closed jorgebg closed 4 years ago

jorgebg commented 4 years ago

Sumary

When running the game with a local master the moves triggered from the debug panel raise the following error:

ERROR: disallowed move: moveName

Steps to reproduce:

  1. Go to the local master docs and open the example in SandBox https://boardgame.io/documentation/#/multiplayer?id=local-master

  2. In the Client, set debug to true and reload the app: https://codesandbox.io/s/boardgameio-dibw3?file=/src/index.js:551-556

  3. Open the developer console.

  4. Select player 0 by clicking on it from the debug panel (otherwise it will raise ERROR: player not active - playerID=[1] as player 1 is selected by default, not sure why):

image

  1. Click on the clickCell move from the debug panel, enter 0 (or leave it empty), and press enter:

image

  1. Observe the error in the developer console:
ERROR: disallowed move: clickCell

I forked the example project following the steps to reproduce so you can take a look right away: https://codesandbox.io/s/boardgameio-forked-1yihh

delucis commented 4 years ago

Thanks for the clear report and reproduction steps!

This is actually a symptom of another bug/error: in this case each client is rendering the Debug Panel (one on top of the other). That’s why player 1 is selected by default — because player 1’s debug panel is rendered second and appears on top. We actually need to fix this some other way by rendering one debug panel per master instead of per client (or potentially have some way of toggling between debug panel instances if there are several).

jorgebg commented 4 years ago

Thank you, the fix worked! I also activated the debug panel only in the first client, as you suggested, and then everything worked as expected. Thanks again!