mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Deck format legality checker (#6166)
* Deck legality checker. Took 51 seconds Took 1 minute Took 1 minute Took 5 minutes Took 3 minutes * Adjust format parsing. Took 8 minutes Took 3 seconds * toString() the xmlName Took 4 minutes * more toStrings() Took 5 minutes * Comments Took 3 minutes * Layout Took 2 minutes * Layout part 2: Electric boogaloo Took 59 seconds * Update cockatrice/src/interface/widgets/visual_database_display/visual_database_display_format_legality_filter_widget.cpp Co-authored-by: RickyRister <42636155+RickyRister@users.noreply.github.com> * Move layout. Took 4 minutes Took 10 seconds * Emit deckModified Took 6 minutes * Fix qOverloads Took 4 minutes * Fix qOverloads Took 12 seconds * Consider text and name in a special way. Took 11 minutes * Adjust "Any number of" oracle text Took 5 minutes * Store allowedCounts by format Took 15 minutes Took 6 seconds * Only restrict vintage. Took 2 minutes * Adjust for DBConverter. Took 6 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de> Co-authored-by: RickyRister <42636155+RickyRister@users.noreply.github.com>
This commit is contained in:
parent
2e2682aad4
commit
ccdda39e78
37 changed files with 987 additions and 35 deletions
|
|
@ -13,6 +13,10 @@
|
|||
#include <libcockatrice/card/database/parser/cockatrice_xml_4.h>
|
||||
#include <libcockatrice/card/relation/card_relation.h>
|
||||
|
||||
static const QList<AllowedCount> kConstructedCounts = {{4, "legal"}, {0, "banned"}};
|
||||
|
||||
static const QList<AllowedCount> kSingletonCounts = {{1, "legal"}, {0, "banned"}};
|
||||
|
||||
SplitCardPart::SplitCardPart(const QString &_name,
|
||||
const QString &_text,
|
||||
const QVariantHash &_properties,
|
||||
|
|
@ -463,6 +467,71 @@ int OracleImporter::importCardsFromSet(const CardSetPtr ¤tSet, const QList
|
|||
return numCards;
|
||||
}
|
||||
|
||||
FormatRulesNameMap OracleImporter::createDefaultMagicFormats()
|
||||
{
|
||||
// Predefined common exceptions
|
||||
CardCondition superTypeIsBasic;
|
||||
superTypeIsBasic.field = "type";
|
||||
superTypeIsBasic.matchType = "contains";
|
||||
superTypeIsBasic.value = "Basic Land";
|
||||
|
||||
ExceptionRule basicLands;
|
||||
basicLands.conditions.append(superTypeIsBasic);
|
||||
|
||||
CardCondition anyNumberAllowed;
|
||||
anyNumberAllowed.field = "text";
|
||||
anyNumberAllowed.matchType = "contains";
|
||||
anyNumberAllowed.value = "A deck can have any number of";
|
||||
|
||||
ExceptionRule mayContainAnyNumber;
|
||||
mayContainAnyNumber.conditions.append(anyNumberAllowed);
|
||||
|
||||
// Map to store default rules
|
||||
FormatRulesNameMap defaultFormatRulesNameMap;
|
||||
|
||||
// ----------------- Helper lambda to create format -----------------
|
||||
auto makeFormat = [&](const QString &name, int minDeck = 60, int maxDeck = -1, int maxSideboardSize = 15,
|
||||
const QList<AllowedCount> &allowedCounts = kConstructedCounts) -> FormatRulesPtr {
|
||||
FormatRulesPtr f(new FormatRules);
|
||||
f->formatName = name;
|
||||
f->allowedCounts = allowedCounts;
|
||||
f->minDeckSize = minDeck;
|
||||
f->maxDeckSize = maxDeck;
|
||||
f->maxSideboardSize = maxSideboardSize;
|
||||
f->exceptions.append(basicLands);
|
||||
f->exceptions.append(mayContainAnyNumber);
|
||||
defaultFormatRulesNameMap.insert(name.toLower(), f);
|
||||
return f;
|
||||
};
|
||||
|
||||
// ----------------- Standard formats -----------------
|
||||
makeFormat("Standard");
|
||||
makeFormat("Modern");
|
||||
makeFormat("Legacy");
|
||||
makeFormat("Pioneer");
|
||||
makeFormat("Historic");
|
||||
makeFormat("Timeless");
|
||||
makeFormat("Future");
|
||||
makeFormat("OldSchool");
|
||||
makeFormat("Premodern");
|
||||
makeFormat("Pauper");
|
||||
makeFormat("Penny");
|
||||
|
||||
// ----------------- Singleton formats -----------------
|
||||
makeFormat("Commander", 100, 100, 15, kSingletonCounts);
|
||||
makeFormat("Duel", 100, 100, 15, kSingletonCounts);
|
||||
makeFormat("Brawl", 60, 60, 15, kSingletonCounts);
|
||||
makeFormat("StandardBrawl", 60, 60, 15, kSingletonCounts);
|
||||
makeFormat("Oathbreaker", 60, 60, 15, kSingletonCounts);
|
||||
makeFormat("PauperCommander", 100, 100, 15, kSingletonCounts);
|
||||
makeFormat("Predh", 100, 100, 15, kSingletonCounts);
|
||||
|
||||
// ----------------- Restricted formats -----------------
|
||||
makeFormat("Vintage", 60, -1, 15, {{4, "legal"}, {1, "restricted"}, {0, "banned"}});
|
||||
|
||||
return defaultFormatRulesNameMap;
|
||||
}
|
||||
|
||||
int OracleImporter::startImport()
|
||||
{
|
||||
static ICardSetPriorityController *noOpController = new NoopCardSetPriorityController();
|
||||
|
|
@ -497,7 +566,8 @@ int OracleImporter::startImport()
|
|||
bool OracleImporter::saveToFile(const QString &fileName, const QString &sourceUrl, const QString &sourceVersion)
|
||||
{
|
||||
CockatriceXml4Parser parser(new NoopCardPreferenceProvider());
|
||||
return parser.saveToFile(sets, cards, fileName, sourceUrl, sourceVersion);
|
||||
|
||||
return parser.saveToFile(createDefaultMagicFormats(), sets, cards, fileName, sourceUrl, sourceVersion);
|
||||
}
|
||||
|
||||
void OracleImporter::clear()
|
||||
|
|
|
|||
|
|
@ -154,6 +154,7 @@ public:
|
|||
int startImport();
|
||||
bool saveToFile(const QString &fileName, const QString &sourceUrl, const QString &sourceVersion);
|
||||
int importCardsFromSet(const CardSetPtr ¤tSet, const QList<QVariant> &cardsList);
|
||||
FormatRulesNameMap createDefaultMagicFormats();
|
||||
const CardNameMap &getCardList() const
|
||||
{
|
||||
return cards;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue