From 5fc211aad46b4473faf82a6134eec0d878a11f77 Mon Sep 17 00:00:00 2001 From: Frederik Holden Date: Thu, 11 Jul 2013 18:02:03 +0200 Subject: [PATCH 1/2] Fix two bugs in the price tag feature --- cockatrice/src/priceupdater.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cockatrice/src/priceupdater.cpp b/cockatrice/src/priceupdater.cpp index 557cf2b77..07ded728e 100644 --- a/cockatrice/src/priceupdater.cpp +++ b/cockatrice/src/priceupdater.cpp @@ -55,8 +55,16 @@ void PriceUpdater::downloadFinished() while (it.hasNext()) { QVariantMap map = it.next().toMap(); QString name = map.value("name").toString().toLower(); - float price = map.value("average").toString().toFloat(); - cardsPrice.insert(name, price); + float price = map.value("price").toString().toFloat(); + QString set = map.value("set_code").toString(); + + /** + * Make sure Masters Edition (MED) isn't the set, as it doesn't + * physically exist. Also check the price to see that the cheapest set + * ends up as the final price. + */ + if (set != "MED" && (!cardsPrice.contains(name) || cardsPrice.value(name) > price)) + cardsPrice.insert(name, price); } InnerDecklistNode *listRoot = deck->getRoot(); From ee841970dac15d218f58c170892c842d3f846ffd Mon Sep 17 00:00:00 2001 From: Frederik Holden Date: Thu, 11 Jul 2013 18:02:03 +0200 Subject: [PATCH 2/2] Price tag feature: correctly select the lowest price of all physical sets --- cockatrice/src/priceupdater.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cockatrice/src/priceupdater.cpp b/cockatrice/src/priceupdater.cpp index 557cf2b77..07ded728e 100644 --- a/cockatrice/src/priceupdater.cpp +++ b/cockatrice/src/priceupdater.cpp @@ -55,8 +55,16 @@ void PriceUpdater::downloadFinished() while (it.hasNext()) { QVariantMap map = it.next().toMap(); QString name = map.value("name").toString().toLower(); - float price = map.value("average").toString().toFloat(); - cardsPrice.insert(name, price); + float price = map.value("price").toString().toFloat(); + QString set = map.value("set_code").toString(); + + /** + * Make sure Masters Edition (MED) isn't the set, as it doesn't + * physically exist. Also check the price to see that the cheapest set + * ends up as the final price. + */ + if (set != "MED" && (!cardsPrice.contains(name) || cardsPrice.value(name) > price)) + cardsPrice.insert(name, price); } InnerDecklistNode *listRoot = deck->getRoot();