-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntity.h
More file actions
63 lines (44 loc) · 1.97 KB
/
Entity.h
File metadata and controls
63 lines (44 loc) · 1.97 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef ENTITY_H
#define ENTITY_H
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
class Monster;
class Player;
class Entity {
protected:
string name;
int maxAmountOfLife;
int currentAmountOfLife; //should be bigger than 0 and lower/equal than maximum
int attackValue;
public:
//constructors
Entity() : 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;
};
//Assignment operator
Entity& operator=(const Entity& Esource);
//destructor
virtual ~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
virtual Entity& operator-=(int num); //reduce the attckValue according the received number
virtual Monster& MonsterAttackPlayer(Player& player);
virtual Player& PlayerAttackMonster(Monster& monster);
int getCurrentAmountOfLife() const;
int getAttackValue() const;
virtual string getType() const=0; //pure virtual method
bool operator==(const Entity& other) const; //This operator will compare characters by their damage multiplied by the current amount of life they have
virtual bool operator>(const Entity& other) const;
virtual bool operator<(const Entity&other) const;
friend ostream& operator<<(ostream& os, const Entity& other);//print
};
#endif