TheCOSCGameProject  1.0
Public Member Functions | List of all members
Player Class Reference

Manages player attributes and actions. More...

#include <player.h>

Public Member Functions

 Player ()
 Constructor for the Player class. More...
 
 ~Player ()
 Destructor for the Player class. More...
 
void getNameFromUser ()
 Get the player's name from user input. More...
 
void getClassFromUser ()
 Get the player's class type from user input. More...
 
bool addToInventory (std::string item)
 Add an item to the player's inventory. More...
 
void removeFromInventory (std::string item)
 Remove an item from the player's inventory. More...
 
void setMaxHelth (int maxHealth)
 Set the player's maximum health. More...
 
void setCurrHealth (int health)
 Set the player's current health. More...
 
void addBuff (std::string buff)
 Add a buff to the player. More...
 
void removeBuff (std::string buff)
 Remove a buff from the player. More...
 
void setResistance (int resistance)
 Set the player's resistance value. More...
 
std::string getName ()
 Get the player's name. More...
 
std::string getClassType ()
 Get the player's class type. More...
 
std::vector< std::string > getInventory ()
 Get the player's inventory. More...
 
int getMaxHealth ()
 Get the player's maximum health. More...
 
int * getCurrHealth ()
 Get the player's current health. More...
 
int getResistance ()
 Get the player's resistance value. More...
 
std::vector< std::string > getBuffs ()
 Get the player's active buffs. More...
 
bool printInventory ()
 
std::vector< int > getNum ()
 
void setDamage (int d)
 
int getDamage ()
 
bool displayStats ()
 
int getCoins ()
 
bool setCoinsPlus (int c)
 
bool setCoinsMinus (int c)
 
void heal ()
 

Detailed Description

Manages player attributes and actions.

The Player class handles the player's inventory, health, class type, buffs, and other attributes. It also provides methods for interacting with these attributes.

Constructor & Destructor Documentation

◆ Player()

Player::Player ( )

Constructor for the Player class.

Initializes the player's attributes with default values.

Initializes the player by obtaining the player's name and class type from user input, and setting the player's maximum and current health to 100.

◆ ~Player()

Player::~Player ( )

Destructor for the Player class.

Cleans up resources when the Player object is destroyed.

Member Function Documentation

◆ addBuff()

void Player::addBuff ( std::string  buff)

Add a buff to the player.

Add a buff to the player's active buffs.

Parameters
buffThe name of the buff to add.

◆ addToInventory()

bool Player::addToInventory ( std::string  item)

Add an item to the player's inventory.

Parameters
itemThe name of the item to add.
itemThe name of the item to add to the inventory.

◆ displayStats()

bool Player::displayStats ( )

◆ getBuffs()

std::vector< std::string > Player::getBuffs ( )

Get the player's active buffs.

Returns
A vector of strings representing the player's active buffs.

◆ getClassFromUser()

void Player::getClassFromUser ( )

Get the player's class type from user input.

Prompts the user to choose a class type for the player character.

Prompts the user to enter their class type and stores it in the classType attribute.

◆ getClassType()

std::string Player::getClassType ( )

Get the player's class type.

Returns
The player's class type.
The player's class type as a string.

◆ getCoins()

int Player::getCoins ( )

◆ getCurrHealth()

int * Player::getCurrHealth ( )

Get the player's current health.

Returns
The player's current health value.
The player's current health as an integer.

◆ getDamage()

int Player::getDamage ( )

◆ getInventory()

std::vector< std::string > Player::getInventory ( )

Get the player's inventory.

Returns
A vector of strings representing the items in the player's inventory.

◆ getMaxHealth()

int Player::getMaxHealth ( )

Get the player's maximum health.

Returns
The player's maximum health value.
The player's maximum health as an integer.

◆ getName()

std::string Player::getName ( )

Get the player's name.

Returns
The player's name.
The player's name as a string.

◆ getNameFromUser()

void Player::getNameFromUser ( )

Get the player's name from user input.

Prompts the user to enter their name, which is then stored in the firstName attribute.

Prompts the user to enter their name and stores it in the firstName attribute.

◆ getNum()

std::vector< int > Player::getNum ( )

◆ getResistance()

int Player::getResistance ( )

Get the player's resistance value.

Returns
The player's resistance value.
The player's resistance as an integer.

◆ heal()

void Player::heal ( )

◆ printInventory()

bool Player::printInventory ( )

◆ removeBuff()

void Player::removeBuff ( std::string  buff)

Remove a buff from the player.

Remove a buff from the player's active buffs.

Parameters
buffThe name of the buff to remove.
buffThe name of the buff to remove.

If the buff is not found, a message is displayed to the user.

◆ removeFromInventory()

void Player::removeFromInventory ( std::string  item)

Remove an item from the player's inventory.

Parameters
itemThe name of the item to remove.
itemThe name of the item to remove from the inventory.

If the item is not found in the inventory, a message is displayed to the user.

◆ setCoinsMinus()

bool Player::setCoinsMinus ( int  c)

◆ setCoinsPlus()

bool Player::setCoinsPlus ( int  c)

◆ setCurrHealth()

void Player::setCurrHealth ( int  health)

Set the player's current health.

Parameters
healthThe current health value to set.
healthThe new current health value.

The health value is clamped between 0 and the player's maximum health.

◆ setDamage()

void Player::setDamage ( int  d)

◆ setMaxHelth()

void Player::setMaxHelth ( int  maxHealth)

Set the player's maximum health.

Parameters
maxHealthThe maximum health value to set.
maxHealthThe new maximum health value.

If the current health exceeds the new maximum health, it is reduced to the maximum health.

◆ setResistance()

void Player::setResistance ( int  resistance)

Set the player's resistance value.

Parameters
resistanceThe resistance value to set.
resistanceThe new resistance value.

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