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
class Item;
class Character
{
public:
vector<string>inventory;
static int number;
int maxHealth;
bool dead = false;
string name;
int health, attack, defence, speed;
Character( string Name, int HP, int AT, int DEF, int SP);
Character();
~Character()
{
number -= 1;
}
string get_name() { return name; }
int get_health() { return health; }
bool get_life() { return dead; }
int get_attack() { return attack; }
int get_defence() { return defence; }
int get_speed() { return speed; }
void set_maxHealth(int newHealth)
{
maxHealth = newHealth;
}
void heal()
{
health = maxHealth;
}
void Stats()
{
cout <<name<<"'s stats are: " << endl;
cout << "Health " << health << " Attack " << attack;
cout << " Defence " << defence << " Speed " <<speed << endl;
}
void killCharacter()
{
dead = true;
}
static void enemyNumber()
{
cout << number << " enemies left." << endl;
}
void get_inventory()
{
cout << "Your inventory: ";
for (int i = 0; i < inventory.size(); i++)
{
cout<<"||" << inventory[i];;
}
cout <<"||"<< endl;
}
};
Character::Character(string Name, int HP, int AT, int DEF, int SP)
{
number += 1;
name = Name;
health = HP;
attack = AT;
defence = DEF;
speed = SP;
};
Character::Character()
{
name = "No name";
health = 10;
attack = 10;
defence = 10;
speed = 10;
};
int Character::number = 0;
std::ostream& operator<<(std::ostream& os, const Character& character)
{
os <<character.name;
return os;
}