Search in sources :

Example 1 with RewardsOperation

use of gartham.c10ver.economy.RewardsOperation in project c10ver by Gartham.

the class Dungeon method generateRandomRoom.

public static DungeonRoom generateRandomRoom() {
    var rand = Math.random();
    if (rand < .7)
        return new EmptyRoom();
    else if (rand < 0.8) {
        List<Creature> creechurrs = new ArrayList<>();
        var enemy = new Nymph();
        if (Math.random() < 0.3)
            creechurrs.add(new Nymph());
        GarmonTeam team = new GarmonTeam("Wilderness", new GarmonFighter(enemy));
        return new EnemyRoom(team);
    } else if (rand < 0.95)
        return new LootRoom(new RewardsOperation().setCloves(BigInteger.valueOf((long) (Math.random() * 158 + 32))));
    else {
        var ro = new RewardsOperation();
        ro.getMults().put(generateRandomMultiplier(), 1);
        if (Math.random() < .2) {
            AbstractMultiplier val = generateRandomMultiplier();
            if (ro.getMults().containsKey(val))
                ro.getMults().put(val, ro.getMults().get(val) + 1);
        }
        return new LootRoom(ro);
    }
}
Also used : GarmonFighter(gartham.c10ver.games.rpg.fighting.battles.app.GarmonFighter) RewardsOperation(gartham.c10ver.economy.RewardsOperation) GarmonTeam(gartham.c10ver.games.rpg.fighting.battles.app.GarmonTeam) Nymph(gartham.c10ver.games.rpg.creatures.Nymph) AbstractMultiplier(gartham.c10ver.economy.AbstractMultiplier) List(java.util.List) ArrayList(java.util.ArrayList)

Example 2 with RewardsOperation

use of gartham.c10ver.economy.RewardsOperation 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 RewardsOperation

use of gartham.c10ver.economy.RewardsOperation 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 RewardsOperation

use of gartham.c10ver.economy.RewardsOperation 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();
}
Also used : Color(java.awt.Color) EconomyUser(gartham.c10ver.economy.users.EconomyUser) MessageChannel(net.dv8tion.jda.api.entities.MessageChannel) Receipt(gartham.c10ver.economy.users.EconomyUser.Receipt) PlayerController(gartham.c10ver.games.rpg.fighting.battles.app.PlayerController) ItemBunch(gartham.c10ver.economy.items.ItemBunch) ButtonClickEvent(net.dv8tion.jda.api.events.interaction.ButtonClickEvent) PlayerFighter(gartham.c10ver.games.rpg.fighting.battles.app.PlayerFighter) Utilities(gartham.c10ver.utils.Utilities) TextChannel(net.dv8tion.jda.api.entities.TextChannel) User(net.dv8tion.jda.api.entities.User) RewardsOperation(gartham.c10ver.economy.RewardsOperation) Button(net.dv8tion.jda.api.interactions.components.Button) InputConsumer(gartham.c10ver.commands.consumers.InputConsumer) GarmonBattle(gartham.c10ver.games.rpg.fighting.battles.app.GarmonBattle) BigInteger(java.math.BigInteger) ActionRow(net.dv8tion.jda.api.interactions.components.ActionRow) GarmonTeam(gartham.c10ver.games.rpg.fighting.battles.app.GarmonTeam) DirectionSelector(gartham.c10ver.response.utils.DirectionSelector) Message(net.dv8tion.jda.api.entities.Message) VoteToken(gartham.c10ver.economy.items.valuables.VoteToken) ButtonBook(gartham.c10ver.response.menus.ButtonBook) GuildChannel(net.dv8tion.jda.api.entities.GuildChannel) EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) Emoji(net.dv8tion.jda.api.entities.Emoji) List(java.util.List) Action(gartham.apps.garthchat.api.execution.Action) MessageBuilder(net.dv8tion.jda.api.MessageBuilder) InputProcessor(gartham.c10ver.commands.InputProcessor) CreatureAI(gartham.c10ver.games.rpg.fighting.battles.app.CreatureAI) Clover(gartham.c10ver.Clover) Receipt(gartham.c10ver.economy.users.EconomyUser.Receipt) ButtonClickEvent(net.dv8tion.jda.api.events.interaction.ButtonClickEvent) PlayerController(gartham.c10ver.games.rpg.fighting.battles.app.PlayerController) Color(java.awt.Color) RewardsOperation(gartham.c10ver.economy.RewardsOperation) GarmonTeam(gartham.c10ver.games.rpg.fighting.battles.app.GarmonTeam) InputProcessor(gartham.c10ver.commands.InputProcessor) GarmonBattle(gartham.c10ver.games.rpg.fighting.battles.app.GarmonBattle) VoteToken(gartham.c10ver.economy.items.valuables.VoteToken) GuildChannel(net.dv8tion.jda.api.entities.GuildChannel) EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) EconomyUser(gartham.c10ver.economy.users.EconomyUser) MessageBuilder(net.dv8tion.jda.api.MessageBuilder) InputConsumer(gartham.c10ver.commands.consumers.InputConsumer) PlayerFighter(gartham.c10ver.games.rpg.fighting.battles.app.PlayerFighter) CreatureAI(gartham.c10ver.games.rpg.fighting.battles.app.CreatureAI)

Example 5 with RewardsOperation

use of gartham.c10ver.economy.RewardsOperation 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

RewardsOperation (gartham.c10ver.economy.RewardsOperation)6 ItemBunch (gartham.c10ver.economy.items.ItemBunch)5 ArrayList (java.util.ArrayList)4 Sandwich (gartham.c10ver.economy.items.utility.foodstuffs.Sandwich)3 EconomyUser (gartham.c10ver.economy.users.EconomyUser)2 GarmonTeam (gartham.c10ver.games.rpg.fighting.battles.app.GarmonTeam)2 BigInteger (java.math.BigInteger)2 List (java.util.List)2 Action (gartham.apps.garthchat.api.execution.Action)1 Clover (gartham.c10ver.Clover)1 InputProcessor (gartham.c10ver.commands.InputProcessor)1 InputConsumer (gartham.c10ver.commands.consumers.InputConsumer)1 AbstractMultiplier (gartham.c10ver.economy.AbstractMultiplier)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 Receipt (gartham.c10ver.economy.users.EconomyUser.Receipt)1 Nymph (gartham.c10ver.games.rpg.creatures.Nymph)1 CreatureAI (gartham.c10ver.games.rpg.fighting.battles.app.CreatureAI)1 GarmonBattle (gartham.c10ver.games.rpg.fighting.battles.app.GarmonBattle)1