From 5306d9b7cde69e8b39f0b8aaf30c1f4918356ee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Tue, 16 Dec 2025 13:10:18 +0100 Subject: [PATCH] Move formats to file. Took 9 minutes Took 4 seconds --- cockatrice/CMakeLists.txt | 1 + .../api_response/archidekt_formats.h | 227 ++++++++++++++++++ .../deck/archidekt_api_response_deck.h | 222 ----------------- ...idekt_api_response_deck_display_widget.cpp | 1 + 4 files changed, 229 insertions(+), 222 deletions(-) create mode 100644 cockatrice/src/interface/widgets/tabs/api/archidekt/api_response/archidekt_formats.h diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index c9fa80e6b..4c3679011 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -230,6 +230,7 @@ set(cockatrice_SOURCES src/interface/widgets/tabs/abstract_tab_deck_editor.cpp src/interface/widgets/tabs/api/archidekt/tab_archidekt.cpp src/interface/widgets/tabs/api/archidekt/api_response/archidekt_deck_listing_api_response.cpp + src/interface/widgets/tabs/api/archidekt/api_response/archidekt_formats.h src/interface/widgets/tabs/api/archidekt/api_response/card/archidekt_api_response_card.cpp src/interface/widgets/tabs/api/archidekt/api_response/card/archidekt_api_response_card_entry.cpp src/interface/widgets/tabs/api/archidekt/api_response/card/archidekt_api_response_edition.cpp diff --git a/cockatrice/src/interface/widgets/tabs/api/archidekt/api_response/archidekt_formats.h b/cockatrice/src/interface/widgets/tabs/api/archidekt/api_response/archidekt_formats.h new file mode 100644 index 000000000..ac1b66e14 --- /dev/null +++ b/cockatrice/src/interface/widgets/tabs/api/archidekt/api_response/archidekt_formats.h @@ -0,0 +1,227 @@ +#ifndef COCKATRICE_ARCHIDEKT_FORMATS_H +#define COCKATRICE_ARCHIDEKT_FORMATS_H +#include +#include + +namespace ArchidektFormats +{ +enum class DeckFormat +{ + Standard = 0, + Modern = 1, + Commander = 2, + Legacy = 3, + Vintage = 4, + Pauper = 5, + Custom = 6, + Frontier = 7, + FutureStandard = 8, + PennyDreadful = 9, + Commander1v1 = 10, + DualCommander = 11, + Brawl = 12, + + // Values outside Archidekt range + Alchemy = 1000, + Historic = 1001, + Gladiator = 1002, + Oathbreaker = 1003, + OldSchool = 1004, + PauperCommander = 1005, + Pioneer = 1006, + PreDH = 1007, + Premodern = 1008, + StandardBrawl = 1009, + Timeless = 1010, + Unknown = 1011 +}; + +inline static QString formatToApiName(DeckFormat format) +{ + switch (format) { + case DeckFormat::Standard: + return "Standard"; + case DeckFormat::Modern: + return "Modern"; + case DeckFormat::Commander: + return "Commander"; + case DeckFormat::Legacy: + return "Legacy"; + case DeckFormat::Vintage: + return "Vintage"; + case DeckFormat::Pauper: + return "Pauper"; + case DeckFormat::Custom: + return "Custom"; + case DeckFormat::Frontier: + return "Frontier"; + case DeckFormat::FutureStandard: + return "Future Std"; + case DeckFormat::PennyDreadful: + return "Penny Dreadful"; + case DeckFormat::Commander1v1: + return "1v1 Commander"; + case DeckFormat::DualCommander: + return "Dual Commander"; + case DeckFormat::Brawl: + return "Brawl"; + + case DeckFormat::Alchemy: + return "Alchemy"; + case DeckFormat::Historic: + return "Historic"; + case DeckFormat::Gladiator: + return "Gladiator"; + case DeckFormat::Oathbreaker: + return "Oathbreaker"; + case DeckFormat::OldSchool: + return "Old School"; + case DeckFormat::PauperCommander: + return "Pauper Commander"; + case DeckFormat::Pioneer: + return "Pioneer"; + case DeckFormat::PreDH: + return "PreDH"; + case DeckFormat::Premodern: + return "Premodern"; + case DeckFormat::StandardBrawl: + return "Standard Brawl"; + case DeckFormat::Timeless: + return "Timeless"; + + default: + return "Unknown"; + } +} + +inline static DeckFormat apiNameToFormat(const QString &name) +{ + const QString n = name.trimmed(); + + if (n.compare("Standard", Qt::CaseInsensitive) == 0) + return DeckFormat::Standard; + if (n.compare("Modern", Qt::CaseInsensitive) == 0) + return DeckFormat::Modern; + if (n.compare("Commander", Qt::CaseInsensitive) == 0) + return DeckFormat::Commander; + if (n.compare("Legacy", Qt::CaseInsensitive) == 0) + return DeckFormat::Legacy; + if (n.compare("Vintage", Qt::CaseInsensitive) == 0) + return DeckFormat::Vintage; + if (n.compare("Pauper", Qt::CaseInsensitive) == 0) + return DeckFormat::Pauper; + if (n.compare("Custom", Qt::CaseInsensitive) == 0) + return DeckFormat::Custom; + if (n.compare("Frontier", Qt::CaseInsensitive) == 0) + return DeckFormat::Frontier; + if (n.compare("Future Std", Qt::CaseInsensitive) == 0) + return DeckFormat::FutureStandard; + if (n.compare("Penny Dreadful", Qt::CaseInsensitive) == 0) + return DeckFormat::PennyDreadful; + if (n.compare("1v1 Commander", Qt::CaseInsensitive) == 0) + return DeckFormat::Commander1v1; + if (n.compare("Dual Commander", Qt::CaseInsensitive) == 0) + return DeckFormat::DualCommander; + if (n.compare("Brawl", Qt::CaseInsensitive) == 0) + return DeckFormat::Brawl; + + if (n.compare("Alchemy", Qt::CaseInsensitive) == 0) + return DeckFormat::Alchemy; + if (n.compare("Historic", Qt::CaseInsensitive) == 0) + return DeckFormat::Historic; + if (n.compare("Gladiator", Qt::CaseInsensitive) == 0) + return DeckFormat::Gladiator; + if (n.compare("Oathbreaker", Qt::CaseInsensitive) == 0) + return DeckFormat::Oathbreaker; + if (n.compare("Old School", Qt::CaseInsensitive) == 0) + return DeckFormat::OldSchool; + if (n.compare("Pauper Commander", Qt::CaseInsensitive) == 0) + return DeckFormat::PauperCommander; + if (n.compare("Pioneer", Qt::CaseInsensitive) == 0) + return DeckFormat::Pioneer; + if (n.compare("PreDH", Qt::CaseInsensitive) == 0) + return DeckFormat::PreDH; + if (n.compare("Premodern", Qt::CaseInsensitive) == 0) + return DeckFormat::Premodern; + if (n.compare("Standard Brawl", Qt::CaseInsensitive) == 0) + return DeckFormat::StandardBrawl; + if (n.compare("Timeless", Qt::CaseInsensitive) == 0) + return DeckFormat::Timeless; + + return DeckFormat::Unknown; +} + +inline static QString formatToCockatriceName(DeckFormat format) +{ + switch (format) { + case DeckFormat::Standard: + return "standard"; + case DeckFormat::Modern: + return "modern"; + case DeckFormat::Commander: + return "commander"; + case DeckFormat::Legacy: + return "legacy"; + case DeckFormat::Vintage: + return "vintage"; + case DeckFormat::Pauper: + return "pauper"; + case DeckFormat::Brawl: + return "brawl"; + case DeckFormat::PennyDreadful: + return "penny"; + case DeckFormat::FutureStandard: + return "future"; + case DeckFormat::Commander1v1: + return "duel"; + case DeckFormat::DualCommander: + return "duel"; + case DeckFormat::Alchemy: + return "alchemy"; + case DeckFormat::Historic: + return "historic"; + case DeckFormat::Gladiator: + return "gladiator"; + case DeckFormat::Oathbreaker: + return "oathbreaker"; + case DeckFormat::OldSchool: + return "oldschool"; + case DeckFormat::PauperCommander: + return "paupercommander"; + case DeckFormat::Pioneer: + return "pioneer"; + case DeckFormat::PreDH: + return "predh"; + case DeckFormat::Premodern: + return "premodern"; + case DeckFormat::StandardBrawl: + return "standardbrawl"; + case DeckFormat::Timeless: + return "timeless"; + + default: + return {}; + } +} + +inline static DeckFormat cockatriceNameToFormat(const QString &apiName) +{ + static const QHash map = { + {"standard", DeckFormat::Standard}, {"modern", DeckFormat::Modern}, + {"commander", DeckFormat::Commander}, {"legacy", DeckFormat::Legacy}, + {"vintage", DeckFormat::Vintage}, {"pauper", DeckFormat::Pauper}, + {"brawl", DeckFormat::Brawl}, {"penny", DeckFormat::PennyDreadful}, + {"future", DeckFormat::FutureStandard}, {"duel", DeckFormat::Commander1v1}, + {"alchemy", DeckFormat::Alchemy}, {"historic", DeckFormat::Historic}, + {"gladiator", DeckFormat::Gladiator}, {"oathbreaker", DeckFormat::Oathbreaker}, + {"oldschool", DeckFormat::OldSchool}, {"paupercommander", DeckFormat::PauperCommander}, + {"pioneer", DeckFormat::Pioneer}, {"predh", DeckFormat::PreDH}, + {"premodern", DeckFormat::Premodern}, {"standardbrawl", DeckFormat::StandardBrawl}, + {"timeless", DeckFormat::Timeless}}; + + return map.value(apiName.toLower(), DeckFormat::Unknown); +} + +} // namespace ArchidektFormats + +#endif // COCKATRICE_ARCHIDEKT_FORMATS_H diff --git a/cockatrice/src/interface/widgets/tabs/api/archidekt/api_response/deck/archidekt_api_response_deck.h b/cockatrice/src/interface/widgets/tabs/api/archidekt/api_response/deck/archidekt_api_response_deck.h index 906e66727..fce437751 100644 --- a/cockatrice/src/interface/widgets/tabs/api/archidekt/api_response/deck/archidekt_api_response_deck.h +++ b/cockatrice/src/interface/widgets/tabs/api/archidekt/api_response/deck/archidekt_api_response_deck.h @@ -12,228 +12,6 @@ #include #include -namespace ArchidektFormats -{ -enum class DeckFormat -{ - // The order is important since archidekt returns an integer - Standard, - Modern, - Commander, - Legacy, - Vintage, - Pauper, - Custom, - Frontier, - FutureStandard, - PennyDreadful, - Commander1v1, - DualCommander, - Brawl, - - // These are outside of archidekts range. - Alchemy, - Historic, - Gladiator, - Oathbreaker, - OldSchool, - PauperCommander, - Pioneer, - PreDH, - Premodern, - StandardBrawl, - Timeless, - Unknown -}; - -inline static QString formatToApiName(DeckFormat format) -{ - switch (format) { - case DeckFormat::Standard: - return "Standard"; - case DeckFormat::Modern: - return "Modern"; - case DeckFormat::Commander: - return "Commander"; - case DeckFormat::Legacy: - return "Legacy"; - case DeckFormat::Vintage: - return "Vintage"; - case DeckFormat::Pauper: - return "Pauper"; - case DeckFormat::Custom: - return "Custom"; - case DeckFormat::Frontier: - return "Frontier"; - case DeckFormat::FutureStandard: - return "Future Std"; - case DeckFormat::PennyDreadful: - return "Penny Dreadful"; - case DeckFormat::Commander1v1: - return "1v1 Commander"; - case DeckFormat::DualCommander: - return "Dual Commander"; - case DeckFormat::Brawl: - return "Brawl"; - - case DeckFormat::Alchemy: - return "Alchemy"; - case DeckFormat::Historic: - return "Historic"; - case DeckFormat::Gladiator: - return "Gladiator"; - case DeckFormat::Oathbreaker: - return "Oathbreaker"; - case DeckFormat::OldSchool: - return "Old School"; - case DeckFormat::PauperCommander: - return "Pauper Commander"; - case DeckFormat::Pioneer: - return "Pioneer"; - case DeckFormat::PreDH: - return "PreDH"; - case DeckFormat::Premodern: - return "Premodern"; - case DeckFormat::StandardBrawl: - return "Standard Brawl"; - case DeckFormat::Timeless: - return "Timeless"; - - default: - return "Unknown"; - } -} - -inline static DeckFormat apiNameToFormat(const QString &name) -{ - const QString n = name.trimmed(); - - if (n.compare("Standard", Qt::CaseInsensitive) == 0) - return DeckFormat::Standard; - if (n.compare("Modern", Qt::CaseInsensitive) == 0) - return DeckFormat::Modern; - if (n.compare("Commander", Qt::CaseInsensitive) == 0) - return DeckFormat::Commander; - if (n.compare("Legacy", Qt::CaseInsensitive) == 0) - return DeckFormat::Legacy; - if (n.compare("Vintage", Qt::CaseInsensitive) == 0) - return DeckFormat::Vintage; - if (n.compare("Pauper", Qt::CaseInsensitive) == 0) - return DeckFormat::Pauper; - if (n.compare("Custom", Qt::CaseInsensitive) == 0) - return DeckFormat::Custom; - if (n.compare("Frontier", Qt::CaseInsensitive) == 0) - return DeckFormat::Frontier; - if (n.compare("Future Std", Qt::CaseInsensitive) == 0) - return DeckFormat::FutureStandard; - if (n.compare("Penny Dreadful", Qt::CaseInsensitive) == 0) - return DeckFormat::PennyDreadful; - if (n.compare("1v1 Commander", Qt::CaseInsensitive) == 0) - return DeckFormat::Commander1v1; - if (n.compare("Dual Commander", Qt::CaseInsensitive) == 0) - return DeckFormat::DualCommander; - if (n.compare("Brawl", Qt::CaseInsensitive) == 0) - return DeckFormat::Brawl; - - if (n.compare("Alchemy", Qt::CaseInsensitive) == 0) - return DeckFormat::Alchemy; - if (n.compare("Historic", Qt::CaseInsensitive) == 0) - return DeckFormat::Historic; - if (n.compare("Gladiator", Qt::CaseInsensitive) == 0) - return DeckFormat::Gladiator; - if (n.compare("Oathbreaker", Qt::CaseInsensitive) == 0) - return DeckFormat::Oathbreaker; - if (n.compare("Old School", Qt::CaseInsensitive) == 0) - return DeckFormat::OldSchool; - if (n.compare("Pauper Commander", Qt::CaseInsensitive) == 0) - return DeckFormat::PauperCommander; - if (n.compare("Pioneer", Qt::CaseInsensitive) == 0) - return DeckFormat::Pioneer; - if (n.compare("PreDH", Qt::CaseInsensitive) == 0) - return DeckFormat::PreDH; - if (n.compare("Premodern", Qt::CaseInsensitive) == 0) - return DeckFormat::Premodern; - if (n.compare("Standard Brawl", Qt::CaseInsensitive) == 0) - return DeckFormat::StandardBrawl; - if (n.compare("Timeless", Qt::CaseInsensitive) == 0) - return DeckFormat::Timeless; - - return DeckFormat::Unknown; -} - -inline static QString formatToCockatriceName(DeckFormat format) -{ - switch (format) { - case DeckFormat::Standard: - return "standard"; - case DeckFormat::Modern: - return "modern"; - case DeckFormat::Commander: - return "commander"; - case DeckFormat::Legacy: - return "legacy"; - case DeckFormat::Vintage: - return "vintage"; - case DeckFormat::Pauper: - return "pauper"; - case DeckFormat::Brawl: - return "brawl"; - case DeckFormat::PennyDreadful: - return "penny"; - case DeckFormat::FutureStandard: - return "future"; - case DeckFormat::Commander1v1: - return "duel"; - case DeckFormat::DualCommander: - return "duel"; - case DeckFormat::Alchemy: - return "alchemy"; - case DeckFormat::Historic: - return "historic"; - case DeckFormat::Gladiator: - return "gladiator"; - case DeckFormat::Oathbreaker: - return "oathbreaker"; - case DeckFormat::OldSchool: - return "oldschool"; - case DeckFormat::PauperCommander: - return "paupercommander"; - case DeckFormat::Pioneer: - return "pioneer"; - case DeckFormat::PreDH: - return "predh"; - case DeckFormat::Premodern: - return "premodern"; - case DeckFormat::StandardBrawl: - return "standardbrawl"; - case DeckFormat::Timeless: - return "timeless"; - - default: - return {}; - } -} - -inline static DeckFormat cockatriceNameToFormat(const QString &apiName) -{ - static const QHash map = { - {"standard", DeckFormat::Standard}, {"modern", DeckFormat::Modern}, - {"commander", DeckFormat::Commander}, {"legacy", DeckFormat::Legacy}, - {"vintage", DeckFormat::Vintage}, {"pauper", DeckFormat::Pauper}, - {"brawl", DeckFormat::Brawl}, {"penny", DeckFormat::PennyDreadful}, - {"future", DeckFormat::FutureStandard}, {"duel", DeckFormat::Commander1v1}, - {"alchemy", DeckFormat::Alchemy}, {"historic", DeckFormat::Historic}, - {"gladiator", DeckFormat::Gladiator}, {"oathbreaker", DeckFormat::Oathbreaker}, - {"oldschool", DeckFormat::OldSchool}, {"paupercommander", DeckFormat::PauperCommander}, - {"pioneer", DeckFormat::Pioneer}, {"predh", DeckFormat::PreDH}, - {"premodern", DeckFormat::Premodern}, {"standardbrawl", DeckFormat::StandardBrawl}, - {"timeless", DeckFormat::Timeless}}; - - return map.value(apiName.toLower(), DeckFormat::Unknown); -} - -} // namespace ArchidektFormats - class ArchidektApiResponseDeck { public: diff --git a/cockatrice/src/interface/widgets/tabs/api/archidekt/display/archidekt_api_response_deck_display_widget.cpp b/cockatrice/src/interface/widgets/tabs/api/archidekt/display/archidekt_api_response_deck_display_widget.cpp index 6c11216ca..8745ca175 100644 --- a/cockatrice/src/interface/widgets/tabs/api/archidekt/display/archidekt_api_response_deck_display_widget.cpp +++ b/cockatrice/src/interface/widgets/tabs/api/archidekt/display/archidekt_api_response_deck_display_widget.cpp @@ -6,6 +6,7 @@ #include "../../../../cards/card_size_widget.h" #include "../../../../cards/deck_card_zone_display_widget.h" #include "../../../../visual_deck_editor/visual_deck_display_options_widget.h" +#include "../api_response/archidekt_formats.h" #include "../api_response/deck/archidekt_api_response_deck.h" #include