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

Represents a specific card instance, defined by its CardInfo and a particular printing. More...

#include <exact_card.h>

Collaboration diagram for ExactCard:
[legend]

Public Member Functions

 ExactCard ()
 Constructs an empty ExactCard.
 ExactCard (const CardInfoPtr &_card, const PrintingInfo &_printing=PrintingInfo())
 Constructs an ExactCard from a card and printing.
CardInfoPtr getCardPtr () const
 Returns the underlying CardInfoPtr.
PrintingInfo getPrinting () const
 Returns the printing information associated with this card.
bool operator== (const ExactCard &other) const
 Compares both card pointer and printing for equality.
QString getName () const
 Convenience helper to get the card's display name.
const CardInfogetInfo () const
 Returns a reference to the underlying CardInfo object.
QString getPixmapCacheKey () const
 Generates a stable cache key for pixmap caching.
bool isEmpty () const
 Indicates whether this ExactCard represents no valid card.
 operator bool () const
 Boolean conversion indicating whether the card is valid (non-empty).
void emitPixmapUpdated () const
 Emits the pixmapUpdated signal on the underlying CardInfo.

Private Attributes

CardInfoPtr card
PrintingInfo printing

Detailed Description

Represents a specific card instance, defined by its CardInfo and a particular printing.

An ExactCard identifies a card not only by its underlying CardInfoPtr (which may be null), but also by its PrintingInfo, which specifies the exact printing/variant. This allows distinguishing between different printings of the same logical card (e.g., different sets, promos, foils).

Constructor & Destructor Documentation

◆ ExactCard() [1/2]

ExactCard::ExactCard ( )

Constructs an empty ExactCard.

The CardInfoPtr will be null, and PrintingInfo will be default-constructed. An empty ExactCard represents "no card".

Default constructor. This will set the CardInfoPtr to null. The printing will be the default-constructed PrintingInfo.

Here is the caller graph for this function:

◆ ExactCard() [2/2]

ExactCard::ExactCard ( const CardInfoPtr & _card,
const PrintingInfo & _printing = PrintingInfo() )
explicit

Constructs an ExactCard from a card and printing.

Parameters
_cardThe card info pointer. May be null.
_printingThe printing details. Defaults to an empty PrintingInfo.
_cardThe card. Can be null.
_printingThe printing. Can be empty.

Member Function Documentation

◆ emitPixmapUpdated()

void ExactCard::emitPixmapUpdated ( ) const

Emits the pixmapUpdated signal on the underlying CardInfo.

Assumes CardInfoPtr is non-null. If called on an empty ExactCard, the behavior is undefined.

Gets the CardInfo to emit the pixmapUpdated signal

Here is the caller graph for this function:

◆ getCardPtr()

CardInfoPtr ExactCard::getCardPtr ( ) const
inlinenodiscard

Returns the underlying CardInfoPtr.

May be null if the ExactCard is empty.

Here is the caller graph for this function:

◆ getInfo()

const CardInfo & ExactCard::getInfo ( ) const
nodiscard

Returns a reference to the underlying CardInfo object.

If the CardInfoPtr is null, returns a reference to a static empty CardInfo instance instead. This avoids null-dereferencing but means modifications to the returned object do not affect the ExactCard.

Returns
A const reference to the CardInfo object.

Gets a view of the underlying cardInfoPtr.

Returns
A const reference to the CardInfo, or an empty CardInfo if card is null
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getName()

QString ExactCard::getName ( ) const
nodiscard

Convenience helper to get the card's display name.

Returns
The card's name, or an empty string if the CardInfoPtr is null.

Convenience method to safely get the card's name.

Returns
The name in the CardInfo, or an empty string if card is null
Here is the caller graph for this function:

◆ getPixmapCacheKey()

QString ExactCard::getPixmapCacheKey ( ) const
nodiscard

Generates a stable cache key for pixmap caching.

The key includes the card's name and (if present) the printing UUID, allowing different printings of the same card to map to different cache entries.

The key used to identify this exact printing in the cache

Here is the caller graph for this function:

◆ getPrinting()

PrintingInfo ExactCard::getPrinting ( ) const
inlinenodiscard

Returns the printing information associated with this card.

May be empty if no specific printing was assigned.

Here is the caller graph for this function:

◆ isEmpty()

bool ExactCard::isEmpty ( ) const
nodiscard

Indicates whether this ExactCard represents no valid card.

An ExactCard is considered empty if the CardInfoPtr is null or the card's name is empty.

Checks if the card is null or empty.

Here is the caller graph for this function:

◆ operator bool()

ExactCard::operator bool ( ) const
explicit

Boolean conversion indicating whether the card is valid (non-empty).

Returns
true if not empty, false otherwise.

Returns true if isEmpty() is false

Here is the call graph for this function:

◆ operator==()

bool ExactCard::operator== ( const ExactCard & other) const

Compares both card pointer and printing for equality.

Two ExactCard objects are equal only if both their CardInfoPtr and PrintingInfo values are equal.

Here is the call graph for this function:

Member Data Documentation

◆ card

CardInfoPtr ExactCard::card
private

◆ printing

PrintingInfo ExactCard::printing
private

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