Hi...
I an designing my first game, like checkers, and decided that messages between client and server will be text based(json).
In the game, each player in its turn, can:
- move to next position
- kill opponent's soldier
- eaten by opponent soldier
option 1: use a single message for all action, and let the server decide if the action is move || kill || eaten
e.g: {TYPE: "MOVE" , SRC_POS: <POSITION> DEST_POS: <POSITION> }
option 2: use a dedicated message for each type of action
e.g: {TYPE: "MOVE" ....} , {TYPE: "KILL" ....} , {TYPE: "EATEN" ....}
I prefer option-2, since its eliminate so many if-else in server code, to figure out what kind of action is.
What is better, and which will cause failures/bugs in future ???