include a list of priorities for maincardtypes in oracle (#3663)
fix #3662
This commit is contained in:
parent
6d27631764
commit
eb4914d36f
2 changed files with 16 additions and 12 deletions
|
@ -66,6 +66,16 @@ bool OracleImporter::readSetsFromByteArray(const QByteArray &data)
|
||||||
return true;
|
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,
|
CardInfoPtr OracleImporter::addCard(QString name,
|
||||||
QString text,
|
QString text,
|
||||||
bool isToken,
|
bool isToken,
|
||||||
|
@ -248,18 +258,9 @@ int OracleImporter::importCardsFromSet(CardSetPtr currentSet, const QList<QVaria
|
||||||
if (!colorIdentity.isEmpty())
|
if (!colorIdentity.isEmpty())
|
||||||
properties.insert("coloridentity", colorIdentity);
|
properties.insert("coloridentity", colorIdentity);
|
||||||
|
|
||||||
{
|
const auto &mainCardType = getMainCardType(card.value("types").toStringList());
|
||||||
const auto &typeList = card.value("types").toStringList();
|
if (!mainCardType.isEmpty()) {
|
||||||
if (typeList.contains("Creature")) {
|
properties.insert("maintype", mainCardType);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
power = getStringPropertyFromMap(card, "power");
|
power = getStringPropertyFromMap(card, "power");
|
||||||
|
|
|
@ -89,10 +89,13 @@ class OracleImporter : public CardDatabase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
|
const QStringList mainCardTypes = {"Planeswalker", "Creature", "Land", "Sorcery",
|
||||||
|
"Instant", "Artifact", "Enchantment"};
|
||||||
QList<SetToDownload> allSets;
|
QList<SetToDownload> allSets;
|
||||||
QVariantMap setsMap;
|
QVariantMap setsMap;
|
||||||
QString dataDir;
|
QString dataDir;
|
||||||
|
|
||||||
|
QString getMainCardType(const QStringList &typeList);
|
||||||
CardInfoPtr addCard(QString name,
|
CardInfoPtr addCard(QString name,
|
||||||
QString text,
|
QString text,
|
||||||
bool isToken,
|
bool isToken,
|
||||||
|
|
Loading…
Reference in a new issue