
_activePlayerPosition = PlayerPositionBottom

If (_activePlayerPosition > PlayerPositionRight) In single-player mode (more about that near the end of the tutorial).Here you moved the logic for turning the card for the active player into its own method because you will need to call that method from two other places: & _activePlayerPosition = PlayerPositionBottom You only want to activate the next player when the CardView has been fully turned over.Ĭhange the turnCardForPlayerAtBottom method to: I chose to use a delay here because that looks better in combination with the card turning animation. This turns the card for the active player and then schedules the activateNextPlayer method to be called after a small delay. Let’s handle the server situation first, because that’s simplest. In the latter case, the client needs to tell the server that the card has been turned over (in the first case, the server obviously already knows). There are two situations you need to handle: when the player who is also the server turns over a card, and when a player on a client turns over a card.

That is typical for card games: the players take turns, so you’ll have to come up with a mechanism that makes players active turn-by-turn and then send the results of whatever this player did to everyone else. That’s a bit sad for the other players, so in this section you’ll give the other players a turn!

Right now, the app will only let a single player turn over cards. In this sixth part of the series, you’ll implement the logic to allow players to take turns, deal with networking edge cases such as out-of-order packets, and start implementing the Snap feature! Going round the table In the first, second, third, fourth, and fifth parts of the series, you created the networking infrastructure and the start of the game, including dealing cards, choosing the start player, and allowing the player to flip cards over. There you can see a video of the game, and we’ll invite you to our special Reader’s Challenge! If you are new to this series, check out the introduction first.

Welcome back to our monster 7-part tutorial series on creating a multiplayer card game over Bluetooth or Wi-Fi using UIKit! This is a post by iOS Tutorial Team member Matthijs Hollemans, an experienced iOS developer and designer. Create a multiplayer networked card game!
