You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

64 lines
1.0 KiB

#include "src/class/player.hpp"
#include <string.h>
Player::Player(std::string playerName)
: Character(playerName)
{
experience = 0;
level = 1;
}
Player::Player(std::string playerName, int playerMaxHP, int playerAtk, int playerDef, int playerLevel, int playerExp)
: Character(playerName, playerMaxHP, playerAtk, playerDef)
{
experience = playerExp;
level = playerLevel;
}
int Player::getLevel()
{
return level;
}
int Player::getExp()
{
return experience;
}
int Player::expToLevelUp()
{
if (level >= PLAYER_MAX_LEVEL)
{
return 0;
}
else
{
return (level * level) - experience;
}
}
bool Player::checkLevelup()
{
return (expToLevelUp() <= 0 && level < PLAYER_MAX_LEVEL);
}
void Player::levelUp()
{
level += 1;
maxHP += 10;
atk += 2;
def += 1;
}
int Player::takeExperience(int bounty)
{
experience = experience + bounty;
if (experience > PLAYER_MAX_EXPERIENCE)
{
experience = PLAYER_MAX_EXPERIENCE;
}
return experience;
}