timadye / werewolf

Oxford Werewolf game
https://oxford-werewolf.eu.meteorapp.com
0 stars 1 forks source link

Stop accessing mongo from the client #11

Open PeterGerrard opened 4 years ago

PeterGerrard commented 4 years ago

There are bits of code in the client like:

Games.update(gameID, {$set: {state: 'nightTime', deaths: [], injuries: []}});

For a prototype this is fine, but longer term it would be preferable to have a cleaner api where onlt the server can access mongo. There are two main reasons:

timadye commented 4 years ago

My current model is to allow Player-specific changes in the client, but global changes should be done by the server. You found a case that breaks that rule, which I should probably fix. More generally, I didn't find a clean protocol to allow the server to roll back an action that the client wanted to do but wasn't allowed. That would be necessary if the client has moved on to another screen. So it's easier to put the check in the client, even though that's not ideal.