mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-02 03:23:56 -07:00
Home tab to replace generic deck editor on startup (#6114)
This commit is contained in:
parent
22c8268f02
commit
93c15c8151
26 changed files with 751 additions and 8 deletions
|
|
@ -14,6 +14,7 @@
|
|||
#include <QMessageBox>
|
||||
#include <QRegularExpression>
|
||||
#include <algorithm>
|
||||
#include <qrandom.h>
|
||||
#include <utility>
|
||||
|
||||
CardDatabase::CardDatabase(QObject *parent) : QObject(parent), loadStatus(NotLoaded)
|
||||
|
|
@ -213,6 +214,19 @@ ExactCard CardDatabase::guessCard(const CardRef &cardRef) const
|
|||
return ExactCard(temp, findPrintingWithId(temp, cardRef.providerId));
|
||||
}
|
||||
|
||||
ExactCard CardDatabase::getRandomCard()
|
||||
{
|
||||
if (cards.isEmpty())
|
||||
return {};
|
||||
|
||||
const auto keys = cards.keys();
|
||||
int randomIndex = QRandomGenerator::global()->bounded(keys.size());
|
||||
const QString &randomKey = keys.at(randomIndex);
|
||||
CardInfoPtr randomCard = getCardInfo(randomKey);
|
||||
|
||||
return ExactCard{randomCard, getPreferredPrinting(randomCard)};
|
||||
}
|
||||
|
||||
CardSetPtr CardDatabase::getSet(const QString &setName)
|
||||
{
|
||||
if (sets.contains(setName)) {
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ public:
|
|||
ExactCard getCardFromSameSet(const QString &cardName, const PrintingInfo &otherPrinting) const;
|
||||
|
||||
[[nodiscard]] ExactCard guessCard(const CardRef &cardRef) const;
|
||||
[[nodiscard]] ExactCard getRandomCard();
|
||||
|
||||
/*
|
||||
* Get a card by its simple name. The name will be simplified in this
|
||||
|
|
@ -98,6 +99,7 @@ public:
|
|||
return cards;
|
||||
}
|
||||
SetList getSetList() const;
|
||||
CardInfoPtr getCardFromMap(const CardNameMap &cardMap, const QString &cardName) const;
|
||||
LoadStatus loadFromFile(const QString &fileName);
|
||||
bool saveCustomTokensToFile();
|
||||
QStringList getAllMainCardTypes() const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue