-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntity.h
More file actions
41 lines (36 loc) · 1.66 KB
/
Entity.h
File metadata and controls
41 lines (36 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef ENTITY_H
#define ENTITY_H
using namespace std;
#include <iostream>
#include <string>
class Entity {
string name;
int maxAmountOfLife;
int currentAmountOfLife; //should be bigger than 0 and lower/equal than maximum
int attackValue;
public:
//constructors
Entity() : name(""),maxAmountOfLife(0), currentAmountOfLife(0), attackValue(0) {};
Entity(string name,int maxAmountOfLife, int damageValue) : name(move(name)),maxAmountOfLife(maxAmountOfLife),
currentAmountOfLife(maxAmountOfLife), attackValue(damageValue) {};
//copy constructor
Entity(const Entity& Esource) {
name = Esource.name;
maxAmountOfLife = Esource.maxAmountOfLife;
currentAmountOfLife = Esource.currentAmountOfLife;
attackValue = Esource.attackValue;
};
//destructor
~Entity();
Entity& operator+=(int num); //increase the currentAmountOfLife by the num which received
Entity& operator-=(const Entity& other); //reduce the currentAmountOfLife according to the received character's attackValue
Entity& operator-=(int num); //reduce the attckValue according the received number
Entity& operator=(const Entity& Esource);
int getCurrentAmountOfLife() const;
int getAttackValue() const;
bool operator==(const Entity& other) const; //This operator will compare characters by their damage multiplied by the current amount of life they have
bool operator>(const Entity& other) const;
bool operator<(const Entity &other) const;
friend ostream& operator<<(ostream& os, const Entity& other);//print
};
#endif