use of pokeraidbot.domain.pokemon.Pokemon in project pokeraidbot by magnusmickelsson.
the class RaidStatusCommand method executeWithConfig.
@Override
protected void executeWithConfig(CommandEvent commandEvent, Config config) {
String gymName = commandEvent.getArgs();
final User user = commandEvent.getAuthor();
final Gym gym = gymRepository.search(user, gymName, config.getRegion());
final Raid raid = raidRepository.getActiveRaidOrFallbackToExRaid(gym, config.getRegion(), user);
final Set<SignUp> signUps = raid.getSignUps();
final int numberOfPeople = raid.getNumberOfPeopleSignedUp();
final Locale localeForUser = localeService.getLocaleForUser(user);
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor(null, null, null);
final Pokemon pokemon = raid.getPokemon();
embedBuilder.setTitle(localeService.getMessageFor(LocaleService.RAIDSTATUS, localeForUser, gym.getName() + (gym.isExGym() ? Emotes.STAR + "" : "")), Utils.getNonStaticMapUrl(gym));
StringBuilder sb = new StringBuilder();
final String activeText = localeService.getMessageFor(LocaleService.ACTIVE, localeForUser);
final String startGroupText = localeService.getMessageFor(LocaleService.START_GROUP, localeForUser);
final String findYourWayText = localeService.getMessageFor(LocaleService.FIND_YOUR_WAY, localeForUser);
final String raidBossText = localeService.getMessageFor(LocaleService.RAID_BOSS, localeForUser);
final Set<String> signUpNames = getNamesOfThoseWithSignUps(raid.getSignUps(), true);
final String allSignUpNames = StringUtils.join(signUpNames, ", ");
sb.append(raidBossText).append(" **").append(pokemon).append("** - ").append("*!raid vs ").append(pokemon.getName()).append("*\n");
sb.append("**").append(activeText).append(":** ").append(printTimeIfSameDay(getStartOfRaid(raid.getEndOfRaid(), false))).append("-").append(printTimeIfSameDay(raid.getEndOfRaid())).append("\t**").append(numberOfPeople).append(" ").append(localeService.getMessageFor(LocaleService.SIGNED_UP, localeForUser)).append("**").append(signUps.size() > 0 ? ":\n" + allSignUpNames : "").append("\n").append(startGroupText).append(":\n*!raid group ").append(printTime(raid.getEndOfRaid().toLocalTime().minusMinutes(15))).append(" ").append(gymName).append("*\n\n");
sb.append(localeService.getMessageFor(LocaleService.CREATED_BY, localeForUser)).append(": ").append(raid.getCreator());
embedBuilder.setFooter(findYourWayText + localeService.getMessageFor(LocaleService.GOOGLE_MAPS, localeService.getLocaleForUser(user)), Utils.getPokemonIcon(pokemon));
embedBuilder.setDescription(sb.toString());
final MessageEmbed messageEmbed = embedBuilder.build();
replyBasedOnConfig(config, commandEvent, messageEmbed);
}
use of pokeraidbot.domain.pokemon.Pokemon 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.Pokemon in project pokeraidbot by magnusmickelsson.
the class UnTrackPokemonCommand method executeWithConfig.
@Override
protected void executeWithConfig(CommandEvent commandEvent, Config config) {
String args = commandEvent.getArgs();
final String userId = commandEvent.getAuthor().getId();
final User user = commandEvent.getAuthor();
if (args == null || args.length() < 1) {
trackingService.removeAllForUser(user);
commandEvent.reactSuccess();
} else {
Pokemon pokemon = pokemonRepository.search(args, user);
trackingService.removeForUser(new PokemonTrackingTarget(userId, pokemon), user);
commandEvent.reactSuccess();
}
removeOriginMessageIfConfigSaysSo(config, commandEvent);
}
use of pokeraidbot.domain.pokemon.Pokemon in project pokeraidbot by magnusmickelsson.
the class TrackPokemonCommand method executeWithConfig.
@Override
protected void executeWithConfig(CommandEvent commandEvent, Config config) {
String args = commandEvent.getArgs();
Pokemon pokemon = pokemonRepository.search(args, commandEvent.getAuthor());
final User user = commandEvent.getAuthor();
trackingService.add(pokemon, user, config);
commandEvent.reactSuccess();
removeOriginMessageIfConfigSaysSo(config, commandEvent);
}
use of pokeraidbot.domain.pokemon.Pokemon 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));
}
Aggregations