[Oracle] Prefer higher-priority maintype when merging split cards (#7272)
Some checks failed
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
Build Desktop / Configure (push) Has been cancelled
Build Docker / Servatrice (arm) (push) Has been cancelled
Build Docker / Servatrice (x86) (push) Has been cancelled
Build Desktop / Debian 13 (push) Has been cancelled
Build Desktop / Debian 12 (push) Has been cancelled
Build Desktop / Fedora 44 (push) Has been cancelled
Build Desktop / Fedora 43 (push) Has been cancelled
Build Desktop / Servatrice_Debian 12 (push) Has been cancelled
Build Desktop / Ubuntu 26.04 (push) Has been cancelled
Build Desktop / Ubuntu 24.04 (push) Has been cancelled
Build Desktop / Arch (push) Has been cancelled
Build Desktop / macOS 13 Intel (push) Has been cancelled
Build Desktop / macOS 14 (push) Has been cancelled
Build Desktop / macOS 15 (push) Has been cancelled
Build Desktop / macOS 26 Debug (push) Has been cancelled
Build Desktop / Windows 10 (push) Has been cancelled
Build Docker / Publish multi-platform Servatrice image (push) Has been cancelled

* [Oracle] Prefer higher-priority maintype when merging split cards

Adventure cards (e.g. Bonecrusher Giant, Virtue of Knowledge) are stored as
split cards in MTGJSON, with a Creature/permanent face and an Instant/Sorcery
adventure face. When the two faces are merged into a single card, the code
previously discarded the second face's maintype entirely, keeping whichever
face was processed first.

If the Instant/Sorcery adventure face appeared first, the merged card got
maintype 'Instant' with tableRow 3. At runtime this made double-clicking the
card on the stack send it to the graveyard instead of the table
(PlayerActions::playCard).

Fix the merge to follow the same priority order used by getMainCardType()
(Planeswalker > Creature > Land > Sorcery > Instant > Artifact > Enchantment),
so the permanent Creature type wins for adventure cards regardless of face
order, matching the physical card and the reported expectations.

Closes #4394

* Extract helper.

* Simplify const

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-09-07 21:22:53 +02:00 committed by GitHub
parent df3defa890
commit 69e8f80fa1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -96,16 +96,30 @@ bool OracleImporter::readSetsFromByteArray(QByteArray data)
return true; return true;
} }
/**
* The priority order used to pick a card's main type when a card has multiple
* types (e.g. "Artifact Creature") or multiple faces (e.g. split/adventure cards).
* A lower index means a higher priority.
*/
static const QStringList MAIN_CARD_TYPE_PRIORITY = {"Planeswalker", "Creature", "Land", "Sorcery",
"Instant", "Artifact", "Enchantment"};
/**
* Returns the priority (index) of the given main card type. Known types map to their
* position in {@link mainCardTypePriority()}, unknown types map to -1 (lowest priority).
*/
static int mainCardTypePriority(const QString &mainCardType)
{
return MAIN_CARD_TYPE_PRIORITY.indexOf(mainCardType);
}
static QString getMainCardType(const QStringList &typeList) static QString getMainCardType(const QStringList &typeList)
{ {
if (typeList.isEmpty()) { if (typeList.isEmpty()) {
return {}; return {};
} }
static const QStringList typePriority = {"Planeswalker", "Creature", "Land", "Sorcery", for (const auto &type : MAIN_CARD_TYPE_PRIORITY) {
"Instant", "Artifact", "Enchantment"};
for (const auto &type : typePriority) {
if (typeList.contains(type)) { if (typeList.contains(type)) {
return type; return type;
} }
@ -460,8 +474,15 @@ int OracleImporter::importCardsFromSet(const CardSetPtr &currentSet, const QJson
properties.insert(prop, thisCardPropertyValue); properties.insert(prop, thisCardPropertyValue);
} else if (prop == "colors" || prop == "coloridentity") { // the card is both colors } else if (prop == "colors" || prop == "coloridentity") { // the card is both colors
properties.insert(prop, originalPropertyValue + thisCardPropertyValue); properties.insert(prop, originalPropertyValue + thisCardPropertyValue);
} else if (prop == "maintype") { // don't create maintypes with //es in them } else if (prop == "maintype") {
continue; // Use the same priority as getMainCardType() to pick the
// "best" type across faces — e.g. Creature over Instant
// for adventure cards like Bonecrusher Giant.
int currentPriority = mainCardTypePriority(originalPropertyValue);
int newPriority = mainCardTypePriority(thisCardPropertyValue);
if (newPriority >= 0 && (currentPriority < 0 || newPriority < currentPriority)) {
properties.insert(prop, thisCardPropertyValue);
}
} else { } else {
properties.insert(prop, properties.insert(prop,
originalPropertyValue + splitCardPropSeparator + thisCardPropertyValue); originalPropertyValue + splitCardPropSeparator + thisCardPropertyValue);