[DeckAnalytics] Enforce WUBRGC ordering for analytics.

Took 6 minutes

Took 7 seconds
This commit is contained in:
Lukas Brübach 2026-01-11 06:39:22 +01:00
parent 0deaa9d9b4
commit 7ed98c40bb
6 changed files with 84 additions and 57 deletions

View file

@ -56,6 +56,31 @@ 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