From 106e9d15383b96076ce89ea14f040c8bff1eac49 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Wed, 9 Jul 2014 09:43:01 +0200 Subject: [PATCH] Updated for new API * Use the new, shortest API m= * for a card, grab prices for all sets * use the lower price for a card from all sets, but avoid prices=0 (e.g.: some M15 cards have no price yet) --- cockatrice/src/priceupdater.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/cockatrice/src/priceupdater.cpp b/cockatrice/src/priceupdater.cpp index 1cf2b064..98d3043d 100644 --- a/cockatrice/src/priceupdater.cpp +++ b/cockatrice/src/priceupdater.cpp @@ -126,14 +126,20 @@ void DBPriceUpdater::updatePrices() muidMap.clear(); CardInfo * card; int muid; + SetList sets; for (int i = 0; i < cards.size(); ++i) { card = db->getCard(cards[i], false); - muid=card->getPreferredMuId(); - q += (i ? "&" : "?") + QString("multiverseid=%1").arg(muid); - muidMap.insert(muid, cards[i]); + sets = card->getSets(); + for(int j = 0; j < sets.size(); ++j) + { + muid=card->getMuId(sets[j]->getShortName()); + //qDebug() << "muid " << muid << " card: " << cards[i] << endl; + q += (i ? "&" : "?") + QString("m=%1").arg(muid); + muidMap.insert(muid, cards[i]); + } } QUrl url(q); - + //qDebug() << "request prices from: " << url.toString() << endl; QNetworkReply *reply = nam->get(QNetworkRequest(url)); connect(reply, SIGNAL(finished()), this, SLOT(downloadFinished())); } @@ -208,7 +214,7 @@ void DBPriceUpdater::downloadFinished() * 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)) + if (set != "MED" && price > 0 && (!cardsPrice.contains(name) || cardsPrice.value(name) > price)) cardsPrice.insert(name, price); } }