views:

40

answers:

2

I am running into some problems right now.

I am developing a card game (Top Trumps) which is played by two players. I wonder how to best setup the architecture.

Right now almost all of the game logic is calculated on client side.

The game state is saved in a database table. The database is updated every second. But since two players are playing there are some problems. It's really hard to not run into problems with this approach.

Maybe it would be better to handle all the Game Logic on the Server Side with a WCF Service and just use the client side as a presenter. The WCF would handle all game logic, save/load the state in database and the two clients can ask for the game state which is sent via XML.

What do you think about that approach? How about performance? Or does somebody maybe know a better approach?

Thank you in advance.

+1  A: 

Game logic on the server is the only way to prevent cheating in any effective way. Never trust a client.

tdammers
But I won that $1,000,000,000 legitimately - my username really is "';UPDATE account SET amount=1000000000;--"
Will A
+1  A: 

You should implement some of the state in both the client and the server - for example, a player can't lay down a card and then immediately lay down another card before the opponent has had a chance to play their card. You're right, though - much of the logic should be handled server-side with clients intermittently checking for updates.

Will A
Yes only problem is how to prevent loading from the database the whole time. I need some way to handle a stateful game object server side but WCF Services are used stateless usually
Ben
How much of a problem do you anticipate with serializing / deserializing the state on each client call? Your database should be caching the queries / data (if written well) - and the state should not be particularly large. How many users are you anticipating?
Will A