CardGame
Rogue-like card videogame
Loading...
Searching...
No Matches
DeckPlayer Class Reference

Represents the player's persistent deck outside of combat. More...

#include <deckPlayer.h>

Collaboration diagram for DeckPlayer:

Public Member Functions

 DeckPlayer ()
 Constructs an empty deck.
 
 DeckPlayer (std::vector< DeckEntry > startingCardList, int maxCardNumbers=20)
 Constructs a deck from an initial list of entries.
 
int getCurrentCardNumber () const
 Returns the total number of cards (sum of all counts).
 
bool isCardPresent (std::string_view cardId) const
 Checks if a card ID is present in the deck.
 
bool addCard (std::string_view cardId)
 Adds a card to the deck, if below max size.
 
bool removeCard (std::string_view cardId)
 Removes one copy of a card, if above minimum size.
 
const std::vector< DeckEntry > & getCardList () const
 Returns the full list of card entries.
 

Friends

std::ostream & operator<< (std::ostream &out, const DeckPlayer &deck)
 Outputs the deck contents to an output stream.
 

Detailed Description

Represents the player's persistent deck outside of combat.

DeckPlayer stores card ownership data between matches. It does not contain CardInstances — only card IDs and counts.

Modifiable by rewards, progression, or deck editing. Serialized separately from combat systems.

Constructor & Destructor Documentation

◆ DeckPlayer() [1/2]

DeckPlayer::DeckPlayer ( )
inline

Constructs an empty deck.

◆ DeckPlayer() [2/2]

DeckPlayer::DeckPlayer ( std::vector< DeckEntry startingCardList,
int  maxCardNumbers = 20 
)

Constructs a deck from an initial list of entries.

Parameters
startingCardListInitial list of card IDs and quantities.
maxCardNumbersMaximum total card count allowed.

Member Function Documentation

◆ addCard()

bool DeckPlayer::addCard ( std::string_view  cardId)

Adds a card to the deck, if below max size.

If the card already exists, increments its count.

Parameters
cardIdID of the card to add.
Returns
true if added, false if deck is full.

◆ getCardList()

const std::vector< DeckEntry > & DeckPlayer::getCardList ( ) const
inline

Returns the full list of card entries.

◆ getCurrentCardNumber()

int DeckPlayer::getCurrentCardNumber ( ) const

Returns the total number of cards (sum of all counts).

◆ isCardPresent()

bool DeckPlayer::isCardPresent ( std::string_view  cardId) const

Checks if a card ID is present in the deck.

Parameters
cardIdID to search for.
Returns
true if at least one copy exists, false otherwise.

◆ removeCard()

bool DeckPlayer::removeCard ( std::string_view  cardId)

Removes one copy of a card, if above minimum size.

If the last copy is removed, the entry is erased entirely.

Parameters
cardIdID of the card to remove.
Returns
true if removed, false otherwise.

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
const DeckPlayer deck 
)
friend

Outputs the deck contents to an output stream.


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