|
CardGame
Rogue-like card videogame
|
Manages all card piles during a single combat. More...
#include <deckCombat.h>
Public Member Functions | |
| DeckCombat (const DeckPlayer &deck_player, const ICardFactory &factory) | |
| Constructs the combat deck from a player's persistent deck. | |
| DrawResult | drawCard () |
| Draws one card from the draw pile to the hand. | |
| DrawData | drawMultipleCards (int amount) |
| void | discardFromHand (int handIndex) |
| Discards a card from the hand to the discard pile. | |
| void | discardWholeHand () |
| int | getHandSize () const |
| Returns the number of cards currently in the hand. | |
| void | discard (std::unique_ptr< CardInstance > exhaustedCard) |
| Moves an exhausted/played card into the discard pile. | |
| std::unique_ptr< CardInstance > | takeFromHand (int index) |
| Removes a card from the hand and transfers ownership to the caller. | |
| std::vector< std::unique_ptr< CardInstance > > & | getHandPile () |
| Returns a reference to the current hand pile. | |
| std::vector< const CardInstance * > | getHandView () const |
| Returns a non-owning view of the current hand for UI rendering. | |
| void | shuffle () |
| void | regenerateDeck () |
Manages all card piles during a single combat.
DeckCombat is the runtime deck system used during an encounter. It is initialized from the player's persistent DeckPlayer and builds a fresh set of CardInstances using the provided ICardFactory.
It owns and manages:
Cards are never duplicated. Ownership moves between piles via std::move. The deck is destroyed at the end of combat.
| DeckCombat::DeckCombat | ( | const DeckPlayer & | deck_player, |
| const ICardFactory & | factory | ||
| ) |
Constructs the combat deck from a player's persistent deck.
Creates runtime CardInstances for each entry in the DeckPlayer.
| deck_player | The source persistent deck. |
| factory | Card creation system used to instantiate CardInstances. |
| void DeckCombat::discard | ( | std::unique_ptr< CardInstance > | exhaustedCard | ) |
Moves an exhausted/played card into the discard pile.
This takes ownership of the CardInstance. If the pointer is null, no action is taken.
| exhaustedCard | Owned card to discard. |
| void DeckCombat::discardFromHand | ( | int | handIndex | ) |
Discards a card from the hand to the discard pile.
| handIndex | Index of the card in the hand pile. If index is out of bounds, no action is taken. |
| void DeckCombat::discardWholeHand | ( | ) |
| DrawResult DeckCombat::drawCard | ( | ) |
Draws one card from the draw pile to the hand.
If the draw pile is empty, no action is taken.
| DrawData DeckCombat::drawMultipleCards | ( | int | amount | ) |
|
inline |
Returns a reference to the current hand pile.
|
inline |
Returns the number of cards currently in the hand.
| std::vector< const CardInstance * > DeckCombat::getHandView | ( | ) | const |
Returns a non-owning view of the current hand for UI rendering.
| void DeckCombat::regenerateDeck | ( | ) |
| void DeckCombat::shuffle | ( | ) |
| std::unique_ptr< CardInstance > DeckCombat::takeFromHand | ( | int | index | ) |
Removes a card from the hand and transfers ownership to the caller.
This is how a card is played: the card is removed from the hand immediately and returned as a std::unique_ptr for effect resolution.
| index | Zero-based hand index. |