8#include <libcockatrice/protocol/pb/color.pb.h>
11inline QColor convertColorToQColor(
const color &c)
13 return QColor(c.r(), c.g(), c.b());
16inline color convertQColorToColor(
const QColor &c)
19 result.set_r(c.red());
20 result.set_g(c.green());
21 result.set_b(c.blue());
27namespace GameSpecificColors
31inline QColor colorHelper(
const QString &name)
33 static const QMap<QString, QColor> colorMap = {
34 {
"W", QColor(245, 245, 220)},
35 {
"U", QColor(80, 140, 255)},
36 {
"B", QColor(60, 60, 60)},
37 {
"R", QColor(220, 60, 50)},
38 {
"G", QColor(70, 160, 70)},
39 {
"Creature", QColor(70, 130, 180)},
40 {
"Instant", QColor(138, 43, 226)},
41 {
"Sorcery", QColor(199, 21, 133)},
42 {
"Enchantment", QColor(218, 165, 32)},
43 {
"Artifact", QColor(169, 169, 169)},
44 {
"Planeswalker", QColor(210, 105, 30)},
45 {
"Land", QColor(110, 80, 50)},
48 if (colorMap.contains(name))
49 return colorMap[name];
51 if (name.length() == 1 && colorMap.contains(name.toUpper()))
52 return colorMap[name.toUpper()];
55 int r = 100 + (h % 120);
56 int g = 100 + ((h >> 8) % 120);
57 int b = 100 + ((h >> 16) % 120);
59 return QColor(r, g, b);
62inline QList<QPair<QString, int>> sortManaMapWUBRGCFirst(
const QMap<QString, int> &input)
64 static const QStringList priorityOrder = {
"W",
"U",
"B",
"R",
"G",
"C"};
66 QList<QPair<QString, int>> result;
67 QSet<QString> consumed;
70 for (
const QString &key : priorityOrder) {
71 auto it = input.find(key);
72 if (it != input.end()) {
73 result.append({it.key(), it.value()});
74 consumed.insert(it.key());
79 for (
auto it = input.begin(); it != input.end(); ++it) {
80 if (!consumed.contains(it.key())) {
81 result.append({it.key(), it.value()});
color makeColor(int r, int g, int b)
Definition color.h:91
uint qHash(const QRegularExpression &key, uint seed) noexcept
Definition deck_list.cpp:18