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); } }
public static async Task GameEnd(SocketCommandContext Context, BlackjackGame game) { EmbedBuilder eb = new EmbedBuilder(); var user = Context.User; if (game.SumHand(game.Hand) > 21) { await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, game.Toasties, Context.Guild.Id); eb.WithAuthor(user.Username + " | You Lose", user.GetAvatarUrl()); eb.WithDescription("Your hand is a bust. You lose `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" + "New balance `" + BalanceDb.GetToasties(user.Id, Context.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, Context.Guild.Id); await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, -game.Toasties, Context.Guild.Id); eb.WithAuthor(user.Username + " | You Win", user.GetAvatarUrl()); eb.WithDescription("Your score is higher than Namiko's. You win `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" + "New balance `" + BalanceDb.GetToasties(user.Id, Context.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, Context.Guild.Id); eb.WithAuthor(user.Username + " | Tie", user.GetAvatarUrl()); eb.WithDescription("Your score is tied with Namiko's. You get your " + ToastieUtil.RandomEmote() + " back!\n" + "Your balance `" + BalanceDb.GetToasties(user.Id, Context.Guild.Id) + "` " + ToastieUtil.RandomEmote()); eb.WithColor(Color.DarkGreen); } else { await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, game.Toasties, Context.Guild.Id); eb.WithAuthor(user.Username + " | You Lose", user.GetAvatarUrl()); eb.WithDescription("Namiko's score is higher. You lose `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" + "New balance `" + BalanceDb.GetToasties(user.Id, Context.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); }
public static async Task Forfeit(SocketCommandContext Context, BlackjackGame game) { var user = Context.User; await BalanceDb.AddToasties(user.Id, game.Toasties / 2, Context.Guild.Id); await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, game.Toasties / 2, Context.Guild.Id); EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor(user.Username + " | You Lose", null, user.GetAvatarUrl()); eb.WithDescription("You forfeit. You get half your toasties back. Lost `" + game.Toasties / 2 + "`" + ToastieUtil.RandomEmote() + "\n" + "New balance `" + BalanceDb.GetToasties(user.Id, Context.Guild.Id) + "`" + ToastieUtil.RandomEmote()); 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); eb.WithColor(Color.DarkBlue); await Send(game, eb); games.Remove(user); }
public static async Task GameContinue(SocketCommandContext Context, BlackjackGame game) { EmbedBuilder eb = new EmbedBuilder(); var user = Context.User; eb.WithAuthor(user.Username + " | Blackjack", user.GetAvatarUrl()); eb.WithDescription("You started a game of blackjack against Namiko! The one closest to 21 wins!\n" + String.Format("{0,10} - to draw another card.\n", "**hit**") + String.Format("{0,10} - to finalize and let Namiko draw.\n", "**stand**") + String.Format("{0,10} - to double your bet and draw only 1 card.\n", "**double**") + String.Format("{0,10} - to forfeit and get half your toasties back.", "**forfeit**")); eb.AddField("Your hand (" + game.SumHand(game.Hand) + ")", HandToString(game.Hand, false), true); eb.AddField("Namiko's hand (" + game.CardValue(game.Dealer[0]) + ")", HandToString(game.Dealer, true), true); eb.WithColor(Color.Green); game.Refresh = DateTime.Now; await Send(game, eb); }