diff --git a/doc/carddatabase_v4/cards.xsd b/doc/carddatabase_v4/cards.xsd
index 9a879302b..92d30b94f 100644
--- a/doc/carddatabase_v4/cards.xsd
+++ b/doc/carddatabase_v4/cards.xsd
@@ -30,6 +30,7 @@
+
diff --git a/libcockatrice_card/libcockatrice/card/card_info.cpp b/libcockatrice_card/libcockatrice/card/card_info.cpp
index 58aa83848..3054a10cf 100644
--- a/libcockatrice_card/libcockatrice/card/card_info.cpp
+++ b/libcockatrice_card/libcockatrice/card/card_info.cpp
@@ -32,7 +32,7 @@ CardInfo::CardInfo(const QString &_name,
{
simpleName = CardInfo::simplifyName(name);
- refreshCachedSetNames();
+ refreshCachedSets();
}
CardInfoPtr CardInfo::newInstance(const QString &_name)
@@ -84,7 +84,7 @@ void CardInfo::addToSet(const CardSetPtr &_set, const PrintingInfo _info)
setsToPrintings[_set->getShortName()].append(_info);
}
- refreshCachedSetNames();
+ refreshCachedSets();
}
void CardInfo::combineLegalities(const QVariantHash &props)
@@ -98,6 +98,12 @@ void CardInfo::combineLegalities(const QVariantHash &props)
}
}
+void CardInfo::refreshCachedSets()
+{
+ refreshCachedSetNames();
+ refreshCachedAltNames();
+}
+
void CardInfo::refreshCachedSetNames()
{
QStringList setList;
@@ -113,6 +119,21 @@ void CardInfo::refreshCachedSetNames()
setsNames = setList.join(", ");
}
+void CardInfo::refreshCachedAltNames()
+{
+ altNames.clear();
+
+ // update the altNames with the flavorNames
+ for (const auto &printings : setsToPrintings) {
+ for (const auto &printing : printings) {
+ QString flavorName = printing.getFlavorName();
+ if (!flavorName.isEmpty()) {
+ altNames.insert(flavorName);
+ }
+ }
+ }
+}
+
QString CardInfo::simplifyName(const QString &name)
{
static const QRegularExpression spaceOrSplit("(\\s+|\\/\\/.*)");
diff --git a/libcockatrice_card/libcockatrice/card/card_info.h b/libcockatrice_card/libcockatrice/card/card_info.h
index a52c0553a..ab1d51a49 100644
--- a/libcockatrice_card/libcockatrice/card/card_info.h
+++ b/libcockatrice_card/libcockatrice/card/card_info.h
@@ -77,8 +77,9 @@ private:
QList reverseRelatedCards; ///< Cards that refer back to this card.
QList reverseRelatedCardsToMe; ///< Cards that consider this card as related.
SetToPrintingsMap setsToPrintings; ///< Mapping from set names to printing variations.
- QString setsNames; ///< Cached, human-readable list of set names.
UiAttributes uiAttributes; ///< Attributes that affect display and game logic
+ QString setsNames; ///< Cached, human-readable list of set names.
+ QSet altNames; ///< Cached set of alternate names, used when searching
///@}
public:
@@ -114,7 +115,8 @@ public:
: QObject(other.parent()), name(other.name), simpleName(other.simpleName), text(other.text),
isToken(other.isToken), properties(other.properties), relatedCards(other.relatedCards),
reverseRelatedCards(other.reverseRelatedCards), reverseRelatedCardsToMe(other.reverseRelatedCardsToMe),
- setsToPrintings(other.setsToPrintings), setsNames(other.setsNames), uiAttributes(other.uiAttributes)
+ setsToPrintings(other.setsToPrintings), uiAttributes(other.uiAttributes), setsNames(other.setsNames),
+ altNames(other.altNames)
{
}
@@ -185,6 +187,10 @@ public:
{
return simpleName;
}
+ const QSet &getAltNames()
+ {
+ return altNames;
+ };
const QString &getText() const
{
return text;
@@ -303,11 +309,11 @@ public:
void combineLegalities(const QVariantHash &props);
/**
- * @brief Refreshes the cached, human-readable list of set names.
+ * @brief Refreshes all cached fields that are calculated from the contained sets and printings.
*
- * Typically called after adding or modifying set memberships.
+ * Typically called after adding or modifying set memberships or printings.
*/
- void refreshCachedSetNames();
+ void refreshCachedSets();
/**
* @brief Simplifies a name for fuzzy matching.
@@ -319,6 +325,21 @@ public:
*/
static QString simplifyName(const QString &name);
+private:
+ /**
+ * @brief Refreshes the cached, human-readable list of set names.
+ *
+ * Typically called after adding or modifying set memberships.
+ */
+ void refreshCachedSetNames();
+
+ /**
+ * @brief Refreshes the cached list of alt names for the card.
+ *
+ * Typically called after adding or modifying the contained printings.
+ */
+ void refreshCachedAltNames();
+
signals:
/**
* @brief Emitted when a pixmap for this card has been updated or finished loading.
diff --git a/libcockatrice_card/libcockatrice/card/database/card_database.cpp b/libcockatrice_card/libcockatrice/card/database/card_database.cpp
index 7e23b4663..57b3ce06e 100644
--- a/libcockatrice_card/libcockatrice/card/database/card_database.cpp
+++ b/libcockatrice_card/libcockatrice/card/database/card_database.cpp
@@ -194,8 +194,9 @@ void CardDatabase::markAllSetsAsKnown()
void CardDatabase::notifyEnabledSetsChanged()
{
// refresh the list of cached set names
- for (const CardInfoPtr &card : cards)
- card->refreshCachedSetNames();
+ for (const CardInfoPtr &card : cards) {
+ card->refreshCachedSets();
+ }
// inform the carddatabasemodels that they need to re-check their list of cards
emit cardDatabaseEnabledSetsChanged();
diff --git a/libcockatrice_card/libcockatrice/card/printing/printing_info.cpp b/libcockatrice_card/libcockatrice/card/printing/printing_info.cpp
index 9de563d78..340998565 100644
--- a/libcockatrice_card/libcockatrice/card/printing/printing_info.cpp
+++ b/libcockatrice_card/libcockatrice/card/printing/printing_info.cpp
@@ -12,4 +12,9 @@ PrintingInfo::PrintingInfo(const CardSetPtr &_set) : set(_set)
QString PrintingInfo::getUuid() const
{
return properties.value("uuid").toString();
+}
+
+QString PrintingInfo::getFlavorName() const
+{
+ return properties.value("flavorName").toString();
}
\ No newline at end of file
diff --git a/libcockatrice_card/libcockatrice/card/printing/printing_info.h b/libcockatrice_card/libcockatrice/card/printing/printing_info.h
index 37d7a15e2..4329ca2f4 100644
--- a/libcockatrice_card/libcockatrice/card/printing/printing_info.h
+++ b/libcockatrice_card/libcockatrice/card/printing/printing_info.h
@@ -110,6 +110,13 @@ public:
* @return A string representing the providerID.
*/
QString getUuid() const;
+
+ /**
+ * @brief Returns the flavorName for this printing.
+ *
+ * @return The flavorName, or empty if it isn't present.
+ */
+ QString getFlavorName() const;
};
#endif // COCKATRICE_PRINTING_INFO_H
diff --git a/oracle/src/oracleimporter.cpp b/oracle/src/oracleimporter.cpp
index 41335d72d..f316e439d 100644
--- a/oracle/src/oracleimporter.cpp
+++ b/oracle/src/oracleimporter.cpp
@@ -293,6 +293,13 @@ int OracleImporter::importCardsFromSet(const CardSetPtr ¤tSet, const QList
printingInfo.setProperty(xmlPropertyName, propertyValue);
}
+ // handle flavorNames specially due to double-faced cards
+ QString faceFlavorName = getStringPropertyFromMap(card, "faceFlavorName");
+ QString flavorName = !faceFlavorName.isEmpty() ? faceFlavorName : getStringPropertyFromMap(card, "flavorName");
+ if (!flavorName.isEmpty()) {
+ printingInfo.setProperty("flavorName", flavorName);
+ }
+
// Identifiers
for (auto i = identifierProperties.cbegin(), end = identifierProperties.cend(); i != end; ++i) {
QString mtgjsonProperty = i.key();