Search in sources :

Example 1 with Hand

use of tk.ardentbot.utils.games.Hand in project Ardent by adamint.

the class Blackjack method noArgs.

@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
    if (sessions.contains(user.getId()))
        return;
    sendTranslatedMessage("Enter an amount to bet", channel, user);
    interactiveOperation(channel, message, betMessage -> {
        try {
            int amountToBet = Integer.parseInt(betMessage.getContent());
            Profile profile = Profile.get(user);
            if (amountToBet <= 0 || profile.getMoney() < amountToBet) {
                sendTranslatedMessage("You entered an invalid amount of money", channel, user);
                return;
            } else if (amountToBet > 5000) {
                sendTranslatedMessage("The max bet is **$5,000**!", channel, user);
                return;
            }
            Hand yourHand = new Hand().generate().generate();
            Hand dealerHand = new Hand().generate().generate();
            sessions.add(user.getId());
            dispatchRound(amountToBet, yourHand, dealerHand, guild, channel, user, message, args);
        } catch (Exception e) {
            sendTranslatedMessage("You need to enter a whole number. Cancelling...", channel, user);
        }
    });
}
Also used : Hand(tk.ardentbot.utils.games.Hand) Profile(tk.ardentbot.utils.rpg.profiles.Profile) BotException(tk.ardentbot.core.misc.logging.BotException)

Aggregations

BotException (tk.ardentbot.core.misc.logging.BotException)1 Hand (tk.ardentbot.utils.games.Hand)1 Profile (tk.ardentbot.utils.rpg.profiles.Profile)1