Represents a complete deck, including metadata, zones, cards, and sideboard plans.
More...
#include <deck_list.h>
|
| | DeckList () |
| | Construct an empty deck.
|
| | DeckList (const DeckList &)=delete |
| | Delete copy constructor.
|
| DeckList & | operator= (const DeckList &)=delete |
| | DeckList (const QString &nativeString) |
| | Construct from a serialized native-format string.
|
| | ~DeckList () override |
| bool | isBlankDeck () const |
| void | forEachCard (const std::function< void(InnerDecklistNode *, DecklistCardNode *)> &func) const |
| | Apply a function to every card in the deck tree.
|
| DeckListMemento | createMemento (const QString &reason) const |
| void | restoreMemento (const DeckListMemento &m) |
| QString | getName () const |
| QString | getComments () const |
| QStringList | getTags () const |
| CardRef | getBannerCard () const |
| QString | getLastLoadedTimestamp () const |
| QList< MoveCard_ToZone > | getCurrentSideboardPlan () |
| void | setCurrentSideboardPlan (const QList< MoveCard_ToZone > &plan) |
| const QMap< QString, SideboardPlan * > & | getSideboardPlans () const |
| bool | readElement (QXmlStreamReader *xml) |
| void | write (QXmlStreamWriter *xml) const |
| bool | loadFromXml (QXmlStreamReader *xml) |
| bool | loadFromString_Native (const QString &nativeString) |
| QString | writeToString_Native () const |
| bool | loadFromFile_Native (QIODevice *device) |
| bool | saveToFile_Native (QIODevice *device) |
| bool | loadFromStream_Plain (QTextStream &stream, bool preserveMetadata) |
| bool | loadFromFile_Plain (QIODevice *device) |
| bool | saveToStream_Plain (QTextStream &stream, bool prefixSideboardCards, bool slashTappedOutSplitCards) |
| bool | saveToFile_Plain (QIODevice *device, bool prefixSideboardCards=true, bool slashTappedOutSplitCards=false) |
| QString | writeToString_Plain (bool prefixSideboardCards=true, bool slashTappedOutSplitCards=false) |
| void | cleanList (bool preserveMetadata=false) |
| bool | isEmpty () const |
| QStringList | getCardList () const |
| QList< CardRef > | getCardRefList () const |
| QList< DecklistCardNode * > | getCardNodes (const QStringList &restrictToZones=QStringList()) const |
| int | getSideboardSize () const |
| InnerDecklistNode * | getRoot () const |
| DecklistCardNode * | addCard (const QString &cardName, const QString &zoneName, int position, const QString &cardSetName=QString(), const QString &cardSetCollectorNumber=QString(), const QString &cardProviderId=QString()) |
| bool | deleteNode (AbstractDecklistNode *node, InnerDecklistNode *rootNode=nullptr) |
| QString | getDeckHash () const |
| void | refreshDeckHash () |
|
| virtual QString | getCardZoneFromName (const QString, QString currentZoneName) |
| | Map a card name to its zone. Override in subclasses for format-specific logic.
|
| virtual QString | getCompleteCardName (const QString &cardName) const |
| | Produce the complete display name of a card. Override in subclasses to add set suffixes or annotations.
|
Represents a complete deck, including metadata, zones, cards, and sideboard plans.
A DeckList is a QObject wrapper around an InnerDecklistNode tree, enriched with metadata like deck name, comments, tags, banner card, and multiple sideboard plans.
Core responsibilities:
- Store and manage the root node tree (zones → groups → cards).
- Provide deck-level metadata (name, comments, tags, banner).
- Support multiple sideboard plans (meta-game strategies).
- Provide import/export in multiple formats:
- Cockatrice native XML format.
- Plain-text list format.
- Provide hashing for deck identity (deck hash).
Ownership:
Signals:
Example workflow:
deck.
addCard(
"Lightning Bolt",
"main", -1);
void addTag(const QString &_tag)
Definition deck_list.h:195
DeckList()
Construct an empty deck.
Definition deck_list.cpp:80
bool saveToFile_Native(QIODevice *device)
Definition deck_list.cpp:241
DecklistCardNode * addCard(const QString &cardName, const QString &zoneName, int position, const QString &cardSetName=QString(), const QString &cardSetCollectorNumber=QString(), const QString &cardProviderId=QString())
Definition deck_list.cpp:594
void setName(const QString &_name=QString())
Definition deck_list.h:182
◆ DeckList() [1/3]
◆ DeckList() [2/3]
◆ DeckList() [3/3]
| DeckList::DeckList |
( |
const QString & | nativeString | ) |
|
|
explicit |
Construct from a serialized native-format string.
◆ ~DeckList()
◆ addCard()
| DecklistCardNode * DeckList::addCard |
( |
const QString & | cardName, |
|
|
const QString & | zoneName, |
|
|
int | position, |
|
|
const QString & | cardSetName = QString(), |
|
|
const QString & | cardSetCollectorNumber = QString(), |
|
|
const QString & | cardProviderId = QString() ) |
◆ addTag
| void DeckList::addTag |
( |
const QString & | _tag | ) |
|
|
inlineslot |
◆ cleanList()
| void DeckList::cleanList |
( |
bool | preserveMetadata = false | ) |
|
Clears all cards and other data from the decklist
- Parameters
-
| preserveMetadata | If true, only clear the cards |
◆ clearTags
| void DeckList::clearTags |
( |
| ) |
|
|
inlineslot |
◆ createMemento()
◆ deckHashChanged
| void DeckList::deckHashChanged |
( |
| ) |
|
|
signal |
Emitted when the deck hash changes.
◆ deckTagsChanged
| void DeckList::deckTagsChanged |
( |
| ) |
|
|
signal |
Emitted when the deck tags are modified.
◆ deleteNode()
◆ forEachCard()
Apply a function to every card in the deck tree.
- Parameters
-
| func | Function taking (zone node, card node). |
Calls a given function on each card in the deck.
◆ getBannerCard()
| CardRef DeckList::getBannerCard |
( |
| ) |
const |
|
inline |
◆ getCardList()
| QStringList DeckList::getCardList |
( |
| ) |
const |
◆ getCardListHelper()
| void DeckList::getCardListHelper |
( |
InnerDecklistNode * | node, |
|
|
QSet< QString > & | result ) |
|
staticprivate |
◆ getCardNodes()
| QList< DecklistCardNode * > DeckList::getCardNodes |
( |
const QStringList & | restrictToZones = QStringList() | ) |
const |
◆ getCardRefList()
| QList< CardRef > DeckList::getCardRefList |
( |
| ) |
const |
◆ getCardRefListHelper()
◆ getCardZoneFromName()
| virtual QString DeckList::getCardZoneFromName |
( |
const QString | , |
|
|
QString | currentZoneName ) |
|
inlineprotectedvirtual |
Map a card name to its zone. Override in subclasses for format-specific logic.
- Parameters
-
| cardName | Card being placed. |
| currentZoneName | Zone candidate. |
- Returns
- Zone name to use.
◆ getComments()
| QString DeckList::getComments |
( |
| ) |
const |
|
inline |
◆ getCompleteCardName()
| virtual QString DeckList::getCompleteCardName |
( |
const QString & | cardName | ) |
const |
|
inlineprotectedvirtual |
Produce the complete display name of a card. Override in subclasses to add set suffixes or annotations.
- Parameters
-
- Returns
- Full display name.
◆ getCurrentSideboardPlan()
| QList< MoveCard_ToZone > DeckList::getCurrentSideboardPlan |
( |
| ) |
|
◆ getDeckHash()
| QString DeckList::getDeckHash |
( |
| ) |
const |
Gets the deck hash. The hash is computed on the first call to this method, and is cached until the decklist is modified.
- Returns
- The deck hash
◆ getLastLoadedTimestamp()
| QString DeckList::getLastLoadedTimestamp |
( |
| ) |
const |
|
inline |
◆ getName()
| QString DeckList::getName |
( |
| ) |
const |
|
inline |
◆ getRoot()
◆ getSideboardPlans()
| const QMap< QString, SideboardPlan * > & DeckList::getSideboardPlans |
( |
| ) |
const |
|
inline |
◆ getSideboardSize()
| int DeckList::getSideboardSize |
( |
| ) |
const |
◆ getTags()
| QStringList DeckList::getTags |
( |
| ) |
const |
|
inline |
◆ getZoneObjFromName()
◆ isBlankDeck()
| bool DeckList::isBlankDeck |
( |
| ) |
const |
|
inline |
◆ isEmpty()
| bool DeckList::isEmpty |
( |
| ) |
const |
|
inline |
◆ loadFromFile_Native()
| bool DeckList::loadFromFile_Native |
( |
QIODevice * | device | ) |
|
◆ loadFromFile_Plain()
| bool DeckList::loadFromFile_Plain |
( |
QIODevice * | device | ) |
|
◆ loadFromStream_Plain()
| bool DeckList::loadFromStream_Plain |
( |
QTextStream & | in, |
|
|
bool | preserveMetadata ) |
Clears the decklist and loads in a new deck from text
- Parameters
-
| in | The text to load |
| preserveMetadata | If true, don't clear the existing metadata |
- Returns
- False if the input was empty, true otherwise.
◆ loadFromString_Native()
| bool DeckList::loadFromString_Native |
( |
const QString & | nativeString | ) |
|
◆ loadFromXml()
| bool DeckList::loadFromXml |
( |
QXmlStreamReader * | xml | ) |
|
◆ operator=()
◆ readElement()
| bool DeckList::readElement |
( |
QXmlStreamReader * | xml | ) |
|
◆ refreshDeckHash()
| void DeckList::refreshDeckHash |
( |
| ) |
|
Invalidates the cached deckHash and emits the deckHashChanged signal.
◆ restoreMemento()
◆ saveToFile_Native()
| bool DeckList::saveToFile_Native |
( |
QIODevice * | device | ) |
|
◆ saveToFile_Plain()
| bool DeckList::saveToFile_Plain |
( |
QIODevice * | device, |
|
|
bool | prefixSideboardCards = true, |
|
|
bool | slashTappedOutSplitCards = false ) |
◆ saveToStream_Plain()
| bool DeckList::saveToStream_Plain |
( |
QTextStream & | stream, |
|
|
bool | prefixSideboardCards, |
|
|
bool | slashTappedOutSplitCards ) |
◆ setBannerCard
| void DeckList::setBannerCard |
( |
const CardRef & | _bannerCard = {} | ) |
|
|
inlineslot |
◆ setComments
| void DeckList::setComments |
( |
const QString & | _comments = QString() | ) |
|
|
inlineslot |
◆ setCurrentSideboardPlan()
| void DeckList::setCurrentSideboardPlan |
( |
const QList< MoveCard_ToZone > & | plan | ) |
|
◆ setLastLoadedTimestamp
| void DeckList::setLastLoadedTimestamp |
( |
const QString & | _lastLoadedTimestamp = QString() | ) |
|
|
inlineslot |
◆ setName
| void DeckList::setName |
( |
const QString & | _name = QString() | ) |
|
|
inlineslot |
◆ setTags
| void DeckList::setTags |
( |
const QStringList & | _tags = QStringList() | ) |
|
|
inlineslot |
◆ write()
| void DeckList::write |
( |
QXmlStreamWriter * | xml | ) |
const |
◆ writeToString_Native()
| QString DeckList::writeToString_Native |
( |
| ) |
const |
◆ writeToString_Plain()
| QString DeckList::writeToString_Plain |
( |
bool | prefixSideboardCards = true, |
|
|
bool | slashTappedOutSplitCards = false ) |
◆ bannerCard
Optional representative card for the deck.
◆ cachedDeckHash
| QString DeckList::cachedDeckHash |
|
mutableprivate |
Cached deck hash, recalculated lazily. An empty string indicates the cache is invalid.
◆ comments
| QString DeckList::comments |
|
private |
Free-form comments or notes.
◆ lastLoadedTimestamp
| QString DeckList::lastLoadedTimestamp |
|
private |
Timestamp string of last load.
◆ name
◆ root
Root of the deck tree (zones + cards).
◆ sideboardPlans
◆ tags
| QStringList DeckList::tags |
|
private |
User-defined tags for deck classification.
The documentation for this class was generated from the following files:
- libcockatrice_deck_list/libcockatrice/deck_list/deck_list.h
- libcockatrice_deck_list/libcockatrice/deck_list/deck_list.cpp