Search in sources :

Example 1 with Clover

use of gartham.c10ver.Clover in project c10ver by Gartham.

the class PlayerController method info.

private DetailedActionReaction info(DetailedMenuMessage<DetailedActionReaction, DetailedActionButton> source) {
    return new DetailedActionReaction("\u2139", "Info", "Check battle queue or enemy stats.", t -> {
        var dam = new DetailedMenuMessage<>(new ActionMessage<>());
        DetailedActionReaction battleQueue = new DetailedActionReaction("Battle Queue", "Check the time until each creature's turn.", DetailedActionReaction.actionMessageAction(dam, t1 -> channel.sendMessage("Battle Queue:").setEmbeds(GarmonUtils.printBattleQueue(battle).build()).queue()));
        DetailedActionReaction back = new DetailedActionReaction("\u2B05", "Back", "Go back to attack menu.", DetailedActionReaction.actionMessageAction(source));
        dam.getReactions().add(battleQueue);
        dam.getReactions().add(back);
        dam.send(clover, channel, player);
    });
}
Also used : WebhookMessageBuilder(club.minnced.discord.webhook.send.WebhookMessageBuilder) Random(java.util.Random) TextChannel(net.dv8tion.jda.api.entities.TextChannel) Controller(gartham.c10ver.games.rpg.fighting.battles.api.Controller) User(net.dv8tion.jda.api.entities.User) List(java.util.List) DetailedActionReaction(gartham.c10ver.response.actions.DetailedActionReaction) GarmonUtils(gartham.c10ver.games.rpg.GarmonUtils) DetailedMenuMessage(gartham.c10ver.response.menus.DetailedMenuMessage) BigInteger(java.math.BigInteger) ActionMessage(gartham.c10ver.response.actions.ActionMessage) Clover(gartham.c10ver.Clover) DetailedActionButton(gartham.c10ver.response.actions.DetailedActionButton) DetailedMenuMessage(gartham.c10ver.response.menus.DetailedMenuMessage) DetailedActionReaction(gartham.c10ver.response.actions.DetailedActionReaction)

Example 2 with Clover

use of gartham.c10ver.Clover 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();
    });
}
Also used : JSONObject(org.alixia.javalibrary.json.JSONObject) Item(gartham.c10ver.economy.items.Item) EconomyUser(gartham.c10ver.economy.users.EconomyUser) RewardsOperation(gartham.c10ver.economy.RewardsOperation) ItemCategory(gartham.c10ver.economy.items.ItemCategory) Utilities(gartham.c10ver.utils.Utilities) BigInteger(java.math.BigInteger) MessageReceivedEvent(net.dv8tion.jda.api.events.message.MessageReceivedEvent) Clover(gartham.c10ver.Clover) EconomyUser(gartham.c10ver.economy.users.EconomyUser) BigInteger(java.math.BigInteger)

Example 3 with Clover

use of gartham.c10ver.Clover 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)

Aggregations

Clover (gartham.c10ver.Clover)3 BigInteger (java.math.BigInteger)3 RewardsOperation (gartham.c10ver.economy.RewardsOperation)2 EconomyUser (gartham.c10ver.economy.users.EconomyUser)2 Utilities (gartham.c10ver.utils.Utilities)2 List (java.util.List)2 TextChannel (net.dv8tion.jda.api.entities.TextChannel)2 User (net.dv8tion.jda.api.entities.User)2 WebhookMessageBuilder (club.minnced.discord.webhook.send.WebhookMessageBuilder)1 Action (gartham.apps.garthchat.api.execution.Action)1 InputProcessor (gartham.c10ver.commands.InputProcessor)1 InputConsumer (gartham.c10ver.commands.consumers.InputConsumer)1 Item (gartham.c10ver.economy.items.Item)1 ItemBunch (gartham.c10ver.economy.items.ItemBunch)1 ItemCategory (gartham.c10ver.economy.items.ItemCategory)1 VoteToken (gartham.c10ver.economy.items.valuables.VoteToken)1 Receipt (gartham.c10ver.economy.users.EconomyUser.Receipt)1 GarmonUtils (gartham.c10ver.games.rpg.GarmonUtils)1 Controller (gartham.c10ver.games.rpg.fighting.battles.api.Controller)1 CreatureAI (gartham.c10ver.games.rpg.fighting.battles.app.CreatureAI)1