-
Notifications
You must be signed in to change notification settings - Fork 0
/
enemy.h
49 lines (40 loc) · 1.42 KB
/
enemy.h
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
#ifndef ENEMY_H
#define ENEMY_H
#include <cmath>
#include <memory>
#include "character.h"
class Item;
class Enemy : public Character {
protected:
// Type type; inherited from Stuff
// int HP; inherited from Character
// int Atk; inherited from Character
// int Def; inherited from Character
bool alreadyMoved = false;
bool hasCompass = false;
bool hostile = false;
public:
// virtual char getChar() const = 0; inherited from Stuff
// int getHP() { return HP; } inherited from Character
// int getAtk() { return Atk; } inherited from Character
// int getDef() { return Def; } inherited from Character
// bool isDead() { return (HP <= 0); } inherited from Character
// void setHP(int hp) { HP = hp; } inherited from Character
// void setAtk(int atk) { Atk = atk; } inherited from Character
// void setDef(int def) { Def = def; } inherited from Character
void assignCompass() {hasCompass = true;}
bool checkCompass() const override {return hasCompass;}
bool getMoved() const override {return alreadyMoved;}
virtual void toggleMoved() override {
alreadyMoved = alreadyMoved ? false : true;
}
void becomeHostile() { hostile = true; }
Enemy(int HP, int Atk, int Def) : Character{HP, Atk, Def} {
type = Type::Enmy;
}
void beAttacked(std::shared_ptr<Stuff> c) override {
double damage = ceil((100 / (100 + static_cast<double>(this->getDef()))) * c->getAtk());
setHP(getHP()-damage <= 0 ? 0 : getHP()-damage);
}
};
#endif