mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-24 15:43:54 -07:00
Have CardDatabase::getPreferredPrintingInfo respect card provider ID overrides (pinned printings)
Took 13 minutes Took 37 seconds Took 10 seconds Took 10 seconds # Commit time for manual adjustment: # Took 30 seconds Took 15 seconds Took 8 minutes Took 21 seconds
This commit is contained in:
parent
dbd1d30ca8
commit
3ccb0cbb23
13 changed files with 97 additions and 38 deletions
|
|
@ -4,10 +4,14 @@
|
|||
#include "../printing/exact_card.h"
|
||||
#include "../set/card_set_comparator.h"
|
||||
#include "card_database.h"
|
||||
#include "interface/settings_card_preference_provider.h"
|
||||
|
||||
#include <qrandom.h>
|
||||
|
||||
CardDatabaseQuerier::CardDatabaseQuerier(QObject *_parent, const CardDatabase *_db) : QObject(_parent), db(_db)
|
||||
CardDatabaseQuerier::CardDatabaseQuerier(QObject *_parent,
|
||||
const CardDatabase *_db,
|
||||
const QSharedPointer<ICardPreferenceProvider> &prefs)
|
||||
: QObject(_parent), db(_db), prefs(prefs)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -204,6 +208,17 @@ PrintingInfo CardDatabaseQuerier::getSpecificPrinting(const QString &cardName,
|
|||
return PrintingInfo(nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the card representing the preferred printing of the cardInfo
|
||||
*
|
||||
* @param cardName The cardName to find the preferred card and printing for
|
||||
* @return A specific printing of a card
|
||||
*/
|
||||
ExactCard CardDatabaseQuerier::getPreferredCard(const QString &cardName) const
|
||||
{
|
||||
return getPreferredCard(getCardInfo(cardName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the card representing the preferred printing of the cardInfo
|
||||
*
|
||||
|
|
@ -236,6 +251,12 @@ PrintingInfo CardDatabaseQuerier::getPreferredPrinting(const CardInfoPtr &cardIn
|
|||
return PrintingInfo(nullptr);
|
||||
}
|
||||
|
||||
const auto &pinnedPrintingProviderId = prefs->getCardPreferenceOverride(cardInfo->getName());
|
||||
|
||||
if (!pinnedPrintingProviderId.isEmpty()) {
|
||||
return getSpecificPrinting({cardInfo->getName(), pinnedPrintingProviderId});
|
||||
}
|
||||
|
||||
SetToPrintingsMap setMap = cardInfo->getSets();
|
||||
if (setMap.empty()) {
|
||||
return PrintingInfo(nullptr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue