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);
});
}
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();
});
}
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();
}
Aggregations