-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMonster.cpp
More file actions
40 lines (31 loc) · 1.06 KB
/
Monster.cpp
File metadata and controls
40 lines (31 loc) · 1.06 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
//
// Created by Nativ on 18/01/2025.
//
#include "Monster.h"
#include "Fighter.h"
Monster::~Monster() = default;
Monster & Monster::operator=(const Monster &monster) {
if (this == &monster)
return *this;
Entity::operator=(monster);
return *this;
}
Monster & Monster::MonsterAttackedBySorcerer(const Player &other) {
if (other.IsItPossibleUseTheSpecialAttack())
this->currentAmountOfLife -= other.getAttackValue() * 2;
else
this->currentAmountOfLife -= other.getAttackValue();
if(this->currentAmountOfLife < 0)
this->currentAmountOfLife = 0;
return *this;
}
Monster & Monster::MonsterAttackedByFighter(const Player &other) {
this->currentAmountOfLife -= other.getAttackValue();
if(this->currentAmountOfLife < 0)
this->currentAmountOfLife = 0;
return *this;
}
ostream& operator<<(ostream& os, const Monster& other) {
os << other.name << " (" << other.currentAmountOfLife << "/" << other.maxAmountOfLife << ")" << " - " << other.attackValue;
return os;
}