Search in sources :

Example 1 with Sandwich

use of gartham.c10ver.economy.items.utility.foodstuffs.Sandwich 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));
        });
}
Also used : Message(net.dv8tion.jda.api.entities.Message) HashMap(java.util.HashMap) DailyCrate(gartham.c10ver.economy.items.utility.crates.DailyCrate) Instant(java.time.Instant) ArrayList(java.util.ArrayList) Pizza(gartham.c10ver.economy.items.utility.foodstuffs.Pizza) Sandwich(gartham.c10ver.economy.items.utility.foodstuffs.Sandwich) Hamburger(gartham.c10ver.economy.items.utility.foodstuffs.Hamburger) VoteToken(gartham.c10ver.economy.items.valuables.VoteToken) BigInteger(java.math.BigInteger) MessageReactionInputConsumer(gartham.c10ver.commands.consumers.MessageReactionInputConsumer) NormalCrate(gartham.c10ver.economy.items.utility.crates.NormalCrate) WeeklyCrate(gartham.c10ver.economy.items.utility.crates.WeeklyCrate) MonthlyCrate(gartham.c10ver.economy.items.utility.crates.MonthlyCrate) EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) EconomyUser(gartham.c10ver.economy.users.EconomyUser) MessageChannel(net.dv8tion.jda.api.entities.MessageChannel) MessageReactionInputConsumer(gartham.c10ver.commands.consumers.MessageReactionInputConsumer) Consumer(java.util.function.Consumer) ItemBunch(gartham.c10ver.economy.items.ItemBunch) AbstractMultiplier(gartham.c10ver.economy.AbstractMultiplier)

Example 2 with Sandwich

use of gartham.c10ver.economy.items.utility.foodstuffs.Sandwich in project c10ver by Gartham.

the class DailyCrate method open.

@Override
public RewardsOperation open() {
    List<ItemBunch<?>> items = new ArrayList<>();
    if (Math.random() < 0.05)
        items.add(new ItemBunch<>(new Sandwich(), Math.random() < 0.2 ? BigInteger.TWO : BigInteger.ONE));
    if (Math.random() < 0.3)
        items.add(new ItemBunch<>(new DailyCrate()));
    else if (Math.random() < 0.007)
        items.add(new ItemBunch<>(new WeeklyCrate()));
    BigInteger cloves = BigInteger.valueOf((long) (Math.random() * 250 + 100));
    return new RewardsOperation().with(items).with(cloves);
}
Also used : Sandwich(gartham.c10ver.economy.items.utility.foodstuffs.Sandwich) ItemBunch(gartham.c10ver.economy.items.ItemBunch) RewardsOperation(gartham.c10ver.economy.RewardsOperation) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger)

Example 3 with Sandwich

use of gartham.c10ver.economy.items.utility.foodstuffs.Sandwich in project c10ver by Gartham.

the class WeeklyCrate method open.

@Override
public RewardsOperation open() {
    List<ItemBunch<?>> items = new ArrayList<>();
    items.add(new ItemBunch<>(new Sandwich(), BigInteger.valueOf((long) (Math.random() * 4 + 2))));
    if (Math.random() > 0.8)
        items.add(new ItemBunch<>(new DailyCrate(), BigInteger.valueOf((long) (2 + Math.random() * 2))));
    if (Math.random() > 0.4)
        items.add(new ItemBunch<>(new Sandwich()));
    if (Math.random() > 0.98)
        items.add(new ItemBunch<>(new MonthlyCrate(), BigInteger.ONE));
    return new RewardsOperation().with(BigInteger.valueOf((long) (350 + Math.random() * 150))).with(items);
}
Also used : Sandwich(gartham.c10ver.economy.items.utility.foodstuffs.Sandwich) ItemBunch(gartham.c10ver.economy.items.ItemBunch) RewardsOperation(gartham.c10ver.economy.RewardsOperation) ArrayList(java.util.ArrayList)

Example 4 with Sandwich

use of gartham.c10ver.economy.items.utility.foodstuffs.Sandwich 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 {
    }
}
Also used : Sandwich(gartham.c10ver.economy.items.utility.foodstuffs.Sandwich) EconomyUser(gartham.c10ver.economy.users.EconomyUser) RewardsOperation(gartham.c10ver.economy.RewardsOperation) ItemBunch(gartham.c10ver.economy.items.ItemBunch)

Aggregations

ItemBunch (gartham.c10ver.economy.items.ItemBunch)4 Sandwich (gartham.c10ver.economy.items.utility.foodstuffs.Sandwich)4 RewardsOperation (gartham.c10ver.economy.RewardsOperation)3 ArrayList (java.util.ArrayList)3 EconomyUser (gartham.c10ver.economy.users.EconomyUser)2 BigInteger (java.math.BigInteger)2 MessageReactionInputConsumer (gartham.c10ver.commands.consumers.MessageReactionInputConsumer)1 AbstractMultiplier (gartham.c10ver.economy.AbstractMultiplier)1 DailyCrate (gartham.c10ver.economy.items.utility.crates.DailyCrate)1 MonthlyCrate (gartham.c10ver.economy.items.utility.crates.MonthlyCrate)1 NormalCrate (gartham.c10ver.economy.items.utility.crates.NormalCrate)1 WeeklyCrate (gartham.c10ver.economy.items.utility.crates.WeeklyCrate)1 Hamburger (gartham.c10ver.economy.items.utility.foodstuffs.Hamburger)1 Pizza (gartham.c10ver.economy.items.utility.foodstuffs.Pizza)1 VoteToken (gartham.c10ver.economy.items.valuables.VoteToken)1 Instant (java.time.Instant)1 HashMap (java.util.HashMap)1 Consumer (java.util.function.Consumer)1 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)1 Message (net.dv8tion.jda.api.entities.Message)1