-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBattleArena.cpp
90 lines (83 loc) · 2.4 KB
/
BattleArena.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
//
// Created by Garfield on 2019-11-18.
//
#include "BattleArena.h"
BattleArena::BattleArena()
{
display_code = 'A';
pokemon_count = 0;
max_num_rivals = 3;
num_rivals_remaining = max_num_rivals;
dollar_cost_per_fight = 4;
stamina_cost_per_fight = 3;
state = RIVALS_AVAILABLE;
cout << " BattleArena default constructed.\n";
}
BattleArena::BattleArena(unsigned int max_rivals , unsigned int stamina_cost , double dollar_cost , int
in_id , Point2D in_loc ): Building('A',in_id,in_loc)
{
pokemon_count = 0;
max_num_rivals = max_rivals;
num_rivals_remaining = max_num_rivals;
dollar_cost_per_fight = dollar_cost;
stamina_cost_per_fight = stamina_cost;
state = RIVALS_AVAILABLE;
cout << "BattleArena constructed.\n";
}
unsigned int BattleArena::GetNumRivalsRemaining()
{
num_rivals_remaining--;
return num_rivals_remaining;
}
bool BattleArena::HasEnoughRivals()
{
if(num_rivals_remaining> 0)
return true;
else
return false;
}
double BattleArena::GetDollarCost()
{
return dollar_cost_per_fight; //* num_rivals_remaining;
}
unsigned int BattleArena::GetStaminaCost()
{
return stamina_cost_per_fight; //* num_rivals_remaining;
}
bool BattleArena::IsAbleToFight( double budget, unsigned int stamina)
{
unsigned int cost_by_stamina = stamina / stamina_cost_per_fight;
unsigned int cost_by_budget = (int)(budget / dollar_cost_per_fight);
unsigned int allowable_units = min(cost_by_budget, cost_by_stamina);
if (allowable_units >0)
return true;
else
return false;
}
bool BattleArena::Update(){
if ((num_rivals_remaining == 0) && (state = RIVALS_AVAILABLE))
{
state = NO_RIVALS_AVAILABLE;
return true;
}
else
return false;
}
bool BattleArena::IsBeaten(){
if (num_rivals_remaining == 0)
return true;
else
return false;
}
void BattleArena::ShowStatus()
{
cout << "Battle Arena Status: ";
Building::ShowStatus();
cout << "\tMax number of rivals: " << num_rivals_remaining << endl;
cout << "\tStamina cost per fight: " << stamina_cost_per_fight << endl;
cout << "\tPokemon dollar per fight: " <<dollar_cost_per_fight << endl;
if (num_rivals_remaining <= 1)
cout << "\t"<< num_rivals_remaining <<" rival is remaining for this arena.\n";
else
cout << "\t"<< num_rivals_remaining <<" rivals are remaining for this arena.\n";
}