Good day! The question arose how best to store the card in an online game (90 sectors for each player, with a unique status for each sector) in the MySQL database. Thank you in advance!

Solution: store the serialized array. Thanks to all!

  • - Does the status change from the actions of the players? - If not, then serialize and stuff every sector or the entire map in BLOB. at once BLOB. - Costantino Rupert
  • Yes, it is changing. - Indev
  • @Indev - If the map is small and there are not many statuses of each cell, then I would zapamit all possible states, for example, on int and store them for each player. - Although, in general, the correct and universal approach, here, of course, is to store a serialized BLOB and carry out a pack-unpack when changes are necessary. Everything else smacks of premature optimization . - Costantino Rupert

2 answers 2

I propose to store the map array in serialized form

  • I agree, especially since there is a farm there, it will be possible to save it even in vatchar - oldzas

It seems to me if the card is static - then there is no sense in storing it in a player (if the game is online and multiplayer), if each player has his own card, then this is contrary to sound logic. I can assume that it is not the map that is stored, but certain objects on it, identifiers of completed tasks ...

I would keep the card in 1 place and depending on the actions of the players update it.

  • Let's just say that each player in the sector has a farm, it is also divided into sectors, in each of which the situation changes (after irrigation, let's say) depending on the player's actions. - Indev