diff --git a/Geekbot.net/Commands/Games/Roll.cs b/Geekbot.net/Commands/Games/Roll/Roll.cs similarity index 83% rename from Geekbot.net/Commands/Games/Roll.cs rename to Geekbot.net/Commands/Games/Roll/Roll.cs index 076cf8f..1c89f19 100644 --- a/Geekbot.net/Commands/Games/Roll.cs +++ b/Geekbot.net/Commands/Games/Roll/Roll.cs @@ -10,7 +10,7 @@ using Geekbot.net.Lib.KvInMemoryStore; using Geekbot.net.Lib.Localization; using Geekbot.net.Lib.RandomNumberGenerator; -namespace Geekbot.net.Commands.Games +namespace Geekbot.net.Commands.Games.Roll { public class Roll : ModuleBase { @@ -42,17 +42,18 @@ namespace Geekbot.net.Commands.Games { var kvKey = $"{Context.Guild.Id}:{Context.User.Id}:RollsPrevious"; - var prevRoll = _kvInMemoryStore.Get(kvKey); - if (prevRoll > 0) + var prevRoll = _kvInMemoryStore.Get(kvKey); + + if (prevRoll?.LastGuess == guess && prevRoll?.GuessedOn.AddDays(1) > DateTime.Now) { - if (prevRoll == guess) - { - await ReplyAsync(transContext.GetString("NoPrevGuess", Context.Message.Author.Mention)); - return; - } + await ReplyAsync(transContext.GetString( + "NoPrevGuess", + Context.Message.Author.Mention, + transContext.FormatDateTimeAsRemaining(prevRoll.GuessedOn.AddDays(1)))); + return; } - _kvInMemoryStore.Set(kvKey, guess); + _kvInMemoryStore.Set(kvKey, new RollTimeout { LastGuess = guess, GuessedOn = DateTime.Now }); await ReplyAsync(transContext.GetString("Rolled", Context.Message.Author.Mention, number, guess)); if (guess == number) diff --git a/Geekbot.net/Commands/Games/Roll/RollTimeout.cs b/Geekbot.net/Commands/Games/Roll/RollTimeout.cs new file mode 100644 index 0000000..81a520f --- /dev/null +++ b/Geekbot.net/Commands/Games/Roll/RollTimeout.cs @@ -0,0 +1,10 @@ +using System; + +namespace Geekbot.net.Commands.Games.Roll +{ + public class RollTimeout + { + public int LastGuess { get; set; } + public DateTime GuessedOn { get; set; } + } +} \ No newline at end of file diff --git a/Geekbot.net/Lib/Localization/Translations.yml b/Geekbot.net/Lib/Localization/Translations.yml index a19a6f3..3c59977 100644 --- a/Geekbot.net/Lib/Localization/Translations.yml +++ b/Geekbot.net/Lib/Localization/Translations.yml @@ -83,8 +83,8 @@ roll: EN: "{0}, you rolled {1}" CHDE: "{0}, du hesch {1} grollt" NoPrevGuess: - EN: ":red_circle: {0}, you can't guess the same number again" - CHDE: ":red_circle: {0}, du chasch nid nomol es gliche rate" + EN: ":red_circle: {0}, you can't guess the same number again, guess another number or wait {1}" + CHDE: ":red_circle: {0}, du chasch nid nomol es gliche rate, rate öppis anders oder warte {1}" cookies: &cookiesAlias GetCookies: EN: "You got {0} cookies, there are now {1} cookies in you cookie jar"