-
Notifications
You must be signed in to change notification settings - Fork 0
/
PokemonGym.cpp
142 lines (117 loc) · 3.41 KB
/
PokemonGym.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
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
#include "PokemonGym.h"
PokemonGym::PokemonGym()
:Building()
{
display_code = 'G';
state = NOT_DEFEATED;
max_number_of_battles = 10;
num_battles_remaining = max_number_of_battles;
health_cost_per_battle = 1;
PokeDollar_cost_per_battle = 1.0;
experience_per_battle = 2;
}
PokemonGym::PokemonGym(unsigned int max_battle, unsigned int health_loss, double PokeDollar_cost, unsigned int exp_per_battle, int in_id, Point2D in_loc)
:Building(in_loc, in_id, 'G')
{
id_num = in_id;
max_number_of_battles = max_battle;
num_battles_remaining = max_battle;
health_cost_per_battle = health_loss;
experience_per_battle = exp_per_battle;
PokeDollar_cost_per_battle = PokeDollar_cost;
location = in_loc;
}
//returns PokeDollar cost for total battles
double PokemonGym::GetPokeDollarCost(unsigned int battle_qty)
{
return battle_qty*PokeDollar_cost_per_battle;
}
//returns health cost for total battles
unsigned int PokemonGym::GetHealthCost(unsigned int battle_qty)
{
return health_cost_per_battle*battle_qty;
}
//Returns number of battles remaining for specific PokemonGym
unsigned int PokemonGym::GetNumBattlesRemaining()
{
return num_battles_remaining;
}
//Returns true if Trainer can battle based on budget/PokemonHealth
bool PokemonGym::IsAbleToBattle(unsigned int battle_qty, double budget, unsigned int health)
{
bool afford = budget >= PokemonGym::GetPokeDollarCost(battle_qty);
bool healthy_enough = health >= PokemonGym::GetHealthCost(battle_qty);
bool can_fight = afford && healthy_enough;
return can_fight;
}
//Calculating XP for total battles fought
unsigned int PokemonGym::TrainPokemon(unsigned int battle_units)
{
unsigned int total_battles, exp_gain;
if (battle_units <= num_battles_remaining)
{
total_battles = num_battles_remaining - battle_units;
exp_gain = total_battles*experience_per_battle;
}
else
{
exp_gain = num_battles_remaining*experience_per_battle;
}
return exp_gain;
}
//returns XP
unsigned int PokemonGym::GetExperiencePerBattle()
{
return experience_per_battle;
}
unsigned int PokemonGym::Battle(unsigned int battle_units)
{
num_battles_remaining = num_battles_remaining - battle_units;
}
//completed update function
bool PokemonGym::Update()
{
char initial_state = state;
if (num_battles_remaining == 0)
{
state = DEFEATED;
display_code = 'g';
cout << "(" << display_code << ")(" << id_num << ") has been beaten" << endl;
}
if ((initial_state == NOT_DEFEATED) && (state == DEFEATED))
{
return true;
}
else
{
return false;
}
}
//return true if no more battles remaining
bool PokemonGym::passed()
{
if (num_battles_remaining == 0)
{
return true;
}
else
{
return false;
}
}
int PokemonGym::GetGymID()
{
return id_num;
}
void PokemonGym::ShowStatus()
{
cout << "**********************************************************" << endl;
cout << "PokemonGymStatus: " << endl;
Building::ShowStatus();
cout << "Max number of battles: " << max_number_of_battles << endl;
cout << "Health cost per battle: " << health_cost_per_battle << endl;
cout << "PokeDollar per battle: " << PokeDollar_cost_per_battle << endl;
cout << "Experience per battle: " << experience_per_battle << endl;
cout << num_battles_remaining << " battle(s) are remaining for this PokemonGym" << endl;
cout << "**********************************************************" << endl;
}