private Pokemon createStarter(int speciesIndex) throws Exception {
/*
* Get the Pokemon species. Use getPokemonByName as once the
* species array gets to gen 3 it loses the pokedex numbering
*/
PokemonSpecies species = null;
switch(speciesIndex) {
case 1:
species = PokemonSpecies.getDefaultData().getPokemonByName("Bulbasaur");
break;
case 4:
species = PokemonSpecies.getDefaultData().getPokemonByName("Charmander");
break;
case 7:
species = PokemonSpecies.getDefaultData().getPokemonByName("Squirtle");
break;
case 152:
species = PokemonSpecies.getDefaultData().getPokemonByName("Chikorita");
break;
case 155:
species = PokemonSpecies.getDefaultData().getPokemonByName("Cyndaquil");
break;
case 158:
species = PokemonSpecies.getDefaultData().getPokemonByName("Totodile");
break;
case 252:
species = PokemonSpecies.getDefaultData().getPokemonByName("Treecko");
break;
case 255:
species = PokemonSpecies.getDefaultData().getPokemonByName("Torchic");
break;
case 258:
species = PokemonSpecies.getDefaultData().getPokemonByName("Mudkip");
break;
case 387:
species = PokemonSpecies.getDefaultData().getPokemonByName("Turtwig");
break;
case 390:
species = PokemonSpecies.getDefaultData().getPokemonByName("Chimchar");
break;
case 393:
species = PokemonSpecies.getDefaultData().getPokemonByName("Piplup");
break;
default:
species = PokemonSpecies.getDefaultData().getPokemonByName("Mudkip");
}
ArrayList<MoveListEntry> possibleMoves = new ArrayList<MoveListEntry>();
MoveListEntry[] moves = new MoveListEntry[4];
Random random = DataService.getBattleMechanics().getRandom();
for (int i = 0; i < species.getStarterMoves().length; i++) {
possibleMoves.add(DataService.getMovesList().getMove(
species.getStarterMoves()[i]));
}
for (int i = 1; i <= 5; i++) {
if (species.getLevelMoves().containsKey(i)) {
possibleMoves.add(DataService.getMovesList().getMove(
species.getLevelMoves().get(i)));
}
}
/*
* possibleMoves sometimes has null moves stored in it, get rid of them
*/
for(int i = 0; i < possibleMoves.size(); i++) {
if(possibleMoves.get(i) == null)
possibleMoves.remove(i);
}
/*
* Now the store the final set of moves for the Pokemon
*/
if (possibleMoves.size() <= 4) {
for (int i = 0; i < possibleMoves.size(); i++) {
moves[i] = possibleMoves.get(i);
}
} else {
MoveListEntry m = null;
for (int i = 0; i < 4; i++) {
if (possibleMoves.size() == 0) {
moves[i] = null;
} else {
while(m == null) {
m = possibleMoves.get(random.nextInt(possibleMoves
.size()));
}
moves[i] = m;
possibleMoves.remove(m);
m = null;
}
}
}
/*
* Get all possible abilities
*/
String [] abilities = species.getAbilities();
/* First select an ability randomly */
String ab = abilities[random.nextInt(abilities.length)];
/*
* Unfortunately, all Pokemon have two possible ability slots but some only have one.
* If the null slot was selected, select the other slot
*/
while(ab == null || ab.equalsIgnoreCase("")) {
ab = abilities[random.nextInt(abilities.length)];
}
/*
* Create the Pokemon object
*/
Pokemon starter = new Pokemon(
DataService.getBattleMechanics(),
species,
PokemonNature.N_QUIRKY,
ab,
null, (random.nextInt(100) > 87 ? Pokemon.GENDER_FEMALE
: Pokemon.GENDER_MALE), 5, new int[] {
random.nextInt(32), // IVs
random.nextInt(32), random.nextInt(32),
random.nextInt(32), random.nextInt(32),
random.nextInt(32) }, new int[] { 0, 0, 0, 0, 0, 0 }, //EVs
moves, new int[] { 0, 0, 0, 0 });
/* Attach their growth rate */
starter.setExpType(species.getGrowthRate());
/* Attach base experience */
starter.setBaseExp(species.getBaseEXP());
/* Set their current exp */
starter.setExp(DataService.getBattleMechanics().getExpForLevel(starter, 5));
/* Set their happiness */
starter.setHappiness(species.getHappiness());
/* Set their name as their species */
starter.setName(starter.getSpeciesName());
return starter;
}