mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-29 09:22:18 -07:00
[DeckEditor] Use CommanderSpellbook.com to estimate bracket if format is 'commander'
Took 2 minutes Took 16 minutes
This commit is contained in:
parent
e9eab328a4
commit
b0035d41cb
32 changed files with 1634 additions and 7 deletions
|
|
@ -214,3 +214,29 @@ void CardsDisplaySettings::setSampleHandSize(int _sampleHandSize)
|
|||
setValue(_sampleHandSize, "sampleHandSize", "cards", "cardSize");
|
||||
emit sampleHandSizeChanged(_sampleHandSize);
|
||||
}
|
||||
|
||||
int CardsDisplaySettings::getDeckEditorCommanderSpellbookIntegrationEnabled() const
|
||||
{
|
||||
return getValue("deckeditorcommanderspellbookintegrationenabled", "interface", QString(),
|
||||
deckEditorCommanderSpellbookIntegrationEnabledIndexUnprompted)
|
||||
.toInt();
|
||||
}
|
||||
|
||||
bool CardsDisplaySettings::getDeckEditorCommanderSpellbookIntegrationUseOfficialBracketNames() const
|
||||
{
|
||||
return getValue("deckeditorcommanderspellbookintegrationuseofficialbracketnames", "interface", QString(), false)
|
||||
.toBool();
|
||||
}
|
||||
|
||||
void CardsDisplaySettings::setDeckEditorCommanderSpellbookIntegrationEnabled(int _enabled)
|
||||
{
|
||||
setValue(_enabled, "deckeditorcommanderspellbookintegrationenabled", "interface");
|
||||
emit deckEditorCommanderSpellbookIntegrationEnabledChanged(_enabled);
|
||||
}
|
||||
|
||||
void CardsDisplaySettings::setDeckEditorCommanderSpellbookIntegrationUseOfficialBracketNames(
|
||||
bool _useOfficialBracketNames)
|
||||
{
|
||||
setValue(_useOfficialBracketNames, "deckeditorcommanderspellbookintegrationuseofficialbracketnames", "interface");
|
||||
emit deckEditorCommanderSpellbookIntegrationUseOfficialBracketNamesChanged(_useOfficialBracketNames);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,14 @@
|
|||
|
||||
#include <libcockatrice/interfaces/interface_cards_display_settings_provider.h>
|
||||
|
||||
enum deckEditorCommanderSpellbookIntegrationEnabledIndex
|
||||
{
|
||||
deckEditorCommanderSpellbookIntegrationEnabledIndexDisabled,
|
||||
deckEditorCommanderSpellbookIntegrationEnabledIndexEnabled,
|
||||
deckEditorCommanderSpellbookIntegrationEnabledIndexAutomatic,
|
||||
deckEditorCommanderSpellbookIntegrationEnabledIndexUnprompted,
|
||||
};
|
||||
|
||||
class CardsDisplaySettings : public SettingsManager, public ICardsDisplaySettingsProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -31,6 +39,12 @@ public:
|
|||
[[nodiscard]] int getArchidektPreviewSize() const override;
|
||||
[[nodiscard]] int getSampleHandSize() const override;
|
||||
|
||||
[[nodiscard]] int getDeckEditorCommanderSpellbookIntegrationEnabled() const;
|
||||
[[nodiscard]] bool getDeckEditorCommanderSpellbookIntegrationUseOfficialBracketNames() const;
|
||||
void setDeckEditorCommanderSpellbookIntegrationEnabled(int _deckEditorCommanderSpellbookIntegrationEnabled);
|
||||
void setDeckEditorCommanderSpellbookIntegrationUseOfficialBracketNames(
|
||||
bool _deckEditorCommanderSpellbookIntegrationUseOfficialBracketNames);
|
||||
|
||||
void setDisplayCardNames(bool _displayCardNames);
|
||||
void setRoundCardCorners(bool _roundCardCorners);
|
||||
void setOverrideAllCardArtWithPersonalPreference(bool _overrideAllCardArt);
|
||||
|
|
@ -66,6 +80,8 @@ signals:
|
|||
void edhRecCardSizeChanged();
|
||||
void archidektPreviewSizeChanged();
|
||||
void sampleHandSizeChanged(int amount);
|
||||
void deckEditorCommanderSpellbookIntegrationEnabledChanged(int _enabled);
|
||||
void deckEditorCommanderSpellbookIntegrationUseOfficialBracketNamesChanged(bool _useOfficialBracketNames);
|
||||
|
||||
public:
|
||||
explicit CardsDisplaySettings(const QString &settingPath, QObject *parent = nullptr);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,194 @@
|
|||
#include "commander_bracket_settings.h"
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
QVariantList CommanderBracketSettings::defaultDefinitions()
|
||||
{
|
||||
return {
|
||||
QVariantMap{{"tag", "R"},
|
||||
{"officialName", "[5] cEDH"},
|
||||
{"displayName", "Ruthless"},
|
||||
{"explanation",
|
||||
"Top-tier competitive decks with maximum optimization, fast combos, and minimal variance."}},
|
||||
QVariantMap{{"tag", "S"},
|
||||
{"officialName", "[4] Optimized"},
|
||||
{"displayName", "Spicy"},
|
||||
{"explanation", "Highly tuned decks with strong synergy and occasional combo finishes."}},
|
||||
QVariantMap{{"tag", "P"},
|
||||
{"officialName", "[3] Upgraded"},
|
||||
{"displayName", "Powerful"},
|
||||
{"explanation", "Focused decks with clear win conditions and solid consistency."}},
|
||||
QVariantMap{{"tag", "O"},
|
||||
{"officialName", "[2] Core"},
|
||||
{"displayName", "Oddball"},
|
||||
{"explanation", "Unconventional or thematic decks with some structure but non-standard choices."}},
|
||||
QVariantMap{{"tag", "C"},
|
||||
{"officialName", "[2] Core"},
|
||||
{"displayName", "Core"},
|
||||
{"explanation", "Preconstructed or precon-level decks with straightforward strategies."}},
|
||||
QVariantMap{{"tag", "E"},
|
||||
{"officialName", "[1] Exhibition"},
|
||||
{"displayName", "Exhibition"},
|
||||
{"explanation", "Ultra-casual, theme-focused decks with minimal optimization."}},
|
||||
QVariantMap{{"tag", "B"},
|
||||
{"officialName", "Banned"},
|
||||
{"displayName", "Banned"},
|
||||
{"explanation", "The deck contains one or more cards banned in Commander."}},
|
||||
};
|
||||
}
|
||||
|
||||
CommanderBracketSettings::CommanderBracketSettings(const QString &settingPath, QObject *parent)
|
||||
: SettingsManager(settingPath + "commander_brackets.ini", "commander_brackets", QString(), parent)
|
||||
{
|
||||
}
|
||||
|
||||
void CommanderBracketSettings::setSchemaVersion(int version)
|
||||
{
|
||||
setValue(version, "schemaVersion");
|
||||
}
|
||||
int CommanderBracketSettings::getSchemaVersion() const
|
||||
{
|
||||
QVariant value = getValue("schemaVersion");
|
||||
return value.isValid() ? value.toInt() : 0;
|
||||
}
|
||||
|
||||
void CommanderBracketSettings::clearDefinitions()
|
||||
{
|
||||
auto settings = getSettings();
|
||||
|
||||
settings.beginGroup("commander_brackets");
|
||||
settings.remove("");
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
void CommanderBracketSettings::saveDefinitions(const QVariantList &definitions)
|
||||
{
|
||||
auto settings = getSettings();
|
||||
|
||||
settings.beginGroup("commander_brackets");
|
||||
|
||||
settings.remove("");
|
||||
|
||||
settings.setValue("schemaVersion", CurrentSchemaVersion);
|
||||
|
||||
for (const auto &entry : definitions) {
|
||||
QVariantMap map = entry.toMap();
|
||||
|
||||
QString tag = map.value("tag").toString();
|
||||
|
||||
if (tag.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
settings.beginGroup(tag);
|
||||
|
||||
settings.setValue("officialName", map.value("officialName"));
|
||||
|
||||
settings.setValue("displayName", map.value("displayName"));
|
||||
|
||||
settings.setValue("explanation", map.value("explanation"));
|
||||
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
QVariantList CommanderBracketSettings::loadDefinitions() const
|
||||
{
|
||||
QVariantList result;
|
||||
|
||||
auto settings = getSettings();
|
||||
|
||||
settings.beginGroup("commander_brackets");
|
||||
|
||||
int version = settings.value("schemaVersion", 0).toInt();
|
||||
|
||||
if (version != CurrentSchemaVersion) {
|
||||
settings.endGroup();
|
||||
return result;
|
||||
}
|
||||
|
||||
QStringList groups = settings.childGroups();
|
||||
|
||||
for (const QString &tag : groups) {
|
||||
settings.beginGroup(tag);
|
||||
|
||||
QVariantMap map;
|
||||
|
||||
map["tag"] = tag;
|
||||
map["officialName"] = settings.value("officialName");
|
||||
map["displayName"] = settings.value("displayName");
|
||||
map["explanation"] = settings.value("explanation");
|
||||
|
||||
result.append(map);
|
||||
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
settings.endGroup();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void CommanderBracketSettings::reloadDefinitions(const QVariantList &definitionsList)
|
||||
{
|
||||
definitions.clear();
|
||||
|
||||
for (const auto &entry : definitionsList) {
|
||||
const auto map = entry.toMap();
|
||||
|
||||
CommanderBracketDefinition definition;
|
||||
|
||||
definition.tag = map.value("tag").toString();
|
||||
definition.officialName = map.value("officialName").toString();
|
||||
definition.displayName = map.value("displayName").toString();
|
||||
definition.explanation = map.value("explanation").toString();
|
||||
|
||||
if (!definition.tag.isEmpty()) {
|
||||
definitions.insert(definition.tag, definition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString CommanderBracketSettings::officialName(const QString &tag) const
|
||||
{
|
||||
auto it = definitions.find(tag);
|
||||
|
||||
if (it == definitions.end()) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
return it->officialName;
|
||||
}
|
||||
|
||||
QString CommanderBracketSettings::displayName(const QString &tag) const
|
||||
{
|
||||
auto it = definitions.find(tag);
|
||||
|
||||
if (it == definitions.end()) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
return it->displayName;
|
||||
}
|
||||
|
||||
QString CommanderBracketSettings::explanation(const QString &tag) const
|
||||
{
|
||||
auto it = definitions.find(tag);
|
||||
|
||||
if (it == definitions.end()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return it->explanation;
|
||||
}
|
||||
|
||||
bool CommanderBracketSettings::contains(const QString &tag) const
|
||||
{
|
||||
return definitions.contains(tag);
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
#ifndef COMMANDER_BRACKET_SETTINGS_H
|
||||
#define COMMANDER_BRACKET_SETTINGS_H
|
||||
|
||||
#include "settings_manager.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QVariantList>
|
||||
|
||||
struct CommanderBracketDefinition
|
||||
{
|
||||
QString tag;
|
||||
|
||||
QString officialName;
|
||||
QString displayName;
|
||||
|
||||
QString explanation;
|
||||
};
|
||||
|
||||
class CommanderBracketSettings : public SettingsManager
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class SettingsCache;
|
||||
|
||||
public:
|
||||
static constexpr int CurrentSchemaVersion = 1;
|
||||
|
||||
static QVariantList defaultDefinitions();
|
||||
|
||||
void clearDefinitions();
|
||||
|
||||
void saveDefinitions(const QVariantList &definitions);
|
||||
|
||||
QVariantList loadDefinitions() const;
|
||||
|
||||
void reloadDefinitions(const QVariantList &definitions);
|
||||
|
||||
QString officialName(const QString &tag) const;
|
||||
QString displayName(const QString &tag) const;
|
||||
QString explanation(const QString &tag) const;
|
||||
bool contains(const QString &tag) const;
|
||||
|
||||
void setSchemaVersion(int version);
|
||||
int getSchemaVersion() const;
|
||||
|
||||
private:
|
||||
explicit CommanderBracketSettings(const QString &settingPath, QObject *parent = nullptr);
|
||||
|
||||
CommanderBracketSettings(const CommanderBracketSettings &) = delete;
|
||||
CommanderBracketSettings &operator=(const CommanderBracketSettings &) = delete;
|
||||
|
||||
QHash<QString, CommanderBracketDefinition> definitions;
|
||||
};
|
||||
|
||||
#endif // COMMANDER_BRACKET_SETTINGS_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue