[DeckListModel] Refactor: Don't access underlying decklist for iteration (#6427)

* [DeckListModel] Refactor: Don't access underlying decklist for iteration

* add docs

* extract method
This commit is contained in:
RickyRister 2025-12-20 04:25:30 -08:00 committed by GitHub
parent 715ee1d6fe
commit 367507e054
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 73 additions and 100 deletions

View file

@ -21,32 +21,26 @@ void DeckListStatisticsAnalyzer::update()
manaCurveMap.clear();
manaDevotionMap.clear();
auto nodes = model->getDeckList()->getCardNodes();
QList<ExactCard> cards = model->getCards();
for (auto *node : nodes) {
CardInfoPtr info = CardDatabaseManager::query()->getCardInfo(node->getName());
if (!info)
continue;
for (const ExactCard &card : cards) {
// ---- Mana curve ----
if (config.computeManaCurve) {
manaCurveMap[card.getInfo().getCmc().toInt()]++;
}
for (int i = 0; i < node->getNumber(); ++i) {
// ---- Mana curve ----
if (config.computeManaCurve) {
manaCurveMap[info->getCmc().toInt()]++;
}
// ---- Mana base ----
if (config.computeManaBase) {
auto mana = determineManaProduction(card.getInfo().getText());
for (auto it = mana.begin(); it != mana.end(); ++it)
manaBaseMap[it.key()] += it.value();
}
// ---- Mana base ----
if (config.computeManaBase) {
auto mana = determineManaProduction(info->getText());
for (auto it = mana.begin(); it != mana.end(); ++it)
manaBaseMap[it.key()] += it.value();
}
// ---- Devotion ----
if (config.computeDevotion) {
auto devo = countManaSymbols(info->getManaCost());
for (auto &d : devo)
manaDevotionMap[d.first] += d.second;
}
// ---- Devotion ----
if (config.computeDevotion) {
auto devo = countManaSymbols(card.getInfo().getManaCost());
for (auto &d : devo)
manaDevotionMap[d.first] += d.second;
}
}