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

Player-controlled entity with a persistent deck. More...

#include <player.h>

Inheritance diagram for Player:
Collaboration diagram for Player:

Public Member Functions

 Player ()
 
 Player (const std::vector< DeckEntry > &startingCardList, int hp=10)
 Constructs a player with an initial deck and starting HP.
 
void setName (std::string_view name)
 Sets the display name of the player.
 
std::string_view getName () const
 Returns the display name of the player.
 
const DeckPlayergetDeckPlayer ()
 Returns the player's persistent deck.
 
- Public Member Functions inherited from Entity
 Entity ()
 
 Entity (int hp, int attack=0, int armor=0)
 
std::string_view getName () const
 Returns the display name of the entity.
 
int getArmor () const
 Returns the current armor value.
 
int getAttack () const
 Returns the current attack value.
 
void resetArmor ()
 Resets armor to zero.
 
void resetAttack ()
 Resets attack to zero.
 
void increaseArmor (int amount)
 Increases armor by the given amount.
 
void increaseAttack (int amount)
 Increases attack by the given amount.
 
void lowerArmor (int amount)
 Decreases armor by the given amount.
 
int getHp () const
 Returns the current HP value.
 
void lowerHp (int amount)
 Decreases HP by the given amount.
 
void increaseHp (int amount)
 Increases HP by the given amount.
 

Additional Inherited Members

- Protected Attributes inherited from Entity
int m_hp {}
 
int m_armor {}
 
int m_attack {}
 
std::string m_name {}
 

Detailed Description

Player-controlled entity with a persistent deck.

Player represents the user-controlled character. In addition to the base Entity combat state (HP, armor), it owns a persistent DeckPlayer used to initialize combat decks for encounters.

The Player object itself is long-lived across combats

Constructor & Destructor Documentation

◆ Player() [1/2]

Player::Player ( )
inline

◆ Player() [2/2]

Player::Player ( const std::vector< DeckEntry > &  startingCardList,
int  hp = 10 
)

Constructs a player with an initial deck and starting HP.

Parameters
startingCardListList of deck entries defining the player's deck.
hpInitial hit points for the player.

Member Function Documentation

◆ getDeckPlayer()

const DeckPlayer & Player::getDeckPlayer ( )
inline

Returns the player's persistent deck.

This deck is used as the source for constructing DeckCombat instances at the start of combat encounters.

◆ getName()

std::string_view Player::getName ( ) const
inline

Returns the display name of the player.

◆ setName()

void Player::setName ( std::string_view  name)
inline

Sets the display name of the player.


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