[DeckAnalytics] Enforce WUBRGC ordering for analytics. (#6509)

* [DeckAnalytics] Enforce WUBRGC ordering for analytics.

Took 6 minutes

Took 7 seconds

* Include QSet

Took 51 seconds

* Move include out of namespace.

Took 6 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-01-14 11:25:45 +01:00 committed by GitHub
parent 21d60ec3f1
commit 289b139be9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 87 additions and 57 deletions

View file

@ -8,6 +8,7 @@
#include <QDialog>
#include <QListWidget>
#include <libcockatrice/utility/color.h>
namespace
{
@ -71,14 +72,16 @@ void ManaBaseWidget::updateDisplay()
// Choose display mode
if (config.displayType == "bar") {
QHash<QString, QColor> colors = {{"W", QColor(248, 231, 185)}, {"U", QColor(14, 104, 171)},
{"B", QColor(21, 11, 0)}, {"R", QColor(211, 32, 42)},
{"G", QColor(0, 115, 62)}, {"C", QColor(150, 150, 150)}};
const QList<QPair<QString, int>> sortedColors = GameSpecificColors::MTG::sortManaMapWUBRGCFirst(mapSorted);
static const QHash<QString, QColor> colorMap = {
{"W", QColor(248, 231, 185)}, {"U", QColor(14, 104, 171)}, {"B", QColor(21, 11, 0)},
{"R", QColor(211, 32, 42)}, {"G", QColor(0, 115, 62)}, {"C", QColor(150, 150, 150)},
};
for (auto color : manaMap.keys()) {
QString label = QString("%1 %2 (%3)").arg(color).arg(manaMap[color]).arg(cardCount.value(color));
for (const auto &[color, count] : sortedColors) {
QString label = QString("%1 %2 (%3)").arg(color).arg(count).arg(cardCount.value(color));
BarWidget *bar = new BarWidget(label, manaMap[color], highest, colors.value(color, Qt::gray), this);
BarWidget *bar = new BarWidget(label, count, highest, colorMap.value(color, Qt::gray), this);
barLayout->addWidget(bar);
}