* optimized card loading. There was some redundant code that wasn't necessary.

* getCardByName seemed to have a initialization error if you tried to use it before the entire game loaded.  The cache would
throw an exception if you tried to use find and it was empty.  I put a guard around it to avoid this issue.

* refactored Zeth's "toggledifficuly" feature to be stored in meta data.  http://code.google.com/p/wagic/source/detail?r=3106
 -- This is slightly modified as it forces a 1 for 1 swap of cards that are specified.
    from the example given this is how it seemed to be used anyways.
 -- since all the information is stored in the meta data, there's no need to alter the deck's
    definition.
This commit is contained in:
techdragon.nguyen@gmail.com
2011-02-14 08:14:35 +00:00
parent 1b5002726c
commit d9efb408e5
6 changed files with 57 additions and 56 deletions

View File

@@ -24,6 +24,7 @@ private:
string mAvatarFilename;
string mColorIndex;
map<int,int> mAlternateCardMap;
// statistical information
int mGamesPlayed, mVictories, mPercentVictories, mDifficulty;
@@ -44,6 +45,7 @@ public:
string getColorIndex();
int getAvatarId(int deckId);
string getStatsSummary();
map<int,int>& getAlternateMappings();
int getDeckId();
int getGamesPlayed();

View File

@@ -120,6 +120,7 @@ public:
MTGCard * _(int id);
MTGCard * getCardById(int id);
MTGCard * getCardByName(string name);
MTGCard * getCard(string inputText);
int load(const char * config_file, const char * setName = NULL, int autoload = 1);
int countByType(const char * _type);
int countByColor(int color);
@@ -154,13 +155,14 @@ protected:
public:
MTGAllCards * database;
map<int, int> cards;
map<int, int> alternates;
string meta_desc;
string meta_name;
int meta_id;
int totalCards();
int totalPrice();
MTGDeck(MTGAllCards * _allcards);
MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_only = 0,int difficultySetting = 0);
MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_only = 0);
int addRandomCards(int howmany, int * setIds = NULL, int nbSets = 0, int rarity = -1, const char * subtype = NULL,
int * colors = NULL, int nbcolors = 0);
int add(int cardid);