Synchronizing the turn in a turn-based game

Options
What is the best practice for synchronizing the turn in a turn-based game?

Let's say the turn structure for the game is:

1) Player 1 turn
2) Player 2 turn
3) Monster turn
Repeat

When the player or monster is done with their turn they do an EndTurn action, and the game transitions to the next turn.

The options I see are:

1) Photon View - Reliable Delta Compressed
From what I see in the documentation, this will send a lot of nulls when the object isn't changing, so this seems wasteful.

2) Photon View - Unreliable
The turn state needs to be reliably synced, so this does not seem ideal

3) RPCs
When a user disconnects and rejoins, they will have to replay dozens or hundreds of EndTurn actions will really all they need to know is the information of the current turn.

4) Custom Properties
This seems the least wasteful, however the turn information may be complicated in a real situation (information about which entities can act, which abilities the player can use that turn, etc), and in that case it seems like you might run across the limits of Custom Properties.

Option 4 (custom properties) seems like the best option, but I just wanted to confirm if there's not some preferred solution that I"m missing.

Comments

  • S_Oliver
    S_Oliver ✭✭✭
    Options
    Hi,
    if you have imported the whole Pun2 asset there is a Utilities Folder with some script for turnbased games, maybe you take a look at this.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @CRho,

    Thank you for choosing Photon!

    4) is the way to go.

    Of course you could add custom events using RaiseEvent optionally cached.

    As @S_Oliver mentioned, check out "Assets\Photon\PhotonUnityNetworking\UtilityScripts\TurnBased\PunTurnManager.cs".
    The code was ported from PUN 1 to PUN 2 but the demo that used it didn't make it to v2.
    here is the documentation page for it.