Repository navigation
Expand file tree
/
Copy pathCreature.cpp
More file actions
244 lines (176 loc) · 5.82 KB
/
Copy pathCreature.cpp
File metadata and controls
244 lines (176 loc) · 5.82 KB
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#include "Creature.h"
#include<iostream>
#include<string>
#include<cstdlib>
#include<ctime>
/****************************************************************************
* Creature::Creature(int a, int SP)
*
* Purpose: Constructor
* Entry: None
* Exit: None
* ***********************************************************************/
Creature::Creature(int a, int sP){
this->armor = a;
this->strPnt = sP;
this->attRoll = 2;
this->defRoll = 1;}
/****************************************************************************
* int Creature::attack()
*
* Purpose: attack function, generates rolls of dice and sets attack values
* Entry: None
* Exit: Returns total attack value
* ***********************************************************************/
int Creature::attack(){
total = 0;
for(int i = 0; i < getRoll(); i++){
indAttack();
std::cout << "\nRolls: ";
roll = general.rollDice();
std::cout << roll << std::endl;
total = total + roll;}
setAttVal(total);
return total;}
/****************************************************************************
* int Creature::attack(bool &achilles)()
*
* Purpose: Basic attack function for Goblin. Returns a flag for achilles.
* Entry: Boolean value by reference to indicate if achilles is active
* Exit: Returns achilles
* ***********************************************************************/
int Creature::attack(bool &achilles){
return achilles;}
/****************************************************************************
* Creature::defense()
*
* Purpose: Basic defenese. Rolls dice and generates defense value
* Entry: None
* Exit: Returns total defense value
* ***********************************************************************/
int Creature::defense(){
total = 0;
for(int i = 0; i < getDefRoll(); i++){
std::cout << getType() << " defends! Rolls: ";
roll= general.rollDice();
std::cout << roll << std::endl;
total = total + roll;}
setDefVal(total);
return total;}
/****************************************************************************
* int Creature::getDmg()
*
* Purpose: Returns damage
* Entry: None
* Exit: Returns damange
* ***********************************************************************/
int Creature::getDmg(){
return dmg;}
/****************************************************************************
* void Creature::setDmg(int hurt)
*
* Purpose: Determines if there is damage and if so, how much
* Entry: total amount of rolls
* Exit: None
* ***********************************************************************/
void Creature::setDmg(int hurt){
if(hurt > 0)
dmg = hurt;
else
dmg = 0;
if(dmg > 0){
dmg = dmg - armor;
if(dmg < 0)
dmg = 0;}}
/****************************************************************************
* int Creature::getRoll()
*
* Purpose: Returns roll
* Entry: None
* Exit: Returns roll
* ***********************************************************************/
int Creature::getRoll(){
return attRoll;}
/****************************************************************************
* int Creature::getDefRoll()
*
* Purpose: Returns defense roll
* Entry: None
* Exit: Returns defense roll
* ***********************************************************************/
int Creature::getDefRoll(){
return defRoll;}
/****************************************************************************
* void Creature::setRoll()
*
* Purpose: Sets the number of times a player can roll die
* Entry: number of rolls
* Exit: None
* ***********************************************************************/
void Creature::setRoll(int num){
attRoll = num;}
/****************************************************************************
* void Creature::setAttVal(int val)
*
* Purpose: Determines and sets attack value
* Entry: integer that is the total of all rolls
* Exit: None
* ***********************************************************************/
void Creature::setAttVal(int val){
attVal = val;}
/****************************************************************************
* int Creature::getAttVal()
*
* Purpose: Returns attack value
* Entry: None
* Exit: Returns attack value
* ***********************************************************************/
int Creature::getAttVal(){
return attVal;}
/****************************************************************************
* void Creature::setDefVal()
*
* Purpose: Determines and sets defense value
* Entry: Integer that is the total of all rolls
* Exit: None
* ***********************************************************************/
void Creature::setDefVal(int val){
defVal = val;}
/****************************************************************************
* int Creature::getDefVal()
*
* Purpose: Returns defense value
* Entry: None
* Exit: Returns defense value
* ***********************************************************************/
int Creature::getDefVal(){
return defVal;}
/****************************************************************************
* void Creature::setSP)
*
* Purpose: Determines and sets strength points
* Entry: None
* Exit: None
* ***********************************************************************/
void Creature::setSP(){
dmg = armor - dmg;
strPnt = strPnt - (armor -dmg);
if(strPnt < 0)
strPnt = 0;}
/****************************************************************************
* int Creature::getSP()
*
* Purpose: Returns strength points
* Entry: None
* Exit: Returns strength points
* ***********************************************************************/
int Creature::getSP(){
return strPnt;}
/****************************************************************************
* Creature::~Creature()
*
* Purpose: Deconstructor
* Entry: None
* Exit: None
* ***********************************************************************/
Creature::~Creature(){}