support for wish cards and deck sideboard

This commit is contained in:
Anthony Calosa
2017-03-07 23:42:34 +08:00
parent 24e3fd3267
commit 030dca051a
16 changed files with 431 additions and 99 deletions

View File

@@ -880,6 +880,12 @@ MTGDeck::MTGDeck(const string& config_file, MTGAllCards * _allcards, int meta_on
meta_unlockRequirements = s.substr(found + 7);
continue;
}
found = s.find("SB:");
if (found != string::npos)
{
Sideboard.push_back(s.substr(found + 3));
continue;
}
continue;
}
if (meta_only) break;
@@ -1101,6 +1107,16 @@ int MTGDeck::removeAll()
return 1;
}
void MTGDeck::replaceSB(vector<string> newSB)
{
if(newSB.size())
{
Sideboard.clear();
Sideboard = newSB;
}
return;
}
int MTGDeck::remove(int cardid)
{
if (cards.find(cardid) == cards.end() || cards[cardid] == 0) return 0;
@@ -1170,6 +1186,18 @@ int MTGDeck::save(const string& destFileName, bool useExpandedDescriptions, cons
}
}
}
//save sideboards
if(Sideboard.size())
{
sort(Sideboard.begin(), Sideboard.end());
for(unsigned int k = 0; k < Sideboard.size(); k++)
{
int checkID = atoi(Sideboard[k].c_str());
if(checkID)
file << "#SB:" << checkID << "\n";
}
}
file.close();
JFileSystem::GetInstance()->Rename(tmp, destFileName);
}