Cockatrice 2026-01-14-Development-2.11.0-beta.46
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
archidekt_formats.h
Go to the documentation of this file.
1#ifndef COCKATRICE_ARCHIDEKT_FORMATS_H
2#define COCKATRICE_ARCHIDEKT_FORMATS_H
3#include <QHash>
4#include <QString>
5
7{
8enum class DeckFormat
9{
11 Modern = 1,
13 Legacy = 3,
15 Pauper = 5,
16 Custom = 6,
22 Brawl = 12,
23
24 // Values outside Archidekt range
25 Alchemy = 1000,
26 Historic = 1001,
27 Gladiator = 1002,
29 OldSchool = 1004,
31 Pioneer = 1006,
32 PreDH = 1007,
33 Premodern = 1008,
35 Timeless = 1010,
36 Unknown = 1011
37};
38
39inline static QString formatToApiName(DeckFormat format)
40{
41 switch (format) {
43 return "Standard";
45 return "Modern";
47 return "Commander";
49 return "Legacy";
51 return "Vintage";
53 return "Pauper";
55 return "Custom";
57 return "Frontier";
59 return "Future Std";
61 return "Penny Dreadful";
63 return "1v1 Commander";
65 return "Dual Commander";
67 return "Brawl";
68
70 return "Alchemy";
72 return "Historic";
74 return "Gladiator";
76 return "Oathbreaker";
78 return "Old School";
80 return "Pauper Commander";
82 return "Pioneer";
84 return "PreDH";
86 return "Premodern";
88 return "Standard Brawl";
90 return "Timeless";
91
92 default:
93 return "Unknown";
94 }
95}
96
97inline static DeckFormat apiNameToFormat(const QString &name)
98{
99 const QString n = name.trimmed();
100
101 if (n.compare("Standard", Qt::CaseInsensitive) == 0)
103 if (n.compare("Modern", Qt::CaseInsensitive) == 0)
104 return DeckFormat::Modern;
105 if (n.compare("Commander", Qt::CaseInsensitive) == 0)
107 if (n.compare("Legacy", Qt::CaseInsensitive) == 0)
108 return DeckFormat::Legacy;
109 if (n.compare("Vintage", Qt::CaseInsensitive) == 0)
110 return DeckFormat::Vintage;
111 if (n.compare("Pauper", Qt::CaseInsensitive) == 0)
112 return DeckFormat::Pauper;
113 if (n.compare("Custom", Qt::CaseInsensitive) == 0)
114 return DeckFormat::Custom;
115 if (n.compare("Frontier", Qt::CaseInsensitive) == 0)
117 if (n.compare("Future Std", Qt::CaseInsensitive) == 0)
119 if (n.compare("Penny Dreadful", Qt::CaseInsensitive) == 0)
121 if (n.compare("1v1 Commander", Qt::CaseInsensitive) == 0)
123 if (n.compare("Dual Commander", Qt::CaseInsensitive) == 0)
125 if (n.compare("Brawl", Qt::CaseInsensitive) == 0)
126 return DeckFormat::Brawl;
127
128 if (n.compare("Alchemy", Qt::CaseInsensitive) == 0)
129 return DeckFormat::Alchemy;
130 if (n.compare("Historic", Qt::CaseInsensitive) == 0)
132 if (n.compare("Gladiator", Qt::CaseInsensitive) == 0)
134 if (n.compare("Oathbreaker", Qt::CaseInsensitive) == 0)
136 if (n.compare("Old School", Qt::CaseInsensitive) == 0)
138 if (n.compare("Pauper Commander", Qt::CaseInsensitive) == 0)
140 if (n.compare("Pioneer", Qt::CaseInsensitive) == 0)
141 return DeckFormat::Pioneer;
142 if (n.compare("PreDH", Qt::CaseInsensitive) == 0)
143 return DeckFormat::PreDH;
144 if (n.compare("Premodern", Qt::CaseInsensitive) == 0)
146 if (n.compare("Standard Brawl", Qt::CaseInsensitive) == 0)
148 if (n.compare("Timeless", Qt::CaseInsensitive) == 0)
150
151 return DeckFormat::Unknown;
152}
153
154inline static QString formatToCockatriceName(DeckFormat format)
155{
156 switch (format) {
158 return "standard";
160 return "modern";
162 return "commander";
164 return "legacy";
166 return "vintage";
168 return "pauper";
170 return "brawl";
172 return "penny";
174 return "future";
176 return "duel";
178 return "duel";
180 return "alchemy";
182 return "historic";
184 return "gladiator";
186 return "oathbreaker";
188 return "oldschool";
190 return "paupercommander";
192 return "pioneer";
194 return "predh";
196 return "premodern";
198 return "standardbrawl";
200 return "timeless";
201
202 default:
203 return {};
204 }
205}
206
207inline static DeckFormat cockatriceNameToFormat(const QString &apiName)
208{
209 static const QHash<QString, DeckFormat> map = {
210 {"standard", DeckFormat::Standard}, {"modern", DeckFormat::Modern},
211 {"commander", DeckFormat::Commander}, {"legacy", DeckFormat::Legacy},
212 {"vintage", DeckFormat::Vintage}, {"pauper", DeckFormat::Pauper},
213 {"brawl", DeckFormat::Brawl}, {"penny", DeckFormat::PennyDreadful},
215 {"alchemy", DeckFormat::Alchemy}, {"historic", DeckFormat::Historic},
216 {"gladiator", DeckFormat::Gladiator}, {"oathbreaker", DeckFormat::Oathbreaker},
217 {"oldschool", DeckFormat::OldSchool}, {"paupercommander", DeckFormat::PauperCommander},
218 {"pioneer", DeckFormat::Pioneer}, {"predh", DeckFormat::PreDH},
219 {"premodern", DeckFormat::Premodern}, {"standardbrawl", DeckFormat::StandardBrawl},
220 {"timeless", DeckFormat::Timeless}};
221
222 return map.value(apiName.toLower(), DeckFormat::Unknown);
223}
224
225} // namespace ArchidektFormats
226
227#endif // COCKATRICE_ARCHIDEKT_FORMATS_H
Definition archidekt_formats.h:7
static DeckFormat cockatriceNameToFormat(const QString &apiName)
Definition archidekt_formats.h:207
static QString formatToApiName(DeckFormat format)
Definition archidekt_formats.h:39
static DeckFormat apiNameToFormat(const QString &name)
Definition archidekt_formats.h:97
DeckFormat
Definition archidekt_formats.h:9
@ Legacy
Definition archidekt_formats.h:13
@ Frontier
Definition archidekt_formats.h:17
@ Premodern
Definition archidekt_formats.h:33
@ OldSchool
Definition archidekt_formats.h:29
@ Oathbreaker
Definition archidekt_formats.h:28
@ PennyDreadful
Definition archidekt_formats.h:19
@ Vintage
Definition archidekt_formats.h:14
@ StandardBrawl
Definition archidekt_formats.h:34
@ FutureStandard
Definition archidekt_formats.h:18
@ DualCommander
Definition archidekt_formats.h:21
@ Alchemy
Definition archidekt_formats.h:25
@ Unknown
Definition archidekt_formats.h:36
@ PauperCommander
Definition archidekt_formats.h:30
@ Custom
Definition archidekt_formats.h:16
@ Timeless
Definition archidekt_formats.h:35
@ Modern
Definition archidekt_formats.h:11
@ Pauper
Definition archidekt_formats.h:15
@ Historic
Definition archidekt_formats.h:26
@ PreDH
Definition archidekt_formats.h:32
@ Commander1v1
Definition archidekt_formats.h:20
@ Commander
Definition archidekt_formats.h:12
@ Standard
Definition archidekt_formats.h:10
@ Pioneer
Definition archidekt_formats.h:31
@ Brawl
Definition archidekt_formats.h:22
@ Gladiator
Definition archidekt_formats.h:27
static QString formatToCockatriceName(DeckFormat format)
Definition archidekt_formats.h:154