Files
wagic/projects/mtg/include/DeckManager.h
wrenczes@gmail.com 6675a7da31 Implemented a lazy load pattern for the deck stats - when the DeckMenu is displaying decks, it calls LoadStats() for only the ones visible in the list. This helps reduces the lag that occurs each time we attempt to load all the AI decks during match selection.
This still could be improved - DeckMetaData's constructor loads an MTGDeck object to parse out the name of a deck from its file.  This means that we crack open 106 files on the first attempt to show the list of opponent decks. I started optimizing this, but reverted, as the list itself is sorted alphabetically.  Currently, with these mods, it's still taking 4 1/2 seconds on my psp to load the opponent list on the first go around.

While at it, did some cleanup - removed the need for passing around a player pointer in some of the DeckStat functions, etc.
2011-01-30 13:06:21 +00:00

45 lines
1.3 KiB
C++

#include <string>
#include <vector>
#include "DeckMetaData.h"
using namespace std;
class DeckManager
{
private:
static bool instanceFlag;
static DeckManager *mInstance;
DeckManager()
{
//private constructor
}
public:
vector<DeckMetaData*> playerDeckOrderList;
vector<DeckMetaData*> aiDeckOrderList;
map<string, StatsWrapper*> playerDeckStatsMap;
map<string, StatsWrapper*> aiDeckStatsMap;
void updateMetaDataList(vector<DeckMetaData*>* refList, bool isAI);
vector<DeckMetaData*> * getPlayerDeckOrderList();
vector<DeckMetaData*> * getAIDeckOrderList();
DeckMetaData* getDeckMetaDataById(int deckId, bool isAI);
DeckMetaData* getDeckMetaDataByFilename(const std::string& filename, bool isAI);
StatsWrapper* getExtendedStatsForDeckId(int deckId, MTGAllCards* collection, bool isAI);
StatsWrapper* getExtendedDeckStats(DeckMetaData* selectedDeck, MTGAllCards* collection, bool isAI);
static DeckManager* GetInstance();
static void EndInstance();
//convenience method to get the difficulty rating between two decks. This should be refined a little more
//since the eventual move of all deck meta data should be managed by this class
static int getDifficultyRating(Player *statsPlayer, Player *player);
~DeckManager();
};