This repository has been archived by the owner on Jan 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpotion.cc
executable file
·182 lines (138 loc) · 3.01 KB
/
potion.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
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#include "potion.h"
#include <map>
#include <cmath>
#include "variable.h"
Potion::Potion(int r, int c):Character('a',r,c),component(0),pr(r),pc(c){}
Potion::~Potion(){
Player* temp = Player::getInstance();
if (component != temp) {
delete component;
}
}
bool HPPotion::posSeen = false;
bool HPPotion::negSeen = false;
bool TempPotion::baSeen = false;
bool TempPotion::waSeen = false;
bool TempPotion::bdSeen = false;
bool TempPotion::wdSeen = false;
void HPPotion::setPosSeen(){
posSeen = true;
}
void HPPotion::setNegSeen(){
negSeen = true;
}
void TempPotion::setBaSeen(){
baSeen = true;
}
void TempPotion::setWaSeen(){
waSeen = true;
}
void TempPotion::setBdSeen(){
bdSeen = true;
}
void TempPotion::setWdSeen(){
wdSeen = true;
}
void HPPotion::setNotPosSeen(){
posSeen = false;
}
void HPPotion::setNotNegSeen(){
negSeen = false;
}
void TempPotion::setNotBaSeen(){
baSeen = false;
}
void TempPotion::setNotWaSeen(){
waSeen = false;
}
void TempPotion::setNotBdSeen(){
bdSeen = false;
}
void TempPotion::setNotWdSeen(){
wdSeen = false;
}
bool HPPotion::getPosSeen(){
return posSeen;
}
bool HPPotion::getNegSeen(){
return negSeen;
}
bool TempPotion::getBaSeen(){
return baSeen;
}
bool TempPotion::getWaSeen(){
return waSeen;
}
bool TempPotion::getBdSeen(){
return bdSeen;
}
bool TempPotion::getWdSeen(){
return wdSeen;
}
int Potion::getAtk(){
return component->getAtk();
}
int Potion::getDef(){
return component->getAtk();
}
void Potion::setCoordinates(int r, int c){
component->setCoordinates(r,c);
}
bool Potion::attack(Character &c){
return component->attack(c);
}
int Potion::getRow(){
if (component) {return component->getRow();}
else {return pr;}
}
int Potion::getColumn(){
if (component) {return component->getColumn();}
else {return pc;}
}
void Potion::increaseGold(int n){
component->increaseGold(n);
}
void Potion::increaseHP(int n){
component->increaseHP(n);
}
int Potion::getGold(){
return component->getGold();
}
int Potion::getHP(){
return component->getHP();
}
int Potion::getPotABS(){
return component->getPotABS();
}
HPPotion::HPPotion(char type, int r, int c):Potion(r,c),health(HPMap[type]){
Character::setType(type);
}
void HPPotion::setAbs(){
if (health<0) health = -health;
}
void HPPotion::action(Character* &c){
c->increaseHP(health);
}
TempPotion::TempPotion(char type, int r, int c):Potion(r,c),atkB(TempMap[type][0]),defB(TempMap[type][1]){
Character::setType(type);
}
void TempPotion::setAbs(){
if (atkB<0) atkB = -atkB;
if (defB<0) defB = -defB;
}
int TempPotion::getAtk(){
return (atkB + component->getAtk());
}
int TempPotion::getDef(){
return (defB + component->getDef());
}
bool TempPotion::attack(Character &c){
int damage = ceil((100 * getAtk() / (100 + c.getDef())));
c.increaseHP(-1*damage);
return true;
}
void TempPotion::action(Character* &c){
component = c;
Character::setType(c->getType());
c = this;
}