Authoritative Multiplayer card game

Hi, I need some help on a turned based card game where cards are secret each player cans see his/her cards only.

Note : if players leave … last player will win

1 - So I need first to create a group of cards for each player .
2 - When a player play a card I want to check if its legal (1.own the card 2. Is it valid to play according to the last card).


  1. Where I should generate the group of cards for each player. I thought match_init but maybe not all players joined the match yet.
  2. Lets say I used arrays to cache the players cards — should I add it to gamestate
    or global like this
    local PlayersCards = {…}
  3. let say the tick is 1 second. If a player played a card… is it going to execute match_loop or have to wait for the tick
  4. I have to make timer for a player to play the card 10 seconds for example — Is using the tick as a timer is good ideas by increasing waitForPlayer+=1 each tick or there is a better approach .

I know some question are silly (maybe all) but I am confused and I need help.

For Question 3

I found the answer by making a loop on my client like this

while (true)

and | print the messages inside “match_loop”
and I notice that match_loop will be printed once each second whatever messages u send

in my case i send messages every 0.2 second … match_loop will print all messages received between that last tick and the current tick.

I’ll answer your questions in order here.

  1. You should generate and assign cards to players when the actual gameplay is ready to start. This is usually after the required players have all joined the match.
  2. Store cards and anything else match-related in the state specific to that match. Avoid using globals wherever possible.
  3. Match loops execute at the fixed interval decided by your match init, the loop never fires on player messages directly.
  4. Use the tick number as a logical clock. Say it’s currently tick X, it’s now a given player’s turn to play a card, and they have 10 seconds to play their turn. You give them until tick X + (10 * tick rate) to act, then consider them idle, have them forfeit, or whatever is appropriate for your game.


For 2,3,4 are very clear now
But for 1 I have one more question

What if the player is matched but he lost internet connection so he is not able to join

Will the other players will be waiting until he join (stuck)

That depends on your game logic. You can have the match handler wait for the player for some time, or consider them failed/left/lost/forfeited.

Your game can do what fits best, but in our experience typically the match is considered void and remaining players go back to matchmake again.

1 Like