Cleanup, bugfixes, Slots, flip, gambling commands localizable.
This commit is contained in:
parent
8983c9c37e
commit
45f69bac58
@ -19,7 +19,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
public partial class Gambling
|
||||
{
|
||||
[Group]
|
||||
public class CurrencyEvents : ModuleBase
|
||||
public class CurrencyEvents : NadekoSubmodule
|
||||
{
|
||||
public enum CurrencyEvent
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
public partial class Gambling
|
||||
{
|
||||
[Group]
|
||||
public class DriceRollCommands : ModuleBase
|
||||
public class DriceRollCommands : NadekoSubmodule
|
||||
{
|
||||
private Regex dndRegex { get; } = new Regex(@"^(?<n1>\d+)d(?<n2>\d+)(?:\+(?<add>\d+))?(?:\-(?<sub>\d+))?$", RegexOptions.Compiled);
|
||||
private Regex fudgeRegex { get; } = new Regex(@"^(?<n1>\d+)d(?:F|f)$", RegexOptions.Compiled);
|
||||
|
@ -17,7 +17,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
public partial class Gambling
|
||||
{
|
||||
[Group]
|
||||
public class DrawCommands : ModuleBase
|
||||
public class DrawCommands : NadekoSubmodule
|
||||
{
|
||||
private static readonly ConcurrentDictionary<IGuild, Cards> AllDecks = new ConcurrentDictionary<IGuild, Cards>();
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using ImageSharp;
|
||||
using NadekoBot.Attributes;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Image = ImageSharp.Image;
|
||||
|
||||
@ -15,7 +13,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
public partial class Gambling
|
||||
{
|
||||
[Group]
|
||||
public class FlipCoinCommands : ModuleBase
|
||||
public class FlipCoinCommands : NadekoSubmodule
|
||||
{
|
||||
private readonly IImagesService _images;
|
||||
|
||||
@ -24,7 +22,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
public FlipCoinCommands()
|
||||
{
|
||||
//todo DI in the future, can't atm
|
||||
this._images = NadekoBot.Images;
|
||||
_images = NadekoBot.Images;
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
@ -36,21 +34,21 @@ namespace NadekoBot.Modules.Gambling
|
||||
{
|
||||
using (var heads = _images.Heads.ToStream())
|
||||
{
|
||||
await Context.Channel.SendFileAsync(heads, "heads.jpg", $"{Context.User.Mention} flipped " + Format.Code("Heads") + ".").ConfigureAwait(false);
|
||||
await Context.Channel.SendFileAsync(heads, "heads.jpg", Context.User.Mention + " " + GetText("flipped", Format.Bold(GetText("heads"))) + ".").ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var tails = _images.Tails.ToStream())
|
||||
{
|
||||
await Context.Channel.SendFileAsync(tails, "tails.jpg", $"{Context.User.Mention} flipped " + Format.Code("Tails") + ".").ConfigureAwait(false);
|
||||
await Context.Channel.SendFileAsync(tails, "tails.jpg", Context.User.Mention + " " + GetText("flipped", Format.Bold(GetText("tails"))) + ".").ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (count > 10 || count < 1)
|
||||
{
|
||||
await Context.Channel.SendErrorAsync("`Invalid number specified. You can flip 1 to 10 coins.`").ConfigureAwait(false);
|
||||
await ReplyErrorLocalized("flip_invalid", 10).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
var imgs = new Image[count];
|
||||
@ -76,14 +74,13 @@ namespace NadekoBot.Modules.Gambling
|
||||
|
||||
if (amount < NadekoBot.BotConfig.MinimumBetAmount)
|
||||
{
|
||||
await Context.Channel.SendErrorAsync($"You can't bet less than {NadekoBot.BotConfig.MinimumBetAmount}{CurrencySign}.")
|
||||
.ConfigureAwait(false);
|
||||
await ReplyErrorLocalized("min_bet_limit", NadekoBot.BotConfig.MinimumBetAmount + CurrencySign).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
var removed = await CurrencyHandler.RemoveCurrencyAsync(Context.User, "Betflip Gamble", amount, false).ConfigureAwait(false);
|
||||
if (!removed)
|
||||
{
|
||||
await Context.Channel.SendErrorAsync($"{Context.User.Mention} You don't have enough {CurrencyPluralName}.").ConfigureAwait(false);
|
||||
await ReplyErrorLocalized("not_enough", CurrencyPluralName).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
//heads = true
|
||||
@ -91,7 +88,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
|
||||
//todo this seems stinky, no time to look at it right now
|
||||
var isHeads = guessStr == "HEADS" || guessStr == "H";
|
||||
bool result = false;
|
||||
var result = false;
|
||||
IEnumerable<byte> imageToSend;
|
||||
if (rng.Next(0, 2) == 1)
|
||||
{
|
||||
@ -107,12 +104,12 @@ namespace NadekoBot.Modules.Gambling
|
||||
if (isHeads == result)
|
||||
{
|
||||
var toWin = (int)Math.Round(amount * NadekoBot.BotConfig.BetflipMultiplier);
|
||||
str = $"{Context.User.Mention}`You guessed it!` You won {toWin}{CurrencySign}";
|
||||
await CurrencyHandler.AddCurrencyAsync(Context.User, "Betflip Gamble", toWin, false).ConfigureAwait(false);
|
||||
str = Context.User.Mention + " " + GetText("flip_guess", toWin + CurrencySign);
|
||||
await CurrencyHandler.AddCurrencyAsync(Context.User, GetText("betflip_gamble"), toWin, false).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
str = $"{Context.User.Mention}`Better luck next time.`";
|
||||
str = Context.User.Mention + " " + GetText("better_luck");
|
||||
}
|
||||
using (var toSend = imageToSend.ToStream())
|
||||
{
|
||||
|
@ -5,7 +5,6 @@ using NadekoBot.Extensions;
|
||||
using NadekoBot.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
@ -16,12 +15,12 @@ namespace NadekoBot.Modules.Gambling
|
||||
public partial class Gambling
|
||||
{
|
||||
[Group]
|
||||
public class Slots : ModuleBase
|
||||
public class Slots : NadekoSubmodule
|
||||
{
|
||||
private static int totalBet = 0;
|
||||
private static int totalPaidOut = 0;
|
||||
private static int _totalBet;
|
||||
private static int _totalPaidOut;
|
||||
|
||||
const int alphaCutOut = byte.MaxValue / 3;
|
||||
private const int _alphaCutOut = byte.MaxValue / 3;
|
||||
|
||||
//here is a payout chart
|
||||
//https://lh6.googleusercontent.com/-i1hjAJy_kN4/UswKxmhrbPI/AAAAAAAAB1U/82wq_4ZZc-Y/DE6B0895-6FC1-48BE-AC4F-14D1B91AB75B.jpg
|
||||
@ -31,14 +30,14 @@ namespace NadekoBot.Modules.Gambling
|
||||
|
||||
public Slots()
|
||||
{
|
||||
this._images = NadekoBot.Images;
|
||||
_images = NadekoBot.Images;
|
||||
}
|
||||
|
||||
public class SlotMachine
|
||||
{
|
||||
public const int MaxValue = 5;
|
||||
|
||||
static readonly List<Func<int[], int>> winningCombos = new List<Func<int[], int>>()
|
||||
static readonly List<Func<int[], int>> _winningCombos = new List<Func<int[], int>>()
|
||||
{
|
||||
//three flowers
|
||||
(arr) => arr.All(a=>a==MaxValue) ? 30 : 0,
|
||||
@ -53,14 +52,14 @@ namespace NadekoBot.Modules.Gambling
|
||||
public static SlotResult Pull()
|
||||
{
|
||||
var numbers = new int[3];
|
||||
for (int i = 0; i < numbers.Length; i++)
|
||||
for (var i = 0; i < numbers.Length; i++)
|
||||
{
|
||||
numbers[i] = new NadekoRandom().Next(0, MaxValue + 1);
|
||||
}
|
||||
int multi = 0;
|
||||
for (int i = 0; i < winningCombos.Count; i++)
|
||||
var multi = 0;
|
||||
foreach (var t in _winningCombos)
|
||||
{
|
||||
multi = winningCombos[i](numbers);
|
||||
multi = t(numbers);
|
||||
if (multi != 0)
|
||||
break;
|
||||
}
|
||||
@ -74,8 +73,8 @@ namespace NadekoBot.Modules.Gambling
|
||||
public int Multiplier { get; }
|
||||
public SlotResult(int[] nums, int multi)
|
||||
{
|
||||
this.Numbers = nums;
|
||||
this.Multiplier = multi;
|
||||
Numbers = nums;
|
||||
Multiplier = multi;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -85,8 +84,8 @@ namespace NadekoBot.Modules.Gambling
|
||||
public async Task SlotStats()
|
||||
{
|
||||
//i remembered to not be a moron
|
||||
var paid = totalPaidOut;
|
||||
var bet = totalBet;
|
||||
var paid = _totalPaidOut;
|
||||
var bet = _totalBet;
|
||||
|
||||
if (bet <= 0)
|
||||
bet = 1;
|
||||
@ -130,33 +129,34 @@ namespace NadekoBot.Modules.Gambling
|
||||
footer: $"Total Bet: {tests * bet} | Payout: {payout * bet} | {payout * 1.0f / tests * 100}%");
|
||||
}
|
||||
|
||||
static HashSet<ulong> runningUsers = new HashSet<ulong>();
|
||||
private static readonly HashSet<ulong> _runningUsers = new HashSet<ulong>();
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
public async Task Slot(int amount = 0)
|
||||
{
|
||||
if (!runningUsers.Add(Context.User.Id))
|
||||
if (!_runningUsers.Add(Context.User.Id))
|
||||
return;
|
||||
try
|
||||
{
|
||||
if (amount < 1)
|
||||
{
|
||||
await Context.Channel.SendErrorAsync($"You can't bet less than 1{NadekoBot.BotConfig.CurrencySign}").ConfigureAwait(false);
|
||||
await ReplyErrorLocalized("min_bet_limit", 1 + CurrencySign).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (amount > 999)
|
||||
{
|
||||
await Context.Channel.SendErrorAsync($"You can't bet more than 999{NadekoBot.BotConfig.CurrencySign}").ConfigureAwait(false);
|
||||
GetText("slot_maxbet", 999 + CurrencySign);
|
||||
await ReplyErrorLocalized("max_bet_limit", 999 + CurrencySign).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!await CurrencyHandler.RemoveCurrencyAsync(Context.User, "Slot Machine", amount, false))
|
||||
{
|
||||
await Context.Channel.SendErrorAsync($"You don't have enough {NadekoBot.BotConfig.CurrencySign}.").ConfigureAwait(false);
|
||||
await ReplyErrorLocalized("not_enough", CurrencySign).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
Interlocked.Add(ref totalBet, amount);
|
||||
Interlocked.Add(ref _totalBet, amount);
|
||||
using (var bgFileStream = NadekoBot.Images.SlotBackground.ToStream())
|
||||
{
|
||||
var bgImage = new ImageSharp.Image(bgFileStream);
|
||||
@ -179,7 +179,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
var x = 95 + 142 * i + j;
|
||||
int y = 330 + k;
|
||||
var toSet = toAdd[j, k];
|
||||
if (toSet.A < alphaCutOut)
|
||||
if (toSet.A < _alphaCutOut)
|
||||
continue;
|
||||
bgPixels[x, y] = toAdd[j, k];
|
||||
}
|
||||
@ -203,7 +203,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
{
|
||||
for (int j = 0; j < pixels.Height; j++)
|
||||
{
|
||||
if (pixels[i, j].A < alphaCutOut)
|
||||
if (pixels[i, j].A < _alphaCutOut)
|
||||
continue;
|
||||
var x = 230 - n * 16 + i;
|
||||
bgPixels[x, 462 + j] = pixels[i, j];
|
||||
@ -228,7 +228,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
{
|
||||
for (int j = 0; j < pixels.Height; j++)
|
||||
{
|
||||
if (pixels[i, j].A < alphaCutOut)
|
||||
if (pixels[i, j].A < _alphaCutOut)
|
||||
continue;
|
||||
var x = 395 - n * 16 + i;
|
||||
bgPixels[x, 462 + j] = pixels[i, j];
|
||||
@ -240,22 +240,22 @@ namespace NadekoBot.Modules.Gambling
|
||||
} while ((printAmount /= 10) != 0);
|
||||
}
|
||||
|
||||
var msg = "Better luck next time ^_^";
|
||||
var msg = GetText("better_luck");
|
||||
if (result.Multiplier != 0)
|
||||
{
|
||||
await CurrencyHandler.AddCurrencyAsync(Context.User, $"Slot Machine x{result.Multiplier}", amount * result.Multiplier, false);
|
||||
Interlocked.Add(ref totalPaidOut, amount * result.Multiplier);
|
||||
Interlocked.Add(ref _totalPaidOut, amount * result.Multiplier);
|
||||
if (result.Multiplier == 1)
|
||||
msg = $"A single {NadekoBot.BotConfig.CurrencySign}, x1 - Try again!";
|
||||
msg = GetText("slot_single", CurrencySign, 1);
|
||||
else if (result.Multiplier == 4)
|
||||
msg = $"Good job! Two {NadekoBot.BotConfig.CurrencySign} - bet x4";
|
||||
msg = GetText("slot_two", CurrencySign, 4);
|
||||
else if (result.Multiplier == 10)
|
||||
msg = "Wow! Lucky! Three of a kind! x10";
|
||||
msg = GetText("slot_three", 10);
|
||||
else if (result.Multiplier == 30)
|
||||
msg = "WOAAHHHHHH!!! Congratulations!!! x30";
|
||||
msg = GetText("slot_jackpot", 30);
|
||||
}
|
||||
|
||||
await Context.Channel.SendFileAsync(bgImage.ToStream(), "result.png", Context.User.Mention + " " + msg + $"\n`Bet:`{amount} `Won:` {amount * result.Multiplier}{NadekoBot.BotConfig.CurrencySign}").ConfigureAwait(false);
|
||||
await Context.Channel.SendFileAsync(bgImage.ToStream(), "result.png", Context.User.Mention + " " + msg + $"\n`{GetText("slot_bet")}:`{amount} `{GetText("slot_won")}:` {amount * result.Multiplier}{NadekoBot.BotConfig.CurrencySign}").ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
finally
|
||||
@ -263,7 +263,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
var _ = Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(2000);
|
||||
runningUsers.Remove(Context.User.Id);
|
||||
_runningUsers.Remove(Context.User.Id);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
}
|
||||
|
||||
[Group]
|
||||
public class WaifuClaimCommands : ModuleBase
|
||||
public class WaifuClaimCommands : NadekoSubmodule
|
||||
{
|
||||
private static ConcurrentDictionary<ulong, DateTime> _divorceCooldowns { get; } = new ConcurrentDictionary<ulong, DateTime>();
|
||||
private static ConcurrentDictionary<ulong, DateTime> _affinityCooldowns { get; } = new ConcurrentDictionary<ulong, DateTime>();
|
||||
|
@ -1,9 +1,9 @@
|
||||
using Discord;
|
||||
using System;
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Attributes;
|
||||
using NadekoBot.Extensions;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NadekoBot.Services;
|
||||
using NadekoBot.Services.Database.Models;
|
||||
@ -42,7 +42,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
var members = role.Members().Where(u => u.Status != UserStatus.Offline && u.Status != UserStatus.Unknown);
|
||||
var membersArray = members as IUser[] ?? members.ToArray();
|
||||
var usr = membersArray[new NadekoRandom().Next(0, membersArray.Length)];
|
||||
await Context.Channel.SendConfirmAsync("🎟 Raffled user", $"**{usr.Username}#{usr.Discriminator}**", footer: $"ID: {usr.Id}").ConfigureAwait(false);
|
||||
await Context.Channel.SendConfirmAsync("🎟 "+ GetText("raffled_user"), $"**{usr.Username}#{usr.Discriminator}**", footer: $"ID: {usr.Id}").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
@ -50,15 +50,14 @@ namespace NadekoBot.Modules.Gambling
|
||||
public async Task Cash([Remainder] IUser user = null)
|
||||
{
|
||||
user = user ?? Context.User;
|
||||
|
||||
await Context.Channel.SendConfirmAsync($"{user.Username} has {GetCurrency(user.Id)} {CurrencySign}").ConfigureAwait(false);
|
||||
await ReplyConfirmLocalized("has", Format.Bold(user.ToString()), $"{GetCurrency(user.Id)} {CurrencySign}").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[Priority(1)]
|
||||
public async Task Cash(ulong userId)
|
||||
{
|
||||
await Context.Channel.SendConfirmAsync($"`{userId}` has {GetCurrency(userId)} {CurrencySign}").ConfigureAwait(false);
|
||||
await ReplyConfirmLocalized("has", Format.Code(userId.ToString()), $"{GetCurrency(userId)} {CurrencySign}").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
@ -70,11 +69,12 @@ namespace NadekoBot.Modules.Gambling
|
||||
var success = await CurrencyHandler.RemoveCurrencyAsync((IGuildUser)Context.User, $"Gift to {receiver.Username} ({receiver.Id}).", amount, false).ConfigureAwait(false);
|
||||
if (!success)
|
||||
{
|
||||
await Context.Channel.SendErrorAsync($"{Context.User.Mention} You don't have enough {CurrencyPluralName}.").ConfigureAwait(false);
|
||||
await ReplyErrorLocalized("not_enough", CurrencyPluralName).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
await CurrencyHandler.AddCurrencyAsync(receiver, $"Gift from {Context.User.Username} ({Context.User.Id}).", amount, true).ConfigureAwait(false);
|
||||
await Context.Channel.SendConfirmAsync($"{Context.User.Mention} gifted {amount}{CurrencySign} to {Format.Bold(receiver.ToString())}!").ConfigureAwait(false);
|
||||
await ReplyConfirmLocalized("gifted", amount + CurrencySign, Format.Bold(receiver.ToString()))
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
@ -93,8 +93,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
return;
|
||||
|
||||
await CurrencyHandler.AddCurrencyAsync(usrId, $"Awarded by bot owner. ({Context.User.Username}/{Context.User.Id})", amount).ConfigureAwait(false);
|
||||
|
||||
await Context.Channel.SendConfirmAsync($"{Context.User.Mention} awarded {amount}{CurrencySign} to <@{usrId}>!").ConfigureAwait(false);
|
||||
await ReplyConfirmLocalized("awarded", amount + CurrencySign, $"<@{usrId}>").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
@ -111,9 +110,10 @@ namespace NadekoBot.Modules.Gambling
|
||||
amount)))
|
||||
.ConfigureAwait(false);
|
||||
|
||||
await Context.Channel.SendConfirmAsync($"Awarded `{amount}` {CurrencyPluralName} to `{users.Count}` users from `{role.Name}` role.")
|
||||
.ConfigureAwait(false);
|
||||
|
||||
await ReplyConfirmLocalized("mass_award",
|
||||
amount + CurrencySign,
|
||||
Format.Bold(users.Count.ToString()),
|
||||
Format.Bold(role.Name)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
@ -125,9 +125,9 @@ namespace NadekoBot.Modules.Gambling
|
||||
return;
|
||||
|
||||
if (await CurrencyHandler.RemoveCurrencyAsync(user, $"Taken by bot owner.({Context.User.Username}/{Context.User.Id})", amount, true).ConfigureAwait(false))
|
||||
await Context.Channel.SendConfirmAsync($"{Context.User.Mention} successfully took {amount} {(amount == 1 ? CurrencyName : CurrencyPluralName)} from {user}!").ConfigureAwait(false);
|
||||
await ReplyConfirmLocalized("take", amount+CurrencySign, Format.Bold(user.ToString())).ConfigureAwait(false);
|
||||
else
|
||||
await Context.Channel.SendErrorAsync($"{Context.User.Mention} was unable to take {amount} {(amount == 1 ? CurrencyName : CurrencyPluralName)} from {user} because the user doesn't have that much {CurrencyPluralName}!").ConfigureAwait(false);
|
||||
await ReplyErrorLocalized("take_fail", amount + CurrencySign, Format.Bold(user.ToString()), CurrencyPluralName).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
|
||||
@ -139,9 +139,9 @@ namespace NadekoBot.Modules.Gambling
|
||||
return;
|
||||
|
||||
if (await CurrencyHandler.RemoveCurrencyAsync(usrId, $"Taken by bot owner.({Context.User.Username}/{Context.User.Id})", amount).ConfigureAwait(false))
|
||||
await Context.Channel.SendConfirmAsync($"{Context.User.Mention} successfully took {amount} {(amount == 1 ? CurrencyName : CurrencyPluralName)} from <@{usrId}>!").ConfigureAwait(false);
|
||||
await ReplyConfirmLocalized("take", amount + CurrencySign, $"<@{usrId}>").ConfigureAwait(false);
|
||||
else
|
||||
await Context.Channel.SendErrorAsync($"{Context.User.Mention} was unable to take {amount} {(amount == 1 ? CurrencyName : CurrencyPluralName)} from `{usrId}` because the user doesn't have that much {CurrencyPluralName}!").ConfigureAwait(false);
|
||||
await ReplyErrorLocalized("take_fail", amount + CurrencySign, Format.Code(usrId.ToString()), CurrencyPluralName).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
//[NadekoCommand, Usage, Description, Aliases]
|
||||
@ -205,49 +205,48 @@ namespace NadekoBot.Modules.Gambling
|
||||
if (amount < 1)
|
||||
return;
|
||||
|
||||
long userFlowers;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
if (!await CurrencyHandler.RemoveCurrencyAsync(Context.User, "Betroll Gamble", amount, false).ConfigureAwait(false))
|
||||
{
|
||||
userFlowers = uow.Currency.GetOrCreate(Context.User.Id).Amount;
|
||||
}
|
||||
|
||||
if (userFlowers < amount)
|
||||
{
|
||||
await Context.Channel.SendErrorAsync($"{Context.User.Mention} You don't have enough {CurrencyPluralName}. You only have {userFlowers}{CurrencySign}.").ConfigureAwait(false);
|
||||
await ReplyErrorLocalized("not_enough", CurrencyPluralName).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
await CurrencyHandler.RemoveCurrencyAsync(Context.User, "Betroll Gamble", amount, false).ConfigureAwait(false);
|
||||
|
||||
var rng = new NadekoRandom().Next(0, 101);
|
||||
var str = $"{Context.User.Mention} `You rolled {rng}.` ";
|
||||
if (rng < 67)
|
||||
var rnd = new NadekoRandom().Next(0, 101);
|
||||
var str = Context.User.Mention + Format.Code(GetText("roll", rnd));
|
||||
if (rnd < 67)
|
||||
{
|
||||
str += "Better luck next time.";
|
||||
}
|
||||
else if (rng < 91)
|
||||
{
|
||||
str += $"Congratulations! You won {amount * NadekoBot.BotConfig.Betroll67Multiplier}{CurrencySign} for rolling above 66";
|
||||
await CurrencyHandler.AddCurrencyAsync(Context.User, "Betroll Gamble", (int)(amount * NadekoBot.BotConfig.Betroll67Multiplier), false).ConfigureAwait(false);
|
||||
}
|
||||
else if (rng < 100)
|
||||
{
|
||||
str += $"Congratulations! You won {amount * NadekoBot.BotConfig.Betroll91Multiplier}{CurrencySign} for rolling above 90.";
|
||||
await CurrencyHandler.AddCurrencyAsync(Context.User, "Betroll Gamble", (int)(amount * NadekoBot.BotConfig.Betroll91Multiplier), false).ConfigureAwait(false);
|
||||
str += GetText("better_luck");
|
||||
}
|
||||
else
|
||||
{
|
||||
str += $"👑 Congratulations! You won {amount * NadekoBot.BotConfig.Betroll100Multiplier}{CurrencySign} for rolling **100**. 👑";
|
||||
await CurrencyHandler.AddCurrencyAsync(Context.User, "Betroll Gamble", (int)(amount * NadekoBot.BotConfig.Betroll100Multiplier), false).ConfigureAwait(false);
|
||||
if (rnd < 91)
|
||||
{
|
||||
str += GetText("br_win", (amount * NadekoBot.BotConfig.Betroll67Multiplier) + CurrencySign, 66);
|
||||
await CurrencyHandler.AddCurrencyAsync(Context.User, "Betroll Gamble",
|
||||
(int) (amount * NadekoBot.BotConfig.Betroll67Multiplier), false).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
else if (rnd < 100)
|
||||
{
|
||||
str += GetText("br_win", (amount * NadekoBot.BotConfig.Betroll91Multiplier) + CurrencySign, 90);
|
||||
await CurrencyHandler.AddCurrencyAsync(Context.User, "Betroll Gamble",
|
||||
(int) (amount * NadekoBot.BotConfig.Betroll91Multiplier), false).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
str += GetText("br_win", (amount * NadekoBot.BotConfig.Betroll100Multiplier) + CurrencySign, 100) + " 👑";
|
||||
await CurrencyHandler.AddCurrencyAsync(Context.User, "Betroll Gamble",
|
||||
(int) (amount * NadekoBot.BotConfig.Betroll100Multiplier), false).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
Console.WriteLine("started sending");
|
||||
await Context.Channel.SendConfirmAsync(str).ConfigureAwait(false);
|
||||
Console.WriteLine("done sending");
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
public async Task Leaderboard()
|
||||
{
|
||||
var richest = new List<Currency>();
|
||||
List<Currency> richest;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
richest = uow.Currency.GetTopRichest(9).ToList();
|
||||
@ -255,22 +254,22 @@ namespace NadekoBot.Modules.Gambling
|
||||
if (!richest.Any())
|
||||
return;
|
||||
|
||||
|
||||
var embed = new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle(NadekoBot.BotConfig.CurrencySign + " Leaderboard");
|
||||
.WithTitle(NadekoBot.BotConfig.CurrencySign + " " + GetText("leaderboard"));
|
||||
|
||||
for (var i = 0; i < richest.Count; i++)
|
||||
{
|
||||
var x = richest[i];
|
||||
var usr = await Context.Guild.GetUserAsync(x.UserId).ConfigureAwait(false);
|
||||
var usrStr = "";
|
||||
if (usr == null)
|
||||
usrStr = x.UserId.ToString();
|
||||
else
|
||||
usrStr = usr.Username?.TrimTo(20, true);
|
||||
var usrStr = usr == null
|
||||
? x.UserId.ToString()
|
||||
: usr.Username?.TrimTo(20, true);
|
||||
|
||||
embed.AddField(efb => efb.WithName("#" + (i + 1) + " " + usrStr).WithValue(x.Amount.ToString() + " " + NadekoBot.BotConfig.CurrencySign).WithIsInline(true));
|
||||
var j = i;
|
||||
embed.AddField(efb => efb.WithName("#" + (j + 1) + " " + usrStr)
|
||||
.WithValue(x.Amount.ToString() + " " + NadekoBot.BotConfig.CurrencySign)
|
||||
.WithIsInline(true));
|
||||
}
|
||||
|
||||
await Context.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||
|
@ -67,15 +67,27 @@ namespace NadekoBot.Modules
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
LogManager.GetCurrentClassLogger().Warn(lowerModuleTypeName + "_" + key + " key is missing from " + cultureInfo + " response strings. PLEASE REPORT THIS.");
|
||||
return NadekoBot.ResponsesResourceManager.GetString(lowerModuleTypeName + "_" + key, _usCultureInfo) ?? $"Error: dkey {lowerModuleTypeName + "_" + key} found!";
|
||||
text = NadekoBot.ResponsesResourceManager.GetString(lowerModuleTypeName + "_" + key, _usCultureInfo) ?? $"Error: dkey {lowerModuleTypeName + "_" + key} not found!";
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
return "I cant tell if you command is executed, because there was an error printing out the response. Key '" +
|
||||
lowerModuleTypeName + "_" + key + "' " + "is missing from resources. Please report this.";
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
public static string GetTextStatic(string key, CultureInfo cultureInfo, string lowerModuleTypeName, params object[] replacements)
|
||||
public static string GetTextStatic(string key, CultureInfo cultureInfo, string lowerModuleTypeName,
|
||||
params object[] replacements)
|
||||
{
|
||||
try
|
||||
{
|
||||
return string.Format(GetTextStatic(key, cultureInfo, lowerModuleTypeName), replacements);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
return "I cant tell if you command is executed, because there was an error printing out the response. Key '" +
|
||||
lowerModuleTypeName + "_" + key + "' " + "is not properly formatted. Please report this.";
|
||||
}
|
||||
}
|
||||
|
||||
protected string GetText(string key) =>
|
||||
GetTextStatic(key, _cultureInfo, LowerModuleTypeName);
|
||||
@ -85,26 +97,26 @@ namespace NadekoBot.Modules
|
||||
|
||||
public Task<IUserMessage> ErrorLocalized(string textKey, params object[] replacements)
|
||||
{
|
||||
var text = GetText(textKey);
|
||||
return Context.Channel.SendErrorAsync(string.Format(text, replacements));
|
||||
var text = GetText(textKey, replacements);
|
||||
return Context.Channel.SendErrorAsync(text);
|
||||
}
|
||||
|
||||
public Task<IUserMessage> ReplyErrorLocalized(string textKey, params object[] replacements)
|
||||
{
|
||||
var text = GetText(textKey);
|
||||
return Context.Channel.SendErrorAsync(Context.User.Mention + " " + string.Format(text, replacements));
|
||||
var text = GetText(textKey, replacements);
|
||||
return Context.Channel.SendErrorAsync(Context.User.Mention + " " + text);
|
||||
}
|
||||
|
||||
public Task<IUserMessage> ConfirmLocalized(string textKey, params object[] replacements)
|
||||
{
|
||||
var text = GetText(textKey);
|
||||
return Context.Channel.SendConfirmAsync(string.Format(text, replacements));
|
||||
var text = GetText(textKey, replacements);
|
||||
return Context.Channel.SendConfirmAsync(text);
|
||||
}
|
||||
|
||||
public Task<IUserMessage> ReplyConfirmLocalized(string textKey, params object[] replacements)
|
||||
{
|
||||
var text = GetText(textKey);
|
||||
return Context.Channel.SendConfirmAsync(Context.User.Mention + " " + string.Format(text, replacements));
|
||||
var text = GetText(textKey, replacements);
|
||||
return Context.Channel.SendConfirmAsync(Context.User.Mention + " " + text);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,2 +1,3 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=modules_005Cadministration_005Ccommands/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=modules_005Cadministration_005Ccommands/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=modules_005Cgambling_005Ccommands/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
234
src/NadekoBot/Resources/ResponseStrings.Designer.cs
generated
234
src/NadekoBot/Resources/ResponseStrings.Designer.cs
generated
@ -2072,6 +2072,240 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to has awarded {0} to {1}.
|
||||
/// </summary>
|
||||
public static string gambling_awarded {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_awarded", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Betflip Gamble.
|
||||
/// </summary>
|
||||
public static string gambling_betflip_gamble {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_betflip_gamble", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Better luck next time ^_^.
|
||||
/// </summary>
|
||||
public static string gambling_better_luck {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_better_luck", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Congratulations! You won {0} for rolling above {1}.
|
||||
/// </summary>
|
||||
public static string gambling_br_win {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_br_win", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to You guessed it! You won {0}.
|
||||
/// </summary>
|
||||
public static string gambling_flip_guess {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_flip_guess", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Invalid number specified. You can flip 1 to {0} coins..
|
||||
/// </summary>
|
||||
public static string gambling_flip_invalid {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_flip_invalid", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to flipped {0}..
|
||||
/// </summary>
|
||||
public static string gambling_flipped {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_flipped", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to has gifted {0} to {1}.
|
||||
/// </summary>
|
||||
public static string gambling_gifted {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_gifted", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0} has {1}.
|
||||
/// </summary>
|
||||
public static string gambling_has {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_has", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Heads.
|
||||
/// </summary>
|
||||
public static string gambling_heads {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_heads", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Leaderboard.
|
||||
/// </summary>
|
||||
public static string gambling_leaderboard {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_leaderboard", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Awarded {0} to {1} users from {2} role..
|
||||
/// </summary>
|
||||
public static string gambling_mass_award {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_mass_award", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to You can't bet more than {0}.
|
||||
/// </summary>
|
||||
public static string gambling_max_bet_limit {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_max_bet_limit", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to You can't bet less than {0}.
|
||||
/// </summary>
|
||||
public static string gambling_min_bet_limit {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_min_bet_limit", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to You don't have enough {0}.
|
||||
/// </summary>
|
||||
public static string gambling_not_enough {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_not_enough", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Raffled User.
|
||||
/// </summary>
|
||||
public static string gambling_raffled_user {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_raffled_user", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to You rolled {0}..
|
||||
/// </summary>
|
||||
public static string gambling_roll {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_roll", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Bet.
|
||||
/// </summary>
|
||||
public static string gambling_slot_bet {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_slot_bet", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to WOAAHHHHHH!!! Congratulations!!! x{0}.
|
||||
/// </summary>
|
||||
public static string gambling_slot_jackpot {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_slot_jackpot", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to A single {0}, x{1}.
|
||||
/// </summary>
|
||||
public static string gambling_slot_single {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_slot_single", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Wow! Lucky! Three of a kind! x{0}.
|
||||
/// </summary>
|
||||
public static string gambling_slot_three {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_slot_three", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Good job! Two {0} - bet x{1}.
|
||||
/// </summary>
|
||||
public static string gambling_slot_two {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_slot_two", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Won.
|
||||
/// </summary>
|
||||
public static string gambling_slot_won {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_slot_won", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Tails.
|
||||
/// </summary>
|
||||
public static string gambling_tails {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_tails", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to successfully took {0} from {1}.
|
||||
/// </summary>
|
||||
public static string gambling_take {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_take", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to was unable to take {0} from{1} because the user doesn't have that much {2}!.
|
||||
/// </summary>
|
||||
public static string gambling_take_fail {
|
||||
get {
|
||||
return ResourceManager.GetString("gambling_take_fail", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Back to ToC.
|
||||
/// </summary>
|
||||
|
@ -870,6 +870,87 @@ Reason: {1}</value>
|
||||
<data name="adminsitration_sb_user" xml:space="preserve">
|
||||
<value>User Soft-Banned</value>
|
||||
</data>
|
||||
<data name="gambling_awarded" xml:space="preserve">
|
||||
<value>has awarded {0} to {1}</value>
|
||||
</data>
|
||||
<data name="gambling_betflip_gamble" xml:space="preserve">
|
||||
<value>Betflip Gamble</value>
|
||||
</data>
|
||||
<data name="gambling_better_luck" xml:space="preserve">
|
||||
<value>Better luck next time ^_^</value>
|
||||
</data>
|
||||
<data name="gambling_br_win" xml:space="preserve">
|
||||
<value>Congratulations! You won {0} for rolling above {1}</value>
|
||||
</data>
|
||||
<data name="gambling_flipped" xml:space="preserve">
|
||||
<value>flipped {0}.</value>
|
||||
<comment>User flipped tails.</comment>
|
||||
</data>
|
||||
<data name="gambling_flip_guess" xml:space="preserve">
|
||||
<value>You guessed it! You won {0}</value>
|
||||
</data>
|
||||
<data name="gambling_flip_invalid" xml:space="preserve">
|
||||
<value>Invalid number specified. You can flip 1 to {0} coins.</value>
|
||||
</data>
|
||||
<data name="gambling_gifted" xml:space="preserve">
|
||||
<value>has gifted {0} to {1}</value>
|
||||
<comment>X has gifted 15 flowers to Y</comment>
|
||||
</data>
|
||||
<data name="gambling_has" xml:space="preserve">
|
||||
<value>{0} has {1}</value>
|
||||
<comment>X has Y flowers</comment>
|
||||
</data>
|
||||
<data name="gambling_heads" xml:space="preserve">
|
||||
<value>Heads</value>
|
||||
</data>
|
||||
<data name="gambling_leaderboard" xml:space="preserve">
|
||||
<value>Leaderboard</value>
|
||||
</data>
|
||||
<data name="gambling_mass_award" xml:space="preserve">
|
||||
<value>Awarded {0} to {1} users from {2} role.</value>
|
||||
</data>
|
||||
<data name="gambling_max_bet_limit" xml:space="preserve">
|
||||
<value>You can't bet more than {0}</value>
|
||||
</data>
|
||||
<data name="gambling_min_bet_limit" xml:space="preserve">
|
||||
<value>You can't bet less than {0}</value>
|
||||
</data>
|
||||
<data name="gambling_not_enough" xml:space="preserve">
|
||||
<value>You don't have enough {0}</value>
|
||||
</data>
|
||||
<data name="gambling_raffled_user" xml:space="preserve">
|
||||
<value>Raffled User</value>
|
||||
</data>
|
||||
<data name="gambling_roll" xml:space="preserve">
|
||||
<value>You rolled {0}.</value>
|
||||
</data>
|
||||
<data name="gambling_slot_bet" xml:space="preserve">
|
||||
<value>Bet</value>
|
||||
</data>
|
||||
<data name="gambling_slot_jackpot" xml:space="preserve">
|
||||
<value>WOAAHHHHHH!!! Congratulations!!! x{0}</value>
|
||||
</data>
|
||||
<data name="gambling_slot_single" xml:space="preserve">
|
||||
<value>A single {0}, x{1}</value>
|
||||
</data>
|
||||
<data name="gambling_slot_three" xml:space="preserve">
|
||||
<value>Wow! Lucky! Three of a kind! x{0}</value>
|
||||
</data>
|
||||
<data name="gambling_slot_two" xml:space="preserve">
|
||||
<value>Good job! Two {0} - bet x{1}</value>
|
||||
</data>
|
||||
<data name="gambling_slot_won" xml:space="preserve">
|
||||
<value>Won</value>
|
||||
</data>
|
||||
<data name="gambling_tails" xml:space="preserve">
|
||||
<value>Tails</value>
|
||||
</data>
|
||||
<data name="gambling_take" xml:space="preserve">
|
||||
<value>successfully took {0} from {1}</value>
|
||||
</data>
|
||||
<data name="gambling_take_fail" xml:space="preserve">
|
||||
<value>was unable to take {0} from{1} because the user doesn't have that much {2}!</value>
|
||||
</data>
|
||||
<data name="help_back_to_toc" xml:space="preserve">
|
||||
<value>Back to ToC</value>
|
||||
</data>
|
||||
|
Loading…
Reference in New Issue
Block a user