question

aaron123 avatar image
aaron123 asked

Current State of Turn Based Games

Iv'e read most of the previous related questions but I want a little clarification. Im making a turn based async game (think risk for mobile) using Unity and Photon. From what I understand, I should create a "GameState" json string in unity after each turn containing all of the important game information (characters, their positions/health) and then send this to PlayFab Group data to be stored for the current room/game. Then, when a player rejoins the room, I can replicate this gamestate in unity by using photons WebRPCs to get the current "GameState" json string from Playfab and parsing it out to replicate the game on the rejoining client. I repeat the sendGameStateToPlayfab(string gameStateJson) function (that I make) after each turn so that it is constantly up to date and any rejoining or just joining players can replicate it on their client. Is this the correct use of PlayFab for an async game? I know its primarily used for authentication and what not, but is their a better way to do the persistent room stuff?

unity3dphoton
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

For the sake of others who haven't seen it, this is the main thread where we discussed saving the state of async games in Photon: https://community.playfab.com/questions/515/207129407-Persistent-turn-based-games-.html.

In general, the pattern would be:

At the end of a player's turn, write the game state info to a Shared Group.

When another player starts their turn, or logs in to check the state of the game, read from that Shared Group.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.