Pokemon Class library

Dependents:   2645_Game_Project_2

Committer:
200923317
Date:
Thu Apr 20 15:34:33 2017 +0000
Revision:
1:7b0bc092dbe5
Parent:
0:1fa2aa6d65e8
Child:
2:bbd4389980c3
1;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
200923317 0:1fa2aa6d65e8 1 #include "Pokemon.h"
200923317 0:1fa2aa6d65e8 2 #include "mbed.h"
200923317 0:1fa2aa6d65e8 3 #include "N5110.h"
200923317 0:1fa2aa6d65e8 4 #include "Gamepad.h"
200923317 1:7b0bc092dbe5 5 #include "Sprites.h"
200923317 0:1fa2aa6d65e8 6 std::string pokeNames[3] = {"Charmander","Bulbasaur","Squirtle"};
200923317 0:1fa2aa6d65e8 7 std::string TypeString[3] = {"Fire", "Grass", "Water"};
200923317 0:1fa2aa6d65e8 8
200923317 0:1fa2aa6d65e8 9 Pokemon::Pokemon(void)
200923317 0:1fa2aa6d65e8 10 {
200923317 0:1fa2aa6d65e8 11 Pokemon(5,20,Fire);
200923317 0:1fa2aa6d65e8 12 }
200923317 0:1fa2aa6d65e8 13
200923317 0:1fa2aa6d65e8 14
200923317 0:1fa2aa6d65e8 15 Pokemon::Pokemon(uns lvl, uns HP, PokeType type)
200923317 0:1fa2aa6d65e8 16 {
200923317 0:1fa2aa6d65e8 17 level = lvl;
200923317 0:1fa2aa6d65e8 18 healthPoints = HP;
200923317 0:1fa2aa6d65e8 19 typing = type;
200923317 0:1fa2aa6d65e8 20 lvlUp = 20;
200923317 0:1fa2aa6d65e8 21 }
200923317 0:1fa2aa6d65e8 22
200923317 0:1fa2aa6d65e8 23
200923317 0:1fa2aa6d65e8 24 void Pokemon::setType(PokeType Type)
200923317 0:1fa2aa6d65e8 25 {
200923317 0:1fa2aa6d65e8 26 typing = Type;
200923317 0:1fa2aa6d65e8 27 healthPoints = 20;
200923317 0:1fa2aa6d65e8 28 level = 5;
200923317 0:1fa2aa6d65e8 29
200923317 0:1fa2aa6d65e8 30 }
200923317 0:1fa2aa6d65e8 31
200923317 0:1fa2aa6d65e8 32 void Pokemon::XP()
200923317 0:1fa2aa6d65e8 33 {
200923317 0:1fa2aa6d65e8 34 if (exp >= lvlUp) {
200923317 0:1fa2aa6d65e8 35 Pokemon::levelUp();
200923317 0:1fa2aa6d65e8 36 lvlUp = lvlUp + 15;
200923317 0:1fa2aa6d65e8 37 }
200923317 0:1fa2aa6d65e8 38 }
200923317 0:1fa2aa6d65e8 39
200923317 0:1fa2aa6d65e8 40 void Pokemon::levelUp()
200923317 0:1fa2aa6d65e8 41 {
200923317 0:1fa2aa6d65e8 42 level ++;
200923317 0:1fa2aa6d65e8 43 healthPoints += 2;
200923317 0:1fa2aa6d65e8 44 exp = 0;
200923317 0:1fa2aa6d65e8 45 }
200923317 0:1fa2aa6d65e8 46
200923317 0:1fa2aa6d65e8 47 std::string Pokemon::Name(void)
200923317 0:1fa2aa6d65e8 48 {
200923317 0:1fa2aa6d65e8 49
200923317 0:1fa2aa6d65e8 50 char name[25];
200923317 0:1fa2aa6d65e8 51 strncpy(name,pokeNames[typing].c_str(), sizeof(name));
200923317 0:1fa2aa6d65e8 52 return name;
200923317 0:1fa2aa6d65e8 53 }
200923317 0:1fa2aa6d65e8 54
200923317 0:1fa2aa6d65e8 55 std::string Pokemon::Type(void)
200923317 0:1fa2aa6d65e8 56 {
200923317 0:1fa2aa6d65e8 57 char typ[15];
200923317 0:1fa2aa6d65e8 58 strncpy(typ,TypeString[typing].c_str(), sizeof(typ));
200923317 0:1fa2aa6d65e8 59 char typeBuffer[30];
200923317 0:1fa2aa6d65e8 60 sprintf(typeBuffer, "Type: %s", typ);
200923317 0:1fa2aa6d65e8 61 return typeBuffer;
200923317 0:1fa2aa6d65e8 62 }
200923317 0:1fa2aa6d65e8 63
200923317 0:1fa2aa6d65e8 64 std::string Pokemon::HP(void)
200923317 0:1fa2aa6d65e8 65 {
200923317 0:1fa2aa6d65e8 66 char stats[50];
200923317 0:1fa2aa6d65e8 67 sprintf(stats, "HP: %u", healthPoints);
200923317 0:1fa2aa6d65e8 68 return stats;
200923317 0:1fa2aa6d65e8 69 }
200923317 0:1fa2aa6d65e8 70
200923317 0:1fa2aa6d65e8 71 std::string Pokemon::Level(void)
200923317 0:1fa2aa6d65e8 72 {
200923317 0:1fa2aa6d65e8 73 char levels[50];
200923317 0:1fa2aa6d65e8 74 sprintf(levels, "Lvl:%u", level);
200923317 0:1fa2aa6d65e8 75 return levels;
200923317 0:1fa2aa6d65e8 76 }
200923317 0:1fa2aa6d65e8 77
200923317 0:1fa2aa6d65e8 78 int Pokemon::attck(Pokemon e)
200923317 0:1fa2aa6d65e8 79 {
200923317 0:1fa2aa6d65e8 80
200923317 0:1fa2aa6d65e8 81 }
200923317 0:1fa2aa6d65e8 82