I am using JavaScript + Node.js+Websockets to develop a multiplayer card game. In my single game version the Win determining calculation is done on the client side (of course) with a function.
It looks something like this:
function(CheckWin){
if (something) {
player1 win
document.getElementById("winning").innerHTML="reason"
}
else if (something) {
player2 win
document.getElementById("winning").innerHTML="reason"
}
else if (something) {
player1 win
document.getElementById("winning").innerHTML="reason"
}
}
It is a bit chunky but that is how it is. So in my multiplayer game I can either:
When all card values are collected, the server emits all the cards value to the client side and then it will execute the function there like it was in my single game (but I heard this is not SAFE)
Execute the function in the server side and then emit the result to the client (but I don't know how to emit all this information, comments, winning to client with socket.io, I think socket.io can only emit limited number of value types, I am planning to emit just the Boolean value win or lose).
I am new with programming/gaming so hopefully this question is not too silly.
player 1 win
andplayer 2 win
between the if and setting the text. \$\endgroup\$