skip all duplicate promos instead of just stars (#3965)
This commit is contained in:
parent
db85ec48c7
commit
45d62b6880
1 changed files with 20 additions and 15 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, bool skipSpecialNums)
|
int OracleImporter::importCardsFromSet(CardSetPtr currentSet, const QList<QVariant> &cardsList, bool skipSpecialCards)
|
||||||
{
|
{
|
||||||
static const QMap<QString, QString> cardProperties{
|
static const QMap<QString, QString> cardProperties{
|
||||||
// mtgjson name => xml name
|
// mtgjson name => xml name
|
||||||
|
@ -226,8 +226,8 @@ int OracleImporter::importCardsFromSet(CardSetPtr currentSet, const QList<QVaria
|
||||||
CardInfoPerSet setInfo;
|
CardInfoPerSet setInfo;
|
||||||
QList<CardRelation *> relatedCards;
|
QList<CardRelation *> relatedCards;
|
||||||
static const QList<QString> specialNumChars = {"★", "s"};
|
static const QList<QString> specialNumChars = {"★", "s"};
|
||||||
QMap<QString, QVariant> specialNumCards;
|
QMap<QString, QVariant> specialPromoCards;
|
||||||
QList<QString> allNumProps;
|
QList<QString> allNameProps;
|
||||||
|
|
||||||
for (const QVariant &cardVar : cardsList) {
|
for (const QVariant &cardVar : cardsList) {
|
||||||
card = cardVar.toMap();
|
card = cardVar.toMap();
|
||||||
|
@ -276,21 +276,26 @@ int OracleImporter::importCardsFromSet(CardSetPtr currentSet, const QList<QVaria
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip cards containing special stuff in the collectors number if it's not the only print
|
if (skipSpecialCards) {
|
||||||
if (skipSpecialNums) {
|
// skip promo cards if it's not the only print
|
||||||
|
if (getStringPropertyFromMap(card, "isPromo") == "true") {
|
||||||
|
specialPromoCards.insert(name, cardVar);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
QString numProperty = setInfo.getProperty("num");
|
QString numProperty = setInfo.getProperty("num");
|
||||||
bool skip = false;
|
bool skip = false;
|
||||||
|
// skip cards containing special stuff in the collectors number like promo cards
|
||||||
for (const QString &specialChar : specialNumChars) {
|
for (const QString &specialChar : specialNumChars) {
|
||||||
if (numProperty.contains(specialChar)) {
|
if (numProperty.contains(specialChar)) {
|
||||||
specialNumCards.insert(numProperty.remove(specialChar), cardVar);
|
|
||||||
skip = true;
|
skip = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (skip) {
|
if (skip) {
|
||||||
|
specialPromoCards.insert(name, cardVar);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
allNumProps.append(numProperty);
|
allNameProps.append(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,16 +406,16 @@ int OracleImporter::importCardsFromSet(CardSetPtr currentSet, const QList<QVaria
|
||||||
numCards++;
|
numCards++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the unique cards with special chars in num
|
// only add the unique promo cards that didn't already exist in the set
|
||||||
if (skipSpecialNums) {
|
if (skipSpecialCards) {
|
||||||
QList<QVariant> extraStarCards;
|
QList<QVariant> nonDuplicatePromos;
|
||||||
for (auto cardIter = specialNumCards.constBegin(); cardIter != specialNumCards.constEnd(); ++cardIter) {
|
for (auto cardIter = specialPromoCards.constBegin(); cardIter != specialPromoCards.constEnd(); ++cardIter) {
|
||||||
if (!allNumProps.contains(cardIter.key())) {
|
if (!allNameProps.contains(cardIter.key())) {
|
||||||
extraStarCards.append(cardIter.value());
|
nonDuplicatePromos.append(cardIter.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!extraStarCards.isEmpty()) {
|
if (!nonDuplicatePromos.isEmpty()) {
|
||||||
numCards += importCardsFromSet(currentSet, extraStarCards, false);
|
numCards += importCardsFromSet(currentSet, nonDuplicatePromos, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return numCards;
|
return numCards;
|
||||||
|
|
Loading…
Reference in a new issue