[DeckList] Add optional restrictToZone param to getZoneNodes (#6534)

This commit is contained in:
RickyRister 2026-01-19 00:27:58 -08:00 committed by GitHub
parent af2995ba96
commit f7e71a0868
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 9 deletions

View file

@ -464,9 +464,9 @@ QList<const DecklistCardNode *> DeckList::getCardNodes(const QSet<QString> &rest
return tree.getCardNodes(restrictToZones);
}
QList<const InnerDecklistNode *> DeckList::getZoneNodes() const
QList<const InnerDecklistNode *> DeckList::getZoneNodes(const QSet<QString> &restrictToZones) const
{
return tree.getZoneNodes();
return tree.getZoneNodes(restrictToZones);
}
int DeckList::getSideboardSize() const

View file

@ -224,7 +224,7 @@ public:
QStringList getCardList(const QSet<QString> &restrictToZones = {}) const;
QList<CardRef> getCardRefList(const QSet<QString> &restrictToZones = {}) const;
QList<const DecklistCardNode *> getCardNodes(const QSet<QString> &restrictToZones = {}) const;
QList<const InnerDecklistNode *> getZoneNodes() const;
QList<const InnerDecklistNode *> getZoneNodes(const QSet<QString> &restrictToZones = {}) const;
int getSideboardSize() const;
DecklistCardNode *addCard(const QString &cardName,

View file

@ -41,10 +41,7 @@ QList<const DecklistCardNode *> DecklistNodeTree::getCardNodes(const QSet<QStrin
{
QList<const DecklistCardNode *> result;
for (auto *zoneNode : getZoneNodes()) {
if (!restrictToZones.isEmpty() && !restrictToZones.contains(zoneNode->getName())) {
continue;
}
for (auto *zoneNode : getZoneNodes(restrictToZones)) {
for (auto *cardNode : *zoneNode) {
auto *cardCardNode = dynamic_cast<DecklistCardNode *>(cardNode);
if (cardCardNode) {
@ -56,13 +53,16 @@ QList<const DecklistCardNode *> DecklistNodeTree::getCardNodes(const QSet<QStrin
return result;
}
QList<const InnerDecklistNode *> DecklistNodeTree::getZoneNodes() const
QList<const InnerDecklistNode *> DecklistNodeTree::getZoneNodes(const QSet<QString> &restrictToZones) const
{
QList<const InnerDecklistNode *> zones;
for (auto *node : *root) {
InnerDecklistNode *currentZone = dynamic_cast<InnerDecklistNode *>(node);
if (!currentZone)
continue;
if (!restrictToZones.isEmpty() && !restrictToZones.contains(currentZone->getName())) {
continue;
}
zones.append(currentZone);
}

View file

@ -45,7 +45,12 @@ public:
*/
QList<const DecklistCardNode *> getCardNodes(const QSet<QString> &restrictToZones = {}) const;
QList<const InnerDecklistNode *> getZoneNodes() const;
/**
* Gets all zone nodes in the tree
* @param restrictToZones If not empty, only get the zone nodes with these names.
* @return A QList containing all the zone nodes in the tree.
*/
QList<const InnerDecklistNode *> getZoneNodes(const QSet<QString> &restrictToZones = {}) const;
/**
* @brief Computes the deck hash