none
Card game development - need help hurry pls:)

    Question

  • Hello,

    I am developing a card game with silverlight, and have made most of my game logic (like shuffling the deck, dealing cards, playing cards etc..), however i have a problem.

    I am not sure how to solve the multiplayer part. I would like to have a room system, but am unsure how to define it.

    This is the picture i have in my head about how it should work. When 4 people are in the room and gameCreator presses the go button i should redirect them to silverlight game page, load a list of players in my silverlight main page, and set the game loop in motion.

    But how should i regulate whos turn is it? How should i update players with current game state? How should I handle the draw (because every player on turn should have his cards at the bottom of the screen)? This part is really hard for me to figure out, so if there is a good soul out there, to explain it to me, or link me to a good tutorial, I would really appriciate it.

    Thanx!

     

    Wednesday, March 17, 2010 11:41 AM

Answers

  • To be honest I havent looked into WCF that much. maybe some one else on this forum might be able to give you more detail on that. The advantage of sockets is its a well known technology and once you have basic socket comms working you can make it as simple or complex as you like.

    What I tend to do is create a sort of serializer and de serializer that can serialize my objects into a binary stream which can then be sent down the socket.

    I will try to find some more simple examples but I think the client server chat client is as simple as it gets, also reading MSDN will help you out alot as well.

    Jase

    Thursday, March 18, 2010 5:17 PM

All replies

  • How I would do it would be to use sockets much like the silverlight client\server chat program.

    http://weblogs.asp.net/mschwarz/archive/2008/03/07/silverlight-2-and-sockets.aspx

     

    http://techblogging.wordpress.com/2008/04/17/creating-a-chat-application-using-socket-in-silverlight/

     

    This basically details how you would run a .net socket server on your server machine and your client silverlight app would communicate to it via sockets. It then becomes easy to send your messages by having the server store an array or list of connected clients, you would identify the recipent using a connection index. 

    For the card deck I would simply randomize the entire deck when the game gets created then I would use a stack to simply pop the next card to be drawen, this stack would be sent to all connected players thus everyone should get the correct next card available.

     

    Jase

     

    Thursday, March 18, 2010 12:28 PM
  • Thank you alot Jayster!

    I have started using wcf service, but am unsure if its a better solution then using sockets.

    I must admit that i felt a little bit scared :) when i saw your tutorials here

    Anyways, i would like to know what do you think is  better to use and why ? Web service or this?

    Is it possible to send complex data using to the server and redistribute it to clients etc.. How hard is it? Do you maybe have any more user friendly material on this topic?

    I hope i am not being annoying, thanks..

    Thursday, March 18, 2010 5:05 PM
  • To be honest I havent looked into WCF that much. maybe some one else on this forum might be able to give you more detail on that. The advantage of sockets is its a well known technology and once you have basic socket comms working you can make it as simple or complex as you like.

    What I tend to do is create a sort of serializer and de serializer that can serialize my objects into a binary stream which can then be sent down the socket.

    I will try to find some more simple examples but I think the client server chat client is as simple as it gets, also reading MSDN will help you out alot as well.

    Jase

    Thursday, March 18, 2010 5:17 PM
  • I solved this with my silverlight online chess system as follows:

    Silverlight Client connects to a WFC service.  WCF service writes and reads data to a SQL Database.

    The player state is not that difficult.  You just have a sql table that contains the table state, and write into it everyones hand, bet and whose turn it is.  Than you can have all the clients read from that table (through the WCF Web Service) once a while.  You can use a timer set to once a second for the read trigger.  If the client reads an entry and it is its turn, you write back the change with the turn going to the next player.

     

    Tuesday, April 06, 2010 1:51 AM
  • hi, i'm also looking for a good sample of this in action as i'm also doing a turned based board game in silverlight. i've been reading about wcf duplex service with silverlight, and it seems to be the method they are encouraging for this type of applicaiton. if anyone can do a turned based example with 3 - 4 clients connected with duplex service.. it would be very much appreciated. thanks
    Sunday, April 25, 2010 2:25 AM