Pokemon Class library

Dependents:   2645_Game_Project_2

Revision:
7:5e2a3c3e2380
Parent:
5:30f8eda741db
Child:
8:b6c9e09401cc
--- a/Pokemon.cpp	Wed May 03 20:56:09 2017 +0000
+++ b/Pokemon.cpp	Wed May 03 21:44:13 2017 +0000
@@ -9,12 +9,14 @@
 
 Pokemon::Pokemon(void)
 {
+    //Standard layout for adding information to the class
     Pokemon(5,20,Fire);
 }
 
 
 Pokemon::Pokemon(uns lvl, uns HP, PokeType type)
 {
+    //setting the information given from the use of this function to use in the class
     level = lvl;
     healthPoints = HP;
     typing = type;
@@ -24,6 +26,7 @@
 
 void Pokemon::setType(PokeType Type)
 {
+    //initial setup of partner pokemon
     typing = Type;
     healthPoints = 20;
     level = 5;
@@ -33,6 +36,7 @@
 
 void Pokemon::levelUp()
 {
+    //increasing the value of the level and Health point variables, and resetting the exp variable when pokemon levels up
     level ++;
     healthPoints += 2;
     exp = 0;
@@ -40,7 +44,7 @@
 
 std::string Pokemon::Name(void)
 {
-
+    //copying the Pokemon name to a character buffer
     char name[25];
     strncpy(name,pokeNames[typing].c_str(), sizeof(name));
     return name;
@@ -48,6 +52,7 @@
 
 std::string Pokemon::Type(void)
 {
+    //copying the Pokemon Type to a character buffer
     char typ[15];
     strncpy(typ,TypeString[typing].c_str(), sizeof(typ));
     char typeBuffer[30];
@@ -57,6 +62,7 @@
 
 std::string Pokemon::HP(void)
 {
+    //copying the Pokemon Health Point stat to a character buffer
     char stats[50];
     sprintf(stats, "HP: %u", healthPoints);
     return stats;
@@ -64,6 +70,7 @@
 
 std::string Pokemon::Level(void)
 {
+    //copying the Pokemon level to a character buffer
     char levels[50];
     sprintf(levels, "Lvl:%u", level);
     return levels;
@@ -71,32 +78,41 @@
 
 int Pokemon::OpponentTurn(Pokemon e)
 {
+    //setting starting damage to 2 less than Pokemon level
     int damage1 = e.level-2;
+    //comparing Pokemon types and Adjusting damage accordingly
     if ((e.typing == Fire && typing == Water )|| (e.typing == Grass && typing == Fire) || (e.typing == Water && typing == Grass)) {//half damage
         damage1 = 0.5 * damage1;
     } else if ((e.typing == Fire && typing == Grass)||(e.typing == Grass && typing == Water)||(e.typing == Water && typing == Fire)) {//double damage
         damage1 = 2 * damage1;
     }
+    //returning final value for damage
     return damage1;
 }
 
 
 int Pokemon::YourTurn(Pokemon e)
 {
+     //setting starting damage to 2 less than Pokemon level
     int damage2 = level -2;
+    //comparing Pokemon types and Adjusting damage accordingly
     if ((e.typing == Fire && typing == Water )|| (e.typing == Grass && typing == Fire) || (e.typing == Water && typing == Grass)) {//double damage
         damage2 = 2 * damage2;
     } else if ((e.typing == Fire && typing == Grass)||(e.typing == Grass && typing == Water)||(e.typing == Water && typing == Fire)) {//half damage
         damage2 = 0.5 * damage2;
     }
+    //returning final value for damage
     return damage2;
 }
 
 void Pokemon::win(N5110 &lcd)
 {
+    //increasing exp by 2 for a win
     exp = exp + 20;
+    //Checking for level up
     if (exp >= lvlUp) {
         Pokemon::levelUp();
+        //increasing value of exp needed for level up 
         lvlUp = lvlUp + 10;
         wait(1.0);
         lcd.clear();
@@ -108,12 +124,14 @@
 
 int Pokemon::HPO(Pokemon e)
 {
+    //getting value for healthpoints
     int HP1 = e.healthPoints;
     return HP1;
 }
 
 int Pokemon::HPA()
 {
+    //getting value for healthpoints
     int HP2 = healthPoints;
     return HP2;
 }
\ No newline at end of file