Handling remote turn shifts
One of the most important aspects of playing a game online is to maintain players’ autonomy and authority over their resources – in this case, their team’s Pieces. Godot Engine offers an interesting system where a SceneTree can structure its nodes’ hierarchies with distinct Multiplayer Authorities.
To set up a node and its children’s Multiplayer Authority, recursively, we can use set_multiplayer_authority()
and pass the respective peer’s ID as an argument. In our case, we are going to change the BlackTeam
and WhiteTeam
nodes’ Multiplayer Authority to match their respective players’ peer IDs.
This will be done by the server, so to keep the application simple, we are going to allow clients and server to share the same script, and we will check which one is running the server instance by using is_multiplayer_authority()
on the CheckerBoard. We should only run this logic if the game is running in...