use of pokeraidbot.domain.pokemon.PokemonTypes in project pokeraidbot by magnusmickelsson.
the class CSVPokemonDataReader method readAll.
public Set<Pokemon> readAll() {
String line;
Set<Pokemon> pokemons = new HashSet<>();
try {
final InputStream resourceAsStream = CSVPokemonDataReader.class.getResourceAsStream(resourceName);
if (resourceAsStream == null) {
throw new FileNotFoundException(resourceName);
}
final InputStreamReader inputStreamReader = new InputStreamReader(resourceAsStream, "UTF-8");
BufferedReader br = new BufferedReader(inputStreamReader);
while ((line = br.readLine()) != null) {
String[] rowElements = line.split(GymDataImportTool.separator);
if (rowElements[0].equalsIgnoreCase("Ndex")) {
// This is the header of the file, ignore
} else {
String id = rowElements[0].trim();
String name = rowElements[1].trim();
String type1 = rowElements[2].trim();
String type2 = rowElements[3].trim();
List<String> types = new ArrayList<>();
if (!type1.equalsIgnoreCase("None")) {
types.add(type1);
}
if (!type2.equalsIgnoreCase("None")) {
types.add(type2);
}
final PokemonTypes pokemonTypes = new PokemonTypes(types);
Pokemon pokemon = new Pokemon(Integer.parseInt(id), name, "About not used", pokemonTypes, "", Utils.getWeaknessesFor(pokemonTypes), Utils.getResistantTo(pokemonTypes));
pokemons.add(pokemon);
}
}
} catch (IOException e) {
LOGGER.error("Error while trying to open pokemon file " + resourceName + ": " + e.getMessage());
}
LOGGER.info("Parsed " + pokemons.size() + " pokemons from \"" + resourceName + "\".");
return pokemons;
}
use of pokeraidbot.domain.pokemon.PokemonTypes in project pokeraidbot by magnusmickelsson.
the class PokemonRepositoryTest method testGetRaikouWithFuzzySearch.
@Test
public void testGetRaikouWithFuzzySearch() throws Exception {
Pokemon pokemon = pokemonRepository.search("Raikou", null);
assertThat(pokemon != null, is(true));
assertThat(pokemon.getTypes(), is(new PokemonTypes("Electric")));
Pokemon search = pokemonRepository.search("Riakuo", null);
assertThat(search, is(pokemon));
}
use of pokeraidbot.domain.pokemon.PokemonTypes in project pokeraidbot by magnusmickelsson.
the class PokemonRepositoryTest method testGetTyranitarWithFuzzySearch.
@Test
public void testGetTyranitarWithFuzzySearch() throws Exception {
Pokemon pokemon = pokemonRepository.search("Tyranitar", null);
assertThat(pokemon != null, is(true));
assertThat(pokemon.getTypes(), is(new PokemonTypes("Dark", "Rock")));
Pokemon search = pokemonRepository.search("Tryantar", null);
assertThat(search, is(pokemon));
}
use of pokeraidbot.domain.pokemon.PokemonTypes in project pokeraidbot by magnusmickelsson.
the class PokemonRepositoryTest method testGetRaikouWithFuzzySearchFirstChars.
@Test
public void testGetRaikouWithFuzzySearchFirstChars() throws Exception {
Pokemon pokemon = pokemonRepository.search("Raikou", null);
assertThat(pokemon != null, is(true));
assertThat(pokemon.getTypes(), is(new PokemonTypes("Electric")));
Pokemon search = pokemonRepository.search("Raik", null);
assertThat(search, is(pokemon));
assertThat(pokemon.isEgg(), is(false));
}
use of pokeraidbot.domain.pokemon.PokemonTypes in project pokeraidbot by magnusmickelsson.
the class PokemonRepositoryTest method assertEggExistsForTier.
private void assertEggExistsForTier(String eggName, String eggSearchName, int eggTier) {
Pokemon pokemon = pokemonRepository.search(eggName + eggTier, null);
assertThat(pokemon != null, is(true));
assertThat(pokemon.getTypes(), is(new PokemonTypes()));
Pokemon search = pokemonRepository.search(eggSearchName + eggTier, null);
assertThat(search, is(pokemon));
assertThat(pokemon.isEgg(), is(true));
}
Aggregations