Amy WOD: Pokemon

Part 1: The basic WOD

For this WOD you will implement Javascript classes to represent aspects of Pokemon Go.

The first class is called “Pokemon”. It has the following fields:

The second class is called “Pokedex”. It has the following fields:

The third class is called “Trainer”. It has the following fields:

The behaviors associated with your Pokemon Go system are:

Here is an example set of commands that illustrate the game so far:

const pikachu = new Pokemon("Pikachu", "Electric");
const squirtle = new Pokemon("Squirtle", "Water");
const charmander = new Pokemon("Charmander", "Fire");
const magikarp = new Pokemon("Magikarp", "Water");

const myPokedex = new Pokedex();
myPokedex.addPokemon(pikachu);
myPokedex.addPokemon(squirtle);
myPokedex.addPokemon(charmander);
myPokedex.addPokemon(magikarp);

console.log(myPokedex.findPokemon("Pikachu"));
// console prints:
//  Pokemon {name: "Pikachu", type: "Electric"}
console.log(myPokedex.findPokemon("Bulbasaur"));
// console prints:
//  Bulbasaur cannot be found in the pokedex.
const amy = new Trainer("Amy", myPokedex);
amy.catchPokemon("Pikachu");
amy.catchPokemon("Squirtle");
amy.catchPokemon("Charmander");
console.log(amy.getLevel());
// console prints:
//  You are level 2

Rx: < 20 min Av: 20-25 min Sd: 25-30 min DNF: 30+ min

Part 2: Let’s make this interesting

Once everyone has finished the WOD, here are some enhancements to provide more interesting behavior.

Make leveling up harder

To reach level 2, the Trainer needs at least one of each kind of Pokemon. To reach level 3, the Trainer needs at least two of each type (Electric, Water, Fire) of Pokemon. And so forth. Your code should allow Trainers to reach any level.

For example,

amy.catchPokemon("Pikachu"));
amy.catchPokemon("Pikachu"));
amy.catchPokemon("Charmander"));
amy.catchPokemon("Charmander"));
amy.catchPokemon("Squirtle"));
console.log(amy.getLevel());
// console prints:
//  You are level 2
amy.catchPokemon("Pikachu"));
console.log(amy.getLevel());
// console prints:
//  You are level 2
amy.catchPokemon("Magikarp"));
console.log(amy.getLevel());
// console prints:
//  You are level 3

Making catching a pokemon harder

Use a random number generator so that when the Trainer invokes the catch Pokemon method, it only actually results in catching a pokemon half the time. (See the FreeCodeCamp exercise on random number generation if you forgot how to use random numbers.)

amy.catchPokemon("Pikachu");
// console prints:
//  Pikachu has been caught!
amy.catchPokemon("Squirtle");
// console prints:
//  Squirtle got away!
amy.catchPokemon("Bulbasaur");
// console prints:
//  Bulbasaur has been caught!
amy.catchPokemon("Magikarp");
// console prints:
//  Magikarp got away!

Submission instructions

You do not have to submit this Amy WOD.


This page is also available via http://goo.gl/a4ZDVh