Search in sources :

Example 6 with Pokemon

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);
}
Also used : Locale(java.util.Locale) SignUp(pokeraidbot.domain.raid.signup.SignUp) User(net.dv8tion.jda.core.entities.User) MessageEmbed(net.dv8tion.jda.core.entities.MessageEmbed) Raid(pokeraidbot.domain.raid.Raid) EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) Gym(pokeraidbot.domain.gym.Gym) Pokemon(pokeraidbot.domain.pokemon.Pokemon)

Example 7 with Pokemon

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;
}
Also used : PokemonTypes(pokeraidbot.domain.pokemon.PokemonTypes) ArrayList(java.util.ArrayList) Pokemon(pokeraidbot.domain.pokemon.Pokemon) HashSet(java.util.HashSet)

Example 8 with Pokemon

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);
}
Also used : User(net.dv8tion.jda.core.entities.User) PokemonTrackingTarget(pokeraidbot.domain.tracking.PokemonTrackingTarget) Pokemon(pokeraidbot.domain.pokemon.Pokemon)

Example 9 with Pokemon

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);
}
Also used : User(net.dv8tion.jda.core.entities.User) Pokemon(pokeraidbot.domain.pokemon.Pokemon)

Example 10 with Pokemon

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));
}
Also used : PokemonTypes(pokeraidbot.domain.pokemon.PokemonTypes) Pokemon(pokeraidbot.domain.pokemon.Pokemon) Test(org.junit.Test)

Aggregations

Pokemon (pokeraidbot.domain.pokemon.Pokemon)22 Gym (pokeraidbot.domain.gym.Gym)11 User (net.dv8tion.jda.core.entities.User)10 Raid (pokeraidbot.domain.raid.Raid)10 LocalDateTime (java.time.LocalDateTime)6 Locale (java.util.Locale)6 UserMessedUpException (pokeraidbot.domain.errors.UserMessedUpException)6 Test (org.junit.Test)5 PokemonTypes (pokeraidbot.domain.pokemon.PokemonTypes)5 LocalTime (java.time.LocalTime)4 PokemonRaidInfo (pokeraidbot.domain.pokemon.PokemonRaidInfo)4 EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)3 MessageEmbed (net.dv8tion.jda.core.entities.MessageEmbed)3 RaidGroup (pokeraidbot.infrastructure.jpa.raid.RaidGroup)3 LocalDate (java.time.LocalDate)2 SignUp (pokeraidbot.domain.raid.signup.SignUp)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 SelfUser (net.dv8tion.jda.core.entities.SelfUser)1 GuildMessageReceivedEvent (net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent)1