|
TheCOSCGameProject
1.0
|
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 () |
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.
| 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 | ( | ) |
| void Player::addBuff | ( | std::string | buff | ) |
Add a buff to the player.
Add a buff to the player's active buffs.
| buff | The name of the buff to add. |
| bool Player::addToInventory | ( | std::string | item | ) |
Add an item to the player's inventory.
| item | The name of the item to add. |
| item | The name of the item to add to the inventory. |
| bool Player::displayStats | ( | ) |
| std::vector< std::string > Player::getBuffs | ( | ) |
Get the player's active buffs.
| 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.
| std::string Player::getClassType | ( | ) |
Get the player's class type.
| int Player::getCoins | ( | ) |
| int * Player::getCurrHealth | ( | ) |
Get the player's current health.
| int Player::getDamage | ( | ) |
| std::vector< std::string > Player::getInventory | ( | ) |
Get the player's inventory.
| int Player::getMaxHealth | ( | ) |
Get the player's maximum health.
| std::string Player::getName | ( | ) |
Get the player's name.
| 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.
| std::vector< int > Player::getNum | ( | ) |
| int Player::getResistance | ( | ) |
Get the player's resistance value.
| void Player::heal | ( | ) |
| bool Player::printInventory | ( | ) |
| void Player::removeBuff | ( | std::string | buff | ) |
Remove a buff from the player.
Remove a buff from the player's active buffs.
| buff | The name of the buff to remove. |
| buff | The name of the buff to remove. |
If the buff is not found, a message is displayed to the user.
| void Player::removeFromInventory | ( | std::string | item | ) |
Remove an item from the player's inventory.
| item | The name of the item to remove. |
| item | The 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.
| bool Player::setCoinsMinus | ( | int | c | ) |
| bool Player::setCoinsPlus | ( | int | c | ) |
| void Player::setCurrHealth | ( | int | health | ) |
Set the player's current health.
| health | The current health value to set. |
| health | The new current health value. |
The health value is clamped between 0 and the player's maximum health.
| void Player::setDamage | ( | int | d | ) |
| void Player::setMaxHelth | ( | int | maxHealth | ) |
Set the player's maximum health.
| maxHealth | The maximum health value to set. |
| maxHealth | The new maximum health value. |
If the current health exceeds the new maximum health, it is reduced to the maximum health.
| void Player::setResistance | ( | int | resistance | ) |
Set the player's resistance value.
| resistance | The resistance value to set. |
| resistance | The new resistance value. |
1.8.13