Merge branch 'master' of gitlab.com:dbgit/open/geekbot
This commit is contained in:
commit
baea4528e1
3 changed files with 22 additions and 11 deletions
|
@ -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<int>(kvKey);
|
||||
if (prevRoll > 0)
|
||||
var prevRoll = _kvInMemoryStore.Get<RollTimeout>(kvKey);
|
||||
|
||||
if (prevRoll?.LastGuess == guess && prevRoll?.GuessedOn.AddDays(1) > DateTime.Now)
|
||||
{
|
||||
if (prevRoll == guess)
|
||||
{
|
||||
await ReplyAsync(transContext.GetString("NoPrevGuess", Context.Message.Author.Mention));
|
||||
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)
|
10
Geekbot.net/Commands/Games/Roll/RollTimeout.cs
Normal file
10
Geekbot.net/Commands/Games/Roll/RollTimeout.cs
Normal file
|
@ -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; }
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue