# How to manage server "view" of game board when it is shared by clients?

I'm currently creating a simultaneous turn based card game in which two players play cards in three lanes to determine who wins points in these lanes.

I've been struggling this past week trying to think of a good way to handle my game board on the nodejs server. The problem I'm having is that the game board consists of 3 lanes and 5 rows in a 2D array (I.E. indexs 0,0 to 2,4). When Player A plays a card to 0,0 on their screen it goes to 0,0 on the server, the problem then comes Player B plays a card in 0,0 locally but it translates to 2,4 on the server.

My question is, is there a better server game board pattern that enables a cleaner structure than to specifically make a playerA and B on my server and have a playerId tied to every call to know whether or not to invert the co-ordinates? If there is no better way, is it better to do the conversion on the client or server side? I.E. after matchmaking will the server tell each client if they are playerA or B or will the server just keep track of it?

Also, less important, but if in the future I wanted to add new gamemodes that support x number more players how will this pattern scale upwards?

If you want to eventually scale up to n players, then I think you'll want to abandon the idea that each player sends & receives input relative to their own local coordinate system.

Rather, all players should agree on one standard coordinate system. If you ask all players what card is at coordinates (2, 4), they should all give you the same answer.

This coordinate system is completely arbitrary. You could choose to use player 1's view of the table, or any other perspective you like.

What differs between players is their view of that universal table coordinate system. Think of this as the position of their camera around the shared table. You can represent this as a matrix that transforms the universal table coordinates into their local screen coordinates.

Each player can keep track of their own table-to-screen matrix as purely local information, without complicating the server logic.

When the player provides input on the screen, you multiply it by the inverse of the table-to-screen matrix to get the corresponding position in the universal table coordinates. That's what you send to the server.

The server can do its computations purely in this universal coordinate system, with every player speaking to it in the same geometric language, and it can send the same update to every player in this same language.

When the player receives data from the server in universal table coordinates, they can update their board state in that same internal representation. Then, when positioning & orienting display objects on screen, they use the table-to-screen matrix to find the corresponding pixel positions for their viewpoint.