[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); 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 int DeckList::getSideboardSize() const

View file

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

View file

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

View file

@ -45,7 +45,12 @@ public:
*/ */
QList<const DecklistCardNode *> getCardNodes(const QSet<QString> &restrictToZones = {}) const; 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 * @brief Computes the deck hash