I am currently building a multiplayer system, and I have a design question about how to manage lot small variations of data between lot of objects.
I’ll start with an example: Let’s say I have 3 players: A, B and C.
A is friendly with B and enemies with C. That means, I must show C that A is an enemy and B that A is friendly.
Now I have 2 different (but small) variations of the same data. This is just an example. Another variation would be that A goes into stealth, and B can see A, but C would not be able to see A.
As said, these are just examples. It is planned to have much more and different states of player data, mostly varying between each object.
How should I manage this? A ton of if blocks, or is there some obvious design pattern I have missed? Since this is a multiplayer game, there will be much more than just 3 players/objects or states for that matter.
The best thing to do is try to get a solid grasp on object-oriented programming, if you’re struggling with the concept. It seems like you don’t have a clear model of what state data you will need to store. Try diagramming the “state” of your game; think of it as a minimal snapshot of what objects exist in your game at a given time, and how they are organized. Something like player.canSee(otherPlayer) can be calculated, and doesn’t necessarily need to be stored.
Even though you probably will not use a database at all, you might find it helpful doing some reading and practice with relational database design. The concepts of relational design will help you organize your thoughts and store information in a clear, consistent way.