Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client is sent a complete copy of initialState #1159

Closed
Jim-with-a-J opened this issue Jul 9, 2023 · 1 comment
Closed

Client is sent a complete copy of initialState #1159

Jim-with-a-J opened this issue Jul 9, 2023 · 1 comment

Comments

@Jim-with-a-J
Copy link

(warning: this is the first time I have used boardgame.io, and also the first time I've used javascript for a personal project, do not assume basic competence)

I made a very simple game with secret state (a draw pile and players' hands). I added the playerView method to filter out the unwanted state, but if I check the network log, the entire starting state is sent to the client as "initialState". This would allow a player to cheat by seeing what cards their opponents started with or would draw next.

How is this normally handled? Is there a way to filter initialState before it is sent to the client, or should I use the unshuffled deck as the initial state and somehow handle the shuffle and deal after the game has started?

I searched through the docs and past issues and only found one mention of this saying "we should handle this via playerView like regular state", but I tried to figure out how this could be done and quickly ran into something to do with Redux, which I know nothing about.

@Jim-with-a-J
Copy link
Author

After re-reading the docs, I think the only way to handle this is to use the unshuffled deck as the initial state and add an initial phase to actually shuffle and deal the cards to the players. I think it might be worth documenting this in the secret state chapter though, since it's easy to overlook that initialState message when testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant