mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-23 23:23:55 -07:00
[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:
parent
715ee1d6fe
commit
367507e054
7 changed files with 73 additions and 100 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue