-
Notifications
You must be signed in to change notification settings - Fork 0
/
trainer.hpp
142 lines (117 loc) · 7.99 KB
/
trainer.hpp
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
//
// trainer.hpp
// Actual Project 3
//
// Created by Grant Finn on 4/5/21.
//
#ifndef TRAINER_H
#define TRAINER_H
#include <string> // we use strings for names within the trainer class as well, so we need to include string here.
#include <vector> // we keep our main roster of pokemon in a vector
#include "pokemon.hpp"//trainers have a roster(array) of pokemon that they fight with, so they need to specifically know what a pokemon is.
/*
TYPING DENOTION FOR POKEMON AND ATTACKS, THIS IS IMPORTANT:
this code denotes the type of attack or type of pokemon that an object is using INTEGERS, not CHARACTERS.
typing order is as such:
Normal - 0
Fire - 1
Water - 2
Grass - 3
Electric - 4
Ground - 5
Rock - 6
Flying - 7
Fighting - 8
Psychic - 9
Dark - 10
Ghost - 11
Ice - 12
Bug - 13
Poison - 14
Dragon - 15
Steel - 16
Fairy - 17
Totaling 18 types, excluding null. NOTE ----->>> When applying this numbering system to the attack side of damage calculation, 1 has to be added, as column zero is being used by the possibility of typeless attacks.
This means attacks of normal type are actually represented by 1, and null attacks by 0.
I don't account for this with any - 1 in any functions or constructors, however; I simply count one higher when inputting the parameters for a newly constructed pokemon. this seemed a lot easier to me,
But obviously isn't as friendly to people who would potentially use my code.
*/
class trainer {
public:
//Default constructor, not for use
trainer();
//the intended constructor for trainer classes. Must have a name and six pokemon objects to add to the roster
trainer(std::string Name, pokemon& roster1, pokemon& roster2, pokemon& roster3, pokemon& roster4, pokemon& roster5, pokemon& roster6);
//Predconditions: None
//Postcondition: returns an integer
//Purpose: returns the quantity in integers of shields that the calling object has.
int getShields();
//Preconditions: None
//Postconditions: Internal, initializes activePoke integer
//Purpose: The primary function for setting the variable activePoke, which denotes what pokemon from the Battle Roster the trainer will use in attacks. when chooseActive is run, at startup or whenever a pokemon
//feints, it will show the user their entire roster and each pokemon's current HP. they are prompted to enter a number to choose an active pokemon. they cannot choose a dead pokemon or a number
//outside of their roster's range.
void chooseActive();
//Preconditions: A parameter of the class trainer
//Postconditions: Internal, changes parameter's active Pokemon's health, and calling object's Pokemon's energy; may prompt chooseActive() for parameter
//Purpose: Function that makes the calling object's active Pokemon use its fast attack against the parameter object's active pokemon. Calculates total damage of the attack,
//factoring in a type matchup of the attack and the defender, and the possibility of the defender having multiple Types. Deals this damage to the enemy Pokemon, adds the attacking pokemon's fast move's energy delta
//to said Pokemon, and if the enemy pokemon has 0 HP or less, prompts the enemy to choose a new pokemon as their active pokemon from their battle roster.
void fastAttack(trainer & enemy);
//Preconditions: A parameter of the class trainer
//Postconditions: Internal, changes parameter's active Pokemon's health, and calling object's Pokemon's energy; may prompt chooseActive() for parameter
//Purpose: Function that makes the calling object's active Pokemon use its fast attack against the parameter object's active pokemon. Calculates total damage of the attack,
//factoring in a type matchup of the attack and the defender, and the possibility of the defender having multiple Types. If the attacking Pokemon does not have sufficient energy, the
//Attack and its calculations are not executed. If the attack can be executed, then the defending trainer has the option to use one of their shields (if they have any remaining) to block the attack.
//if the attack is blocked, the defender's health does not change, but the Attacker's energy still goes down by the cost of the attack. If the Defender has no shields, then the calculated damage
//is done to the defending pokemon, and the attacking pokemon loses energy equivalent to the cost of the attack.
//If the enemy pokemon has 0 HP or less, prompts the enemy to choose a new pokemon as their active pokemon from their battle roster.
void chargedAttack(trainer & enemy);
//Preconditions: A parameter of the class trainer
//Postconditions: Internal, makes changes to the calling object either based on fastAttack(), chargedAttack(), or chooseActive()
//Purpose: Prompts the user to have the calling object "take a turn" against the parameter object. The function displays what calling object is taking the turn, displays the Name, HP and Energy of
//the calling object's active pokemon, and displays three options for the user to choose. The user can either Fast Attack against the parameter, Charged Attack against the parameter (if the active pokemon has enough energy!)
//Or change their own active pokemon to another in their battle roster. The function displays the name of the fast attack, and the name of the charged attack if it is available.
void turnAgainst(trainer& enemy);
//Preconditions: None
//Postconditions: Internal; changes the value of the battleRoster integer array, outputs text for user interface
//Purpose: This function allows the user to changew which three pokemon they have out of all of their pokemon in their battle roster. All pokemon that the user has in their normal roster are
//displayed next to a number, and the user is prompted to enter three numbers, each which match a pokemon, to be put into their battle roster. The user is then told which thee they have chosen.
void chooseBattleRoster();
void printtestcases();
//Preconditions: None
//Postconditions: Returns a value of type integer
//Purpose: Returns the cooldown value of the calling object's active pokemon's fast move for reference.
float getCooldown() const;
//Preconditions: None
//Postconditions: Returns a value of type integer
//Purpose: Returns the duration value of the calling object's active pokemon's fast move for reference.
float getDuration() const;
//Preconditions: None
//Postconditions: Returns a value of type integer
//Purpose: Returns the current waitTime value of the calling object for reference.
float getWaitTime() const;
//Preconditions: An integer value
//Postconditions: Internal, changes calling object's value for waitTime variable
//Purpose: Allows the waitTime variable of the calling object to be changed by the amount input as an integer parameter
void changeWaitTime(float num);
//preconditions: None
//Postconditions: outputs a value of type Boolean
//Purpose: Function that looks at all three pokemon the calling object has that are indexed in its battle roster, and returns a value of false if all three pokemon are dead, or have zero or less health.
//Otherwise, this function returns as true.
bool notDead();
private:
//the name of the trainer
std::string name;
//An array of numbers that represent the battle roster. Each number denotes a slot within the normal roster where a pokemon that is in the battle roster can be found!
int battleRoster[3];
//The vector of pokemon where all pokemon the trainer has are held
std::vector<pokemon> roster;
//an integer that represents which pokemon in the battle roster (a.k.a which number in the battle roster that points to the normal roster) is the pokemon active in battle.
int activePoke;
//I honestly could've set this as 2 right off the bat, but I felt more comfortable letting my constructors handle it. The shields the trainer has.
int shields;
//The amount of time the trainer has to wait before they can take another turn, measured in whole numbers.
float waitTime;
};
#endif //TRAINER_H