mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-21 18:02:14 -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
|
|
@ -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