Let users eat their cookies
This commit is contained in:
parent
fd75fef973
commit
fe08eee049
2 changed files with 37 additions and 1 deletions
|
@ -70,7 +70,7 @@ namespace Geekbot.net.Commands.Rpg
|
||||||
|
|
||||||
[Command("give", RunMode = RunMode.Async)]
|
[Command("give", RunMode = RunMode.Async)]
|
||||||
[Summary("Give cookies to someone")]
|
[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
|
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<CookiesModel> GetUser(ulong userId)
|
private async Task<CookiesModel> GetUser(ulong userId)
|
||||||
{
|
{
|
||||||
var user = _database.Cookies.FirstOrDefault(u =>u.GuildId.Equals(Context.Guild.Id.AsLong()) && u.UserId.Equals(userId.AsLong())) ?? await CreateNewRow(userId);
|
var user = _database.Cookies.FirstOrDefault(u =>u.GuildId.Equals(Context.Guild.Id.AsLong()) && u.UserId.Equals(userId.AsLong())) ?? await CreateNewRow(userId);
|
||||||
|
|
|
@ -117,6 +117,14 @@
|
||||||
"NotEnoughToGive": {
|
"NotEnoughToGive": {
|
||||||
"EN": "You don't have enough cookies",
|
"EN": "You don't have enough cookies",
|
||||||
"CHDE": "Du hesch nid gnueg guetzli"
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue