-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic.cc
32 lines (26 loc) · 800 Bytes
/
basic.cc
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
#include "basic.h"
#include <cmath>
#include "enemy.h"
BasicPC::BasicPC(int HP, int Atk, int Def, int Gold, std::string Name, bool compass, bool BS)
: PC{HP, Atk, Def, Gold, Name, compass, BS} {}
int BasicPC::Combat(Enemy *enemy) {
srand(time(NULL));
int random = rand() % 2;
if (random == 0) {
int pc_def = this->getDef();
int enemy_atk = enemy->getAtk();
int Damage = ceil(((double)100 / (double)(100 + pc_def)) * enemy_atk);
if (this->BS == true) {
this->setHP(this->getHP() - Damage / 2);
return (double)Damage / (double)2;
}
else if (this->BS == false) {
this->setHP(this->getHP() - Damage);
return Damage;
}
}
else {
return 0;
}
return 0;
}