-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathFighterInterface.h
More file actions
197 lines (179 loc) · 6.42 KB
/
FighterInterface.h
File metadata and controls
197 lines (179 loc) · 6.42 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
#ifndef FIGHTERINTERFACE_HPP_
#define FIGHTERINTERFACE_HPP_
#include <iostream>
#include <string>
#include <vector>
/*
* WARNING: It is expressly forbidden to modify any part of this document, including its name
*/
/*
* This class specifies the methods for a fighter.
*
* All fighters have the following attributes:
* Name - The fighter's name
* Hit Points - The amount of health the fighter has, with a specified maximum; reaching 0 is equivalent to losing. A Fighter's
* starting Hit Points (which is a Fighter's maximum Hit Points) must be greater than 0. There is no upper bound to what
* a Fighter's starting/maximum Hit Points could be.
* Strength - Physical power, used to determine hit point regeneration. Must be greater than 0. No maximum value.
* Speed - Dexterity and physical movement, used to reduce damage when being attacked. Must be greater than 0. No maximum value.
* Magic - Magical prowess, used for some special abilities. Must be greater than 0. No maximum value.
*
* The three fighter types have unique abilities:
* Robot - Relies on strength to deal damage. Also can use stored energy to temporarily increase damage (max/starting energy equal to 2*magic).
* Only Robots have energy.
* Archer - Relies on speed to deal damage. Also can increase its speed for the remainder of the battle (no max bonus speed).
* Cleric - Relies on magic to deal damage. Also can heal itself using mana, restoring hit points (max/starting mana equal to 5*magic).
* Only Clerics have mana.
*
* More details about how stats are used and how abilities work can be found in the comments below.
*/
/*
* ROBOT_ABILITY_COST
* The amount of energy a Robot needs to perform its special ability.
*/
const int ROBOT_ABILITY_COST = 5;
/*
* CLERIC_ABILITY_COST
* The amount of mana a Cleric needs to perform its special ability.
*/
const int CLERIC_ABILITY_COST = 25;
class FighterInterface
{
public:
FighterInterface() {}
virtual ~FighterInterface() {}
/*
* getName()
*
* Returns the name of this fighter.
*/
virtual std::string getName() const = 0;
/*
* getMaximumHP()
*
* Returns the maximum hit points of this fighter.
*/
virtual int getMaximumHP() const = 0;
/*
* getCurrentHP()
*
* Returns the current hit points of this fighter.
*/
virtual int getCurrentHP() const = 0;
/*
* getStrength()
*
* Returns the strength stat of this fighter.
*/
virtual int getStrength() const = 0;
/*
* getSpeed()
*
* Returns the speed stat of this fighter.
*/
virtual int getSpeed() const = 0;
/*
* getMagic()
*
* Returns the magic stat of this fighter.
*/
virtual int getMagic() const = 0;
/*
* getDamage()
*
* Returns the amount of damage a fighter will deal.
*
* Robot:
* This value is equal to the Robot's strength plus any additional damage added for having just used its special ability.
*
* Archer:
* This value is equal to the Archer's speed.
*
* Cleric:
* This value is equal to the Cleric's magic.
*/
virtual int getDamage() = 0;
/*
* takeDamage(int)
*
* Reduces the fighter's current hit points by an amount equal to the given
* damage minus one fourth of the fighter's speed. This method must reduce
* the fighter's current hit points by at least one. It is acceptable for
* this method to give the fighter negative current hit points.
*
* Examples:
* damage=10, speed=7 => damage_taken=9
* damage=10, speed=9 => damage_taken=8
* damage=10, speed=50 => damage_taken=1
*/
virtual void takeDamage(int damage) = 0;
/*
* reset()
*
* Restores a fighter's current hit points to its maximum hit points.
*
* Robot:
* Also restores a Robot's current energy to its maximum value (which is 2 times its magic).
* Also resets a Robot's bonus damage (calculated when a Robot uses its ability) to 0.
*
* Archer:
* Also resets an Archer's current speed to its original value.
*
* Cleric:
* Also restores a Cleric's current mana to its maximum value (which is 5 times its magic).
*/
virtual void reset() = 0;
/*
* regenerate()
*
* Increases the fighter's current hit points by an amount equal to one sixth of
* the fighter's strength. This method must increase the fighter's current hit
* points by at least one. Do not allow the current hit points to exceed the
* maximum hit points.
*
* Cleric:
* Also increases a Cleric's current mana by an amount equal to one fifth of the
* Cleric's magic. This method must increase the Cleric's current mana by at
* least one. Do not allow the current mana to exceed the maximum mana (again, 5 times its magic).
*/
virtual void regenerate() = 0;
/*
* useAbility()
*
* Attempts to perform a special ability based on the type of fighter. The
* fighter will attempt to use this special ability just prior to attacking
* every turn.
*
* Robot: Shockwave Punch
* Adds bonus damage to the Robot's next attack (and only its next attack) equal to (strength * ((current_energy/maximum_energy)^4)).
* Can only be used if the Robot has at least [ROBOT_ABILITY_COST] energy.
* Decreases the Robot's current energy by [ROBOT_ABILITY_COST] (after calculating the additional damage) when used.
* Examples:
* strength=20, current_energy=20, maximum_energy=20 => bonus_damage=20
* strength=20, current_energy=15, maximum_energy=20 => bonus_damage=6
* strength=20, current_energy=10, maximum_energy=20 => bonus_damage=1
* strength=20, current_energy=5, maximum_energy=20 => bonus_damage=0
* Robot Note:
* The bonus damage formula should be computed using double arithmetic, and only
* the final result should be cast into an integer.
*
* Archer: Quickstep
* Increases the Archer's speed by one point each time the ability is used.
* This bonus lasts until the reset() method is used.
* This ability always works; there is no maximum bonus speed.
*
* Cleric: Healing Light
* Increases the Cleric's current hit points by an amount equal to one third of its magic.
* Can only be used if the Cleric has at least [CLERIC_ABILITY_COST] mana.
* Will be used even if the Cleric's current HP is equal to their maximum HP.
* Decreases the Cleric's current mana by [CLERIC_ABILITY_COST] when used.
* Cleric Note:
* This ability, when successful, must increase the Cleric's current hit points
* by at least one, unless doing so would given the Cleric more hit points than its maximum hit points.
* Do not allow the current hit points to exceed the maximum hit points.
*
* Return true if the ability was used; false otherwise.
*/
virtual bool useAbility() = 0;
};
#endif /* FIGHTERINTERFACE_HPP_ */