Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
CardInfo Class Reference

Represents a card and its associated metadata, properties, and relationships. More...

#include <card_info.h>

Inheritance diagram for CardInfo:
[legend]
Collaboration diagram for CardInfo:
[legend]

Classes

class  UiAttributes
 Attributes of the card that affect display and game logic. More...

Public Member Functions

 CardInfo (const QString &_name, const QString &_text, bool _isToken, QVariantHash _properties, const QList< CardRelation * > &_relatedCards, const QList< CardRelation * > &_reverseRelatedCards, SetToPrintingsMap _sets, UiAttributes _uiAttributes)
 Constructs a CardInfo with full initialization.
 CardInfo (const CardInfo &other)
 Copy constructor for CardInfo.
CardInfoPtr clone () const
 Clones the current CardInfo instance.
void setSmartPointer (CardInfoPtr _ptr)
 Sets the internal smart pointer to self.
Basic Properties Accessors
const QString & getName () const
const QString & getSimpleName () const
const QSet< QString > & getAltNames ()
const QString & getText () const
void setText (const QString &_text)
bool getIsToken () const
QStringList getProperties () const
QString getProperty (const QString &propertyName) const
void setProperty (const QString &_name, const QString &_value)
bool hasProperty (const QString &propertyName) const
const SetToPrintingsMapgetSets () const
const QString & getSetsNames () const
Related Cards Accessors
const QList< CardRelation * > & getRelatedCards () const
const QList< CardRelation * > & getReverseRelatedCards () const
const QList< CardRelation * > & getReverseRelatedCards2Me () const
QList< CardRelation * > getAllRelatedCards () const
void resetReverseRelatedCards2Me ()
void addReverseRelatedCards2Me (CardRelation *cardRelation)
UI Positioning
const UiAttributesgetUiAttributes () const
const QChar getColorChar () const

Static Public Member Functions

static CardInfoPtr newInstance (const QString &_name)
 Creates a new instance with only the card name.
static CardInfoPtr newInstance (const QString &_name, const QString &_text, bool _isToken, QVariantHash _properties, const QList< CardRelation * > &_relatedCards, const QList< CardRelation * > &_reverseRelatedCards, SetToPrintingsMap _sets, UiAttributes _uiAttributes)
 Creates a new instance with full initialization.

Private Attributes

Private Card Properties

CardInfoPtr smartThis
 Smart pointer to self for safe cross-references.
QString name
 Full name of the card.
QString simpleName
 Simplified name for fuzzy matching.
QString text
 Text description or rules text of the card.
bool isToken
 Whether this card is a token or not.
QVariantHash properties
 Key-value store of dynamic card properties.
QList< CardRelation * > relatedCards
 Forward references to related cards.
QList< CardRelation * > reverseRelatedCards
 Cards that refer back to this card.
QList< CardRelation * > reverseRelatedCardsToMe
 Cards that consider this card as related.
SetToPrintingsMap setsToPrintings
 Mapping from set names to printing variations.
UiAttributes uiAttributes
 Attributes that affect display and game logic.
QString setsNames
 Cached, human-readable list of set names.
QSet< QString > altNames
 Cached set of alternate names, used when searching.

Legacy/Convenience Property Accessors

const QString getCardType () const
void setCardType (const QString &value)
const QString getCmc () const
const QString getColors () const
void setColors (const QString &value)
const QString getLoyalty () const
const QString getMainCardType () const
const QString getManaCost () const
const QString getPowTough () const
void setPowTough (const QString &value)
QString getCorrectedName () const
 Returns a version of the card name safe for file storage or fuzzy matching.
void addToSet (const CardSetPtr &_set, PrintingInfo _info=PrintingInfo())
 Adds a printing to a specific set.
void combineLegalities (const QVariantHash &props)
 Combines legality properties from a provided map.
void refreshCachedSets ()
 Refreshes all cached fields that are calculated from the contained sets and printings.
static QString simplifyName (const QString &name)
 Simplifies a name for fuzzy matching.
void refreshCachedSetNames ()
 Refreshes the cached, human-readable list of set names.
void refreshCachedAltNames ()
 Refreshes the cached list of alt names for the card.
void pixmapUpdated (const PrintingInfo &printing)
 Emitted when a pixmap for this card has been updated or finished loading.
void cardInfoChanged (CardInfoPtr card)
 Emitted when card properties or state have changed.

Detailed Description

Represents a card and its associated metadata, properties, and relationships.

CardInfo holds both static information (name, text, flags) and dynamic data (properties, set memberships, relationships). It also integrates with signals/slots, allowing observers to react to property or visual updates.

Each CardInfo may belong to multiple sets through its printings, and can be related to other cards through defined relationships.

Constructor & Destructor Documentation

◆ CardInfo() [1/2]

CardInfo::CardInfo ( const QString & _name,
const QString & _text,
bool _isToken,
QVariantHash _properties,
const QList< CardRelation * > & _relatedCards,
const QList< CardRelation * > & _reverseRelatedCards,
SetToPrintingsMap _sets,
UiAttributes _uiAttributes )
explicit

Constructs a CardInfo with full initialization.

Parameters
_nameThe name of the card.
_textRules text or description of the card.
_isTokenFlag indicating whether the card is a token.
_propertiesArbitrary key-value properties.
_relatedCardsForward references to related cards.
_reverseRelatedCardsBackward references to related cards.
_setsMap of set names to printing information.
_uiAttributesAttributes that affect display and game logic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CardInfo() [2/2]

CardInfo::CardInfo ( const CardInfo & other)
inline

Copy constructor for CardInfo.

Performs a deep copy of properties, sets, and related card lists.

Parameters
otherAnother CardInfo to copy.
Here is the call graph for this function:

Member Function Documentation

◆ addReverseRelatedCards2Me()

void CardInfo::addReverseRelatedCards2Me ( CardRelation * cardRelation)
inline

◆ addToSet()

void CardInfo::addToSet ( const CardSetPtr & _set,
PrintingInfo _info = PrintingInfo() )

Adds a printing to a specific set.

Updates the mapping and refreshes the cached list of set names.

Parameters
_setThe set to which the card should be added.
_infoOptional printing information.
Here is the call graph for this function:

◆ cardInfoChanged

void CardInfo::cardInfoChanged ( CardInfoPtr card)
signal

Emitted when card properties or state have changed.

Parameters
cardShared pointer to the CardInfo instance that changed.
Here is the caller graph for this function:

◆ clone()

CardInfoPtr CardInfo::clone ( ) const
inlinenodiscard

Clones the current CardInfo instance.

Uses the copy constructor and ensures the smart pointer is properly set.

Returns
Shared pointer to the cloned CardInfo.
Here is the call graph for this function:

◆ combineLegalities()

void CardInfo::combineLegalities ( const QVariantHash & props)

Combines legality properties from a provided map.

Useful for merging format legality flags from multiple sources.

Parameters
propsKey-value mapping of format legalities.

◆ getAllRelatedCards()

QList< CardRelation * > CardInfo::getAllRelatedCards ( ) const
inlinenodiscard
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAltNames()

const QSet< QString > & CardInfo::getAltNames ( )
inline

◆ getCardType()

const QString CardInfo::getCardType ( ) const
nodiscard
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCmc()

const QString CardInfo::getCmc ( ) const
nodiscard
Here is the call graph for this function:

◆ getColorChar()

const QChar CardInfo::getColorChar ( ) const
nodiscard
Here is the call graph for this function:

◆ getColors()

const QString CardInfo::getColors ( ) const
nodiscard
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCorrectedName()

QString CardInfo::getCorrectedName ( ) const
nodiscard

Returns a version of the card name safe for file storage or fuzzy matching.

Removes invalid characters, replaces spacing markers, and normalizes diacritics.

Returns
Corrected card name as a QString.
Here is the caller graph for this function:

◆ getIsToken()

bool CardInfo::getIsToken ( ) const
inlinenodiscard
Here is the caller graph for this function:

◆ getLoyalty()

const QString CardInfo::getLoyalty ( ) const
nodiscard
Here is the call graph for this function:

◆ getMainCardType()

const QString CardInfo::getMainCardType ( ) const
nodiscard
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getManaCost()

const QString CardInfo::getManaCost ( ) const
nodiscard
Here is the call graph for this function:

◆ getName()

const QString & CardInfo::getName ( ) const
inlinenodiscard

◆ getPowTough()

const QString CardInfo::getPowTough ( ) const
nodiscard
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getProperties()

QStringList CardInfo::getProperties ( ) const
inlinenodiscard

◆ getProperty()

QString CardInfo::getProperty ( const QString & propertyName) const
inlinenodiscard
Here is the caller graph for this function:

◆ getRelatedCards()

const QList< CardRelation * > & CardInfo::getRelatedCards ( ) const
inlinenodiscard
Here is the caller graph for this function:

◆ getReverseRelatedCards()

const QList< CardRelation * > & CardInfo::getReverseRelatedCards ( ) const
inlinenodiscard

◆ getReverseRelatedCards2Me()

const QList< CardRelation * > & CardInfo::getReverseRelatedCards2Me ( ) const
inlinenodiscard
Here is the caller graph for this function:

◆ getSets()

const SetToPrintingsMap & CardInfo::getSets ( ) const
inlinenodiscard
Here is the caller graph for this function:

◆ getSetsNames()

const QString & CardInfo::getSetsNames ( ) const
inlinenodiscard

◆ getSimpleName()

const QString & CardInfo::getSimpleName ( ) const
inlinenodiscard

◆ getText()

const QString & CardInfo::getText ( ) const
inlinenodiscard
Here is the caller graph for this function:

◆ getUiAttributes()

const UiAttributes & CardInfo::getUiAttributes ( ) const
inlinenodiscard
Here is the caller graph for this function:

◆ hasProperty()

bool CardInfo::hasProperty ( const QString & propertyName) const
inlinenodiscard

◆ newInstance() [1/2]

CardInfoPtr CardInfo::newInstance ( const QString & _name)
static

Creates a new instance with only the card name.

All other fields are set to defaults.

Parameters
_nameThe card name.
Returns
Shared pointer to the new CardInfo instance.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ newInstance() [2/2]

CardInfoPtr CardInfo::newInstance ( const QString & _name,
const QString & _text,
bool _isToken,
QVariantHash _properties,
const QList< CardRelation * > & _relatedCards,
const QList< CardRelation * > & _reverseRelatedCards,
SetToPrintingsMap _sets,
UiAttributes _uiAttributes )
static

Creates a new instance with full initialization.

Parameters
_nameName of the card.
_textRules text or description.
_isTokenToken flag.
_propertiesArbitrary properties.
_relatedCardsForward relationships.
_reverseRelatedCardsReverse relationships.
_setsPrinting information per set.
_uiAttributesAttributes that affect display and game logic
Returns
Shared pointer to the new CardInfo instance.
Here is the call graph for this function:

◆ pixmapUpdated

void CardInfo::pixmapUpdated ( const PrintingInfo & printing)
signal

Emitted when a pixmap for this card has been updated or finished loading.

Parameters
printingSpecific printing for which the pixmap has updated.
Here is the caller graph for this function:

◆ refreshCachedAltNames()

void CardInfo::refreshCachedAltNames ( )
private

Refreshes the cached list of alt names for the card.

Typically called after adding or modifying the contained printings.

Here is the caller graph for this function:

◆ refreshCachedSetNames()

void CardInfo::refreshCachedSetNames ( )
private

Refreshes the cached, human-readable list of set names.

Typically called after adding or modifying set memberships.

Here is the caller graph for this function:

◆ refreshCachedSets()

void CardInfo::refreshCachedSets ( )

Refreshes all cached fields that are calculated from the contained sets and printings.

Typically called after adding or modifying set memberships or printings.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetReverseRelatedCards2Me()

void CardInfo::resetReverseRelatedCards2Me ( )
Here is the call graph for this function:

◆ setCardType()

void CardInfo::setCardType ( const QString & value)
Here is the call graph for this function:

◆ setColors()

void CardInfo::setColors ( const QString & value)
Here is the call graph for this function:

◆ setPowTough()

void CardInfo::setPowTough ( const QString & value)
Here is the call graph for this function:

◆ setProperty()

void CardInfo::setProperty ( const QString & _name,
const QString & _value )
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setSmartPointer()

void CardInfo::setSmartPointer ( CardInfoPtr _ptr)
inline

Sets the internal smart pointer to self.

Used internally to allow safe cross-references among CardInfo and CardSet.

Parameters
_ptrShared pointer pointing to this instance.

◆ setText()

void CardInfo::setText ( const QString & _text)
inline
Here is the call graph for this function:

◆ simplifyName()

QString CardInfo::simplifyName ( const QString & name)
static

Simplifies a name for fuzzy matching.

Converts to lowercase, removes punctuation/spacing.

Parameters
nameOriginal name string.
Returns
Simplified name string.
Here is the caller graph for this function:

Member Data Documentation

◆ altNames

QSet<QString> CardInfo::altNames
private

Cached set of alternate names, used when searching.

◆ isToken

bool CardInfo::isToken
private

Whether this card is a token or not.

◆ name

QString CardInfo::name
private

Full name of the card.

◆ properties

QVariantHash CardInfo::properties
private

Key-value store of dynamic card properties.

◆ relatedCards

QList<CardRelation *> CardInfo::relatedCards
private

Forward references to related cards.

◆ reverseRelatedCards

QList<CardRelation *> CardInfo::reverseRelatedCards
private

Cards that refer back to this card.

◆ reverseRelatedCardsToMe

QList<CardRelation *> CardInfo::reverseRelatedCardsToMe
private

Cards that consider this card as related.

◆ setsNames

QString CardInfo::setsNames
private

Cached, human-readable list of set names.

◆ setsToPrintings

SetToPrintingsMap CardInfo::setsToPrintings
private

Mapping from set names to printing variations.

◆ simpleName

QString CardInfo::simpleName
private

Simplified name for fuzzy matching.

◆ smartThis

CardInfoPtr CardInfo::smartThis
private

Smart pointer to self for safe cross-references.

◆ text

QString CardInfo::text
private

Text description or rules text of the card.

◆ uiAttributes

UiAttributes CardInfo::uiAttributes
private

Attributes that affect display and game logic.


The documentation for this class was generated from the following files: