fixed some things

This commit is contained in:
Kwoth 2017-02-25 16:35:09 +01:00
parent 316c05436e
commit a413184a43
4 changed files with 34 additions and 44 deletions

View File

@ -6,7 +6,6 @@ using NadekoBot.Attributes;
using System;
using System.Collections.Concurrent;
using System.Linq;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Threading;
@ -15,8 +14,6 @@ using System.Net.Http;
using ImageSharp;
using NadekoBot.DataStructures;
using NLog;
using ImageSharp.Drawing.Pens;
using SixLabors.Shapes;
namespace NadekoBot.Modules.Games
{
@ -37,7 +34,7 @@ namespace NadekoBot.Modules.Games
if (string.IsNullOrWhiteSpace(list))
return;
var listArr = list.Split(';');
if (listArr.Count() < 2)
if (listArr.Length < 2)
return;
var rng = new NadekoRandom();
await Context.Channel.SendConfirmAsync("🤔", listArr[rng.Next(0, listArr.Length)]).ConfigureAwait(false);
@ -57,7 +54,7 @@ namespace NadekoBot.Modules.Games
[NadekoCommand, Usage, Description, Aliases]
public async Task Rps(string input)
{
Func<int,string> GetRPSPick = (p) =>
Func<int,string> getRpsPick = (p) =>
{
switch (p)
{
@ -93,15 +90,15 @@ namespace NadekoBot.Modules.Games
var nadekoPick = new NadekoRandom().Next(0, 3);
string msg;
if (pick == nadekoPick)
msg = GetText("rps_draw", GetRPSPick(pick));
msg = GetText("rps_draw", getRpsPick(pick));
else if ((pick == 0 && nadekoPick == 1) ||
(pick == 1 && nadekoPick == 2) ||
(pick == 2 && nadekoPick == 0))
msg = GetText("rps_win", NadekoBot.Client.CurrentUser.Mention,
GetRPSPick(nadekoPick), GetRPSPick(pick));
getRpsPick(nadekoPick), getRpsPick(pick));
else
msg = GetText("rps_win", Context.User.Mention, GetRPSPick(pick),
GetRPSPick(nadekoPick));
msg = GetText("rps_win", Context.User.Mention, getRpsPick(pick),
getRpsPick(nadekoPick));
await Context.Channel.SendConfirmAsync(msg).ConfigureAwait(false);
}
@ -110,7 +107,7 @@ namespace NadekoBot.Modules.Games
public class GirlRating
{
private static Logger _log = LogManager.GetCurrentClassLogger();
private static readonly Logger _log = LogManager.GetCurrentClassLogger();
public double Crazy { get; }
public double Hot { get; }
@ -132,19 +129,17 @@ namespace NadekoBot.Modules.Games
using (var ms = new MemoryStream(NadekoBot.Images.WifeMatrix.ToArray(), false))
using (var img = new ImageSharp.Image(ms))
{
var clr = new ImageSharp.Color(0x0000ff);
const int minx = 35;
const int miny = 385;
const int length = 345;
var pointx = (int)(minx + length * (Hot / 10));
var pointy = (int)(miny - length * ((Crazy - 4) / 6));
var p = new Pen(ImageSharp.Color.Red, 5);
using (var pointMs = new MemoryStream(NadekoBot.Images.RategirlDot.ToArray(), false))
using (var pointImg = new ImageSharp.Image(pointMs))
{
img.DrawImage(pointImg, 100, default(ImageSharp.Size), new Point(pointx - 10, pointy - 10));
img.DrawImage(pointImg, 100, default(Size), new Point(pointx - 10, pointy - 10));
}
string url;
@ -196,12 +191,10 @@ namespace NadekoBot.Modules.Games
var roll = rng.Next(1, 1001);
if (uid == 185968432783687681 ||
uid == 265642040950390784)
roll += 100;
if ((uid == 185968432783687681 ||
uid == 265642040950390784) && roll >= 900)
roll = 1000;
if (uid == 68946899150839808)
roll = 990;
double hot;
double crazy;
@ -234,7 +227,7 @@ namespace NadekoBot.Modules.Games
else if (roll < 951)
{
hot = NextDouble(8, 10);
crazy = NextDouble(4, 10);
crazy = NextDouble(7, .6 * hot + 4);
advice = "Below the crazy line, above an 8 hot, but still about 7 crazy. This is your DATE ZONE. " +
"You can stay in the date zone indefinitely. These are the girls you introduce to your friends and your family. " +
"They're good looking, and they're reasonably not crazy most of the time. You can stay here indefinitely.";

View File

@ -501,7 +501,7 @@ namespace NadekoBot.Resources {
}
/// <summary>
/// Looks up a localized string similar to Stops people from repeating same message X times in a row. You can specify to either mute, kick or ban the offenders..
/// Looks up a localized string similar to Stops people from repeating same message X times in a row. You can specify to either mute, kick or ban the offenders. Max message count is 10..
/// </summary>
public static string antispam_desc {
get {

View File

@ -2443,7 +2443,7 @@
<value>antispam</value>
</data>
<data name="antispam_desc" xml:space="preserve">
<value>Stops people from repeating same message X times in a row. You can specify to either mute, kick or ban the offenders.</value>
<value>Stops people from repeating same message X times in a row. You can specify to either mute, kick or ban the offenders. Max message count is 10.</value>
</data>
<data name="antispam_usage" xml:space="preserve">
<value>`{0}antispam 3 Mute` or `{0}antispam 4 Kick` or `{0}antispam 6 Ban`</value>

View File

@ -1,13 +1,10 @@
using NadekoBot.DataStructures;
using NLog;
using NLog;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NadekoBot.Services.Impl
@ -16,26 +13,26 @@ namespace NadekoBot.Services.Impl
{
private readonly Logger _log;
private const string basePath = "data/images/";
private const string _basePath = "data/images/";
private const string headsPath = basePath + "coins/heads.png";
private const string tailsPath = basePath + "coins/tails.png";
private const string _headsPath = _basePath + "coins/heads.png";
private const string _tailsPath = _basePath + "coins/tails.png";
private const string currencyImagesPath = basePath + "currency";
private const string diceImagesPath = basePath + "dice";
private const string _currencyImagesPath = _basePath + "currency";
private const string _diceImagesPath = _basePath + "dice";
private const string slotBackgroundPath = basePath + "slots/background.png";
private const string slotNumbersPath = basePath + "slots/numbers/";
private const string slotEmojisPath = basePath + "slots/emojis/";
private const string _slotBackgroundPath = _basePath + "slots/background.png";
private const string _slotNumbersPath = _basePath + "slots/numbers/";
private const string _slotEmojisPath = _basePath + "slots/emojis/";
private const string _wifeMatrixPath = basePath + "rategirl/wifematrix.png";
private const string _rategirlDot = basePath + "rategirl/dot.png";
private const string _wifeMatrixPath = _basePath + "rategirl/wifematrix.png";
private const string _rategirlDot = _basePath + "rategirl/dot.png";
public ImmutableArray<byte> Heads { get; private set; }
public ImmutableArray<byte> Tails { get; private set; }
//todo C#7
//todo C#7 tuples
public ImmutableArray<KeyValuePair<string, ImmutableArray<byte>>> Currency { get; private set; }
public ImmutableArray<KeyValuePair<string, ImmutableArray<byte>>> Dice { get; private set; }
@ -65,29 +62,29 @@ namespace NadekoBot.Services.Impl
{
_log.Info("Loading images...");
var sw = Stopwatch.StartNew();
Heads = File.ReadAllBytes(headsPath).ToImmutableArray();
Tails = File.ReadAllBytes(tailsPath).ToImmutableArray();
Heads = File.ReadAllBytes(_headsPath).ToImmutableArray();
Tails = File.ReadAllBytes(_tailsPath).ToImmutableArray();
Currency = Directory.GetFiles(currencyImagesPath)
Currency = Directory.GetFiles(_currencyImagesPath)
.Select(x => new KeyValuePair<string, ImmutableArray<byte>>(
Path.GetFileName(x),
File.ReadAllBytes(x).ToImmutableArray()))
.ToImmutableArray();
Dice = Directory.GetFiles(diceImagesPath)
Dice = Directory.GetFiles(_diceImagesPath)
.OrderBy(x => int.Parse(Path.GetFileNameWithoutExtension(x)))
.Select(x => new KeyValuePair<string, ImmutableArray<byte>>(x,
File.ReadAllBytes(x).ToImmutableArray()))
.ToImmutableArray();
SlotBackground = File.ReadAllBytes(slotBackgroundPath).ToImmutableArray();
SlotBackground = File.ReadAllBytes(_slotBackgroundPath).ToImmutableArray();
SlotNumbers = Directory.GetFiles(slotNumbersPath)
SlotNumbers = Directory.GetFiles(_slotNumbersPath)
.OrderBy(f => int.Parse(Path.GetFileNameWithoutExtension(f)))
.Select(x => File.ReadAllBytes(x).ToImmutableArray())
.ToImmutableArray();
SlotEmojis = Directory.GetFiles(slotEmojisPath)
SlotEmojis = Directory.GetFiles(_slotEmojisPath)
.OrderBy(f => int.Parse(Path.GetFileNameWithoutExtension(f)))
.Select(x => File.ReadAllBytes(x).ToImmutableArray())
.ToImmutableArray();