Exemple #1
0
        public static async Task GameTimeout(SocketUser user, BlackjackGame game)
        {
            {
                EmbedBuilder eb  = new EmbedBuilder();
                var          bot = game.Message.Author.Id;

                game.Stand();

                if (game.SumHand(game.Hand) > 21)
                {
                    await BalanceDb.AddToasties(bot, game.Toasties, game.Channel.Guild.Id);

                    eb.WithAuthor(user.Username + " | Timeout", user.GetAvatarUrl());
                    eb.WithDescription("Your hand is a bust. You lose `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" +
                                       "New balance `" + BalanceDb.GetToasties(user.Id, game.Channel.Guild.Id) + "` " + ToastieUtil.RandomEmote());
                    eb.WithColor(Color.DarkRed);
                }

                else if (game.SumHand(game.Hand) > game.SumHand(game.Dealer) || game.SumHand(game.Dealer) > 21)
                {
                    await BalanceDb.AddToasties(user.Id, game.Toasties * 2, game.Channel.Guild.Id);

                    await BalanceDb.AddToasties(bot, -game.Toasties, game.Channel.Guild.Id);

                    eb.WithAuthor(user.Username + " | Timeout", user.GetAvatarUrl());
                    eb.WithDescription("Your score is higher than Namiko's. You win `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" +
                                       "New balance `" + BalanceDb.GetToasties(user.Id, game.Channel.Guild.Id) + "` " + ToastieUtil.RandomEmote());
                    eb.WithColor(Color.Gold);
                }

                else if (game.SumHand(game.Hand) == game.SumHand(game.Dealer))
                {
                    await BalanceDb.AddToasties(user.Id, game.Toasties, game.Channel.Guild.Id);

                    eb.WithAuthor(user.Username + " | Timeout", user.GetAvatarUrl());
                    eb.WithDescription("Your score is tied with Namiko's. You get your " + ToastieUtil.RandomEmote() + " back!\n" +
                                       "Your balance `" + BalanceDb.GetToasties(user.Id, game.Channel.Guild.Id) + "` " + ToastieUtil.RandomEmote());
                    eb.WithColor(Color.DarkGreen);
                }

                else
                {
                    await BalanceDb.AddToasties(bot, game.Toasties, game.Channel.Guild.Id);

                    eb.WithAuthor(user.Username + " | Timeout", user.GetAvatarUrl());
                    eb.WithDescription("Namiko's score is higher. You lose `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" +
                                       "New balance `" + BalanceDb.GetToasties(user.Id, game.Channel.Guild.Id) + "` " + ToastieUtil.RandomEmote());
                    eb.WithColor(Color.DarkRed);
                }

                eb.AddField("Your hand (" + game.SumHand(game.Hand) + ")", HandToString(game.Hand, false), true);
                eb.AddField("Namiko's hand (" + game.SumHand(game.Dealer) + ")", HandToString(game.Dealer, false), true);

                await Send(game, eb);

                games.Remove(user);
            }
        }
Exemple #2
0
 public static async Task Stand(SocketCommandContext Context, BlackjackGame game)
 {
     game.Stand();
     await GameEnd(Context, game);
 }