[Game] Collect deck-view cards via DeckList::getCardNodes

This commit is contained in:
Lukas Brübach 2026-08-30 22:50:14 +02:00 committed by GitHub
parent 987ebcaa35
commit f53eecff15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,10 +8,8 @@
#include <QMouseEvent> #include <QMouseEvent>
#include <QtMath> #include <QtMath>
#include <algorithm> #include <algorithm>
#include <functional>
#include <libcockatrice/card/card_info.h> #include <libcockatrice/card/card_info.h>
#include <libcockatrice/deck_list/deck_list.h> #include <libcockatrice/deck_list/deck_list.h>
#include <libcockatrice/deck_list/tree/deck_list_card_node.h>
#include <libcockatrice/settings/cards_display_settings.h> #include <libcockatrice/settings/cards_display_settings.h>
DeckViewCardDragItem::DeckViewCardDragItem(DeckViewCard *_item, DeckViewCardDragItem::DeckViewCardDragItem(DeckViewCard *_item,
@ -383,24 +381,15 @@ void DeckViewScene::rebuildTree()
} }
// Cards in custom zones nested under a board are regular board cards in-game. // Cards in custom zones nested under a board are regular board cards in-game.
// They are collected recursively and reported with the top-level board zone // They are collected recursively (like every other consumer) and reported with
// as their origin, so that sideboard plans keep working. // the top-level board zone as their origin, so that sideboard plans keep working.
std::function<void(const InnerDecklistNode *)> addZoneCards = [&addZoneCards, container, currentZone, for (auto *currentCard : deck->getCardNodes({currentZone->getName()})) {
this](const InnerDecklistNode *zone) { for (int k = 0; k < currentCard->getNumber(); ++k) {
for (int j = 0; j < zone->size(); j++) { auto *newCard = new DeckViewCard(container, currentCard->toCardRef(), currentZone->getName());
auto *currentCard = dynamic_cast<DecklistCardNode *>(zone->at(j)); container->addCard(newCard);
if (currentCard) { emit newCardAdded(newCard);
for (int k = 0; k < currentCard->getNumber(); ++k) {
auto *newCard = new DeckViewCard(container, currentCard->toCardRef(), currentZone->getName());
container->addCard(newCard);
emit newCardAdded(newCard);
}
} else if (auto *innerZone = dynamic_cast<InnerDecklistNode *>(zone->at(j))) {
addZoneCards(innerZone);
}
} }
}; }
addZoneCards(currentZone);
} }
} }