mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-26 08:33:54 -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);
|
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
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue