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 <Daenyth+git@gmail.com>
This commit is contained in:
Frederik Holden 2013-07-11 18:02:03 +02:00 committed by Daenyth
parent 347d30a84b
commit c0fdbb2cca

View file

@ -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();