mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-16 07:22:16 -07:00
Change deck analytics bars to be more meaningful by using the highest value instead of the total sum as the ceiling.
This commit is contained in:
parent
ed0f09b7fd
commit
8a47412db2
3 changed files with 24 additions and 11 deletions
|
|
@ -50,9 +50,11 @@ void ManaBaseWidget::updateDisplay()
|
|||
delete item;
|
||||
}
|
||||
|
||||
int totalSum = 0;
|
||||
int highestEntry = 0;
|
||||
for (auto entry : manaBaseMap) {
|
||||
totalSum += entry;
|
||||
if (entry > highestEntry) {
|
||||
highestEntry = entry;
|
||||
}
|
||||
}
|
||||
|
||||
// Define color mapping for mana types
|
||||
|
|
@ -66,7 +68,7 @@ void ManaBaseWidget::updateDisplay()
|
|||
|
||||
for (auto manaColor : manaBaseMap.keys()) {
|
||||
QColor barColor = manaColors.contains(manaColor) ? manaColors[manaColor] : Qt::gray;
|
||||
BarWidget *barWidget = new BarWidget(QString(manaColor), manaBaseMap[manaColor], totalSum, barColor, this);
|
||||
BarWidget *barWidget = new BarWidget(QString(manaColor), manaBaseMap[manaColor], highestEntry, barColor, this);
|
||||
barLayout->addWidget(barWidget);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,9 +77,11 @@ void ManaCurveWidget::updateDisplay()
|
|||
}
|
||||
}
|
||||
|
||||
int totalSum = 0;
|
||||
int highestEntry = 0;
|
||||
for (const auto &entry : manaCurveMap) {
|
||||
totalSum += entry.second;
|
||||
if (entry.second > highestEntry) {
|
||||
highestEntry = entry.second;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert unordered_map to ordered map to ensure sorting by CMC
|
||||
|
|
@ -88,7 +90,7 @@ void ManaCurveWidget::updateDisplay()
|
|||
// Add new widgets to the layout in sorted order
|
||||
for (const auto &entry : sortedManaCurve) {
|
||||
BarWidget *barWidget =
|
||||
new BarWidget(QString::number(entry.first), entry.second, totalSum, QColor(11, 11, 11), this);
|
||||
new BarWidget(QString::number(entry.first), entry.second, highestEntry, QColor(11, 11, 11), this);
|
||||
barLayout->addWidget(barWidget);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,9 +77,11 @@ void ManaDevotionWidget::updateDisplay()
|
|||
delete item;
|
||||
}
|
||||
|
||||
int totalSum = 0;
|
||||
int highestEntry = 0;
|
||||
for (auto entry : manaDevotionMap) {
|
||||
totalSum += entry.second;
|
||||
if (highestEntry < entry.second) {
|
||||
highestEntry = entry.second;
|
||||
}
|
||||
}
|
||||
|
||||
// Define color mapping for devotion bars
|
||||
|
|
@ -89,14 +91,13 @@ void ManaDevotionWidget::updateDisplay()
|
|||
|
||||
for (auto entry : manaDevotionMap) {
|
||||
QColor barColor = manaColors.count(entry.first) ? manaColors[entry.first] : Qt::gray;
|
||||
BarWidget *barWidget = new BarWidget(QString(entry.first), entry.second, totalSum, barColor, this);
|
||||
BarWidget *barWidget = new BarWidget(QString(entry.first), entry.second, highestEntry, barColor, this);
|
||||
barLayout->addWidget(barWidget);
|
||||
}
|
||||
|
||||
update(); // Update the widget display
|
||||
}
|
||||
|
||||
// Function to count mana symbols W, U, B, R, G in the input string
|
||||
std::unordered_map<char, int> ManaDevotionWidget::countManaSymbols(const QString &manaString)
|
||||
{
|
||||
std::unordered_map<char, int> manaCounts = {{'W', 0}, {'U', 0}, {'B', 0}, {'R', 0}, {'G', 0}};
|
||||
|
|
@ -114,15 +115,23 @@ std::unordered_map<char, int> ManaDevotionWidget::countManaSymbols(const QString
|
|||
char mana2 = manaString[i].toLatin1();
|
||||
manaCounts[mana1]++;
|
||||
manaCounts[mana2]++;
|
||||
} else {
|
||||
// Handle cases like "{W/}" where second part is invalid
|
||||
manaCounts[mana1]++;
|
||||
}
|
||||
} else {
|
||||
manaCounts[mana1]++;
|
||||
}
|
||||
}
|
||||
// Ensure we always skip to the closing '}'
|
||||
while (i < len && manaString[i] != '}') {
|
||||
++i; // Skip to closing '}'
|
||||
++i;
|
||||
}
|
||||
}
|
||||
// Check if the character is a standalone mana symbol (not inside {})
|
||||
else if (manaCounts.find(manaString[i].toLatin1()) != manaCounts.end()) {
|
||||
manaCounts[manaString[i].toLatin1()]++;
|
||||
}
|
||||
}
|
||||
|
||||
return manaCounts;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue