Game Development Reference
In-Depth Information
Unique game states are just like normal games states, but with a key. When any one
player adds a game state with a key, no other player can add a game state with the
same key. If a subsequent game state is added with the same key, the add operation
will fail and the sender is notified. So even if two players add a game state with the
same key at the same time, the Pulse server guarantees that only one will succeed
and the other will receive an error.
Card distribution
Among the 35 cards, we need to make sure that in our multiplayer implementation a
card is only at one place—either in the deck or with one of the players.
After we create the necessary card in card manager, we also shuffle the cards. Note
that each client does this operation independently. So the order of the cards in the
deck in each player will be different. At the start of the game, each player needs to
start with three cards. To implement this, we use the unique game states. Note that,
the ID of each card it represents is the same in all clients.
From the previous flow-chart, we can see that there are three entry points into getting
three cards into player's hand. The first one is when the game is set to start. We get a
card from the local deck and create a unique game state with the key set to the card ID.
The card ID is unique and the ID that represents the card is the same on all the clients.
However, after shuffling the initial deck, the order may be different within each client.
Because of different orders on different clients, the conflict of two players getting the
same card is also minimized. The top card of the deck is at index 0.
 
Search WWH ::




Custom Search