From c0fdbb2ccadf90ef9b97b82343585d299f1460c4 Mon Sep 17 00:00:00 2001 From: Frederik Holden Date: Thu, 11 Jul 2013 18:02:03 +0200 Subject: [PATCH] Fix two bugs in the price tag feature "The price tag feature currently has two bugs. 1. The final price that a card ends up with is the one in the last set alphabetically, instead of the one from the set with the lowest price. 2. Black Lotus Project sometimes gets in prices for cards from Masters Edition, for some reason. This set only exists in Magic the Gathering: Online, i.e., not physically, and should not be considered. This might be considered a BLP bug and not a Cockatrice bug. This patch fixes those two bugs. I also changed the price value to be based on BLP's "price" value instead of the "average" value. Seems more logical." Signed-off-by: Daenyth --- 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 557cf2b7..07ded728 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();