Cockatrice 2026-06-01-Development-3.1.0-beta.3
A 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 }
104 if (n.compare("Modern", Qt::CaseInsensitive) == 0) {
105 return DeckFormat::Modern;
106 }
107 if (n.compare("Commander", Qt::CaseInsensitive) == 0) {
109 }
110 if (n.compare("Legacy", Qt::CaseInsensitive) == 0) {
111 return DeckFormat::Legacy;
112 }
113 if (n.compare("Vintage", Qt::CaseInsensitive) == 0) {
114 return DeckFormat::Vintage;
115 }
116 if (n.compare("Pauper", Qt::CaseInsensitive) == 0) {
117 return DeckFormat::Pauper;
118 }
119 if (n.compare("Custom", Qt::CaseInsensitive) == 0) {
120 return DeckFormat::Custom;
121 }
122 if (n.compare("Frontier", Qt::CaseInsensitive) == 0) {
124 }
125 if (n.compare("Future Std", Qt::CaseInsensitive) == 0) {
127 }
128 if (n.compare("Penny Dreadful", Qt::CaseInsensitive) == 0) {
130 }
131 if (n.compare("1v1 Commander", Qt::CaseInsensitive) == 0) {
133 }
134 if (n.compare("Dual Commander", Qt::CaseInsensitive) == 0) {
136 }
137 if (n.compare("Brawl", Qt::CaseInsensitive) == 0) {
138 return DeckFormat::Brawl;
139 }
140
141 if (n.compare("Alchemy", Qt::CaseInsensitive) == 0) {
142 return DeckFormat::Alchemy;
143 }
144 if (n.compare("Historic", Qt::CaseInsensitive) == 0) {
146 }
147 if (n.compare("Gladiator", Qt::CaseInsensitive) == 0) {
149 }
150 if (n.compare("Oathbreaker", Qt::CaseInsensitive) == 0) {
152 }
153 if (n.compare("Old School", Qt::CaseInsensitive) == 0) {
155 }
156 if (n.compare("Pauper Commander", Qt::CaseInsensitive) == 0) {
158 }
159 if (n.compare("Pioneer", Qt::CaseInsensitive) == 0) {
160 return DeckFormat::Pioneer;
161 }
162 if (n.compare("PreDH", Qt::CaseInsensitive) == 0) {
163 return DeckFormat::PreDH;
164 }
165 if (n.compare("Premodern", Qt::CaseInsensitive) == 0) {
167 }
168 if (n.compare("Standard Brawl", Qt::CaseInsensitive) == 0) {
170 }
171 if (n.compare("Timeless", Qt::CaseInsensitive) == 0) {
173 }
174
175 return DeckFormat::Unknown;
176}
177
178inline static QString formatToCockatriceName(DeckFormat format)
179{
180 switch (format) {
182 return "standard";
184 return "modern";
186 return "commander";
188 return "legacy";
190 return "vintage";
192 return "pauper";
194 return "brawl";
196 return "penny";
198 return "future";
200 return "duel";
202 return "duel";
204 return "alchemy";
206 return "historic";
208 return "gladiator";
210 return "oathbreaker";
212 return "oldschool";
214 return "paupercommander";
216 return "pioneer";
218 return "predh";
220 return "premodern";
222 return "standardbrawl";
224 return "timeless";
225
226 default:
227 return {};
228 }
229}
230
231inline static DeckFormat cockatriceNameToFormat(const QString &apiName)
232{
233 static const QHash<QString, DeckFormat> map = {
234 {"standard", DeckFormat::Standard}, {"modern", DeckFormat::Modern},
235 {"commander", DeckFormat::Commander}, {"legacy", DeckFormat::Legacy},
236 {"vintage", DeckFormat::Vintage}, {"pauper", DeckFormat::Pauper},
237 {"brawl", DeckFormat::Brawl}, {"penny", DeckFormat::PennyDreadful},
239 {"alchemy", DeckFormat::Alchemy}, {"historic", DeckFormat::Historic},
240 {"gladiator", DeckFormat::Gladiator}, {"oathbreaker", DeckFormat::Oathbreaker},
241 {"oldschool", DeckFormat::OldSchool}, {"paupercommander", DeckFormat::PauperCommander},
242 {"pioneer", DeckFormat::Pioneer}, {"predh", DeckFormat::PreDH},
243 {"premodern", DeckFormat::Premodern}, {"standardbrawl", DeckFormat::StandardBrawl},
244 {"timeless", DeckFormat::Timeless}};
245
246 return map.value(apiName.toLower(), DeckFormat::Unknown);
247}
248
249} // namespace ArchidektFormats
250
251#endif // COCKATRICE_ARCHIDEKT_FORMATS_H
Definition archidekt_formats.h:7
static DeckFormat cockatriceNameToFormat(const QString &apiName)
Definition archidekt_formats.h:231
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:178