-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcharacterbase.cpp
More file actions
39 lines (35 loc) · 860 Bytes
/
Copy pathcharacterbase.cpp
File metadata and controls
39 lines (35 loc) · 860 Bytes
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
#include"characterbase.h"
#include<iostream>
void characterBase::takeDamage(int enemyDamage) {
if (Armor > 0)
{
int armorDamage = enemyDamage * 70 / 100;
int healthDamage = enemyDamage * 30 / 100;
if (Armor >= armorDamage)
{
Armor -= armorDamage;
Health -= healthDamage;
}
else
{
int kalan = armorDamage - Armor;
Armor = 0;
Health -= healthDamage + kalan;
}
}
else
{
Health -= enemyDamage;
}
if (Health < 0) {
Health = 0;
}
}
void characterBase::attack(characterBase& target) {
target.takeDamage(Damage);
}
void characterBase::showStats() const {
std::cout << " Can: " << Health << std::endl;
std::cout << " Zirh: " << Armor << std::endl;
std::cout << " Hasar: " << Damage << std::endl;
}