- Home /
Need Help with Card Game Multiplayer(Unet)?
Hello, I am making a multiplayer card game which is a turn based game with multiplayer. I am confused with the approach. Should I shuffle cards and initialize deck at the server? Can someone guide me a bit? I am currently thinking of making a deck at server only which will initialize and shuffle the deck. What should be my approach? Kindly help a bit.
Answer by tormentoarmagedoom · Sep 24, 2018 at 12:08 PM
Good day.
As all multiplayer Server-Client games there are some things that must be done to prevent cheats, to prevent sync breaks, etc.... The Correct, or best way to do in your gamne should be:
The server thinks everything, The client only "says" to the server what he wants to do, what card ants top play, what buton he press and its the server who execute the "damage method", shuffle the deck, draw a card, destroy obvjects, etc.. and the server comunicates what he "think" to the clients, and clients only paint what server said is happening. But then, everything that does not need to be "think" like rendering the sprites, visual effects, must be executed in the client.
So lets make a siple situation:
Server select 4 random cards to draw, and inform the client what cards have been picked.
The client then executes a animation drawing 4 cards and rendering that cards images/text.
Thent he client select one card to play itm, and informs the server that wants to play that card.
The server recieve this order, and see that kind of card needs an opbjective to be played, so informs the clients that a target must be selected.
The client render the "select objective sprite/cursor" and selects an objective. Of course, client informs the server what objective he selected.
Then the server recieve this information, decide if its a possible objective for that card (imagine yes, it is) so informs the client that needs to play the animation "fireball" to that objective, informs also how much damage is done, etc..
The client then renders the animation of fireball, renders a text showing how much damage has been done, etc..
As you see, the client do not think, do not check, or compare elements, just follow the server orders (Paint this, render that, activate this...) And is the server who does all the job.
This is the way you need to do everything, to prevent 2 clients to think the same problem and give different results..
Bye!
Note that to prevent cheating it's also important to only tell clients the information they have to know / can know. Even if a certain information isn't used / shown on the client it shouldn't be there in the first place. For example the unrevealed cards in a deck or the cards of an opponent should never be told to a client.
I've never played WoW but our docent back then told us that for simplicity they stored the loot infotmation of each monster inside the monster itself. So a cheater can cherry pick the monsters with the best loot. Of course they fixed it but it shows that even AAA companies don't think about everything ^^.
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Time problem with Joining to Multilayer game 1 Answer
How do I create a multiplayer turnbased game server? 0 Answers
Can I create a separate server and use the Unity game objects in it? 0 Answers
Please help! In function Create room my button is not working, line 64 I think 0 Answers