Cockatrice 2026-10-19-Development-3.1.2-beta.2
A 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 <QList>
5#include <QSharedPointer>
6#include <QString>
7
8class CardInfo;
9
11
13{
14 QString field; // e.g. "type", "maintype", "text"
15 QString matchType; // "contains", "equals", "regex", "notContains", etc.
16 QString value; // e.g. "Basic Land"
17};
18
20{
21 int max = 0; // 4, 1, 0, or -1 for unlimited
22 QString label; // "legal", "restricted", "banned"
23};
24
26{
28 int maxCopies = -1; // -1 = unlimited
29};
30
32{
33 QString formatName;
34 int minDeckSize = 60;
35 int maxDeckSize = -1; // -1 = unlimited
37
39
40 QList<ExceptionRule> exceptions; // Cards allowed to break maxCopies
41};
42
51
52// convert string to enum
53inline CardMatchType matchTypeFromString(const QString &str)
54{
55 if (str == "equals") {
57 }
58 if (str == "notEquals") {
60 }
61 if (str == "contains") {
63 }
64 if (str == "notContains") {
66 }
67 if (str == "regex") {
69 }
70 return CardMatchType::Equals; // fallback default
71}
72
73bool cardMatchesCondition(const CardInfo &card, const CardCondition &cond);
74
75bool exceptionAppliesToCard(const CardInfo &card, const ExceptionRule &rule);
76
77bool cardHasAnyException(const CardInfo &card, const FormatRules &format);
78
79#endif // COCKATRICE_FORMAT_LEGALITY_RULES_H
QSharedPointer< CardInfo > CardInfoPtr
Definition card_info.cpp:15
Represents a card and its associated metadata, properties, and relationships.
Definition card_info.h:54
Definition remote_connection_controller.h:20
Definition arrow_registry.h:10
bool exceptionAppliesToCard(const CardInfo &card, const ExceptionRule &rule)
Definition format_legality_rules.cpp:38
bool cardHasAnyException(const CardInfo &card, const FormatRules &format)
Definition format_legality_rules.cpp:48
bool cardMatchesCondition(const CardInfo &card, const CardCondition &cond)
Definition format_legality_rules.cpp:8
CardMatchType matchTypeFromString(const QString &str)
Definition format_legality_rules.h:53
CardMatchType
Definition format_legality_rules.h:44
@ Equals
Definition format_legality_rules.h:45
@ NotEquals
Definition format_legality_rules.h:46
@ NotContains
Definition format_legality_rules.h:48
@ Regex
Definition format_legality_rules.h:49
@ Contains
Definition format_legality_rules.h:47
Definition format_legality_rules.h:20
int max
Definition format_legality_rules.h:21
QString label
Definition format_legality_rules.h:22
Definition format_legality_rules.h:13
QString value
Definition format_legality_rules.h:16
QString field
Definition format_legality_rules.h:14
QString matchType
Definition format_legality_rules.h:15
Definition format_legality_rules.h:26
int maxCopies
Definition format_legality_rules.h:28
QList< CardCondition > conditions
Definition format_legality_rules.h:27
Definition format_legality_rules.h:32
int maxSideboardSize
Definition format_legality_rules.h:36
QString formatName
Definition format_legality_rules.h:33
QList< AllowedCount > allowedCounts
Definition format_legality_rules.h:38
int maxDeckSize
Definition format_legality_rules.h:35
int minDeckSize
Definition format_legality_rules.h:34
QList< ExceptionRule > exceptions
Definition format_legality_rules.h:40