Cockatrice 2026-01-14-Development-2.11.0-beta.46
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
format_legality_rules.h
Go to the documentation of this file.
1#ifndef COCKATRICE_FORMAT_LEGALITY_RULES_H
2#define COCKATRICE_FORMAT_LEGALITY_RULES_H
3
4#include <QRegularExpression>
5#include <QSharedPointer>
6#include <QString>
7
8class CardInfo;
9using CardInfoPtr = QSharedPointer<CardInfo>;
10
12{
13 QString field; // e.g. "type", "maintype", "text"
14 QString matchType; // "contains", "equals", "regex", "notContains", etc.
15 QString value; // e.g. "Basic Land"
16};
17
19{
20 int max = 0; // 4, 1, 0, or -1 for unlimited
21 QString label; // "legal", "restricted", "banned"
22};
23
25{
26 QList<CardCondition> conditions; // All must match
27 int maxCopies = -1; // -1 = unlimited
28};
29
31{
32 QString formatName;
33 int minDeckSize = 60;
34 int maxDeckSize = -1; // -1 = unlimited
36
37 QList<AllowedCount> allowedCounts;
38
39 QList<ExceptionRule> exceptions; // Cards allowed to break maxCopies
40};
41
50
51// convert string to enum
52inline CardMatchType matchTypeFromString(const QString &str)
53{
54 if (str == "equals")
56 if (str == "notEquals")
58 if (str == "contains")
60 if (str == "notContains")
62 if (str == "regex")
64 return CardMatchType::Equals; // fallback default
65}
66
67bool cardMatchesCondition(const CardInfo &card, const CardCondition &cond);
68
69bool exceptionAppliesToCard(const CardInfo &card, const ExceptionRule &rule);
70
71bool cardHasAnyException(const CardInfo &card, const FormatRules &format);
72
73#endif // COCKATRICE_FORMAT_LEGALITY_RULES_H
QSharedPointer< CardInfo > CardInfoPtr
Definition card_info.cpp:20
Represents a card and its associated metadata, properties, and relationships.
Definition card_info.h:49
bool exceptionAppliesToCard(const CardInfo &card, const ExceptionRule &rule)
Definition format_legality_rules.cpp:35
CardMatchType matchTypeFromString(const QString &str)
Definition format_legality_rules.h:52
CardMatchType
Definition format_legality_rules.h:43
@ Equals
Definition format_legality_rules.h:44
@ NotEquals
Definition format_legality_rules.h:45
@ NotContains
Definition format_legality_rules.h:47
@ Regex
Definition format_legality_rules.h:48
@ Contains
Definition format_legality_rules.h:46
bool cardHasAnyException(const CardInfo &card, const FormatRules &format)
Definition format_legality_rules.cpp:45
bool cardMatchesCondition(const CardInfo &card, const CardCondition &cond)
Definition format_legality_rules.cpp:5
Definition format_legality_rules.h:19
int max
Definition format_legality_rules.h:20
QString label
Definition format_legality_rules.h:21
Definition format_legality_rules.h:12
QString value
Definition format_legality_rules.h:15
QString field
Definition format_legality_rules.h:13
QString matchType
Definition format_legality_rules.h:14
Definition format_legality_rules.h:25
int maxCopies
Definition format_legality_rules.h:27
QList< CardCondition > conditions
Definition format_legality_rules.h:26
Definition format_legality_rules.h:31
int maxSideboardSize
Definition format_legality_rules.h:35
QString formatName
Definition format_legality_rules.h:32
QList< AllowedCount > allowedCounts
Definition format_legality_rules.h:37
int maxDeckSize
Definition format_legality_rules.h:34
int minDeckSize
Definition format_legality_rules.h:33
QList< ExceptionRule > exceptions
Definition format_legality_rules.h:39