question

brendan avatar image
brendan asked

Turn based game - Where to start

AAA
started a topic on Sat, 11 July 2015 at 2:58 PM

I've been developing a simple turn based card game in Unity, void of any real network or multiplayer aspects - just the game logic and some graphics. Yesterday I decided it was time to work on Multiplayer, and first I found Photon, and naturally that lead me to PlayFab. I've been reading docs and examples for a day, but I'm still confused. Here are my basic questions:

1) My game is a two player, turn-based game. That means I don't care about continuous syncing - I should only have to send or receive data when a player performs an action. This means I should use the App ID for Photo Turnbased, right?

2) When I first found Photon, I followed their guides and downloaded their Unity package to my Unity project. Then I later found PlayFab. Now I'm not sure what package I need. the PlayFab SDK and Photon's Unity package?

3) Where in the world does my game logic go? I'm very confused (and inexperienced) about this. Traditionally, the game logic is within the Unity project, in scripts attached to objects. But if neither of the players are servers, where do I put my game code? I want to make sure players don't cheat (authoritative).

Thanks and I hope to get going with PlayFab/Photon soon!

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

Best Answer
Brendan Vanous said on Tue, 14 July 2015 at 6:41 PM

No, that's accurate. Anything you give the client authority over is a cheating vector. If you've got features that would be negatively impacted by cheating (player-versus-player competition being key), you need to host that logic elsewhere. For many asynchronous game types, hosting the logic in Cloud Script could be the way to go - it allows you to host JavaScript which can be used to make authoritative decisions, award goods, etc.

Where you may need a custom game server (possibly built using Photon Server) would be if you have complex, realtime needs, as with most first-person shooters (like Call of Duty and the like). There's a range of games in between which fall on one side or the other of the line of what they really need, but you can get a feel for the capabilities of webhooks via Photon in this post: https://playfab.com/docs/triggering-webhook/. It does sound like you'll want to have a hook for Room creation and join - have a look at the post, and let us know if it helps to answer this.

Brendan


9 Comments
Brendan Vanous said on Sun, 12 July 2015 at 4:01 PM

Actually, the Photon Cloud services are designed for synchronous (realtime) connections between players. The significant difference between Photon Turnbased and Photon Realtime is that Photon Turnbased has a lower messages per second limit. If you want to have any realtime connection between players, whether for gameplay or chat, their solutions provide a very convenient and simple way to enable that.

In your specific case, you can manage a turnbased, asynchronous game as shown in our blog and sample: https://playfab.com/blog/creating-turn-based-asynchronous-matchmaker-without-dedicated-server/.

For your game logic, if you were to have session-based gameplay, where players join a server which is the host, I would recommend Photon Cloud, unless you have very complex realtime needs (in which case you would likely need to code your own custom game server, which we could then host in our elastic backend). If your game is completely asynchronous, your best bet might be to write your logic in our service using Cloud Script, so that you can update it there whenever you need to.

So for 1, 2, and 3, the question is, what are all the features you need? If you require absolutely no direct interaction between players, you probably don't need to use the Photon Cloud. In that case, you can use our plugin and SDK to drive your game, and Cloud Script or dedicated servers to manage the server-authoritative logic.

Brendan


AAA said on Sun, 12 July 2015 at 4:45 PM

Here's a brief description of my game: Hearthstone

If that doesn't describe it for you, it is a simple turn based card game. The only interaction I need between players is when they perform actions. These actions should be sent to their server only when they have been performed by the player, the server should validate it based on its logic, and return the message (if valid) back to both players.

So you're saying I don't need Photon at all, and I can code my entire game in Cloud Script? Also, when will C# be supported?

If this is the case, that is very, very compelling. It would look something like this, right?

Player1 tells the Server (Cloud Script) that he wants to place CardA down on the table

The Server says this is a valid move

Player1's game state does not change, as this was valid

Player2 receives the message that Player1 placed CardA down, and Unity interprets this and places the card down.

Also, chat doesn't need to be real-time, it can also be sent only on command for my purposes.

Thanks for the help. I have Register and Login working already, and I'm very excited about PlayFab!


AAA said on Sun, 12 July 2015 at 4:56 PM

By the way, a bit off topic, but I need to sign up for Premium if this is the case. Will I be charged during development of the game? Is there an "I am in test mode", mode?

Thanks


Brendan Vanous said on Sun, 12 July 2015 at 9:32 PM

Hi again,

Generally speaking, the Hearthstone gameplay model is actually synchronous - realtime gameplay between users. For that style of game, I would recommend using Photon Cloud to set up a room per game and manage the player interactions. In fact, the Exit Games team have recently announced plugins for their Photon Cloud servers, so you could run your game logic in their environment, and use PlayFab for all authentication, score tracking, player data, title data, in-game sales, etc., etc. (everything which isn't solely associated with the game session).

It's still possible to use our Cloud Script for some validation logic, but your primary logic would then be managed in the Photon Cloud. We don't have a date yet for C# support, so I would plan on using the JavaScript version for the time being.

Brendan


Brendan Vanous said on Sun, 12 July 2015 at 9:53 PM

Oh yes, and to answer your question about tiers - while in development, please leave your title set to Test mode, so that we know not to bill you. When you launch your game, that would be the time to move it to the Premium tier.

Brendan


AAA said on Mon, 13 July 2015 at 6:37 AM

Alright, got the opposite answer from Photon. I've read Photon's product lines so many times, I wish it was more clear.

I've contacted Photon about early access to their Realtime plugins for game logic. Hopefully it works out.


Brendan Vanous said on Mon, 13 July 2015 at 10:22 AM

Sounds good! Let us know if you run into any other issues or questions.

Brendan


AAA said on Mon, 13 July 2015 at 3:30 PM

I'm still trying to pick the right solution. Please humour me just a bit more because I really want to get back to the game side of things (and so far PlayFab + Unity is the only component that has been abnormally easy).

Photon Cloud and CloudScript and WebHooks are definitely not making sense to me for my purposes. I don't see any conceivable way to have a complex game reside within these services. I think what I really need is an application server (so maybe Photon Server..).

When player's find a game to play, a new Game() needs to be made, List<Player> players needs to be .Add() ed to, and this must persist so that the Game can continue to be the authority on what is going on (it's this guy's turn, no you can't use that card that you don't have, you only have 10 coins, etc).

I can't put game logic in Unity as apparently people can cheat. 100% of the game flow must reside elsewhere, and the clients must only be able to send and receive messages to the server.

Am I still off the map here? Is there some concept I am not grasping?

Thanks again.


Brendan Vanous said on Tue, 14 July 2015 at 6:41 PM

No, that's accurate. Anything you give the client authority over is a cheating vector. If you've got features that would be negatively impacted by cheating (player-versus-player competition being key), you need to host that logic elsewhere. For many asynchronous game types, hosting the logic in Cloud Script could be the way to go - it allows you to host JavaScript which can be used to make authoritative decisions, award goods, etc.

Where you may need a custom game server (possibly built using Photon Server) would be if you have complex, realtime needs, as with most first-person shooters (like Call of Duty and the like). There's a range of games in between which fall on one side or the other of the line of what they really need, but you can get a feel for the capabilities of webhooks via Photon in this post: https://playfab.com/docs/triggering-webhook/. It does sound like you'll want to have a hook for Room creation and join - have a look at the post, and let us know if it helps to answer this.

Brendan

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.