mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
[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:
parent
21d60ec3f1
commit
289b139be9
6 changed files with 87 additions and 57 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue