use of pokeraidbot.domain.gym.Gym 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();
}
use of pokeraidbot.domain.gym.Gym 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.gym.Gym in project pokeraidbot by magnusmickelsson.
the class GymCommands method executeWithConfig.
@Override
protected void executeWithConfig(CommandEvent event, Config config) {
final User user = event.getAuthor();
final String eventArgs = event.getArgs();
if (!isUserServerMod(event, config) && !isUserAdministrator(event)) {
throw new UserMessedUpException(user, localeService.getMessageFor(LocaleService.NO_PERMISSION, localeService.getLocaleForUser(user)));
}
if (eventArgs.startsWith("get ")) {
String gymName = eventArgs.replaceAll("get\\s{1,3}", "").trim();
final Gym gym = gymRepository.findByName(gymName, config.getRegion());
replyBasedOnConfig(config, event, "Found gym: " + gym.toStringDetails());
} else {
String[] gymArgs = eventArgs.replaceAll("gym\\s{1,3}", "").trim().split(";");
if (gymArgs == null || gymArgs.length < 4 || gymArgs.length > 4) {
replyBasedOnConfig(config, event, "Bad syntax, should be: !raid gym add {gymname};{latitude};{longitude};{exgym true or false");
return;
} else {
final Random random = new Random();
random.setSeed(System.currentTimeMillis());
Gym gym = new Gym(gymArgs[0], "" + random.nextInt(99999999), gymArgs[1], gymArgs[2], config.getRegion(), Boolean.valueOf(gymArgs[3]));
gymRepository.addTemporary(user, gym, config.getRegion());
replyBasedOnConfig(config, event, "Gym added temporarily: " + gym.toStringDetails());
}
}
}
use of pokeraidbot.domain.gym.Gym in project pokeraidbot by magnusmickelsson.
the class RemoveSignUpCommand method executeWithConfig.
@Override
protected void executeWithConfig(CommandEvent commandEvent, Config config) {
final User user = commandEvent.getAuthor();
final String userName = user.getName();
final Locale localeForUser = localeService.getLocaleForUser(user);
String gymName = commandEvent.getArgs();
final Gym gym = gymRepository.search(user, gymName, config.getRegion());
final Raid raid = raidRepository.getActiveRaidOrFallbackToExRaid(gym, config.getRegion(), user);
final SignUp removed = raid.remove(user, raidRepository);
if (removed != null) {
commandEvent.reactSuccess();
removeOriginMessageIfConfigSaysSo(config, commandEvent);
} else {
final String message = localeService.getMessageFor(LocaleService.NO_SIGNUP_AT_GYM, localeForUser, userName, gym.getName());
replyErrorBasedOnConfig(config, commandEvent, new UserMessedUpException(user, message));
}
}
use of pokeraidbot.domain.gym.Gym in project pokeraidbot by magnusmickelsson.
the class WhereIsGymInChatCommand method executeWithConfig.
@Override
protected void executeWithConfig(CommandEvent commandEvent, Config config) {
String gymName = commandEvent.getArgs();
final Gym gym = gymRepository.search(commandEvent.getAuthor(), gymName, config.getRegion());
String staticUrl = Utils.getStaticMapUrl(gym);
String nonStaticUrl = Utils.getNonStaticMapUrl(gym);
final MessageEmbed messageEmbed = new EmbedBuilder().setImage(staticUrl).setTitle(gym.getName(), nonStaticUrl).build();
replyMapInChat(config, commandEvent, messageEmbed);
}
Aggregations