CardGame
Rogue-like card videogame
Loading...
Searching...
No Matches
deckCombat.h
Go to the documentation of this file.
1#ifndef DECKCOMBAT_H
2#define DECKCOMBAT_H
3
4#include "drawData.h"
5
6#include <memory>
7#include <string>
8#include <string_view>
9#include <vector>
10
11class DeckPlayer;
12class DeckEntry;
13class CardInstance;
14class ICardFactory;
15
17{
18 bool reshuffled{false};
19 const CardInstance* cardDrawn{nullptr};
20};
21
38{
39 public:
48 DeckCombat(const DeckPlayer& deck_player, const ICardFactory& factory);
49
56
57 DrawData drawMultipleCards(int amount);
58
65 void discardFromHand(int handIndex);
66
67 void discardWholeHand();
68
70 int getHandSize() const { return m_handPile.size(); }
71
72 // bool isValidHandIndex(int index) const;
73
81 void discard(std::unique_ptr<CardInstance> exhaustedCard);
82
92 std::unique_ptr<CardInstance> takeFromHand(int index);
93
94 // /**
95 // * @brief Returns a reference to a card currently in hand.
96 // *
97 // * @warning No bounds checking is performed. Prefer getHandView() for read-only UI
98 // * and takeFromHand() for safe ownership transfer.
99 // *
100 // * @param index Zero-based hand index.
101 // * @return Reference to the card at the given index.
102 // */
103 // CardInstance& getCardInHand(int index) { return *m_handPile[index]; }
104
106 std::vector<std::unique_ptr<CardInstance>>& getHandPile() { return m_handPile; }
107
113 std::vector<const CardInstance*> getHandView() const;
114
115 void shuffle();
116
117 void regenerateDeck();
118
119 private:
120 std::vector<std::unique_ptr<CardInstance>> m_drawPile;
121 std::vector<std::unique_ptr<CardInstance>> m_handPile;
122 std::vector<std::unique_ptr<CardInstance>> m_discardPile;
123
124 const ICardFactory& m_factory;
125
133 void populateDeck(const std::vector<DeckEntry>& cardList);
134};
135
136#endif // DECKCOMBAT_H
Represents a runtime instance of a card during combat.
Definition: cardInstance.h:21
Manages all card piles during a single combat.
Definition: deckCombat.h:38
std::unique_ptr< CardInstance > takeFromHand(int index)
Removes a card from the hand and transfers ownership to the caller.
Definition: deckCombat.cpp:81
std::vector< std::unique_ptr< CardInstance > > & getHandPile()
Returns a reference to the current hand pile.
Definition: deckCombat.h:106
void discardFromHand(int handIndex)
Discards a card from the hand to the discard pile.
Definition: deckCombat.cpp:107
void shuffle()
Definition: deckCombat.cpp:143
void regenerateDeck()
Definition: deckCombat.cpp:145
int getHandSize() const
Returns the number of cards currently in the hand.
Definition: deckCombat.h:70
void discardWholeHand()
Definition: deckCombat.cpp:122
void discard(std::unique_ptr< CardInstance > exhaustedCard)
Moves an exhausted/played card into the discard pile.
Definition: deckCombat.cpp:97
std::vector< const CardInstance * > getHandView() const
Returns a non-owning view of the current hand for UI rendering.
Definition: deckCombat.cpp:130
DrawData drawMultipleCards(int amount)
Definition: deckCombat.cpp:31
DrawResult drawCard()
Draws one card from the draw pile to the hand.
Definition: deckCombat.cpp:54
Represents the player's persistent deck outside of combat.
Definition: deckPlayer.h:23
Interface for card instance creation.
Definition: ICardFactory.h:17
Represents a single card entry in the player's persistent deck.
Definition: deckEntry.h:16
Definition: drawData.h:8
Definition: deckCombat.h:17
bool reshuffled
Definition: deckCombat.h:18
const CardInstance * cardDrawn
Definition: deckCombat.h:19