Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
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; | ||
} |