mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-09 01:23:57 -07:00
Use getCards()
Took 4 minutes
This commit is contained in:
parent
2c4920560c
commit
07a67e5854
1 changed files with 61 additions and 69 deletions
|
|
@ -19,90 +19,82 @@ void DeckListStatisticsAnalyzer::analyze()
|
|||
{
|
||||
clearData();
|
||||
|
||||
auto nodes = model->getDeckList()->getCardNodes();
|
||||
QList<ExactCard> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue