From 5f28dff30ebb3c3cfc3ca0b9b23cca09575ea9f3 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Thu, 2 Jul 2015 09:22:05 +0200 Subject: [PATCH 1/2] Fix #1188 --- oracle/src/oracleimporter.cpp | 61 +++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/oracle/src/oracleimporter.cpp b/oracle/src/oracleimporter.cpp index 3ead4102..e8c254b7 100644 --- a/oracle/src/oracleimporter.cpp +++ b/oracle/src/oracleimporter.cpp @@ -76,33 +76,38 @@ CardInfo *OracleImporter::addCard(const QString &setName, cardName = cardName.replace("Æ", "AE"); cardName = cardName.replace("’", "'"); - // Remove {} around mana costs - cardCost.remove(QChar('{')); - cardCost.remove(QChar('}')); + CardInfo * card; + if (cards.contains(cardName)) { + card = cards.value(cardName); + } else { + // Remove {} around mana costs + cardCost.remove(QChar('{')); + cardCost.remove(QChar('}')); - // detect mana generator artifacts - bool mArtifact = false; - if (cardType.endsWith("Artifact")) - for (int i = 0; i < cardTextRows.size(); ++i) - if (cardTextRows[i].contains("{T}") && cardTextRows[i].contains("to your mana pool")) - mArtifact = true; + // detect mana generator artifacts + bool mArtifact = false; + if (cardType.endsWith("Artifact")) + for (int i = 0; i < cardTextRows.size(); ++i) + if (cardTextRows[i].contains("{T}") && cardTextRows[i].contains("to your mana pool")) + mArtifact = true; - // detect cards that enter the field tapped - bool cipt = cardText.contains("Hideaway") || (cardText.contains(cardName + " enters the battlefield tapped") && !cardText.contains(cardName + " enters the battlefield tapped unless")); - - // insert the card and its properties - CardInfo *card = new CardInfo(this, cardName, isToken, cardCost, cmc, cardType, cardPT, cardText, colors, relatedCards, upsideDown, cardLoyalty, cipt); - int tableRow = 1; - QString mainCardType = card->getMainCardType(); - if ((mainCardType == "Land") || mArtifact) - tableRow = 0; - else if ((mainCardType == "Sorcery") || (mainCardType == "Instant")) - tableRow = 3; - else if (mainCardType == "Creature") - tableRow = 2; - card->setTableRow(tableRow); - - cards.insert(cardName, card); + // detect cards that enter the field tapped + bool cipt = cardText.contains("Hideaway") || (cardText.contains(cardName + " enters the battlefield tapped") && !cardText.contains(cardName + " enters the battlefield tapped unless")); + + // insert the card and its properties + card = new CardInfo(this, cardName, isToken, cardCost, cmc, cardType, cardPT, cardText, colors, relatedCards, upsideDown, cardLoyalty, cipt); + int tableRow = 1; + QString mainCardType = card->getMainCardType(); + if ((mainCardType == "Land") || mArtifact) + tableRow = 0; + else if ((mainCardType == "Sorcery") || (mainCardType == "Instant")) + tableRow = 3; + else if (mainCardType == "Creature") + tableRow = 2; + card->setTableRow(tableRow); + + cards.insert(cardName, card); + } card->setMuId(setName, cardId); return card; @@ -190,6 +195,12 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data) CardInfo *card = addCard(set->getShortName(), cardName, false, cardId, cardCost, cmc, cardType, cardPT, cardLoyalty, cardText, colors, relatedCards, upsideDown); if (!set->contains(card)) { + + if(cardName=="Mountain") + { + qDebug() << cardName << " " << set->getShortName(); + } + card->addToSet(set); cards++; } From 5e1566046e7609242dffadfe4df0ed4b2ed28adb Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Thu, 2 Jul 2015 15:31:14 +0200 Subject: [PATCH 2/2] removed debug --- oracle/src/oracleimporter.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/oracle/src/oracleimporter.cpp b/oracle/src/oracleimporter.cpp index e8c254b7..8eef9a2f 100644 --- a/oracle/src/oracleimporter.cpp +++ b/oracle/src/oracleimporter.cpp @@ -195,12 +195,6 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data) CardInfo *card = addCard(set->getShortName(), cardName, false, cardId, cardCost, cmc, cardType, cardPT, cardLoyalty, cardText, colors, relatedCards, upsideDown); if (!set->contains(card)) { - - if(cardName=="Mountain") - { - qDebug() << cardName << " " << set->getShortName(); - } - card->addToSet(set); cards++; }