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).
Questions:
Where I should generate the group of cards for each player. I thought match_init but maybe not all players joined the match yet.
Lets say I used arrays to cache the players cards — should I add it to gamestate
or global like this
local PlayersCards = {…}
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
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.
Thanks
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.
Store cards and anything else match-related in the state specific to that match. Avoid using globals wherever possible.
Match loops execute at the fixed interval decided by your match init, the loop never fires on player messages directly.
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.