mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 17:02:15 -07:00
Support multiple <set> tags per card within the database
This will allow us to show off all different printings for cards that might appear multiple times in a set (alt arts, Secret Lairs, etc.)
This commit is contained in:
parent
7ae1349ac8
commit
db53066d89
12 changed files with 159 additions and 152 deletions
|
|
@ -32,20 +32,24 @@ PictureToLoad::PictureToLoad(CardInfoPtr _card)
|
|||
: card(std::move(_card)), urlTemplates(SettingsCache::instance().downloads().getAllURLs())
|
||||
{
|
||||
if (card) {
|
||||
for (const auto &set : card->getSets()) {
|
||||
sortedSets << set.getPtr();
|
||||
for (const auto &x : card->getSets()) {
|
||||
for (const auto &set : x) {
|
||||
sortedSets << set.getPtr();
|
||||
}
|
||||
}
|
||||
if (sortedSets.empty()) {
|
||||
sortedSets << CardSet::newInstance("", "", "", QDate());
|
||||
}
|
||||
std::sort(sortedSets.begin(), sortedSets.end(), SetDownloadPriorityComparator());
|
||||
// If the pixmapCacheKey corresponds to a specific set, we have to try to load it first.
|
||||
for (const auto &set : card->getSets()) {
|
||||
if (QLatin1String("card_") + card->getName() + QString("_") + QString(set.getProperty("uuid")) ==
|
||||
card->getPixmapCacheKey()) {
|
||||
long long setIndex = sortedSets.indexOf(set.getPtr());
|
||||
CardSetPtr setForCardProviderID = sortedSets.takeAt(setIndex);
|
||||
sortedSets.prepend(setForCardProviderID);
|
||||
for (const auto &x : card->getSets()) {
|
||||
for (const auto &set : x) {
|
||||
if (QLatin1String("card_") + card->getName() + QString("_") + QString(set.getProperty("uuid")) ==
|
||||
card->getPixmapCacheKey()) {
|
||||
long long setIndex = sortedSets.indexOf(set.getPtr());
|
||||
CardSetPtr setForCardProviderID = sortedSets.takeAt(setIndex);
|
||||
sortedSets.prepend(setForCardProviderID);
|
||||
}
|
||||
}
|
||||
}
|
||||
// The first time called, nextSet will also populate the Urls for the first set.
|
||||
|
|
|
|||
|
|
@ -167,9 +167,11 @@ CardInfoPerSet PrintingSelector::getSetForUUID(const QString &uuid)
|
|||
{
|
||||
CardInfoPerSetMap cardInfoPerSets = selectedCard->getSets();
|
||||
|
||||
for (const auto &cardInfoPerSet : cardInfoPerSets) {
|
||||
if (cardInfoPerSet.getProperty("uuid") == uuid) {
|
||||
return cardInfoPerSet;
|
||||
for (const auto &x : cardInfoPerSets) {
|
||||
for (const auto &cardInfoPerSet : x) {
|
||||
if (cardInfoPerSet.getProperty("uuid") == uuid) {
|
||||
return cardInfoPerSet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -182,15 +184,18 @@ QList<CardInfoPerSet> PrintingSelector::prependPrintingsInDeck(const QList<CardI
|
|||
QList<QPair<CardInfoPerSet, int>> countList;
|
||||
|
||||
// Collect sets with their counts
|
||||
for (const auto &cardInfoPerSet : cardInfoPerSets) {
|
||||
QModelIndex find_card =
|
||||
deckModel->findCard(selectedCard->getName(), DECK_ZONE_MAIN, cardInfoPerSet.getProperty("uuid"));
|
||||
if (find_card.isValid()) {
|
||||
int count =
|
||||
deckModel->data(find_card, Qt::DisplayRole).toInt(); // Ensure the count is treated as an integer
|
||||
if (count > 0) {
|
||||
countList.append(qMakePair(cardInfoPerSet, count));
|
||||
for (const auto &x : cardInfoPerSets) {
|
||||
for (const auto &cardInfoPerSet : x) {
|
||||
QModelIndex find_card =
|
||||
deckModel->findCard(selectedCard->getName(), DECK_ZONE_MAIN, cardInfoPerSet.getProperty("uuid"));
|
||||
if (find_card.isValid()) {
|
||||
int count =
|
||||
deckModel->data(find_card, Qt::DisplayRole).toInt(); // Ensure the count is treated as an integer
|
||||
if (count > 0) {
|
||||
countList.append(qMakePair(cardInfoPerSet, count));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -226,8 +231,11 @@ QList<CardInfoPerSet> PrintingSelector::sortSets()
|
|||
|
||||
QList<CardSetPtr> sortedSets;
|
||||
|
||||
for (const auto &set : cardInfoPerSets) {
|
||||
sortedSets << set.getPtr();
|
||||
for (const auto &x : cardInfoPerSets) {
|
||||
for (const auto &set : x) {
|
||||
sortedSets << set.getPtr();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sortedSets.empty()) {
|
||||
|
|
@ -244,8 +252,11 @@ QList<CardInfoPerSet> PrintingSelector::sortSets()
|
|||
// Reconstruct sorted list of CardInfoPerSet
|
||||
for (const auto &set : sortedSets) {
|
||||
for (auto it = cardInfoPerSets.begin(); it != cardInfoPerSets.end(); ++it) {
|
||||
if (it.value().getPtr() == set) {
|
||||
sortedCardInfoPerSets << it.value();
|
||||
for (const auto &x : it.value()) {
|
||||
if (x.getPtr() == set) {
|
||||
sortedCardInfoPerSets << it.value();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ void DlgEditTokens::actAddToken()
|
|||
|
||||
QString setName = CardDatabase::TOKENS_SETNAME;
|
||||
CardInfoPerSetMap sets;
|
||||
sets.insert(setName, CardInfoPerSet(databaseModel->getDatabase()->getSet(setName)));
|
||||
sets[setName].append(CardInfoPerSet(databaseModel->getDatabase()->getSet(setName)));
|
||||
CardInfoPtr card = CardInfo::newInstance(name, "", true, QVariantHash(), QList<CardRelation *>(),
|
||||
QList<CardRelation *>(), sets, false, -1, false);
|
||||
card->setCardType("Token");
|
||||
|
|
|
|||
|
|
@ -266,8 +266,11 @@ CardInfoPtr CardInfo::newInstance(const QString &_name,
|
|||
_sets, _cipt, _tableRow, _upsideDownArt));
|
||||
ptr->setSmartPointer(ptr);
|
||||
|
||||
for (const CardInfoPerSet &set : _sets) {
|
||||
set.getPtr()->append(ptr);
|
||||
for (const auto &x : _sets) {
|
||||
for (const CardInfoPerSet &set : x) {
|
||||
set.getPtr()->append(ptr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ptr;
|
||||
|
|
@ -288,7 +291,7 @@ QString CardInfo::getCorrectedName() const
|
|||
void CardInfo::addToSet(const CardSetPtr &_set, const CardInfoPerSet _info)
|
||||
{
|
||||
_set->append(smartThis);
|
||||
sets.insert(_set->getShortName(), _info);
|
||||
sets[_set->getShortName()].append(_info);
|
||||
|
||||
refreshCachedSetNames();
|
||||
}
|
||||
|
|
@ -297,9 +300,12 @@ void CardInfo::refreshCachedSetNames()
|
|||
{
|
||||
QStringList setList;
|
||||
// update the cached list of set names
|
||||
for (const auto &set : sets) {
|
||||
if (set.getPtr()->getEnabled()) {
|
||||
setList << set.getPtr()->getShortName();
|
||||
for (const auto &x : sets) {
|
||||
for (const auto &set : x) {
|
||||
if (set.getPtr()->getEnabled()) {
|
||||
setList << set.getPtr()->getShortName();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
setsNames = setList.join(", ");
|
||||
|
|
@ -396,8 +402,10 @@ void CardDatabase::addCard(CardInfoPtr card)
|
|||
// if card already exists just add the new set property
|
||||
if (cards.contains(card->getName())) {
|
||||
CardInfoPtr sameCard = cards[card->getName()];
|
||||
for (const CardInfoPerSet &set : card->getSets()) {
|
||||
sameCard->addToSet(set.getPtr(), set);
|
||||
for (const auto &x : card->getSets()) {
|
||||
for (const CardInfoPerSet &set : x) {
|
||||
sameCard->addToSet(set.getPtr(), set);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -456,12 +464,14 @@ CardInfoPtr CardDatabase::getCardByNameAndProviderId(const QString &cardName, co
|
|||
return info;
|
||||
}
|
||||
|
||||
for (const auto &set : info->getSets()) {
|
||||
if (set.getProperty("uuid") == providerId) {
|
||||
CardInfoPtr cardFromSpecificSet = info->clone();
|
||||
cardFromSpecificSet->setPixmapCacheKey(QLatin1String("card_") + QString(info->getName()) + QString("_") +
|
||||
QString(set.getProperty("uuid")));
|
||||
return cardFromSpecificSet;
|
||||
for (const auto &x : info->getSets()) {
|
||||
for (const auto &set : x) {
|
||||
if (set.getProperty("uuid") == providerId) {
|
||||
CardInfoPtr cardFromSpecificSet = info->clone();
|
||||
cardFromSpecificSet->setPixmapCacheKey(QLatin1String("card_") + QString(info->getName()) +
|
||||
QString("_") + QString(set.getProperty("uuid")));
|
||||
return cardFromSpecificSet;
|
||||
}
|
||||
}
|
||||
}
|
||||
return {};
|
||||
|
|
@ -630,11 +640,13 @@ CardInfoPerSet CardDatabase::getPreferredSetForCard(const QString &cardName) con
|
|||
CardInfoPerSet preferredCard;
|
||||
SetPriorityComparator comparator;
|
||||
|
||||
for (auto &cardInfoForSet : setMap) {
|
||||
CardSetPtr currentSet = cardInfoForSet.getPtr();
|
||||
if (!preferredSet || comparator(currentSet, preferredSet)) {
|
||||
preferredSet = currentSet;
|
||||
preferredCard = cardInfoForSet;
|
||||
for (const auto &x : setMap) {
|
||||
for (auto &cardInfoForSet : x) {
|
||||
CardSetPtr currentSet = cardInfoForSet.getPtr();
|
||||
if (!preferredSet || comparator(currentSet, preferredSet)) {
|
||||
preferredSet = currentSet;
|
||||
preferredCard = cardInfoForSet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -657,9 +669,11 @@ CardInfoPerSet CardDatabase::getSpecificSetForCard(const QString &cardName, cons
|
|||
return CardInfoPerSet(nullptr);
|
||||
}
|
||||
|
||||
for (auto &cardInfoForSet : setMap) {
|
||||
if (cardInfoForSet.getProperty("uuid") == providerId) {
|
||||
return cardInfoForSet;
|
||||
for (const auto &x : setMap) {
|
||||
for (auto &cardInfoForSet : x) {
|
||||
if (cardInfoForSet.getProperty("uuid") == providerId) {
|
||||
return cardInfoForSet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class ICardDatabaseParser;
|
|||
typedef QMap<QString, QString> QStringMap;
|
||||
typedef QSharedPointer<CardInfo> CardInfoPtr;
|
||||
typedef QSharedPointer<CardSet> CardSetPtr;
|
||||
typedef QMap<QString, CardInfoPerSet> CardInfoPerSetMap;
|
||||
typedef QMap<QString, QList<CardInfoPerSet>> CardInfoPerSetMap;
|
||||
|
||||
Q_DECLARE_METATYPE(CardInfoPtr)
|
||||
|
||||
|
|
@ -306,15 +306,36 @@ public:
|
|||
{
|
||||
if (!sets.contains(setName))
|
||||
return "";
|
||||
return sets[setName].getProperty(propertyName);
|
||||
}
|
||||
void setSetProperty(const QString &setName, const QString &_name, const QString &_value)
|
||||
{
|
||||
if (!sets.contains(setName))
|
||||
return;
|
||||
|
||||
sets[setName].setProperty(_name, _value);
|
||||
emit cardInfoChanged(smartThis);
|
||||
/*
|
||||
for (const auto &x : card->getSets()) {
|
||||
for (const auto &set : x) {
|
||||
if (QLatin1String("card_") + card->getName() + QString("_") + QString(set.getProperty("uuid")) ==
|
||||
card->getPixmapCacheKey()) {
|
||||
long long setIndex = sortedSets.indexOf(set.getPtr());
|
||||
CardSetPtr setForCardProviderID = sortedSets.takeAt(setIndex);
|
||||
sortedSets.prepend(setForCardProviderID);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
for (const auto &set : sets[setName]) {
|
||||
if (QLatin1String("card_") + this->getName() + QString("_") + QString(set.getProperty("uuid")) ==
|
||||
this->getPixmapCacheKey()) {
|
||||
return set.getProperty(propertyName);
|
||||
}
|
||||
}
|
||||
|
||||
return sets[setName][0].getProperty(propertyName);
|
||||
}
|
||||
void setSetProperty(const QString &, const QString &, const QString &)
|
||||
{
|
||||
// if (!sets.contains(setName))
|
||||
// return;
|
||||
//
|
||||
// sets[setName].setProperty(_name, _value);
|
||||
// emit cardInfoChanged(smartThis);
|
||||
}
|
||||
|
||||
// related cards
|
||||
|
|
|
|||
|
|
@ -97,9 +97,11 @@ bool CardDatabaseModel::checkCardHasAtLeastOneEnabledSet(CardInfoPtr card)
|
|||
if (!showOnlyCardsFromEnabledSets)
|
||||
return true;
|
||||
|
||||
for (const auto &set : card->getSets()) {
|
||||
if (set.getPtr()->getEnabled())
|
||||
return true;
|
||||
for (const auto &x : card->getSets()) {
|
||||
for (const auto &set : x) {
|
||||
if (set.getPtr()->getEnabled())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ void CockatriceXml3Parser::loadCardsFromXml(QXmlStreamReader &xml)
|
|||
if (attrs.hasAttribute("rarity")) {
|
||||
setInfo.setProperty("rarity", attrs.value("rarity").toString());
|
||||
}
|
||||
_sets.insert(setName, setInfo);
|
||||
_sets[setName].append(setInfo);
|
||||
// related cards
|
||||
} else if (xmlName == "related" || xmlName == "reverse-related") {
|
||||
CardRelation::AttachType attach = CardRelation::DoesNotAttach;
|
||||
|
|
@ -331,24 +331,26 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfoPtr &in
|
|||
|
||||
// sets
|
||||
const CardInfoPerSetMap sets = info->getSets();
|
||||
for (CardInfoPerSet set : sets) {
|
||||
xml.writeStartElement("set");
|
||||
xml.writeAttribute("rarity", set.getProperty("rarity"));
|
||||
xml.writeAttribute("muId", set.getProperty("muid"));
|
||||
xml.writeAttribute("uuId", set.getProperty("uuid"));
|
||||
for (const auto &x : sets) {
|
||||
for (CardInfoPerSet set : x) {
|
||||
xml.writeStartElement("set");
|
||||
xml.writeAttribute("rarity", set.getProperty("rarity"));
|
||||
xml.writeAttribute("muId", set.getProperty("muid"));
|
||||
xml.writeAttribute("uuId", set.getProperty("uuid"));
|
||||
|
||||
tmpString = set.getProperty("num");
|
||||
if (!tmpString.isEmpty()) {
|
||||
xml.writeAttribute("num", tmpString);
|
||||
tmpString = set.getProperty("num");
|
||||
if (!tmpString.isEmpty()) {
|
||||
xml.writeAttribute("num", tmpString);
|
||||
}
|
||||
|
||||
tmpString = set.getProperty("picurl");
|
||||
if (!tmpString.isEmpty()) {
|
||||
xml.writeAttribute("picURL", tmpString);
|
||||
}
|
||||
|
||||
xml.writeCharacters(set.getPtr()->getShortName());
|
||||
xml.writeEndElement();
|
||||
}
|
||||
|
||||
tmpString = set.getProperty("picurl");
|
||||
if (!tmpString.isEmpty()) {
|
||||
xml.writeAttribute("picURL", tmpString);
|
||||
}
|
||||
|
||||
xml.writeCharacters(set.getPtr()->getShortName());
|
||||
xml.writeEndElement();
|
||||
}
|
||||
|
||||
// related cards
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ void CockatriceXml4Parser::loadCardsFromXml(QXmlStreamReader &xml)
|
|||
attrName = "picurl";
|
||||
setInfo.setProperty(attrName, attr.value().toString());
|
||||
}
|
||||
_sets.insert(setName, setInfo);
|
||||
_sets[setName].append(setInfo);
|
||||
}
|
||||
// related cards
|
||||
} else if (xmlName == "related" || xmlName == "reverse-related") {
|
||||
|
|
@ -284,14 +284,16 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfoPtr &in
|
|||
xml.writeEndElement();
|
||||
|
||||
// sets
|
||||
for (CardInfoPerSet set : info->getSets()) {
|
||||
xml.writeStartElement("set");
|
||||
for (QString propName : set.getProperties()) {
|
||||
xml.writeAttribute(propName, set.getProperty(propName));
|
||||
}
|
||||
for (const auto &x : info->getSets()) {
|
||||
for (CardInfoPerSet set : x) {
|
||||
xml.writeStartElement("set");
|
||||
for (QString propName : set.getProperties()) {
|
||||
xml.writeAttribute(propName, set.getProperty(propName));
|
||||
}
|
||||
|
||||
xml.writeCharacters(set.getPtr()->getShortName());
|
||||
xml.writeEndElement();
|
||||
xml.writeCharacters(set.getPtr()->getShortName());
|
||||
xml.writeEndElement();
|
||||
}
|
||||
}
|
||||
|
||||
// related cards
|
||||
|
|
|
|||
|
|
@ -109,9 +109,11 @@ static void setupParserRules()
|
|||
search["RarityQuery"] = [](const peg::SemanticValues &sv) -> Filter {
|
||||
StringMatcher matcher = sv[0].get<StringMatcher>();
|
||||
return [=](CardData x) -> bool {
|
||||
for (const auto &set : x->getSets().values()) {
|
||||
if (matcher(set.getProperty("rarity")))
|
||||
return true;
|
||||
for (const auto &y : x->getSets().values()) {
|
||||
for (const auto &set : y) {
|
||||
if (matcher(set.getProperty("rarity")))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -203,11 +203,13 @@ bool FilterItem::acceptText(const CardInfoPtr info) const
|
|||
bool FilterItem::acceptSet(const CardInfoPtr info) const
|
||||
{
|
||||
bool status = false;
|
||||
for (const auto &set : info->getSets()) {
|
||||
if (set.getPtr()->getShortName().compare(term, Qt::CaseInsensitive) == 0 ||
|
||||
set.getPtr()->getLongName().compare(term, Qt::CaseInsensitive) == 0) {
|
||||
status = true;
|
||||
break;
|
||||
for (const auto &x : info->getSets()) {
|
||||
for (const auto &set : x) {
|
||||
if (set.getPtr()->getShortName().compare(term, Qt::CaseInsensitive) == 0 ||
|
||||
set.getPtr()->getLongName().compare(term, Qt::CaseInsensitive) == 0) {
|
||||
status = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -336,9 +338,11 @@ bool FilterItem::acceptRarity(const CardInfoPtr info) const
|
|||
}
|
||||
}
|
||||
|
||||
for (const auto &set : info->getSets()) {
|
||||
if (set.getProperty("rarity").compare(converted_term, Qt::CaseInsensitive) == 0) {
|
||||
return true;
|
||||
for (const auto &x : info->getSets()) {
|
||||
for (const auto &set : x) {
|
||||
if (set.getProperty("rarity").compare(converted_term, Qt::CaseInsensitive) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ CardInfoPtr OracleImporter::addCard(QString name,
|
|||
// insert the card and its properties
|
||||
QList<CardRelation *> reverseRelatedCards;
|
||||
CardInfoPerSetMap setsInfo;
|
||||
setsInfo.insert(setInfo.getPtr()->getShortName(), setInfo);
|
||||
setsInfo[setInfo.getPtr()->getShortName()].append(setInfo);
|
||||
CardInfoPtr newCard = CardInfo::newInstance(name, text, isToken, properties, relatedCards, reverseRelatedCards,
|
||||
setsInfo, cipt, tableRow, upsideDown);
|
||||
|
||||
|
|
@ -193,9 +193,7 @@ QString OracleImporter::getStringPropertyFromMap(const QVariantMap &card, const
|
|||
return card.contains(propertyName) ? card.value(propertyName).toString() : QString("");
|
||||
}
|
||||
|
||||
int OracleImporter::importCardsFromSet(const CardSetPtr ¤tSet,
|
||||
const QList<QVariant> &cardsList,
|
||||
bool skipSpecialCards)
|
||||
int OracleImporter::importCardsFromSet(const CardSetPtr ¤tSet, const QList<QVariant> &cardsList)
|
||||
{
|
||||
// mtgjson name => xml name
|
||||
static const QMap<QString, QString> cardProperties{
|
||||
|
|
@ -225,11 +223,6 @@ int OracleImporter::importCardsFromSet(const CardSetPtr ¤tSet,
|
|||
for (const QVariant &cardVar : cardsList) {
|
||||
card = cardVar.toMap();
|
||||
|
||||
// skip alternatives
|
||||
if (getStringPropertyFromMap(card, "isAlternative") == "true") {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Currently used layouts are:
|
||||
* augment, double_faced_token, flip, host, leveler, meld, normal, planar,
|
||||
* saga, scheme, split, token, transform, vanguard
|
||||
|
|
@ -286,42 +279,6 @@ int OracleImporter::importCardsFromSet(const CardSetPtr ¤tSet,
|
|||
}
|
||||
|
||||
QString numComponent{};
|
||||
if (skipSpecialCards) {
|
||||
QString numProperty = setInfo.getProperty("num");
|
||||
// skip promo cards if it's not the only print, cards with two faces are different cards
|
||||
if (allNameProps.contains(faceName)) {
|
||||
// check for alternative versions
|
||||
if (layout != "normal")
|
||||
continue;
|
||||
|
||||
// alternative versions have a letter in the end of num like abc
|
||||
// note this will also catch p and s, those will get removed later anyway
|
||||
QChar lastChar = numProperty.at(numProperty.size() - 1);
|
||||
if (!lastChar.isLetter())
|
||||
continue;
|
||||
|
||||
numComponent = " (" + QString(lastChar) + ")";
|
||||
faceName += numComponent; // add to facename to make it unique
|
||||
}
|
||||
if (getStringPropertyFromMap(card, "isPromo") == "true") {
|
||||
specialPromoCards.insert(faceName, cardVar);
|
||||
continue;
|
||||
}
|
||||
bool skip = false;
|
||||
// skip cards containing special stuff in the collectors number like promo cards
|
||||
for (const QString &specialChar : specialNumChars) {
|
||||
if (numProperty.contains(specialChar)) {
|
||||
skip = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (skip) {
|
||||
specialPromoCards.insert(faceName, cardVar);
|
||||
continue;
|
||||
} else {
|
||||
allNameProps.append(faceName);
|
||||
}
|
||||
}
|
||||
|
||||
// special handling properties
|
||||
colors = card.value("colors").toStringList().join("");
|
||||
|
|
@ -463,18 +420,6 @@ int OracleImporter::importCardsFromSet(const CardSetPtr ¤tSet,
|
|||
numCards++;
|
||||
}
|
||||
|
||||
// only add the unique promo cards that didn't already exist in the set
|
||||
if (skipSpecialCards) {
|
||||
QList<QVariant> nonDuplicatePromos;
|
||||
for (auto cardIter = specialPromoCards.constBegin(); cardIter != specialPromoCards.constEnd(); ++cardIter) {
|
||||
if (!allNameProps.contains(cardIter.key())) {
|
||||
nonDuplicatePromos.append(cardIter.value());
|
||||
}
|
||||
}
|
||||
if (!nonDuplicatePromos.isEmpty()) {
|
||||
numCards += importCardsFromSet(currentSet, nonDuplicatePromos, false);
|
||||
}
|
||||
}
|
||||
return numCards;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ public:
|
|||
bool readSetsFromByteArray(const QByteArray &data);
|
||||
int startImport();
|
||||
bool saveToFile(const QString &fileName, const QString &sourceUrl, const QString &sourceVersion);
|
||||
int importCardsFromSet(const CardSetPtr ¤tSet, const QList<QVariant> &cards, bool skipSpecialNums = true);
|
||||
int importCardsFromSet(const CardSetPtr ¤tSet, const QList<QVariant> &cards);
|
||||
QList<SetToDownload> &getSets()
|
||||
{
|
||||
return allSets;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue