Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#include "Character.hpp"
#include <cmath>
using namespace std;
void Character::updateStats()
{
this->hpMax = this->level*10+100;
this->hp = this->hpMax;
this->manaMax = this->level*5+100;
this->mana = this->manaMax;
this->damage=this->level*5+15;
this->defence=this->level*2+10;
}
Character::Character(std::string userName)
{
this->userName = userName;
this->level = 1;
this->exp=1000;
this->expMax=(this->level*100);
this->damage=20;
this->defence=10;
this->gold=0;
this->updateStats();
}
Character::~Character()
{
}
bool Character::updateLevel()
{
if(this->exp>=this->expMax)
{
this->level++;
this->exp -=this->expMax;
this->expMax=(this->level*100);
return true;
}
return false;
}
const std::string Character::getMenuBar()
{
std::stringstream ss;
ss<<"Name: "<<this->userName<<"|"
<<"Level: "<<this->level<<"|"
<<"Experience: "<<this->exp<<"/"<<this->expMax<<"|"
<<"HP: "<<this->hp<<"/"<<this->hpMax<<"|"
<<"Mana: "<<this->mana<<"/"<<this->manaMax;
return ss.str();
}
const std::string Character::toString()
{
std:: stringstream ss;
ss << "Name:"<<this->userName<<"\n"
<<"Level:"<<this->level<<"\n"
<<"Experience: "<<this->exp<<"/"<<this->expMax<<"\n"
<<"\n"
<<"HP: "<<this->hp<<"/"<<this->hpMax<<"\n"
<<"Mana: "<<this->mana<<"/"<<this->manaMax<<"\n"
<<"Damage: "<<this->damage<<"\n"
<<"Defence: "<<this->defence<<"\n"
<<"\n"
<<"Gold: "<<this->gold<<"\n"
<<"\n";
return ss.str();
}