include a list of priorities for maincardtypes in oracle (#3663)

fix #3662
This commit is contained in:
ebbit1q 2019-03-16 20:00:34 +01:00 committed by Zach H
parent 6d27631764
commit eb4914d36f
2 changed files with 16 additions and 12 deletions

View file

@ -66,6 +66,16 @@ bool OracleImporter::readSetsFromByteArray(const QByteArray &data)
return true;
}
QString OracleImporter::getMainCardType(const QStringList &typeList)
{
for (const auto &type : mainCardTypes) {
if (typeList.contains(type)) {
return type;
}
}
return typeList.first();
}
CardInfoPtr OracleImporter::addCard(QString name,
QString text,
bool isToken,
@ -248,18 +258,9 @@ int OracleImporter::importCardsFromSet(CardSetPtr currentSet, const QList<QVaria
if (!colorIdentity.isEmpty())
properties.insert("coloridentity", colorIdentity);
{
const auto &typeList = card.value("types").toStringList();
if (typeList.contains("Creature")) {
properties.insert("maintype", "Creature");
} else if (typeList.contains("Land")) {
properties.insert("maintype", "Land");
} else {
const auto &maintype = typeList.first();
if (!maintype.isEmpty()) {
properties.insert("maintype", maintype);
}
}
const auto &mainCardType = getMainCardType(card.value("types").toStringList());
if (!mainCardType.isEmpty()) {
properties.insert("maintype", mainCardType);
}
power = getStringPropertyFromMap(card, "power");

View file

@ -89,10 +89,13 @@ class OracleImporter : public CardDatabase
{
Q_OBJECT
private:
const QStringList mainCardTypes = {"Planeswalker", "Creature", "Land", "Sorcery",
"Instant", "Artifact", "Enchantment"};
QList<SetToDownload> allSets;
QVariantMap setsMap;
QString dataDir;
QString getMainCardType(const QStringList &typeList);
CardInfoPtr addCard(QString name,
QString text,
bool isToken,