First some background...
I'm currently working on a "practice project" to keep up and refine my programming skills. The project is a card game system (similar to MTG and other trading card games). I currently have the following concepts implemented:
There are Players that can be created/saved/loaded, which contain profile information, win/loss statistics, and a list of Decks. Each Deck contains a list of Cards (they are actually instantiations of the four different Card types, not the abstract Cards themselves), which have all the attributes needed for game-play.
The issue...
Saving Players, Decks, and Cards is unnecessarily redundant. If there are multiple Decks with the same Cards or multiple Players with similar Decks, then the program will be saving the same Cards over and over again. For Example: If Card A is very popular, then Players will put multiple copies into multiple Decks. So, the same card will be saved over and over again.
Conceptual solution...
The idea is that Players and Decks are unique, but Cards are from a common pool (a set or collection that everyone can use to build Decks). Therefore, I have created a directory for saving/loading Players and their Decks and a separate directory for storing individual Cards that are part of a set. I would like saving and loading of Players and Decks to utilize Card IDs, which will then reference the Card directory for loading and instantiating the actual objects. Additionally, the reverse needs to happen upon saving (not saving the Deck with Cards, but with Card IDs).
The question(s)...
Is there a design pattern I should be utilizing to help with the saving/loading based on IDs? Should I break up Decks into Decks for game-play and Deck lists for storage? Should I created and store PlayerProfiles with DeckLists and use those to save/load Players and Decks?
NOTE: If you would like to see the code, let me know. It's just too much to post right here.
Aucun commentaire:
Enregistrer un commentaire