Jump to content
  • Advertisement
Sign in to follow this  
crancran

Multi-Player Card Game Design

This topic is 3264 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been working on trying to layout my class design for an online multi player card game server engine. Unfortunately, I cannot seem to find a layout that really seems ideal for what I am trying to accomplish and I hope that others here may be able to offer some advice or past experience knowledge. At a high level I would expect to have classes that encapsulate: class CGameServer; // Server class CGameServerContext; // Server Connection class CGamePlayer; // Player (After Authenticated) class CGame; // Game session For simplicity, lets assume for the moment we're going to tackle a Black Jack game where 2+ players play against one another. Before thinking specifically about the classes outlined above, it's worth saying that only the server is trusted. Specific states in a game require that a response be sent from the client in a specific time period. If a client fails to submit a response, it is the game server's responsibility to advance the state of the game and/or forfeit the player's turn and keep moving. We cannot and should not rely on the client to do this. How would some of you accomplish this? From a game logic perspective, we could look at two alternatives. Subclassing CGame to a CBlackjackGame object and putting the game code in the subobject or by implementing a CGameHandler object and subclassing the handler. The handler approach would leave us with classes like: CGameHandler CPokerGameHandler : public CGameHandler CTexasHoldemGameHandler : public CPokerHandler CBlackjackGameHandler : public CGameHandler Anyone have a preference of one way over another? Does one way offer any additional benefits? One final caveat to the class design discussion is to keep in mind that some games would be considered Tournaments between large numbers of players. A tournament between 100 players would span 10 tables as a table could hold no more than 10 players (or less) depending on the game the tournament represents. As players are eliminated and the number of players reduced, tables are consolidated. Anyone have any advice you can offer me?

Share this post


Link to post
Share on other sites
Advertisement
My advice is to not go overboard with the objects and the inheritance. Keep it simple. All you really need is a client and a server, and these can internally handle the players and the connections. If you want, you could have a base GameServer and GameClient which understand the general notion that there a bunch of players sitting at a table with cards and chips, possibly one being the dealer. Then you can subclass those to get a BlackjackServer and BlackjackClient, which further understand that each player is dealt two cards, all are visible except for the dealer's first card. Then each player in turn is dealt cards until they stand or bust, etc. The biggest difference between the server and the client is that the client's only job is to render information known to the local player such as the visible cards and chip counts, and forward user decisions based on that information to the server. The server on the other hand knows everything such as the rules of the game and what cards each player has. It basically tells the client what to do, and when. Most of the work involved in implementing a new game will be on the server, since a lot of client functionality will remain the same (render cards/chips/layers, pop up a dialog). Finally, it should be possible to instantiate multiple client objects in the same application, if the user wants to be sitting at multiple tables or playing in multiple tournaments simultaneously.

As for tournaments, I would use a two-tier system with a special tournament server. The clients and servers mentioned above only know how to deal with a single table when it comes to the actual game. However, they're also a aware of a special "coordinator" server. The server (a single table) reports chip counts to the coordinator, and the coordinator can shuffle around clients to different servers as they advanced through the ranks. The individual servers and clients have no idea that a tournament is being played or why players are joining and leaving tables. The coordinator does however, and manages the entire tournament. As a matter of fact, always having a special coordinator server ever when there isn't a tournament could help manage your players. It can handle the authentication of the players before handing them off to the server, so that the server can focus entirely on the game.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!