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

Moves are called twice when using multiplayer: Local() #1091

Closed
holgersindbaek opened this issue Aug 31, 2022 · 5 comments
Closed

Moves are called twice when using multiplayer: Local() #1091

holgersindbaek opened this issue Aug 31, 2022 · 5 comments

Comments

@holgersindbaek
Copy link
Contributor

I'm playing around with the framework by doing an implementation of 2048.

Everything worked great until I added multiplayer: Local(). If multiplayer is set to that, then all moves are called twice for some reason, which is a problem for games like 2048 where a random tile is randomly added on a move.

I'm not sure if this is a feature or a bug?

I've tweaked the tictactoe-example with a console.log in the clicCell move function. You can see in the example that it's being called twice: https://codesandbox.io/s/boardgame-io-forked-sbedgl?file=/src/game.js.

@andrewminerd
Copy link

I believe this is part of an optimistic update made by the client. You can disable moves from being made on the client:
https://boardgame.io/documentation/#/secret-state?id=disabling-moves-that-manipulate-secret-state-on-the-client

@holgersindbaek
Copy link
Contributor Author

That seemed to do the trick. Thanks.

@holgersindbaek
Copy link
Contributor Author

If anyone wants to try out the finished version made with boardgame.io, you can check it out here: https://2048-online.io/.

@delucis
Copy link
Member

delucis commented Dec 3, 2022

Plays great @holgersindbaek! Feel free to add it to our list of games built with boardgame.io https://boardgame.io/documentation/#/notable_projects

@holgersindbaek
Copy link
Contributor Author

I'm happy you like it @delucis 🙂. Thanks for the suggestion. I've created a pull request here: #1118.

I really liked my experience with boardgame.io. I might even remake my solitaire games (https://online-solitaire.com/) with it at some point.

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

3 participants