Helper to query deckList for DecklistCardNodes. (#6242)

* Helper to query deckList for DecklistCardNodes.

Took 30 minutes

Took 6 minutes

Took 2 minutes

* Fix unused.

Took 3 minutes


Took 1 minute

* Convert string to string list.

Took 2 minutes

* Adjust to rebase.

Took 2 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2025-11-15 17:21:43 +01:00 committed by GitHub
parent f62e29f5d5
commit ace4063371
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 117 additions and 194 deletions

View file

@ -83,28 +83,15 @@ QList<ExactCard> VisualDeckEditorSampleHandWidget::getRandomCards(int amountToGe
DeckList *decklist = deckListModel->getDeckList();
if (!decklist)
return randomCards;
InnerDecklistNode *listRoot = decklist->getRoot();
if (!listRoot)
return randomCards;
QList<DecklistCardNode *> cardsInDeck = decklist->getCardNodes({DECK_ZONE_MAIN});
// Collect all cards in the main deck, allowing duplicates based on their count
for (int i = 0; i < listRoot->size(); i++) {
InnerDecklistNode *currentZone = dynamic_cast<InnerDecklistNode *>(listRoot->at(i));
if (!currentZone)
continue;
if (currentZone->getName() != DECK_ZONE_MAIN)
continue; // Only process the main deck
for (int j = 0; j < currentZone->size(); j++) {
DecklistCardNode *currentCard = dynamic_cast<DecklistCardNode *>(currentZone->at(j));
if (!currentCard)
continue;
for (int k = 0; k < currentCard->getNumber(); ++k) {
ExactCard card = CardDatabaseManager::query()->getCard(currentCard->toCardRef());
if (card) {
mainDeckCards.append(card);
}
for (auto currentCard : cardsInDeck) {
for (int k = 0; k < currentCard->getNumber(); ++k) {
ExactCard card = CardDatabaseManager::query()->getCard(currentCard->toCardRef());
if (card) {
mainDeckCards.append(card);
}
}
}