Adding a way to mark decks as "locked" based on options requirements (option on or off). Can be used for example to lock a deck until a specific set is not unlocked. Works for both player decks (could be used for premade?) and AI decks.
This commit is contained in:
@@ -20,6 +20,7 @@ private:
|
|||||||
string mFilename;
|
string mFilename;
|
||||||
string mDescription;
|
string mDescription;
|
||||||
string mName;
|
string mName;
|
||||||
|
vector<int> mUnlockRequirements;
|
||||||
int mDeckId;
|
int mDeckId;
|
||||||
string mAvatarFilename;
|
string mAvatarFilename;
|
||||||
string mColorIndex;
|
string mColorIndex;
|
||||||
@@ -44,6 +45,7 @@ public:
|
|||||||
string getAvatarFilename();
|
string getAvatarFilename();
|
||||||
string getColorIndex();
|
string getColorIndex();
|
||||||
string getStatsSummary();
|
string getStatsSummary();
|
||||||
|
vector<int> getUnlockRequirements();
|
||||||
|
|
||||||
int getDeckId();
|
int getDeckId();
|
||||||
int getGamesPlayed();
|
int getGamesPlayed();
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ public:
|
|||||||
string meta_desc;
|
string meta_desc;
|
||||||
string meta_name;
|
string meta_name;
|
||||||
vector<string> meta_AIHints;
|
vector<string> meta_AIHints;
|
||||||
|
string meta_unlockRequirements;
|
||||||
|
|
||||||
int meta_id;
|
int meta_id;
|
||||||
int totalCards();
|
int totalCards();
|
||||||
|
|||||||
@@ -30,6 +30,13 @@ void DeckMetaData::LoadDeck()
|
|||||||
mName = trim(deck.meta_name);
|
mName = trim(deck.meta_name);
|
||||||
mDescription = trim(deck.meta_desc);
|
mDescription = trim(deck.meta_desc);
|
||||||
mDeckId = atoi((mFilename.substr(mFilename.find("deck") + 4, mFilename.find(".txt"))).c_str());
|
mDeckId = atoi((mFilename.substr(mFilename.find("deck") + 4, mFilename.find(".txt"))).c_str());
|
||||||
|
|
||||||
|
vector<string> requirements = split(deck.meta_unlockRequirements, ',');
|
||||||
|
for(size_t i = 0; i < requirements.size(); ++i)
|
||||||
|
{
|
||||||
|
mUnlockRequirements.push_back(Options::getID(requirements[i]));
|
||||||
|
}
|
||||||
|
|
||||||
mDeckLoaded = true;
|
mDeckLoaded = true;
|
||||||
if (!mIsAI)
|
if (!mIsAI)
|
||||||
mAvatarFilename = "avatar.jpg";
|
mAvatarFilename = "avatar.jpg";
|
||||||
@@ -115,6 +122,12 @@ int DeckMetaData::getDeckId()
|
|||||||
return mDeckId;
|
return mDeckId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<int> DeckMetaData::getUnlockRequirements()
|
||||||
|
{
|
||||||
|
return mUnlockRequirements;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
string DeckMetaData::getAvatarFilename()
|
string DeckMetaData::getAvatarFilename()
|
||||||
{
|
{
|
||||||
return mAvatarFilename;
|
return mAvatarFilename;
|
||||||
|
|||||||
@@ -51,29 +51,44 @@ vector<DeckMetaData *> GameState::BuildDeckList(const string& path, const string
|
|||||||
|
|
||||||
if (meta)
|
if (meta)
|
||||||
{
|
{
|
||||||
found = 1;
|
//Check if the deck is unlocked based on sets etc...
|
||||||
if (statsPlayer)
|
bool unlocked = true;
|
||||||
|
vector<int> unlockRequirements = meta->getUnlockRequirements();
|
||||||
|
for (size_t i = 0; i < unlockRequirements.size(); ++i)
|
||||||
{
|
{
|
||||||
std::ostringstream aiStatsDeckName;
|
if (! options[unlockRequirements[i]].number)
|
||||||
aiStatsDeckName << smallDeckPrefix << "_deck" << nbDecks;
|
{
|
||||||
meta->mStatsFilename = aiStatsDeckName.str();
|
unlocked = false;
|
||||||
meta->mIsAI = true;
|
break;
|
||||||
if (meta->mPlayerDeck != statsPlayer->GetCurrentDeckStatsFile())
|
}
|
||||||
{
|
|
||||||
meta->mPlayerDeck = statsPlayer->GetCurrentDeckStatsFile();
|
|
||||||
meta->Invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::ostringstream playerStatsDeckName;
|
|
||||||
playerStatsDeckName << "stats/player_deck" << nbDecks << ".txt";
|
|
||||||
meta->mStatsFilename = options.profileFile(playerStatsDeckName.str());
|
|
||||||
meta->mIsAI = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
retList.push_back(meta);
|
if (unlocked)
|
||||||
nbDecks++;
|
{
|
||||||
|
found = 1;
|
||||||
|
if (statsPlayer)
|
||||||
|
{
|
||||||
|
std::ostringstream aiStatsDeckName;
|
||||||
|
aiStatsDeckName << smallDeckPrefix << "_deck" << nbDecks;
|
||||||
|
meta->mStatsFilename = aiStatsDeckName.str();
|
||||||
|
meta->mIsAI = true;
|
||||||
|
if (meta->mPlayerDeck != statsPlayer->GetCurrentDeckStatsFile())
|
||||||
|
{
|
||||||
|
meta->mPlayerDeck = statsPlayer->GetCurrentDeckStatsFile();
|
||||||
|
meta->Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::ostringstream playerStatsDeckName;
|
||||||
|
playerStatsDeckName << "stats/player_deck" << nbDecks << ".txt";
|
||||||
|
meta->mStatsFilename = options.profileFile(playerStatsDeckName.str());
|
||||||
|
meta->mIsAI = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
retList.push_back(meta);
|
||||||
|
nbDecks++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
meta = NULL;
|
meta = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -698,7 +698,6 @@ MTGDeck::MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_onl
|
|||||||
meta_id = atoi(meta_name.substr(4).c_str());
|
meta_id = atoi(meta_name.substr(4).c_str());
|
||||||
wagic::ifstream file(config_file);
|
wagic::ifstream file(config_file);
|
||||||
std::string s;
|
std::string s;
|
||||||
|
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
while (std::getline(file, s))
|
while (std::getline(file, s))
|
||||||
@@ -726,6 +725,12 @@ MTGDeck::MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_onl
|
|||||||
meta_AIHints.push_back(s.substr(found + 5));
|
meta_AIHints.push_back(s.substr(found + 5));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
found = s.find("UNLOCK:");
|
||||||
|
if (found != string::npos)
|
||||||
|
{
|
||||||
|
meta_unlockRequirements = s.substr(found + 7);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (meta_only) break;
|
if (meta_only) break;
|
||||||
|
|||||||
Reference in New Issue
Block a user