diff --git a/Geekbot.net/Commands/Rpg/Cookies.cs b/Geekbot.net/Commands/Rpg/Cookies.cs index 21077bf..3e3e98c 100644 --- a/Geekbot.net/Commands/Rpg/Cookies.cs +++ b/Geekbot.net/Commands/Rpg/Cookies.cs @@ -70,7 +70,7 @@ namespace Geekbot.net.Commands.Rpg [Command("give", RunMode = RunMode.Async)] [Summary("Give cookies to someone")] - public async Task PeekIntoCookieJar([Summary("User")] IUser user, [Summary("amount")] int amount) + public async Task GiveACookie([Summary("User")] IUser user, [Summary("amount")] int amount) { try { @@ -99,6 +99,34 @@ namespace Geekbot.net.Commands.Rpg } } + [Command("eat", RunMode = RunMode.Async)] + [Summary("Eat a cookie")] + public async Task EatACookie() + { + try + { + var transDict = await _translation.GetDict(Context); + var actor = await GetUser(Context.User.Id); + + if (actor.Cookies < 5) + { + await ReplyAsync(string.Format(transDict["NotEnoughCookiesToEat"])); + return; + } + + var amount = new Random().Next(1, 5); + actor.Cookies -= amount; + + await SetUser(actor); + + await ReplyAsync(string.Format(transDict["AteCookies"], amount, actor.Cookies)); + } + catch (Exception e) + { + await _errorHandler.HandleCommandException(e, Context); + } + } + private async Task GetUser(ulong userId) { var user = _database.Cookies.FirstOrDefault(u =>u.GuildId.Equals(Context.Guild.Id.AsLong()) && u.UserId.Equals(userId.AsLong())) ?? await CreateNewRow(userId); diff --git a/Geekbot.net/Lib/Localization/Translations.json b/Geekbot.net/Lib/Localization/Translations.json index 191c4ff..7747016 100644 --- a/Geekbot.net/Lib/Localization/Translations.json +++ b/Geekbot.net/Lib/Localization/Translations.json @@ -117,6 +117,14 @@ "NotEnoughToGive": { "EN": "You don't have enough cookies", "CHDE": "Du hesch nid gnueg guetzli" + }, + "NotEnoughCookiesToEat": { + "EN": "Your cookie jar looks almost empty, you should probably not eat a cookie", + "CHDE": "Du hesch chuum no guetzli ih dineri büchs, du sötsch warschinli keini esse" + }, + "AteCookies": { + "EN": "You ate {0} cookies, you've only got {1} cookies left", + "CHDE": "Du hesch {0} guetzli gesse und hesch jezt no {1} übrig" } } } \ No newline at end of file