mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 17:15:09 -07:00
[Card] Import Scryfall Tagger tags from MTGJson
This commit is contained in:
parent
7a2492ac67
commit
1803fce56c
3 changed files with 85 additions and 0 deletions
|
|
@ -505,6 +505,21 @@ int OracleImporter::importCardsFromSet(const CardSetPtr ¤tSet, const QJson
|
|||
properties.insert("coloridentity", colorIdentity);
|
||||
}
|
||||
|
||||
// Scryfall Tagger tags (resolved by MTGJSON into the `tags` array).
|
||||
// Stored space-separated so the `tags:` search can match each slug as a
|
||||
// discrete token; slugs never contain whitespace.
|
||||
QStringList tags;
|
||||
for (const QJsonValue &tag : card.value("tags").toArray()) {
|
||||
const QString tagSlug = tag.toString().trimmed().toLower();
|
||||
if (!tagSlug.isEmpty() && !tags.contains(tagSlug)) {
|
||||
tags.append(tagSlug);
|
||||
}
|
||||
}
|
||||
if (!tags.isEmpty()) {
|
||||
tags.sort();
|
||||
properties.insert("tags", tags.join(" "));
|
||||
}
|
||||
|
||||
const auto &mainCardType = getMainCardType(card.value("types").toVariant().toStringList());
|
||||
if (mainCardType.isEmpty()) {
|
||||
qDebug() << "warning: no mainCardType for card:" << name;
|
||||
|
|
@ -651,6 +666,14 @@ int OracleImporter::importCardsFromSet(const CardSetPtr ¤tSet, const QJson
|
|||
if (newPriority >= 0 && (currentPriority < 0 || newPriority < currentPriority)) {
|
||||
properties.insert(prop, thisCardPropertyValue);
|
||||
}
|
||||
} else if (prop == "tags") {
|
||||
// Tags are oracle-level: union both faces instead of
|
||||
// concatenating them with the split-card separator.
|
||||
QStringList merged =
|
||||
(originalPropertyValue + " " + thisCardPropertyValue).split(" ", Qt::SkipEmptyParts);
|
||||
merged.removeDuplicates();
|
||||
merged.sort();
|
||||
properties.insert(prop, merged.join(" "));
|
||||
} else {
|
||||
properties.insert(prop,
|
||||
originalPropertyValue + splitCardPropSeparator + thisCardPropertyValue);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue