Hi There
I want to make a poker game, and players will have their private cards, and don't want share with other clients. can we store cards in state and only send to specific user ?
private state
Make the clients listen to their own cards something like:
room.listen("cards/player1/:cards");
room.listen("cards/player2/:cards");
etc.
Hey @gabrieltong, welcome!
I'd suggest sending the private data you're not synching directly to the only client that should've access to it. I'm using exactly like this on a game I'm currently working on:
Server-side:
this.send(client, ['cards', privateCards]);
Client-side:
room.onMessage.add(function(message) {
let [type, data] = message;
if (type === "cards") {
console.log("your cards are:", data);
}
});
@jalu's suggestion is handy, but if the user spends some time in the developer console he might retrieve the hands of the other players in order to cheat in the game.