-
Notifications
You must be signed in to change notification settings - Fork 0
/
arena.cpp
51 lines (42 loc) · 1.2 KB
/
arena.cpp
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
#include "arena.h"
arena::arena(monster* monster, Alice* alice) {
this->alice_fighter = alice;
this->monster_fighter = monster;
}
void arena::startBattle() {
alice_fighter->startBattle();
monster_fighter->startBattle();
}
void arena::visualize() const {
system("CLS");
string toRepMonster = this->monster_fighter->visuals();
string toRepAlice = this->alice_fighter->visuals();
std::cout << toRepAlice;
for (int i = 0; i < 45; i++)
std::cout << '=';
std::cout << std::endl << toRepMonster;
std::cout << "\nAlice health: " << this->alice_fighter->getHealth() << std::endl <<
"Monster health: " << this->monster_fighter->getHealth() << std::endl;
}
void arena::figth(bool& startOver) {
this->startBattle();
bool alice_turn = true;
while (!(alice_fighter->dead() || monster_fighter->isDead())) {
visualize();
if (alice_turn == true) {
monster_fighter->takeDamage(alice_fighter->doDamage());
alice_turn = false;
}
else {
alice_fighter->takeDamage(monster_fighter->doDamage());
alice_turn = true;
}
system("PAUSE");
}
if (alice_fighter->dead())
startOver = true;
else
this->monster_fighter->defeat();
}
arena::~arena() {
}