You can write some structs like this:
// A separate struct for stats allow you to add and remove
// stats parameters without touch pokemon struct.
struct stats
{
int hp;
int attack;
int defense;
};
typedef struct stats stats_t;
struct pokemon
{
string name;
stats_t stats;
// You can also add some behaviour to your pokemons.
void defend_from_attack(int incomming_attack)
{
// And for instance.
stats.defense -= incomming_attack;
}
void attack(pokemon attacked_pokemon)
{
attacked_pokemon.defend_from_attack(stats.attack);
}
// This is cool right?
void evolve(stats_t new_stats)
{
stats = new_stats;
}
}
All you need now is a function that reads the file (or files) where you put your pokemon's stats. If you're using YAML is even easier. That function has to read the file and return an instance of pokemon
with the required data.
The following example follows your seudocode:
// Assume the YAML file has been open.
// find string with name "pikachu"
struct pokemon pikachu;
// find defense for pokemon pikachu
// defense = pikachu defense
pikachu.stats.defense = defense;
//find HP for pokemon pikachu
//HP = pikachu HP
pikachu.stats.hp = HP;
//find attack for pokemon pikachu
//attack = pikachu attack
pikachu.stats.attack = attack;
Implementing that function is up to you, I think you must already have an idea of how to doit.