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();
|
clearData();
|
||||||
|
|
||||||
auto nodes = model->getDeckList()->getCardNodes();
|
QList<ExactCard> cards = model->getCards();
|
||||||
|
|
||||||
for (auto *node : nodes) {
|
for (auto card : cards) {
|
||||||
CardInfoPtr info = CardDatabaseManager::query()->getCardInfo(node->getName());
|
auto info = card.getInfo();
|
||||||
if (!info) {
|
const int cmc = info.getCmc().toInt();
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int count = node->getNumber();
|
|
||||||
const int cmc = info->getCmc().toInt();
|
|
||||||
|
|
||||||
// Convert once
|
// Convert once
|
||||||
QStringList types = info->getMainCardType().split(' ');
|
QStringList types = info.getMainCardType().split(' ');
|
||||||
QStringList subtypes = info->getCardType().split('-').last().split(" ");
|
QStringList subtypes = info.getCardType().split('-').last().split(" ");
|
||||||
QString colors = info->getColors();
|
QString colors = info.getColors();
|
||||||
int power = info->getPowTough().split("/").first().toInt();
|
int power = info.getPowTough().split("/").first().toInt();
|
||||||
int toughness = info->getPowTough().split("/").last().toInt();
|
int toughness = info.getPowTough().split("/").last().toInt();
|
||||||
|
|
||||||
// For each copy of card
|
// For each copy of card
|
||||||
for (int i = 0; i < count; ++i) {
|
// ---------------- Mana Curve ----------------
|
||||||
|
if (config.computeManaCurve) {
|
||||||
|
manaCurveMap[cmc]++;
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------- Mana Curve ----------------
|
// per-type curve
|
||||||
if (config.computeManaCurve) {
|
for (auto &t : types) {
|
||||||
manaCurveMap[cmc]++;
|
manaCurveByType[t][cmc]++;
|
||||||
}
|
manaCurveCardsByType[t][cmc].append(info->getName());
|
||||||
|
}
|
||||||
|
|
||||||
// per-type curve
|
// Per-subtype curve
|
||||||
for (auto &t : types) {
|
for (auto &st : subtypes) {
|
||||||
manaCurveByType[t][cmc]++;
|
manaCurveBySubtype[st][cmc]++;
|
||||||
manaCurveCardsByType[t][cmc].append(info->getName());
|
manaCurveCardsBySubtype[st][cmc].append(info->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Per-subtype curve
|
// per-color curve
|
||||||
for (auto &st : subtypes) {
|
for (auto &c : colors) {
|
||||||
manaCurveBySubtype[st][cmc]++;
|
manaCurveByColor[c][cmc]++;
|
||||||
manaCurveCardsBySubtype[st][cmc].append(info->getName());
|
manaCurveCardsByColor[c][cmc].append(info->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// per-color curve
|
// Power/toughness
|
||||||
for (auto &c : colors) {
|
manaCurveByPower[QString::number(power)][cmc]++;
|
||||||
manaCurveByColor[c][cmc]++;
|
manaCurveCardsByPower[QString::number(power)][cmc].append(info->getName());
|
||||||
manaCurveCardsByColor[c][cmc].append(info->getName());
|
manaCurveByToughness[QString::number(toughness)][cmc]++;
|
||||||
}
|
manaCurveCardsByToughness[QString::number(toughness)][cmc].append(info->getName());
|
||||||
|
|
||||||
// Power/toughness
|
// ========== Category Counts ===========
|
||||||
manaCurveByPower[QString::number(power)][cmc]++;
|
for (auto &t : types) {
|
||||||
manaCurveCardsByPower[QString::number(power)][cmc].append(info->getName());
|
typeCount[t]++;
|
||||||
manaCurveByToughness[QString::number(toughness)][cmc]++;
|
}
|
||||||
manaCurveCardsByToughness[QString::number(toughness)][cmc].append(info->getName());
|
for (auto &st : subtypes) {
|
||||||
|
subtypeCount[st]++;
|
||||||
|
}
|
||||||
|
for (auto &c : colors) {
|
||||||
|
colorCount[c]++;
|
||||||
|
}
|
||||||
|
manaValueCount[cmc]++;
|
||||||
|
|
||||||
// ========== Category Counts ===========
|
// ---------------- Mana Base ----------------
|
||||||
for (auto &t : types) {
|
if (config.computeManaBase) {
|
||||||
typeCount[t]++;
|
auto prod = determineManaProduction(info->getText());
|
||||||
}
|
for (auto it = prod.begin(); it != prod.end(); ++it) {
|
||||||
for (auto &st : subtypes) {
|
if (it.value() > 0) {
|
||||||
subtypeCount[st]++;
|
productionPipCount[it.key()] += it.value();
|
||||||
}
|
productionCardCount[it.key()]++;
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
manaBaseMap[it.key()] += it.value();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------- Devotion ----------------
|
// ---------------- Devotion ----------------
|
||||||
if (config.computeDevotion) {
|
if (config.computeDevotion) {
|
||||||
auto devo = countManaSymbols(info->getManaCost());
|
auto devo = countManaSymbols(info->getManaCost());
|
||||||
for (auto &d : devo) {
|
for (auto &d : devo) {
|
||||||
if (d.second > 0) {
|
if (d.second > 0) {
|
||||||
devotionPipCount[QString(d.first)] += d.second;
|
devotionPipCount[QString(d.first)] += d.second;
|
||||||
devotionCardCount[QString(d.first)]++;
|
devotionCardCount[QString(d.first)]++;
|
||||||
}
|
|
||||||
manaDevotionMap[d.first] += d.second;
|
|
||||||
}
|
}
|
||||||
|
manaDevotionMap[d.first] += d.second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue