use of pokeraidbot.domain.pokemon.Pokemon in project pokeraidbot by magnusmickelsson.
the class AlterRaidCommand method changePokemon.
// todo: move to service
public static void changePokemon(GymRepository gymRepository, LocaleService localeService, PokemonRepository pokemonRepository, RaidRepository raidRepository, CommandEvent commandEvent, Config config, User user, String userName, String newPokemonName, String... gymArguments) {
String whatToChangeTo;
StringBuilder gymNameBuilder;
String gymName;
Gym gym;
Raid raid;
whatToChangeTo = newPokemonName;
gymNameBuilder = new StringBuilder();
for (String arg : gymArguments) {
gymNameBuilder.append(arg).append(" ");
}
gymName = gymNameBuilder.toString().trim();
gym = gymRepository.search(user, gymName, config.getRegion());
Raid pokemonRaid = raidRepository.getActiveRaidOrFallbackToExRaid(gym, config.getRegion(), user);
final Pokemon pokemon = pokemonRepository.search(whatToChangeTo, user);
if (pokemonRaid.isExRaid()) {
throw new UserMessedUpException(userName, localeService.getMessageFor(LocaleService.EX_NO_CHANGE_POKEMON, localeService.getLocaleForUser(user)));
}
// Anybody should be able to report hatched eggs
if (!pokemonRaid.getPokemon().isEgg()) {
verifyPermission(localeService, commandEvent, user, pokemonRaid, config);
}
if (Utils.isRaidExPokemon(whatToChangeTo)) {
throw new UserMessedUpException(userName, localeService.getMessageFor(LocaleService.EX_CANT_CHANGE_RAID_TYPE, localeService.getLocaleForUser(user)));
}
raid = raidRepository.changePokemon(pokemonRaid, pokemon, commandEvent.getGuild(), config, user, "!raid change pokemon " + pokemon.getName() + " " + gymName);
commandEvent.reactSuccess();
removeOriginMessageIfConfigSaysSo(config, commandEvent);
LOGGER.info("Changed pokemon for raid: " + raid);
}
use of pokeraidbot.domain.pokemon.Pokemon in project pokeraidbot by magnusmickelsson.
the class PokemonRaidStrategyService method populateRaidInfoForBoss.
private void populateRaidInfoForBoss(PokemonRepository pokemonRepository, String pokemonName, String maxCp, int bossTier) {
final Pokemon pokemon = pokemonRepository.getByName(pokemonName.toUpperCase());
if (pokemon == null) {
LOGGER.warn("Exception when getting pokemon by name " + pokemonName + " - needs to be added to repo data file.");
return;
}
pokemonRaidInfo.put(pokemonName.toUpperCase(), new PokemonRaidInfo(pokemon, maxCp, bossTier));
}
use of pokeraidbot.domain.pokemon.Pokemon in project pokeraidbot by magnusmickelsson.
the class NewRaidExCommand method executeWithConfig.
@Override
protected void executeWithConfig(CommandEvent commandEvent, Config config) {
final User user = commandEvent.getAuthor();
final String[] args = commandEvent.getArgs().replaceAll("\\s{1,3}", " ").split(" ");
if (args.length < 3) {
throw new UserMessedUpException(user, localeService.getMessageFor(LocaleService.BAD_SYNTAX, localeService.getLocaleForUser(user), "!raid ex mewtwo 2017-11-11 10:00 solna platform"));
}
String pokemonName = args[0];
final Pokemon pokemon = pokemonRepository.search(pokemonName, user);
final Locale locale = localeService.getLocaleForUser(user);
if (!Utils.isRaidExPokemon(pokemon.getName())) {
throw new UserMessedUpException(user, localeService.getMessageFor(LocaleService.NOT_EX_RAID, locale, pokemonName));
}
String dateString = args[1];
String timeString = args[2];
LocalTime endsAtTime = Utils.parseTime(user, timeString, localeService);
LocalDate endsAtDate = Utils.parseDate(user, dateString, localeService);
LocalDateTime endsAt = LocalDateTime.of(endsAtDate, endsAtTime);
assertTimeNotInNoRaidTimespan(user, endsAtTime, localeService);
if (endsAtDate.isAfter(LocalDate.now().plusDays(20))) {
throw new UserMessedUpException(user, localeService.getMessageFor(LocaleService.EX_DATE_LIMITS, locale));
}
assertCreateRaidTimeNotBeforeNow(user, endsAt, localeService);
StringBuilder gymNameBuilder = new StringBuilder();
for (int i = 3; i < args.length; i++) {
gymNameBuilder.append(args[i]).append(" ");
}
String gymName = gymNameBuilder.toString().trim();
final Gym gym = gymRepository.search(user, gymName, config.getRegion());
final Raid raid = new Raid(pokemon, endsAt, gym, localeService, config.getRegion());
if (!raid.isExRaid()) {
throw new UserMessedUpException(user, localeService.getMessageFor(LocaleService.NOT_EX_RAID, locale, pokemonName));
}
raidRepository.newRaid(user, raid, commandEvent.getGuild(), config, "!raid ex " + raid.getPokemon().getName() + " " + printTimeIfSameDay(raid.getEndOfRaid()) + " " + gym.getName());
replyBasedOnConfig(config, commandEvent, localeService.getMessageFor(LocaleService.NEW_RAID_CREATED, locale, raid.toString(locale)));
}
use of pokeraidbot.domain.pokemon.Pokemon in project pokeraidbot by magnusmickelsson.
the class PokemonVsCommand method executeWithConfig.
@Override
protected void executeWithConfig(CommandEvent commandEvent, Config config) {
String pokemonName = commandEvent.getArgs();
final Pokemon pokemon = repo.search(pokemonName, commandEvent.getAuthor());
final RaidBossCounters counters = raidInfoService.getCounters(pokemon);
final String maxCp = raidInfoService.getMaxCp(pokemon);
StringBuilder builder = new StringBuilder();
final Locale localeForUser = localeService.getLocaleForUser(commandEvent.getAuthor());
builder.append("**").append(pokemon).append("**\n");
builder.append(localeService.getMessageFor(LocaleService.WEAKNESSES, localeForUser)).append(Utils.printWeaknesses(pokemon)).append("\n").append(localeService.getMessageFor(LocaleService.RESISTANT, localeForUser)).append(pokemon.getResistant());
if (counters != null) {
builder.append("\n");
appendBestCounters(counters, builder, localeForUser);
}
if (maxCp != null) {
builder.append("\nMax CP level 20 (100% IV): ").append(maxCp).append("\n");
}
replyBasedOnConfig(config, commandEvent, builder.toString());
}
use of pokeraidbot.domain.pokemon.Pokemon in project pokeraidbot by magnusmickelsson.
the class RaidOverviewCommand method getOverviewMessage.
private static String getOverviewMessage(Config config, LocaleService localeService, RaidRepository raidRepository, ClockService clockService, Locale locale, PokemonRaidStrategyService strategyService) {
Set<Raid> raids = raidRepository.getAllRaidsForRegion(config.getRegion());
StringBuilder stringBuilder = new StringBuilder();
if (raids.size() == 0) {
stringBuilder.append(localeService.getMessageFor(LocaleService.LIST_NO_RAIDS, locale));
} else {
StringBuilder exRaids = new StringBuilder();
stringBuilder.append("**").append(localeService.getMessageFor(LocaleService.CURRENT_RAIDS, locale));
stringBuilder.append(":**");
stringBuilder.append("\n").append(localeService.getMessageFor(LocaleService.RAID_DETAILS, locale)).append("\n");
Pokemon currentPokemon = null;
for (Raid raid : raids) {
final Pokemon raidBoss = raid.getPokemon();
if (!raid.isExRaid() && (currentPokemon == null || (!currentPokemon.equals(raidBoss)))) {
currentPokemon = raid.getPokemon();
final PokemonRaidInfo raidInfo = strategyService.getRaidInfo(currentPokemon);
stringBuilder.append("\n**").append(currentPokemon.getName()).append("**");
if (raidInfo != null && raidInfo.getBossTier() > 0) {
stringBuilder.append(" (").append(raidInfo.getBossTier()).append(")");
}
stringBuilder.append("\n");
}
final int numberOfPeople = raid.getNumberOfPeopleSignedUp();
final Gym raidGym = raid.getGym();
final Set<RaidGroup> groups = raidRepository.getGroups(raid);
if (!raid.isExRaid()) {
if (raidGym.isExGym()) {
stringBuilder.append("**").append(raidGym.getName()).append(Emotes.STAR + "**");
} else {
stringBuilder.append("*").append(raidGym.getName()).append("*");
}
stringBuilder.append(" ").append(printTimeIfSameDay(getStartOfRaid(raid.getEndOfRaid(), false))).append("-").append(printTime(raid.getEndOfRaid().toLocalTime()));
if (groups.size() < 1) {
stringBuilder.append(" (**").append(numberOfPeople).append("**)");
} else {
stringBuilder.append(raidRepository.listGroupsForRaid(raid, groups));
}
stringBuilder.append("\n");
} else {
exRaids.append("\n*").append(raidGym.getName());
exRaids.append("* ").append(localeService.getMessageFor(LocaleService.RAID_BETWEEN, locale, printTimeIfSameDay(getStartOfRaid(raid.getEndOfRaid(), true)), printTime(raid.getEndOfRaid().toLocalTime())));
if (groups.size() < 1) {
exRaids.append(" (**").append(numberOfPeople).append("**)");
} else {
exRaids.append(raidRepository.listGroupsForRaid(raid, groups));
}
}
}
final String exRaidList = exRaids.toString();
if (exRaidList.length() > 1) {
stringBuilder.append("\n**Raid-EX:**").append(exRaidList);
}
}
stringBuilder.append("\n\n").append(localeService.getMessageFor(LocaleService.UPDATED_EVERY_X, locale, LocaleService.asString(TimeUnit.SECONDS, locale), String.valueOf(60))).append(" ").append(localeService.getMessageFor(LocaleService.LAST_UPDATE, locale, printTime(clockService.getCurrentTime())));
return stringBuilder.toString();
}
Aggregations