-
Notifications
You must be signed in to change notification settings - Fork 0
/
warrior.cpp
69 lines (49 loc) · 1.18 KB
/
warrior.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# include "warrior.h"
HANDLE jConsole = GetStdHandle(STD_OUTPUT_HANDLE);
Warrior::Warrior(){
name = "";
level = 1;
hp = getMaxhp();
}
Warrior::Warrior(string s, int l){
name = s;
level = l;
hp = getMaxhp();
}
void Warrior::setHp(double hp){
this->hp = hp;
if(this->hp>getMaxhp())
this->hp = getMaxhp();
}
void Warrior::setName(string n){
this->name = n;
}
string Warrior::getName() const{
return name;
}
int Warrior::getLevel() const {
return level;
}
double Warrior::getHp() const {
return hp;
}
double Warrior::getMaxhp() const {
return (level*20 + 100);
}
void Warrior::barizise(double value, double max_value, int colour){
SetConsoleTextAttribute(jConsole, colour);
int total_length = 18;
int bar_length = (value/max_value)*total_length;
if(bar_length == 0 && value != 0)
bar_length = 1;
for(int i = 0; i < bar_length; i++){
if(bar_length < 5){
SetConsoleTextAttribute(jConsole, 12);
}
cout<<char(219);
}
for(int i = 0; i < total_length - bar_length; i++){
cout<<' ';
}
SetConsoleTextAttribute(jConsole, 7);
}