From 5ed0ee4ef8a78e5b5b5bc1e86afa4327b7c304e4 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 15 Feb 2017 11:17:55 +0100 Subject: [PATCH] Draw commands done --- .../Modules/Gambling/Commands/DrawCommand.cs | 23 +++++++++++-------- .../Resources/ResponseStrings.Designer.cs | 18 +++++++++++++++ src/NadekoBot/Resources/ResponseStrings.resx | 6 +++++ 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs b/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs index b9ae375b..7471f7d0 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs @@ -4,8 +4,6 @@ using ImageSharp; using NadekoBot.Attributes; using NadekoBot.Extensions; using NadekoBot.Modules.Gambling.Models; -using NLog; -using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; @@ -19,15 +17,15 @@ namespace NadekoBot.Modules.Gambling [Group] public class DrawCommands : NadekoSubmodule { - private static readonly ConcurrentDictionary AllDecks = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary _allDecks = new ConcurrentDictionary(); - private const string cardsPath = "data/images/cards"; + private const string _cardsPath = "data/images/cards"; [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] public async Task Draw(int num = 1) { - var cards = AllDecks.GetOrAdd(Context.Guild, (s) => new Cards()); + var cards = _allDecks.GetOrAdd(Context.Guild, (s) => new Cards()); var images = new List(); var cardObjects = new List(); if (num > 5) num = 5; @@ -35,12 +33,19 @@ namespace NadekoBot.Modules.Gambling { if (cards.CardPool.Count == 0 && i != 0) { - try { await Context.Channel.SendErrorAsync("No more cards in a deck.").ConfigureAwait(false); } catch { } + try + { + await ReplyErrorLocalized("no_more_cards").ConfigureAwait(false); + } + catch + { + // ignored + } break; } var currentCard = cards.DrawACard(); cardObjects.Add(currentCard); - using (var stream = File.OpenRead(Path.Combine(cardsPath, currentCard.ToString().ToLowerInvariant()+ ".jpg").Replace(' ','_'))) + using (var stream = File.OpenRead(Path.Combine(_cardsPath, currentCard.ToString().ToLowerInvariant()+ ".jpg").Replace(' ','_'))) images.Add(new Image(stream)); } MemoryStream bitmapStream = new MemoryStream(); @@ -59,7 +64,7 @@ namespace NadekoBot.Modules.Gambling { //var channel = (ITextChannel)Context.Channel; - AllDecks.AddOrUpdate(Context.Guild, + _allDecks.AddOrUpdate(Context.Guild, (g) => new Cards(), (g, c) => { @@ -67,7 +72,7 @@ namespace NadekoBot.Modules.Gambling return c; }); - await Context.Channel.SendConfirmAsync("Deck reshuffled.").ConfigureAwait(false); + await ReplyConfirmLocalized("deck_reshuffled").ConfigureAwait(false); } } } diff --git a/src/NadekoBot/Resources/ResponseStrings.Designer.cs b/src/NadekoBot/Resources/ResponseStrings.Designer.cs index 95a0be9a..7dda445c 100644 --- a/src/NadekoBot/Resources/ResponseStrings.Designer.cs +++ b/src/NadekoBot/Resources/ResponseStrings.Designer.cs @@ -2108,6 +2108,15 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to Deck reshuffled.. + /// + public static string gambling_deck_reshuffled { + get { + return ResourceManager.GetString("gambling_deck_reshuffled", resourceCulture); + } + } + /// /// Looks up a localized string similar to You guessed it! You won {0}. /// @@ -2198,6 +2207,15 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to No more cards in the deck.. + /// + public static string gambling_no_more_cards { + get { + return ResourceManager.GetString("gambling_no_more_cards", resourceCulture); + } + } + /// /// Looks up a localized string similar to You don't have enough {0}. /// diff --git a/src/NadekoBot/Resources/ResponseStrings.resx b/src/NadekoBot/Resources/ResponseStrings.resx index 6fee14d7..eb8b565a 100644 --- a/src/NadekoBot/Resources/ResponseStrings.resx +++ b/src/NadekoBot/Resources/ResponseStrings.resx @@ -882,6 +882,9 @@ Reason: {1} Congratulations! You won {0} for rolling above {1} + + Deck reshuffled. + flipped {0}. User flipped tails. @@ -918,6 +921,9 @@ Reason: {1} You don't have enough {0} + + No more cards in the deck. + Raffled User