mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
[DeckListModel] optimize by iterating over cardNodes instead of ExactCards (#6485)
* [DeckListModel] optimize by iterating over cardNodes instead of ExactCards * fix build failure * another optimization * fix build failure
This commit is contained in:
parent
f16c552d97
commit
746f2af044
6 changed files with 67 additions and 76 deletions
|
|
@ -81,13 +81,30 @@ void VisualDeckEditorSampleHandWidget::updateDisplay()
|
|||
}
|
||||
}
|
||||
|
||||
static QList<ExactCard> cardNodesToExactCards(QList<const DecklistCardNode *> nodes)
|
||||
{
|
||||
QList<ExactCard> cards;
|
||||
for (auto node : nodes) {
|
||||
ExactCard card = CardDatabaseManager::query()->getCard(node->toCardRef());
|
||||
if (card) {
|
||||
for (int k = 0; k < node->getNumber(); ++k) {
|
||||
cards.append(card);
|
||||
}
|
||||
} else {
|
||||
qDebug() << "Card not found in database!";
|
||||
}
|
||||
}
|
||||
|
||||
return cards;
|
||||
}
|
||||
|
||||
QList<ExactCard> VisualDeckEditorSampleHandWidget::getRandomCards(int amountToGet)
|
||||
{
|
||||
QList<ExactCard> randomCards;
|
||||
if (!deckListModel)
|
||||
return randomCards;
|
||||
|
||||
QList<ExactCard> mainDeckCards = deckListModel->getCardsForZone(DECK_ZONE_MAIN);
|
||||
QList<ExactCard> mainDeckCards = cardNodesToExactCards(deckListModel->getCardNodesForZone(DECK_ZONE_MAIN));
|
||||
|
||||
if (mainDeckCards.isEmpty())
|
||||
return randomCards;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue