use of tk.ardentbot.utils.rpg.profiles.Profile in project Ardent by adamint.
the class Divorce method noArgs.
@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
Marriage marriage = Marry.getMarriage(user);
if (marriage == null)
sendTranslatedMessage("You're not married!", channel, user);
else {
sendTranslatedMessage("Are you sure you want to divorce this person? There's a 50% chance that half of your assets will be " + "transferred to them. Respond **yes** if you want to go through with the divorce, or **no** if not.", channel, user);
interactiveOperation(channel, message, responseMessage -> {
if (responseMessage.getContent().equalsIgnoreCase("yes")) {
r.db("data").table("marriages").filter(row -> row.g("user_one").eq(user.getId()).or(row.g("user_two").eq(user.getId()))).delete().run(connection);
sendTranslatedMessage("You're now single", channel, user);
boolean takeAllMoney = !new SecureRandom().nextBoolean();
if (takeAllMoney) {
Profile userProfile = Profile.get(user);
Profile divorceeProfile = Profile.get(UserUtils.getUserById(marriage.getUser_one().equals(user.getId()) ? marriage.getUser_two() : marriage.getUser_one()));
divorceeProfile.addMoney(userProfile.getMoney() / 2);
userProfile.removeMoney(userProfile.getMoney() / 2);
sendTranslatedMessage("Unlucky! Half of your assets were transferred to your ex.", channel, user);
}
} else
sendTranslatedMessage("Ok, cancelling the divorce, but you should probably go to couples' therapy.", channel, user);
});
}
}
use of tk.ardentbot.utils.rpg.profiles.Profile in project Ardent by adamint.
the class UserUtils method hasTierTwoPermissions.
public static boolean hasTierTwoPermissions(User user) {
String id = user.getId();
boolean normalPermissions = isStaff(user) || tierTwopatrons.contains(id) || tierThreepatrons.contains(id);
if (!normalPermissions) {
Profile profile = Profile.get(user);
for (Badge badge : profile.getBadges()) {
if (BadgesList.from(badge.getId()).getId().equalsIgnoreCase(BadgesList.PREMIUM_TRIAL.getId())) {
return true;
}
}
return false;
} else
return true;
}
use of tk.ardentbot.utils.rpg.profiles.Profile in project Ardent by adamint.
the class UserUtils method hasTierThreePermissions.
public static boolean hasTierThreePermissions(User user) {
String id = user.getId();
boolean normalPermissions = isStaff(user) || tierThreepatrons.contains(id);
if (!normalPermissions) {
Profile profile = Profile.get(user);
for (Badge badge : profile.getBadges()) {
if (BadgesList.from(badge.getId()).getId().equalsIgnoreCase(BadgesList.PREMIUM_TRIAL.getId())) {
return true;
}
}
return false;
} else
return true;
}
use of tk.ardentbot.utils.rpg.profiles.Profile in project Ardent by adamint.
the class TriviaGame method finish.
public void finish(Shard shard, Command command) throws Exception {
totalRounds = 9001;
final int bonus = 250;
final int perQuestion = 50;
Trivia.gamesInSession.remove(this);
Trivia.gamesSettingUp.remove(guildId);
Guild guild = shard.jda.getGuildById(guildId);
TextChannel channel = guild.getTextChannelById(textChannelId);
channel.sendMessage(displayScores(shard, command).build()).queue();
channel.sendMessage("Thanks for playing! You'll receive **$50** for every correct answer").queue();
Map<String, Integer> sorted = MapUtils.sortByValue(scores);
Iterator<Map.Entry<String, Integer>> iterator = sorted.entrySet().iterator();
int current = 0;
while (iterator.hasNext()) {
Map.Entry<String, Integer> entry = iterator.next();
User user = guild.getMemberById(entry.getKey()).getUser();
Profile profile = Profile.get(user);
profile.addMoney(perQuestion * entry.getValue());
if (current == 0 && !isSolo() && scores.size() > 1) {
profile.addMoney(bonus);
channel.sendMessage(user.getAsMention() + ", you won a **$250** bonus for being so smart!").queue();
}
current++;
}
}
use of tk.ardentbot.utils.rpg.profiles.Profile in project Ardent by adamint.
the class ProfileUpdater method updateProfiles.
public static void updateProfiles() {
Cursor<HashMap> profiles = r.db("data").table("profiles").run(connection);
profiles.forEach(hashMap -> {
Profile profile = asPojo(hashMap, Profile.class);
if (profile.getUser() == null && !Ardent.testingBot) {
r.table("profiles").get(profile.user_id).delete().run(connection);
return;
}
for (Iterator<Badge> iterator = profile.getBadges().iterator(); iterator.hasNext(); ) {
Badge badge = iterator.next();
if (badge.getExpirationEpochSeconds() < Instant.now().getEpochSecond() && badge.getExpirationEpochSeconds() != 1) {
User user = profile.getUser();
if (user != null) {
user.openPrivateChannel().queue(privateChannel -> {
Ardent.shard0.help.sendTranslatedMessage("Your badge with the ID of **" + badge.getName() + "** has " + "expired" + ".", privateChannel, user);
r.db("data").table("badges").filter(row -> row.g("user_id").eq(user.getId()).and(row.g("badge_id").eq(badge.getId()))).delete().run(connection);
iterator.remove();
});
}
}
}
});
}
Aggregations