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());
28namespace GameSpecificColors
32inline QColor colorHelper(
const QString &name)
34 static const QMap<QString, QColor> colorMap = {
35 {
"W", QColor(245, 245, 220)},
36 {
"U", QColor(80, 140, 255)},
37 {
"B", QColor(60, 60, 60)},
38 {
"R", QColor(220, 60, 50)},
39 {
"G", QColor(70, 160, 70)},
40 {
"Creature", QColor(70, 130, 180)},
41 {
"Instant", QColor(138, 43, 226)},
42 {
"Sorcery", QColor(199, 21, 133)},
43 {
"Enchantment", QColor(218, 165, 32)},
44 {
"Artifact", QColor(169, 169, 169)},
45 {
"Planeswalker", QColor(210, 105, 30)},
46 {
"Land", QColor(110, 80, 50)},
49 if (colorMap.contains(name)) {
50 return colorMap[name];
53 if (name.length() == 1 && colorMap.contains(name.toUpper())) {
54 return colorMap[name.toUpper()];
58 int r = 100 + (h % 120);
59 int g = 100 + ((h >> 8) % 120);
60 int b = 100 + ((h >> 16) % 120);
62 return QColor(r, g, b);
65inline QList<QPair<QString, int>> sortManaMapWUBRGCFirst(
const QMap<QString, int> &input)
67 static const QStringList priorityOrder = {
"W",
"U",
"B",
"R",
"G",
"C"};
69 QList<QPair<QString, int>> result;
70 QSet<QString> consumed;
73 for (
const QString &key : priorityOrder) {
74 auto it = input.find(key);
75 if (it != input.end()) {
76 result.append({it.key(), it.value()});
77 consumed.insert(it.key());
82 for (
auto it = input.begin(); it != input.end(); ++it) {
83 if (!consumed.contains(it.key())) {
84 result.append({it.key(), it.value()});
color makeColor(int r, int g, int b)
Definition color.h:94
uint qHash(const QRegularExpression &key, uint seed) noexcept
Definition deck_list.cpp:18