sneaky game will say a number of rewarded users at the end
This commit is contained in:
parent
8791bc55f5
commit
f850d62c89
@ -78,6 +78,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
_secretCode += _sneakyGameStatusChars[rng.Next(0, _sneakyGameStatusChars.Length)];
|
_secretCode += _sneakyGameStatusChars[rng.Next(0, _sneakyGameStatusChars.Length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var game = NadekoBot.Client.Game?.Name;
|
||||||
await NadekoBot.Client.SetGameAsync($"type {_secretCode} for " + NadekoBot.BotConfig.CurrencyPluralName)
|
await NadekoBot.Client.SetGameAsync($"type {_secretCode} for " + NadekoBot.BotConfig.CurrencyPluralName)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
try
|
try
|
||||||
@ -94,10 +95,11 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
await Task.Delay(num * 1000);
|
await Task.Delay(num * 1000);
|
||||||
NadekoBot.Client.MessageReceived -= SneakyGameMessageReceivedEventHandler;
|
NadekoBot.Client.MessageReceived -= SneakyGameMessageReceivedEventHandler;
|
||||||
|
|
||||||
|
var cnt = _sneakyGameAwardedUsers.Count;
|
||||||
_sneakyGameAwardedUsers.Clear();
|
_sneakyGameAwardedUsers.Clear();
|
||||||
_secretCode = String.Empty;
|
_secretCode = String.Empty;
|
||||||
|
|
||||||
await NadekoBot.Client.SetGameAsync($"SneakyGame event ended.")
|
await NadekoBot.Client.SetGameAsync($"SneakyGame event ended. {cnt} users received a reward.")
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ namespace NadekoBot.Modules.Games
|
|||||||
private static Tuple<string, Stream> GetRandomCurrencyImage()
|
private static Tuple<string, Stream> GetRandomCurrencyImage()
|
||||||
{
|
{
|
||||||
var rng = new NadekoRandom();
|
var rng = new NadekoRandom();
|
||||||
var images = NadekoBot.Images.CurrencyImages;
|
var images = NadekoBot.Images.Currency;
|
||||||
|
|
||||||
return images[rng.Next(0, images.Count)];
|
return images[rng.Next(0, images.Count)];
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,8 @@ namespace NadekoBot.Services
|
|||||||
Stream Heads { get; }
|
Stream Heads { get; }
|
||||||
Stream Tails { get; }
|
Stream Tails { get; }
|
||||||
|
|
||||||
IImmutableList<Tuple<string, Stream>> CurrencyImages { get; }
|
IImmutableList<Tuple<string, Stream>> Currency { get; }
|
||||||
|
IImmutableList<Tuple<string, Stream>> Dice { get; }
|
||||||
|
|
||||||
Task Reload();
|
Task Reload();
|
||||||
}
|
}
|
||||||
|
@ -19,16 +19,22 @@ namespace NadekoBot.Services.Impl
|
|||||||
private const string tailsPath = "data/images/coins/tails.png";
|
private const string tailsPath = "data/images/coins/tails.png";
|
||||||
|
|
||||||
private const string currencyImagesPath = "data/currency_images";
|
private const string currencyImagesPath = "data/currency_images";
|
||||||
|
private const string diceImagesPath = "data/images/dice";
|
||||||
|
|
||||||
private byte[] heads;
|
private byte[] heads;
|
||||||
public Stream Heads => new MemoryStream(heads, false);
|
public Stream Heads => new MemoryStream(heads, false);
|
||||||
|
|
||||||
private byte[] tails;
|
private byte[] tails;
|
||||||
public Stream Tails => new MemoryStream(tails, false);
|
public Stream Tails => new MemoryStream(tails, false);
|
||||||
//todo tuple
|
//todo C#7
|
||||||
private IReadOnlyDictionary<string, byte[]> currencyImages;
|
private IReadOnlyDictionary<string, byte[]> currency;
|
||||||
public IImmutableList<Tuple<string, Stream>> CurrencyImages =>
|
public IImmutableList<Tuple<string, Stream>> Currency =>
|
||||||
currencyImages.Select(x => new Tuple<string, Stream>(x.Key, (Stream)new MemoryStream(x.Value, false)))
|
currency.Select(x => new Tuple<string, Stream>(x.Key, new MemoryStream(x.Value, false)))
|
||||||
|
.ToImmutableArray();
|
||||||
|
|
||||||
|
private IReadOnlyDictionary<string, byte[]> dice;
|
||||||
|
public IImmutableList<Tuple<string, Stream>> Dice =>
|
||||||
|
dice.Select(x => new Tuple<string, Stream>(x.Key, new MemoryStream(x.Value, false)))
|
||||||
.ToImmutableArray();
|
.ToImmutableArray();
|
||||||
|
|
||||||
private ImagesService()
|
private ImagesService()
|
||||||
@ -52,7 +58,8 @@ namespace NadekoBot.Services.Impl
|
|||||||
heads = File.ReadAllBytes(headsPath);
|
heads = File.ReadAllBytes(headsPath);
|
||||||
tails = File.ReadAllBytes(tailsPath);
|
tails = File.ReadAllBytes(tailsPath);
|
||||||
|
|
||||||
currencyImages = Directory.GetFiles(currencyImagesPath).ToDictionary(x => Path.GetFileName(x), x => File.ReadAllBytes(x));
|
currency = Directory.GetFiles(currencyImagesPath).ToDictionary(x => Path.GetFileName(x), x => File.ReadAllBytes(x));
|
||||||
|
dice = Directory.GetFiles(diceImagesPath).ToDictionary(x => Path.GetFileName(x), x => File.ReadAllBytes(x));
|
||||||
_log.Info($"Images loaded after {sw.Elapsed.TotalSeconds:F2}s!");
|
_log.Info($"Images loaded after {sw.Elapsed.TotalSeconds:F2}s!");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
Loading…
Reference in New Issue
Block a user