I will probably use javascript to develop an online board/card game. My approach will be to have a client that will be able to work in standalone mode, so it must enforce rules. That means for example, if a player can't play a card, he or she shouldn't even be able to play it. This is to enhance the user experience.
The idea here is to add hooks to send and receive events to and from the server, and share the code that implements the game rules between the server and the client. I don't see the point of writing them twice.
So, if I play in "server" mode, the client will update the server with my actions (verifying them as well), and the server will send me updates about the rest of the players.
Is there any framework to leverage this work?
For the server side, my options seem to be Node.js (unstable, but everything would be JS and that's neat), Erlang + erlang_js, and maybe some of those weird frameworks that "compile into javascript", that I'm no really fond of.
Sounds like Ape fits your requirements rather closely. It supports javascript modules so you can run the same code on the server as you use for clients and sending messages between different users is well supported (check out the mmorpg and chat demos).
I've been using RingoJs http://ringojs.org for exactly this - client&server code sharing - for a while.
For writing networked browser games easier i'm developing a thin layer on top of that: http://gamejs.org
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With