mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-27 00:53:55 -07:00
Helper to query deckList for DecklistCardNodes. (#6242)
* Helper to query deckList for DecklistCardNodes. Took 30 minutes Took 6 minutes Took 2 minutes * Fix unused. Took 3 minutes Took 1 minute * Convert string to string list. Took 2 minutes * Adjust to rebase. Took 2 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
f62e29f5d5
commit
ace4063371
11 changed files with 117 additions and 194 deletions
|
|
@ -266,35 +266,16 @@ int CardAmountWidget::countCardsInZone(const QString &deckZone)
|
|||
return -1;
|
||||
}
|
||||
|
||||
InnerDecklistNode *listRoot = decklist->getRoot();
|
||||
if (!listRoot) {
|
||||
return -1;
|
||||
}
|
||||
QList<DecklistCardNode *> cardsInDeck = decklist->getCardNodes({deckZone});
|
||||
|
||||
int count = 0;
|
||||
|
||||
for (auto *i : *listRoot) {
|
||||
auto *countCurrentZone = dynamic_cast<InnerDecklistNode *>(i);
|
||||
if (!countCurrentZone) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (countCurrentZone->getName() != deckZone) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (auto *cardNode : *countCurrentZone) {
|
||||
auto *currentCard = dynamic_cast<DecklistCardNode *>(cardNode);
|
||||
if (!currentCard) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int k = 0; k < currentCard->getNumber(); ++k) {
|
||||
if (currentCard->getCardProviderId() == rootCard.getPrinting().getProperty("uuid")) {
|
||||
count++;
|
||||
}
|
||||
for (auto currentCard : cardsInDeck) {
|
||||
for (int k = 0; k < currentCard->getNumber(); ++k) {
|
||||
if (currentCard->getCardProviderId() == rootCard.getPrinting().getProperty("uuid")) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue