- Home /
Can we use "Photon cloud" for a card game like poker in Unity3d?
I first planned to make a poker game using "Photon server" which provides game logic to be kept on server side, and makes all the game logic decisions, but is it possible to make poker game without issues using "Photon Cloud" (Photon Realtime/Photon Turn-based) such that the peers are able to handle the game logic between themselves. and if yes then who decides which players turn is it and which player exceeded his timelimt to play a turn, and if some how a single peer among them is set as host what happens when the player decides to leave the room in between or loses network, how and how takes over in such case.
Answer by 334499p · Jul 19, 2015 at 06:59 PM
Photon Cloud CAN support this kind of game and switching masterclient control if the masterclient leaves is automatic. Network logic and variables can be stored in a scene object by using RPCs. For example:
If(PhotonNetwork.isMasterclient){
sceneObject.GetComponent< PhotonView >().RPC("switchTurns", PhotonTargets.All, turnInt);
}
The above would be received by the sceneObject which has the following script:
Public Int Turn;
[RPC]
void switchTurns(Int t){
Turn = t;
}
The above script would serve as a safety net incase the masterclient leaves. While the masterclient remains stable, they would control all game logic such as timers. When that masterclient leaves all players would have the masterclient data however due to the above safety net script and someone would automatically assume control of game logic as long as the are the PhotonNetwork.isMasterClient... The gamelogic script would be inactive in all players except the masterclient.