Multiplayer Gaming Features
|
|
Turn Based Support |
The Manic API includes methods which provide a developer with support for turn based games (any number of players) and the storage of turn based data (the "Manic Turn Service").
An online turn-based, peer-to-peer, multiplayer game would not necessarily need to utilize these methods if all players are connected to each other for the duration of the game. However, if a player drops out of the game before it is over (possibly due to an incoming phone call or a dead battery or if the player loses their Internet connection), and the game state is not stored on a back-end server, it would be impossible for that player (and possibly all of the other players) to finish the game.
The Manic provided functionality is intended to support turn based games which do not generate massive amounts of game state for each turn and also which do not generate a large number of turns in extremely short amounts of time. A game of checkers which might generate one turn every few seconds or every few minutes would be a reasonable use-case . A game which is generating hundreds of turns per second would not be a reasonable use-case (assuming you could even classify such a game as a turn-based-game).
Creation of Turn Games
There are two ways a turn game can be created on the Manic Turn service.
1. Automatically Created (Online) Turn Games
You can request a turn-session-ID when calling any of the three real-time online player-matching functions (random matching, friend matching, private matching). When you do this, a new turn game will automatically be created and all players who were matched together will be registered as players of the turn game. The new turn-game will be automatically flagged as "started". Automatically Created Turn Games requires that all opponents are online at the time of the initial matching process.
2. Manually Created (Offline) Turn Games
A player can manually create a new offline turn game. The player who creates the game is considered the turn-game owner. The owner of the turn-game could send special game invites to one or more players or friends to get them to join the turn-game.
You might choose to support manually created turn games if you want players to be able to create turn based games which are offline from the very beginning.
There are three types of manually created turn games:
- public Turn games – anyone can join the game as long as it has not started and is not full
- friend Turn games – any friend of the owner can join the game as long as it has not started and is not full
- private Turn games – only people on a special invitee list can join the game and they can only join if the game has not started and is not full
The owner of a manually created turn game has the ability to
- specify the type of turn game when it is first created (public/friend/private)
- add/remove players to/from the invitee list for private games (if the game has not yet started)
- boot a player from the match (if the game has not yet started)
- cancel the game
- start the game – once it is started, no other players can join it and the owner has no special control over the game anymore – all participants are treated as equal game players Until the owner starts a manually created turn game, other players can see it in a list of available turn games - depending on the type of the game (public/friend/private) and whether or not the player has access to see it.
Disconnected (Offline) Play
The Manic "Turn Service" includes full support for disconnected (offline) play for Turn based games. This support includes
- players can switch from online play to offline, turn-based play as required
- players can create new Turn games at anytime (while disconnected)
- players can join disconnected Turn based games which are not yet full and which have not yet started
- players can submit their turn data to the Manic service and other players in the game will be notified the turn has been taken and when it is their turn to play
- players can have multiple offline turn-based games in progress at the same time
- you could potentially also provide players who are involved in a disconnected game with the option to "reconnect" with each other if they are available again at a later time. You would first need to coordinate getting the players back online together. This could be done manually by the players themselves, or you could assist with this by using the Manic Game Invite functionality. Once the players are reconnected to each other, you would also need to allow the players to choose whether they want to resume an existing (disconnected) game or start a new game.
Dealing with Player Disconnections During Online Play
Please keep in mind that as a game developer, you have no control over when a player may drop out of an online, turn-based game. To allow for these random disconnections, we suggest you implement turn-handling logic similar to the following:
- assume all players (A, B, and C) are connected and playing the game in an online fashion
- your game determines the order in which the players will take their turns (players may lose turns or skip turns, etc)
- assume it is currently player A's turn - all other players in the game (B and C) know it is player A's turn and are waiting to receive the move info from player A
- player A makes his move in his local game
- player A's game will FIRST submit the turn data to the Manic turn-storage service (along with some additional info including the id of the player who will take the next turn and also a true/false value indicating if player A is currently "online" with all other opponents)
- after receiving confirmation the turn data was submitted successfully, player A's game will then send the move data to player B and C (who are still connected to player A in peer-topeer online fashion)
- it is now player B's turn - player B will make her move in her local game
- at this point, one of the players loses their connection to the game (could be player A, B, or C).
- if player B is still in the game, her game will submit the turn to Manic along with an indication that she is NOT connected to all players
- depending on how your game is designed, you may want to inform player B (and all of the other players) that one or more players have left the game and the game is now running in "disconnected mode"
- while the game is running in "disconnected mode", each player will take their turn in isolation and submit it to the Manic service
- when "disconnected" turns are submitted to the Manic service, notifications are sent out (either to the person who needs to take the next turn or to all players in the game) notifying them a turn has been taken
- at that point, the other players can restart their app, download the new turn data, and if it is their turn, make their move, and submit it to the Manic service - in this model, all subsequent turns are handled in a disconnected fashion with all turn data being relayed through the Manic "turn service"
- in step #8 above, if it was player B who left the game, when she returns to the game later, she will see that it is still her turn (submission of her move did not complete successfully). At this point, she can potentially review/redo her move and then submit it to the Manic service
Expiration of Turn Games
When you enable Turn Server support for your game with the Manic service, you must also specify
- the maximum amount of time a player can take to complete one turn of the game
- the amount of time in advance of turn expiry that the Manic service should send the player a reminder message
- the contents of the reminder message to send to the players who are late completing their turn

