Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
A Primer on Cards

The Cockatrice Card Library

All non-gui code related to cards used by Cockatrice is contained within libcockatrice_card.

A Basic Card Object: CardInfo

A CardInfo object is the translational unit used by the CardDatabase to represent an on-disk XML entry as an in-memory Qt object.

For a complete overview of the fields that define a CardInfo object, see the class documentation and more specifically PrivateCardProperties.

These fields correspond to either entries or a combination of entries in the XML card entry to which the CardDatabaseParser applies special logic to map, populate or determine their respective values in the CardInfo object.

Any property to which special parsing is not applied is stored in CardInfo::properties and may be retrieved or set with CardInfo::getProperty() or CardInfo::setProperty() as well as CardInfo::getProperties() to get a collection of the property keys a CardInfo contains.

For more information on how special fields contained within PrivateCardProperties are parsed, see CockatriceXml4Parser::loadCardsFromXml().

Apart from access to the basic and extended properties of a card, CardInfo also provides two important mechanisms to us. The first is the CardInfo::pixmapUpdated() signal, which allows the CardPictureLoader to signal when it is done manipulating (in most cases: loading) the QPixmap of an ExactCard::getPixmapCacheKey(), where the ExactCard::card corresponds to this CardInfo object.

Put simply: Whenever the CardPictureLoader loads a new PrintingInfo which is not already in the cache, it emits this signal so that any widget using a CardInfo object can update the display of it to possibly use this new QPixmap.

Attention
It should be noted that it is not possible to use CardPictureLoader::getPixmap() with anything but an ExactCard, which is a CardInfo object associated with a PrintingInfo, i.e. a definitive printing of a specific card

The other signal, CardInfo::cardInfoChanged() conceptually works much the same way, except it is concerned with the properties of the CardInfo object.

Getting specific: PrintingInfo and ExactCard

Printing Info

A CardInfo object describes the basic properties of a card in much the same way that we say "Two cards with the same name are and should be equal if their properties are equal". However, there are certain (mostly visual) properties which might differ between printings of a card but still conceptually classify two instances of a card as "the same card". The most obvious example to this are cards which fundamentally share all properties except the artwork depicted on the card.

We refer to such differences as Printings and track them in the PrintingInfo class. A PrintingInfo is always related to the CardSet that introduced the variation. Multiple variations can exist in the same CardSet and the respective PrintingInfo::getProperty() can be used to determine the differences, such as the collector numbers on the printings, if there are any.

Exact Card

A CardInfo object is used to hold the functional properties of a card and a PrintingInfo object can be used to hold the visual properties of a card. To represent a 'physical' card, as in, a concrete immutable instance of a card, we can use ExactCard, which combines a CardInfo and a PrintingInfo object into one class. The class is used as a container around CardInfo objects whenever the user (and thus the program) expects to be presented with a defined card printing.

Using Cards

For more information on the XML database schema which the CardDatabaseParser parses to generate CardInfo objects, see Card Database Schema and Parsing.

For more information on querying the CardDatabase for CardInfo objects, see Querying the Card Database.

For more information on displaying CardInfo and ExactCard objects using Qt Widgets, see Displaying Cards.

For more information on how card pictures are loaded from disk or the network, see Loading Card Pictures as well as the CardPictureLoader documentation.