diff --git a/cockatrice/src/interface/widgets/deck_analytics/deck_list_statistics_analyzer.cpp b/cockatrice/src/interface/widgets/deck_analytics/deck_list_statistics_analyzer.cpp index 017c0b168..c40aa9255 100644 --- a/cockatrice/src/interface/widgets/deck_analytics/deck_list_statistics_analyzer.cpp +++ b/cockatrice/src/interface/widgets/deck_analytics/deck_list_statistics_analyzer.cpp @@ -19,90 +19,82 @@ void DeckListStatisticsAnalyzer::analyze() { clearData(); - auto nodes = model->getDeckList()->getCardNodes(); + QList cards = model->getCards(); - for (auto *node : nodes) { - CardInfoPtr info = CardDatabaseManager::query()->getCardInfo(node->getName()); - if (!info) { - continue; - } - - const int count = node->getNumber(); - const int cmc = info->getCmc().toInt(); + for (auto card : cards) { + auto info = card.getInfo(); + const int cmc = info.getCmc().toInt(); // Convert once - QStringList types = info->getMainCardType().split(' '); - QStringList subtypes = info->getCardType().split('-').last().split(" "); - QString colors = info->getColors(); - int power = info->getPowTough().split("/").first().toInt(); - int toughness = info->getPowTough().split("/").last().toInt(); + QStringList types = info.getMainCardType().split(' '); + QStringList subtypes = info.getCardType().split('-').last().split(" "); + QString colors = info.getColors(); + int power = info.getPowTough().split("/").first().toInt(); + int toughness = info.getPowTough().split("/").last().toInt(); // For each copy of card - for (int i = 0; i < count; ++i) { + // ---------------- Mana Curve ---------------- + if (config.computeManaCurve) { + manaCurveMap[cmc]++; + } - // ---------------- Mana Curve ---------------- - if (config.computeManaCurve) { - manaCurveMap[cmc]++; - } + // per-type curve + for (auto &t : types) { + manaCurveByType[t][cmc]++; + manaCurveCardsByType[t][cmc].append(info->getName()); + } - // per-type curve - for (auto &t : types) { - manaCurveByType[t][cmc]++; - manaCurveCardsByType[t][cmc].append(info->getName()); - } + // Per-subtype curve + for (auto &st : subtypes) { + manaCurveBySubtype[st][cmc]++; + manaCurveCardsBySubtype[st][cmc].append(info->getName()); + } - // Per-subtype curve - for (auto &st : subtypes) { - manaCurveBySubtype[st][cmc]++; - manaCurveCardsBySubtype[st][cmc].append(info->getName()); - } + // per-color curve + for (auto &c : colors) { + manaCurveByColor[c][cmc]++; + manaCurveCardsByColor[c][cmc].append(info->getName()); + } - // per-color curve - for (auto &c : colors) { - manaCurveByColor[c][cmc]++; - manaCurveCardsByColor[c][cmc].append(info->getName()); - } + // Power/toughness + manaCurveByPower[QString::number(power)][cmc]++; + manaCurveCardsByPower[QString::number(power)][cmc].append(info->getName()); + manaCurveByToughness[QString::number(toughness)][cmc]++; + manaCurveCardsByToughness[QString::number(toughness)][cmc].append(info->getName()); - // Power/toughness - manaCurveByPower[QString::number(power)][cmc]++; - manaCurveCardsByPower[QString::number(power)][cmc].append(info->getName()); - manaCurveByToughness[QString::number(toughness)][cmc]++; - manaCurveCardsByToughness[QString::number(toughness)][cmc].append(info->getName()); + // ========== Category Counts =========== + for (auto &t : types) { + typeCount[t]++; + } + for (auto &st : subtypes) { + subtypeCount[st]++; + } + for (auto &c : colors) { + colorCount[c]++; + } + manaValueCount[cmc]++; - // ========== Category Counts =========== - for (auto &t : types) { - typeCount[t]++; - } - for (auto &st : subtypes) { - subtypeCount[st]++; - } - for (auto &c : colors) { - colorCount[c]++; - } - manaValueCount[cmc]++; - - // ---------------- Mana Base ---------------- - if (config.computeManaBase) { - auto prod = determineManaProduction(info->getText()); - for (auto it = prod.begin(); it != prod.end(); ++it) { - if (it.value() > 0) { - productionPipCount[it.key()] += it.value(); - productionCardCount[it.key()]++; - } - manaBaseMap[it.key()] += it.value(); + // ---------------- Mana Base ---------------- + if (config.computeManaBase) { + auto prod = determineManaProduction(info->getText()); + for (auto it = prod.begin(); it != prod.end(); ++it) { + if (it.value() > 0) { + productionPipCount[it.key()] += it.value(); + productionCardCount[it.key()]++; } + manaBaseMap[it.key()] += it.value(); } + } - // ---------------- Devotion ---------------- - if (config.computeDevotion) { - auto devo = countManaSymbols(info->getManaCost()); - for (auto &d : devo) { - if (d.second > 0) { - devotionPipCount[QString(d.first)] += d.second; - devotionCardCount[QString(d.first)]++; - } - manaDevotionMap[d.first] += d.second; + // ---------------- Devotion ---------------- + if (config.computeDevotion) { + auto devo = countManaSymbols(info->getManaCost()); + for (auto &d : devo) { + if (d.second > 0) { + devotionPipCount[QString(d.first)] += d.second; + devotionCardCount[QString(d.first)]++; } + manaDevotionMap[d.first] += d.second; } } }