boardgameio / boardgame.io

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

Current stage not accessible #697

Closed pociej closed 4 years ago

pociej commented 4 years ago

I used to use phases and now im trying to migrate to newest, i replaced phases by stages, but now im unable to read current stage. Phase field is presented in ctx object by stage is not. How then one can know what is current stage? I understand that moret han one player can be in given stage but its esential to be able to know if given player is in given stage when rendering game board.

delucis commented 4 years ago

This is available in ctx.activePlayers, which will either be null (no-one is in a stage) or a map of player IDs to stage names, e.g. { '1': 'stage-name' }.

pociej commented 4 years ago

@delucis thx for quick reply. Problem is that it is always null. I see no way to have game setup that says what is start stage for player, and also even after manual call events.setActivePlayers(['0']) or events.setAvtivePlyers({all : 'myStageName' }) or whatever it stays null.

delucis commented 4 years ago

Where are you calling setActivePlayers? You can initialise the stages at the start of the turn using turn.activePlayers as described here.

pociej commented 4 years ago

Okay if setup turn.activePlayers like this i see what should be there btu still events dosnt work. I can call setActivePlayers or endStage nothing happened.

EDIT: IT is somehow related with SocketIO server with Local multiplayer it works. Will investigate deeper.