Search in sources :

Example 1 with GarmonTeam

use of gartham.c10ver.games.rpg.fighting.battles.app.GarmonTeam 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 GarmonTeam

use of gartham.c10ver.games.rpg.fighting.battles.app.GarmonTeam in project c10ver by Gartham.

the class GarmonUtils method printBattleQueue.

public static EmbedBuilder printBattleQueue(GarmonBattle battle) {
    EmbedBuilder builder = new EmbedBuilder().setTitle(String.join(" vs ", JavaTools.mask(battle.getTeams(), GarmonTeam::getName)));
    builder.setColor(new Color(0xe6da00));
    for (int i = 0; i < battle.getFighterCount() - 1; i++) {
        var f = battle.getBattleQueue().get(i);
        builder.addField("\uD83D\uDD50\uFE0F " + battle.getTicksTillTurn().get(f) + "   " + f.getEmoji() + ' ' + f.getName(), getField(f, battle) + "\n\u200b", false);
    }
    var f = battle.getBattleQueue().get(battle.getFighterCount() - 1);
    builder.addField("\uD83D\uDD50\uFE0F " + battle.getTicksTillTurn().get(f) + "   " + f.getEmoji() + ' ' + f.getName(), getField(f, battle), false);
    return builder;
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) WebhookEmbedBuilder(club.minnced.discord.webhook.send.WebhookEmbedBuilder) Color(java.awt.Color) GarmonTeam(gartham.c10ver.games.rpg.fighting.battles.app.GarmonTeam)

Example 3 with GarmonTeam

use of gartham.c10ver.games.rpg.fighting.battles.app.GarmonTeam 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

GarmonTeam (gartham.c10ver.games.rpg.fighting.battles.app.GarmonTeam)3 RewardsOperation (gartham.c10ver.economy.RewardsOperation)2 Color (java.awt.Color)2 List (java.util.List)2 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)2 WebhookEmbedBuilder (club.minnced.discord.webhook.send.WebhookEmbedBuilder)1 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 ItemBunch (gartham.c10ver.economy.items.ItemBunch)1 VoteToken (gartham.c10ver.economy.items.valuables.VoteToken)1 EconomyUser (gartham.c10ver.economy.users.EconomyUser)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 GarmonFighter (gartham.c10ver.games.rpg.fighting.battles.app.GarmonFighter)1 PlayerController (gartham.c10ver.games.rpg.fighting.battles.app.PlayerController)1