mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-13 01:24:46 -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)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue