-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSorcerer.cpp
More file actions
48 lines (38 loc) · 1.23 KB
/
Sorcerer.cpp
File metadata and controls
48 lines (38 loc) · 1.23 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
//
// Created by Nativ on 18/01/2025.
//
#include "Sorcerer.h"
#include "Monster.h"
Sorcerer::~Sorcerer() = default;
Sorcerer& Sorcerer::operator=(const Sorcerer& other) {
if (this == &other)
return *this;
Player::operator=(other);
return *this;
}
string Sorcerer::getType() const {
return "sorcerer";
}
bool Sorcerer::IsItPossibleUseTheSpecialAttack() const {
if (this->roundCounter == 0 || this->roundCounter == 5)
return true;
return false;
}
Player& Sorcerer::PlayerAttackMonster(Monster &other) { //Sorcerer attack monster
other.MonsterAttackedBySorcerer(*this);
return *this;
}
Sorcerer& Sorcerer::PlayerAttackedByGoblin(const Monster &other) {
int damage = static_cast<int>(std::round(0.5 * other.getAttackValue()));
this->currentAmountOfLife -= damage;
if (this->currentAmountOfLife <= 0)
this->currentAmountOfLife = 0;
return *this;
}
Sorcerer & Sorcerer::PlayerAttackedByDragon(const Monster &other) {
int damage = static_cast<int>(std::round(2 * other.getAttackValue()));
this->currentAmountOfLife -= damage;
if (this->currentAmountOfLife <= 0)
this->currentAmountOfLife = 0;
return *this;
}