use of pokeraidbot.infrastructure.jpa.raid.RaidEntitySignUp in project pokeraidbot by magnusmickelsson.
the class RaidRepository method removeFromSignUp.
public Raid removeFromSignUp(String raidId, User user, int mystic, int instinct, int valor, int plebs, LocalDateTime startAt) {
RaidEntity raidEntity = findEntityByRaidId(raidId);
if (raidEntity == null) {
throw new UserMessedUpException(user, localeService.getMessageFor(LocaleService.NO_RAID_AT_GYM, localeService.getLocaleForUser(user)));
}
RaidEntitySignUp signUp = raidEntity.getSignUp(user.getName());
final String startAtTime = Utils.printTime(startAt.toLocalTime());
if (signUp == null) {
// Ignore this case, when there is no signup to remove from. Silent ignore.
} else if (startAtTime.equals(signUp.getEta())) {
final int sum = signUp.getNumberOfPeople() - mystic - instinct - valor - plebs;
if (sum <= 0) {
// Remove signup
raidEntity.removeSignUp(signUp);
} else {
signUp.setNumberOfPeople(sum, localeService, user);
}
raidEntity = raidEntityRepository.save(raidEntity);
} else {
// Ignore if they're trying to remove signups for a group they're no longer signed up for - we let them untick their emote
}
return getRaidInstance(raidEntity);
}
Aggregations