Study Dungeon  1.0.0
A group project for COSC345
Public Member Functions
Player Class Reference

Class that represents a Player. More...

#include <player.h>

Public Member Functions

 Player ()
 Construct a new Player object.
 
 Player (int hitPoints, int maxHitPoints, size_t handSize, const std::vector< PlayingCard > &deck)
 Construct a new Player object. More...
 
int getHitPoints ()
 Returns the current hit points of the player. More...
 
void setHitPoints (int value)
 Sets the current hit points of the player. More...
 
int getMaxHitPoints ()
 Returns the max hit points of the player. More...
 
void setMaxHitPoints (int value)
 Sets the maximum hit points of the player. More...
 
std::vector< PlayingCardgetHand ()
 Returns the player's hand. More...
 
void setHand (const std::vector< PlayingCard > &hand)
 Set the player's hand. More...
 
size_t getHandSize ()
 Returns the hand size of the player. More...
 
void setHandSize (size_t handSize)
 Sets the hand size of the player. More...
 
std::vector< PlayingCardgetDeck ()
 Get the Deck of the player. More...
 
void setDeck (const std::vector< PlayingCard > &deck)
 Set the Deck of the player. More...
 
void drawCard ()
 Draws a card from the player's deck and adds it to the player's hand.
 
void removeCard (PlayingCard &card)
 Removes the given card from the player's hand. More...
 
void addCard (PlayingCard &card)
 Adds the given card to the player's hand. More...
 
PlayingCard getCard (int index)
 Returns the PlayingCard object that corresponds to the index given. More...
 
void damage (int amount)
 Applies damage equal to amount to the player. More...
 
void heal (int amount)
 Heals the player a given amount. More...
 
std::string toString ()
 Converts the player object to a string. More...
 
void printHand ()
 Prints the hand of the player to std::cout.
 

Detailed Description

Class that represents a Player.

Constructor & Destructor Documentation

◆ Player()

Player::Player ( int  hitPoints,
int  maxHitPoints,
size_t  handSize,
const std::vector< PlayingCard > &  deck 
)

Construct a new Player object.

Parameters
hitPointsthe current hit points of the player
maxHitPointsthe maximum hit points of the player
handthe hand (list of cards) of the player

Member Function Documentation

◆ addCard()

void Player::addCard ( PlayingCard card)

Adds the given card to the player's hand.

Parameters
cardthe card to add to the player's hand.

◆ damage()

void Player::damage ( int  amount)

Applies damage equal to amount to the player.

Parameters
amountthe amount to damage the player.

◆ getCard()

PlayingCard Player::getCard ( int  index)

Returns the PlayingCard object that corresponds to the index given.

Parameters
indexthe index of the card to get
Returns
PlayingCard the object that corresponds to the given index.

◆ getDeck()

std::vector< PlayingCard > Player::getDeck ( )

Get the Deck of the player.

Returns
std::vector<PlayingCard>

◆ getHand()

std::vector< PlayingCard > Player::getHand ( )

Returns the player's hand.

Returns
std::vector<PlayingCard> the player's hand

◆ getHandSize()

size_t Player::getHandSize ( )

Returns the hand size of the player.

Returns
int the hand size

◆ getHitPoints()

int Player::getHitPoints ( )

Returns the current hit points of the player.

Returns
int the current hit points of the player

◆ getMaxHitPoints()

int Player::getMaxHitPoints ( )

Returns the max hit points of the player.

Returns
int the max hit points of the player.

◆ heal()

void Player::heal ( int  amount)

Heals the player a given amount.

Parameters
amountthe amount to heal the player.

◆ removeCard()

void Player::removeCard ( PlayingCard card)

Removes the given card from the player's hand.

Parameters
cardthe card to remove from the player's hand.

◆ setDeck()

void Player::setDeck ( const std::vector< PlayingCard > &  deck)

Set the Deck of the player.

Parameters
deckThe deck of cards for the player

◆ setHand()

void Player::setHand ( const std::vector< PlayingCard > &  hand)

Set the player's hand.

Set the player's hand to the given vector of playing cards. Note, this function should not be used to add or remove a card for the player's hand. To add a card to the player's hand, use addCard(). To remove a card from the player's hand, use removeCard().

Parameters
handthe vector of playing cards to set as the player's hand

◆ setHandSize()

void Player::setHandSize ( size_t  handSize)

Sets the hand size of the player.

Parameters
handSizethe hand size to set too

◆ setHitPoints()

void Player::setHitPoints ( int  value)

Sets the current hit points of the player.

Sets the current hit points of the player to the value given, as long as the value is less than the maximum hit points and more than -1. Note that this function should not be used to damage or heal the player. To damage the player, use the damage() function. To heal the player, use the heal() function.

Parameters
valuethe value for the hit points to be set to.

◆ setMaxHitPoints()

void Player::setMaxHitPoints ( int  value)

Sets the maximum hit points of the player.

Parameters
valuethe value to set the player's maximum hit points.

◆ toString()

std::string Player::toString ( )

Converts the player object to a string.

Returns
std::string the string version of the player.

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