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:
wagic.the.homebrew
2011-05-06 06:40:00 +00:00
parent efad3f652f
commit 7beb958067
5 changed files with 57 additions and 21 deletions

View File

@@ -51,29 +51,44 @@ vector<DeckMetaData *> GameState::BuildDeckList(const string& path, const string
if (meta)
{
found = 1;
if (statsPlayer)
//Check if the deck is unlocked based on sets etc...
bool unlocked = true;
vector<int> unlockRequirements = meta->getUnlockRequirements();
for (size_t i = 0; i < unlockRequirements.size(); ++i)
{
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;
if (! options[unlockRequirements[i]].number)
{
unlocked = false;
break;
}
}
retList.push_back(meta);
nbDecks++;
if (unlocked)
{
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;
}