Pokemon Class - kquinn1/FundComp_pokemon GitHub Wiki
Pokemon Class: Pokemon.cpp & Pokemon.h
Documentation written by Katie Quinn
Note: the class represents Pokemon using Generation 1 rules/classifications. For example, there is only one special IV, EV, and base statistic as opposed to a special attack IV, EV, and base as well as a special defense IV, EV, and base statistic.
This class will act as the top level class for the pokemon inheritance structure used to implement the game. Derived classes: Types, then species.
TODO: Create diagram of pokemon class hierarchy
int level: represents the level of a pokemon. Starts at 1. Determines the attack, defense, special attack, special defense, speed, and HP of a pokemon using formulas shown in this article.
string type: contains the pokemon’s type e.g. electrical, fire, etc.
Base stats are characteristics that define each Pokemon species. Each species has a specific base statistic value for HP, Attack, Defense, Speed, and Special (according to Generation 1 standards).
int base_A: This is used to store the base attack variable. It is used in calculating the attack variable.
int base_D: This is used to store the base defense of a pokemon species.
int base_Speed: This is used to store the base speed of a pokemon species.
int base_HP: This is used to store the base HP of a pokemon species.
Individual values (IVs) can be referred to as determinant values as they are the equivalent of genes for Pokemon. They help determine the stats of a pokemon. These values are responsible for variation in stats amongst untrained Pokemon of the same species. IVs, base stats, and EVs (discused later) help determine the actual pokemon stats. A Pokemon’s IVs are generated by the actual game when it is obtained as an egg or encountered in the wild. IVs range between 0 and 15. Effectively, the program calculates a random number using rand in order to determine each IV. The actual game calculates IV_HP based on the other IVs. Currently, the program does not reflect this.
int IV_A: This is the individual value for attack. It is generated to be a random number between 0 and 15.
int IV_D: IV for defense. Random number between 0 and 15.
int IV_Speed: IV for speed. Random number between 0 and 15.
int IV_Spec: IV for special (special defense and attack). Random number between 0 and 15.
int IV_HP: IV for HP (health). Currently a random number between 0 and 15.
TODO: Should be a number generated by the last digit of each of the IVs in binary.
Effort or experience values are based on a pokemon’s experience. When a pokemon is generated, the value is 0. There is a maximum EV of 65535 for each stat. If a pokemon is defeated, their base stats are “converted” to effort points and then added to the EVs of the pokemon that defeated them. EVs are factored into the Pokemon’s stats when it levels up.
int EV_A: EV for attack. Starts at 0.
int EV_D: EV for defense. Starts at 0.
int EV_Speed: EV for speed. Starts at 0.
int EV_Spec: EV for special attack and defense. Starts at 0.
int EV_HP: EV for HP (health). Starts at 0.
The following stats are calculated using the public member functions. They are based on base stats, IV stats, and EV stats. A specific formula is used in calculating each statistic.
int attack: Represents the attack statistic of a pokemon.
int defense: Represents the defense statistic of a pokemon.
int specAttack: Represents the special attack of a pokemon.
int specDefense: Represents the special defense of a pokemon.
int speed: Represents the speed of a pokemon. This is important as it determines what pokemon in a battle will go first.
int HP: Represents the health of a pokemon. It is the number of “damage points” a pokemon can take on before it faints. If a pokemon faints, it cannot be used in battle.
TODO: Each pokemon should have 4 Attacks. This can be implemented using composition. The code is currently commented out in Pokemon.h. Should have a way to update what attacks there are, using a virtual void function. The function will be defined in a specific Pokemon class. In reality, the player will not utilize the game enough for there to be a need to allow the user to change what attacks the pokemon has. I think it would be easiest for the Pokemon to have set moves.
Pokemon(int level): constructor sets the level of the pokemon. Other functions set/determine the other variables.
TODO: add functions to reflect set functions for base variables, etc
void setIVs(): function sets IVs to random number between 0 and 15. Calls to setIV_HP().
void intiEVs(): function initializes EVs to 0.
void updateEV_A(int): updates EV_A by adding the integer passed. allows for EVs to be updated based on the base stats of the pokemon they beat.
void updateEV_D(int)
void updateEV_Speed(int)
void updateEV_Spec(int)
void setIV_HP(): This function should accurately calculated the IV_HP of a pokemon based on the other IV variables. TODO: change the function from declaring IV_HP from a random number between 0 and 15 to be a combination of the last binary digit of each of the IV variables. Need a way to convert binary to decimal and vice versa.
void setAttack(): this calculates the attack of a pokemon from base_A, IV_A, and EV_A using a specific formula.
void setDef(): this calculates the defense of a pokemon from base_D, IV_D, and EV_D using a specific formula.
void set_spec_A(): this calculates the special attack of a pokemon from base_Spec, IV_Spec, and EV_Spec using a specific formula.
void set_spec_D():this calculates the special defense of a pokemon from base_Spec, IV_Spec, and EV_Spec using a specific formula.
void setSpeed():this calculates the speed of a pokemon from base_Speed, IV_Speed, and EV_Speed using a specific formula.
void setHP():this calculates the attack of a pokemon from base_HP, IV_HP, and EV_HP using a specific formula.
int getAttack: returns the attack statistic of a pokemon. Will be used to calculate damage, etc.
int getDefense: returns the defense statistic of a pokemon.
int getSpecA(): returns the special attack of a pokemon.
int getSpecD(): returns the special defense of a pokemon.
int getSpeed(): returns the speed of a pokemon.
int getHP(): returns the HP or health of a pokemon.
int updateHP(int): updates the health of a pokemon. The integer it takes in will be the damage calculated on each turn of a battle. It will return a 0 if the pokemon has not fainted and a 1 if the pokemon faints and cannot be used further in battle without healing.
int getLevel(): returns the level of a pokemon.
void updateLevel(int): updates the level of a pokemon by increasing by int.
TODO: change this to be an accurate calculation of a level based on statistics.
string getType(): returns the string type
void setType(string): used in the types classes (currently Normal, electric, fire, water, grass)
void setBaseA(int): Called in species class to set a species base attack.
void setBaseD(int): Called in species class to set a species base defense.
void setBaseSpec(int): Called in species class to set a species base special.
void setBaseSpeed(int): Called in species class to set a species base speed.
void setBaseHP(int): Called in species class to set a species base HP (health).
TODO: Add a function that calls to update EVs maybe, updates statistics, maybe level, every time a pokemon has battled.
http://bulbapedia.bulbagarden.net/wiki/Stats http://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_base_stats_(Generation_I) http://bulbapedia.bulbagarden.net/wiki/Individual_values http://bulbapedia.bulbagarden.net/wiki/Effort_values