mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
[DeckList] Add optional restrictToZone param to getZoneNodes (#6534)
This commit is contained in:
parent
af2995ba96
commit
f7e71a0868
4 changed files with 14 additions and 9 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue