Code design decision - dictionary VS nodes

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By putskan

Hey guys,
I’m writing a mini multiplayer game, in which a player create a room and others join and play.
Once the game ends, the room closes and the players’ data are being discarded.

Therefore, I need to store room data, which contains the players’ details (nickname, player_id, player_team).

I wonder which is a better way of storing the data:

  1. Use a Player.tscn node under Room node.
  2. Save the players’ data as a dictionary in

Which would you go with and why?
Thanks in advance!

doesn’t really matter, the simplest/fastest done possible, just refactor as you see fit during your dev

Omicron | 2020-12-24 17:50

Thanks! went with dicts.

putskan | 2021-01-03 20:19

:bust_in_silhouette: Reply From: TheoTheTorch

I think you should go with the 2nd option, as dictionarys are simpler than nodes, and therefore I think that they are more efficcent. (also they can be saved in .json which you might want to do later, but that’s another question in itself.)

PS: Good luck with finishing your game :wink:

Thanks man!
I’ve taken your advice. It’s also a bit more indicative and visual for me I guess.

putskan | 2021-01-03 20:18

Glad I could help!

TheoTheTorch | 2021-01-04 02:28