mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 09:05:10 -07:00
[Game] Collect deck-view cards via DeckList::getCardNodes
This commit is contained in:
parent
987ebcaa35
commit
f53eecff15
1 changed files with 8 additions and 19 deletions
|
|
@ -8,10 +8,8 @@
|
|||
#include <QMouseEvent>
|
||||
#include <QtMath>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <libcockatrice/card/card_info.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>
|
||||
|
||||
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.
|
||||
// They are collected recursively and reported with the top-level board zone
|
||||
// as their origin, so that sideboard plans keep working.
|
||||
std::function<void(const InnerDecklistNode *)> addZoneCards = [&addZoneCards, container, currentZone,
|
||||
this](const InnerDecklistNode *zone) {
|
||||
for (int j = 0; j < zone->size(); j++) {
|
||||
auto *currentCard = dynamic_cast<DecklistCardNode *>(zone->at(j));
|
||||
if (currentCard) {
|
||||
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);
|
||||
}
|
||||
// They are collected recursively (like every other consumer) and reported with
|
||||
// the top-level board zone as their origin, so that sideboard plans keep working.
|
||||
for (auto *currentCard : deck->getCardNodes({currentZone->getName()})) {
|
||||
for (int k = 0; k < currentCard->getNumber(); ++k) {
|
||||
auto *newCard = new DeckViewCard(container, currentCard->toCardRef(), currentZone->getName());
|
||||
container->addCard(newCard);
|
||||
emit newCardAdded(newCard);
|
||||
}
|
||||
};
|
||||
addZoneCards(currentZone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue