Keep stars but only sometimes, add scheme cards back (#3904)
* ignore stars and promos but only sometimes this will correct #3706 and #3715 being a bit overzealous in removing cards and thus fix scheme cards being removed in entirety fix #3845 note that this causes a lot more cards to be added that are in promo sets, if these promo sets should prove to be problematic they should be disabled somehow as having them as an option is still nice. * remove debug lines
This commit is contained in:
parent
a80c756dcb
commit
1815094249
2 changed files with 36 additions and 14 deletions
|
@ -201,7 +201,7 @@ QString OracleImporter::getStringPropertyFromMap(QVariantMap card, QString prope
|
||||||
return card.contains(propertyName) ? card.value(propertyName).toString() : QString("");
|
return card.contains(propertyName) ? card.value(propertyName).toString() : QString("");
|
||||||
}
|
}
|
||||||
|
|
||||||
int OracleImporter::importCardsFromSet(CardSetPtr currentSet, const QList<QVariant> &cardsList)
|
int OracleImporter::importCardsFromSet(CardSetPtr currentSet, const QList<QVariant> &cardsList, bool skipSpecialNums)
|
||||||
{
|
{
|
||||||
static const QMap<QString, QString> cardProperties{
|
static const QMap<QString, QString> cardProperties{
|
||||||
// mtgjson name => xml name
|
// mtgjson name => xml name
|
||||||
|
@ -220,11 +220,14 @@ int OracleImporter::importCardsFromSet(CardSetPtr currentSet, const QList<QVaria
|
||||||
QString ptSeparator("/");
|
QString ptSeparator("/");
|
||||||
QVariantMap card;
|
QVariantMap card;
|
||||||
QString layout, name, text, colors, colorIdentity, maintype, power, toughness;
|
QString layout, name, text, colors, colorIdentity, maintype, power, toughness;
|
||||||
bool isToken;
|
static const bool isToken = false;
|
||||||
QStringList additionalNames;
|
QStringList additionalNames;
|
||||||
QVariantHash properties;
|
QVariantHash properties;
|
||||||
CardInfoPerSet setInfo;
|
CardInfoPerSet setInfo;
|
||||||
QList<CardRelation *> relatedCards;
|
QList<CardRelation *> relatedCards;
|
||||||
|
static const QList<QString> specialNumChars = {"★", "s"};
|
||||||
|
QMap<QString, QVariant> specialNumCards;
|
||||||
|
QList<QString> allNumProps;
|
||||||
|
|
||||||
for (const QVariant &cardVar : cardsList) {
|
for (const QVariant &cardVar : cardsList) {
|
||||||
card = cardVar.toMap();
|
card = cardVar.toMap();
|
||||||
|
@ -236,9 +239,9 @@ int OracleImporter::importCardsFromSet(CardSetPtr currentSet, const QList<QVaria
|
||||||
layout = getStringPropertyFromMap(card, "layout");
|
layout = getStringPropertyFromMap(card, "layout");
|
||||||
|
|
||||||
// don't import tokens from the json file
|
// don't import tokens from the json file
|
||||||
isToken = false;
|
if (layout == "token") {
|
||||||
if (layout == "token")
|
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// normal cards handling
|
// normal cards handling
|
||||||
name = getStringPropertyFromMap(card, "name");
|
name = getStringPropertyFromMap(card, "name");
|
||||||
|
@ -273,14 +276,22 @@ int OracleImporter::importCardsFromSet(CardSetPtr currentSet, const QList<QVaria
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip cards containing a star char in the collectors number
|
// skip cards containing special stuff in the collectors number if it's not the only print
|
||||||
if (setInfo.getProperty("num").contains("★")) {
|
if (skipSpecialNums) {
|
||||||
continue;
|
QString numProperty = setInfo.getProperty("num");
|
||||||
}
|
bool skip = false;
|
||||||
|
for (const QString &specialChar : specialNumChars) {
|
||||||
// skip prerelease foils
|
if (numProperty.contains(specialChar)) {
|
||||||
if (setInfo.getProperty("num").contains("s")) {
|
specialNumCards.insert(numProperty.remove(specialChar), cardVar);
|
||||||
continue;
|
skip = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (skip) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
allNumProps.append(numProperty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// special handling properties
|
// special handling properties
|
||||||
|
@ -349,7 +360,6 @@ int OracleImporter::importCardsFromSet(CardSetPtr currentSet, const QList<QVaria
|
||||||
[](const SplitCardPart &a, const SplitCardPart &b) -> bool { return a.getIndex() < b.getIndex(); });
|
[](const SplitCardPart &a, const SplitCardPart &b) -> bool { return a.getIndex() < b.getIndex(); });
|
||||||
|
|
||||||
text = QString("");
|
text = QString("");
|
||||||
isToken = false;
|
|
||||||
properties.clear();
|
properties.clear();
|
||||||
relatedCards.clear();
|
relatedCards.clear();
|
||||||
|
|
||||||
|
@ -391,6 +401,18 @@ int OracleImporter::importCardsFromSet(CardSetPtr currentSet, const QList<QVaria
|
||||||
numCards++;
|
numCards++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add the unique cards with special chars in num
|
||||||
|
if (skipSpecialNums) {
|
||||||
|
QList<QVariant> extraStarCards;
|
||||||
|
for (auto cardIter = specialNumCards.constBegin(); cardIter != specialNumCards.constEnd(); ++cardIter) {
|
||||||
|
if (!allNumProps.contains(cardIter.key())) {
|
||||||
|
extraStarCards.append(cardIter.value());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!extraStarCards.isEmpty()) {
|
||||||
|
numCards += importCardsFromSet(currentSet, extraStarCards, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
return numCards;
|
return numCards;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ public:
|
||||||
bool readSetsFromByteArray(const QByteArray &data);
|
bool readSetsFromByteArray(const QByteArray &data);
|
||||||
int startImport();
|
int startImport();
|
||||||
bool saveToFile(const QString &fileName);
|
bool saveToFile(const QString &fileName);
|
||||||
int importCardsFromSet(CardSetPtr currentSet, const QList<QVariant> &cards);
|
int importCardsFromSet(CardSetPtr currentSet, const QList<QVariant> &cards, bool skipSpecialNums = true);
|
||||||
QList<SetToDownload> &getSets()
|
QList<SetToDownload> &getSets()
|
||||||
{
|
{
|
||||||
return allSets;
|
return allSets;
|
||||||
|
|
Loading…
Reference in a new issue