[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

@ -22,6 +22,8 @@ inline color convertQColorToColor(const QColor &c)
return result;
}
#include <QSet>
namespace GameSpecificColors
{
namespace MTG
@ -56,6 +58,32 @@ inline QColor colorHelper(const QString &name)
return QColor(r, g, b);
}
inline QList<QPair<QString, int>> sortManaMapWUBRGCFirst(const QMap<QString, int> &input)
{
static const QStringList priorityOrder = {"W", "U", "B", "R", "G", "C"};
QList<QPair<QString, int>> result;
QSet<QString> consumed;
// 1. Add priority colors in fixed order
for (const QString &key : priorityOrder) {
auto it = input.find(key);
if (it != input.end()) {
result.append({it.key(), it.value()});
consumed.insert(it.key());
}
}
// 2. Add remaining keys (QMap iteration is already sorted)
for (auto it = input.begin(); it != input.end(); ++it) {
if (!consumed.contains(it.key())) {
result.append({it.key(), it.value()});
}
}
return result;
}
} // namespace MTG
} // namespace GameSpecificColors
#endif