use of gartham.c10ver.economy.users.EconomyUser in project c10ver by Gartham.
the class VoteManager method handleVoteRoleAdded.
public void handleVoteRoleAdded(Member member) {
Instant voteTime = Instant.now();
List<ItemBunch<?>> items = new ArrayList<>();
items.add(new ItemBunch<>(new WeeklyCrate(), Math.random() > 0.5 ? 3 : 2));
if (Math.random() > 0.5)
items.add(new ItemBunch<>(new MonthlyCrate()));
if (Math.random() > 0.95)
items.add(new ItemBunch<>(new DailyCrate(), 50));
items.add(new ItemBunch<>(new NormalCrate(), (long) (Math.random() * 5 + 3)));
items.add(new ItemBunch<>(new Pizza(), (long) (Math.random() * 5 + 3)));
items.add(new ItemBunch<>(new Sandwich(), (long) (Math.random() * 7 + 3)));
items.add(new ItemBunch<>(new Hamburger(), (long) (Math.random() * 2 + 4)));
items.add(new ItemBunch<>(new VoteToken(Type.NORMAL), 5));
Map<AbstractMultiplier, Integer> multipliers = new HashMap<>();
if (Math.random() > 0.2)
multipliers.put(AbstractMultiplier.ofHr(12, BigDecimal.valueOf(2, 1)), 1);
if (Math.random() > 0.3)
multipliers.put(AbstractMultiplier.ofHr(12, BigDecimal.valueOf(3, 1)), 1);
if (Math.random() > 0.5)
multipliers.put(AbstractMultiplier.ofHr(12, BigDecimal.valueOf(5, 1)), 1);
EconomyUser u = clover.getEconomy().getUser(member.getId());
u.incrementVoteCount();
var rec = u.reward(RewardsOperation.build(u, member.getGuild(), BigInteger.valueOf((long) (Math.random() * 3000 + 5000)), multipliers, items));
var s = clover.getEconomy().getServer(member.getGuild().getId());
EmbedBuilder embed = new EmbedBuilder().setAuthor(member.getUser().getAsTag() + " just voted!", null, member.getUser().getEffectiveAvatarUrl()).setDescription(member.getUser().getAsMention() + " just voted and received:\n" + Utilities.listRewards(rec) + "\n\nYou can [vote on top.gg by clicking me](https://top.gg/servers/" + member.getGuild().getId() + "/vote).");
MessageChannel channel = s.getVoteChannel() != null ? member.getGuild().getTextChannelById(s.getVoteChannel()) : member.getUser().openPrivateChannel().complete();
if (u.getSettings().isVoteRemindersEnabled()) {
scheduleReminder(member, s, voteTime);
channel.sendMessageEmbeds(embed.setFooter("----> You currently have vote reminders enabled. Disable them with: ~settings vr false <----").build()).queue();
} else
channel.sendMessageEmbeds(embed.setFooter("You can automatically be reminded when it's time to vote by reacting to this message! (Click the alarm clock.)").build()).queue((Consumer<? super Message>) t -> {
t.addReaction("\u23F0").queue();
clover.getEventHandler().getReactionAdditionProcessor().registerInputConsumer(((MessageReactionInputConsumer<MessageReactionAddEvent>) (event, b, consumer) -> {
if (event.getReactionEmote().isEmoji() && event.getReactionEmote().getEmoji().equals("\u23F0")) {
clover.getEventHandler().getReactionAdditionProcessor().removeInputConsumer(consumer);
channel.sendMessage(member.getAsMention() + " vote reminders are now enabled for you! To turn them off, run the command: `~settings vr false`.").queue();
scheduleReminder(member, s, voteTime);
setVotingRemindersEnabled(u, s.getServerID(), true);
return true;
} else
return false;
}).expires(Instant.now().plusSeconds(180)).filter(member.getUser(), channel));
});
}
use of gartham.c10ver.economy.users.EconomyUser in project c10ver by Gartham.
the class Bomb method consume.
public void consume(MessageReceivedEvent event, Clover clover) {
// TODO Link with a volatile boolean map (or the like) to assert that the same
// bomb isn't "consumed" twice.
event.getGuild().findMembers(a -> !a.getUser().isBot()).onSuccess(t -> {
BigInteger tot = BigInteger.ZERO;
for (var x : t) {
EconomyUser user = clover.getEconomy().getUser(x.getId());
var rec = user.reward(RewardsOperation.build(user, event.getGuild(), BigInteger.valueOf((int) (Math.random() * 200) + 50)));
tot = tot.add(rec.getRewards().getRewardedCloves());
}
event.getChannel().sendMessage(event.getAuthor().getAsMention() + " just used a bomb! It exploded into a total of " + Utilities.format(tot) + " cloves!").queue();
});
}
use of gartham.c10ver.economy.users.EconomyUser in project c10ver by Gartham.
the class DungeonGame method startDungeon.
private void startDungeon(ButtonClickEvent e) {
// This is broken lmao.
t = e.getMessage();
// try {
// Thread.sleep((long) (Math.random() * 3500 + 1500));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
var dungeon = Dungeon.simpleEasyDungeon();
var initialRoom = dungeon.getInitialRoom();
var dirsel = new CustomDirsel();
dirsel.disableDirections();
for (var d : initialRoom.getConnectionDirectionsUnmodifiable()) dirsel.enable(d);
var inp = new InputConsumer<ButtonClickEvent>() {
DungeonRoom currentRoom = initialRoom;
@Override
public boolean consume(ButtonClickEvent event, InputProcessor<? extends ButtonClickEvent> processor, InputConsumer<ButtonClickEvent> consumer) {
if (event.getMessageIdLong() != t.getIdLong())
return false;
if (event.getUser().getIdLong() != target.getIdLong()) {
event.reply("That's not for you. >:(").setEphemeral(true).queue();
return true;
}
if (event.getComponentId().equals("act")) {
if (currentRoom.isClaimed()) {
event.reply("You already collected the loot from this room... (You're not supposed to be able to click that button again!)").setEphemeral(true).queue();
return true;
}
currentRoom.setClaimed(true);
var user = clover.getEconomy().getUser(target.getId());
Receipt receipt;
var lr = (LootRoom) currentRoom;
receipt = user.reward(lr.getRewards().autoSetMultipliers(user, channel.getType().isGuild() ? ((GuildChannel) channel).getGuild() : null));
currentRoom.prepare(dirsel, "act");
event.editComponents(dirsel.actionRows()).queue();
t.reply(target.getAsMention() + ", you earned:\n\n" + Utilities.listRewards(receipt)).queue();
// Resend message? Send ephemeral rewards?
} else if (event.getComponentId().equals("repeat")) {
var dsn = new CustomDirsel();
dsn.disableManaged();
var s = channel.sendMessageEmbeds(event.getMessage().getEmbeds()).setActionRows(event.getMessage().getActionRows());
event.editComponents(dsn.actionRows()).queue(x -> s.queue(q -> t = q));
} else {
var dir = DirectionSelector.getDirectionSelected(event);
currentRoom = currentRoom.getRoom(dir);
if (currentRoom == null) {
// Player moved in the wrong direction.
event.reply("You are not supposed to be able to click that!").setEphemeral(true).queue();
return true;
// processor.removeInputConsumer(consumer);
} else if (!currentRoom.isClaimed() && currentRoom instanceof EnemyRoom) {
dirsel.reset();
dirsel.disableManaged();
event.editComponents(dirsel.actionRows()).setContent("**You got into a fight!!!**").setEmbeds(new EmbedBuilder().setColor(new Color(0xFF0000)).setTitle("Room #" + (dungeon.index(currentRoom) + 1)).setDescription("```" + currentRoom.getRoom().tilemapString() + "```").setFooter("Choose a path.").build()).queue();
channel.sendMessage("The room was full of enemies!").queue(x -> {
channel.sendTyping().queue(x0 -> {
var room = (EnemyRoom) currentRoom;
currentRoom.setClaimed(true);
GarmonTeam player = new GarmonTeam(target.getAsTag(), new PlayerFighter(target.getName(), target.getEffectiveAvatarUrl(), BigInteger.valueOf(25), BigInteger.valueOf(100), BigInteger.valueOf(100), BigInteger.valueOf(25), BigInteger.valueOf(5)));
var team = room.getEnemies();
GarmonBattle battle = new GarmonBattle(player, team);
player.setController(new PlayerController(battle, clover, target, channel));
team.setController(new CreatureAI(battle, channel));
battle.startAsync(true, winner -> {
if (winner == player) {
EconomyUser user = clover.getEconomy().getUser(target.getId());
RewardsOperation rewop = RewardsOperation.build(user, channel.getGuild(), BigInteger.valueOf((long) (Math.random() * 142 + 25)), new ItemBunch<>(new VoteToken(gartham.c10ver.economy.items.valuables.VoteToken.Type.NORMAL)));
currentRoom.prepare(dirsel, "act");
channel.sendMessage(target.getAsMention() + ", you won the fight!\nYou earned:\n\n" + Utilities.listRewards(user.reward(rewop))).setEmbeds(new EmbedBuilder().setColor(new Color(0xFF00)).setTitle("Room #" + (dungeon.index(currentRoom) + 1)).setDescription("```" + currentRoom.getRoom().tilemapString() + "```").setFooter("Choose a path.").build()).setActionRows(dirsel.actionRows()).queue(msg -> t = msg);
}
}, (long) (2000 + Math.random() * 1000));
});
});
} else {
currentRoom.prepare(dirsel, "act");
event.editMessageEmbeds(new EmbedBuilder().setTitle("Room #" + (dungeon.index(currentRoom) + 1)).setDescription("```" + currentRoom.getRoom().tilemapString() + "```").setFooter("Choose a path.").build()).setActionRows(dirsel.actionRows()).setContent("").queue();
}
}
return true;
}
};
clover.getEventHandler().getButtonClickProcessor().registerInputConsumer(inp);
t.editMessage(new MessageBuilder().setEmbeds(new EmbedBuilder().setTitle("W1-1").setDescription("```" + initialRoom.getRoom().tilemapString() + "```").setFooter("Choose a path.").build()).setActionRows(dirsel.actionRows()).build()).queue();
}
use of gartham.c10ver.economy.users.EconomyUser in project c10ver by Gartham.
the class ExploreCommand method handle.
private void handle(CommandInvocation inv, boolean safari) {
if (Math.random() < 0.3) {
int rand = (int) (Math.random() * 5);
String msg;
RewardsOperation op;
EconomyUser user = clover.getEconomy().getUser(inv.event.getAuthor().getId());
switch(rand) {
case 0:
var cloves = Utilities.randBIFromMean(32, 15);
msg = inv.event.getAuthor().getAsMention() + ", you found " + Utilities.format(cloves) + " hidden in a bush.";
op = RewardsOperation.build(user, inv.event.getGuild(), cloves);
break;
case 1:
cloves = Utilities.randBIFromMean(75, 15);
msg = inv.event.getAuthor().getAsMention() + ", you found a wallet in the woods with " + Utilities.format(cloves) + " in it.";
op = RewardsOperation.build(user, inv.event.getGuild(), cloves);
break;
case 2:
cloves = Utilities.randBIFromMean(82, 15);
msg = inv.event.getAuthor().getAsMention() + ", you stumble upon a cave with a chest in it full of " + Utilities.format(cloves) + '.';
op = RewardsOperation.build(user, inv.event.getGuild(), cloves);
break;
case 3:
cloves = Utilities.randBIFromMean(64, 15);
msg = inv.event.getAuthor().getAsMention() + ", you stole " + Utilities.format(cloves) + " from an unsuspecting politican's mailbox.";
op = RewardsOperation.build(user, inv.event.getGuild(), cloves);
break;
case 4:
cloves = Utilities.randBIFromMean(73, 15);
msg = inv.event.getAuthor().getAsMention() + ", you purchased a sandwich but used so many coupons that the store paid you " + Utilities.format(cloves) + " back.";
op = RewardsOperation.build(user, inv.event.getGuild(), cloves, new ItemBunch<>(new Sandwich()));
break;
default:
assert false : "Random value not handled by switch.";
msg = null;
op = null;
}
assert msg != null && op != null : "Values were assigned null by switch.";
inv.event.getChannel().sendMessage(msg + "\n\n" + Utilities.listRewards(user.reward(op))).queue();
} else {
}
}
Aggregations