mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 01:38:27 -04:00
Kotz's editorconfig styles slightly modified. Target typed new usage. Brackets in expressions used for clarity.
This commit is contained in:
@@ -41,8 +41,8 @@ public sealed class AcrophobiaGame : IDisposable
|
||||
public Phase CurrentPhase { get; private set; } = Phase.Submission;
|
||||
public ImmutableArray<char> StartingLetters { get; private set; }
|
||||
|
||||
private readonly Dictionary<AcrophobiaUser, int> submissions = new Dictionary<AcrophobiaUser, int>();
|
||||
private readonly SemaphoreSlim locker = new SemaphoreSlim(1, 1);
|
||||
private readonly Dictionary<AcrophobiaUser, int> submissions = new();
|
||||
private readonly SemaphoreSlim locker = new(1, 1);
|
||||
public Options Opts { get; }
|
||||
private readonly NadekoRandom _rng;
|
||||
|
||||
@@ -51,7 +51,7 @@ public sealed class AcrophobiaGame : IDisposable
|
||||
public event Func<string, Task> OnUserVoted = delegate { return Task.CompletedTask; };
|
||||
public event Func<AcrophobiaGame, ImmutableArray<KeyValuePair<AcrophobiaUser, int>>, Task> OnEnded = delegate { return Task.CompletedTask; };
|
||||
|
||||
private readonly HashSet<ulong> _usersWhoVoted = new HashSet<ulong>();
|
||||
private readonly HashSet<ulong> _usersWhoVoted = new();
|
||||
|
||||
public AcrophobiaGame(Options options)
|
||||
{
|
||||
|
@@ -4,7 +4,7 @@ namespace NadekoBot.Modules.Games.Common.ChatterBot;
|
||||
|
||||
public class ChatterBotSession : IChatterBotSession
|
||||
{
|
||||
private static NadekoRandom Rng { get; } = new NadekoRandom();
|
||||
private static NadekoRandom Rng { get; } = new();
|
||||
|
||||
private readonly string _chatterBotId;
|
||||
private readonly IHttpClientFactory _httpFactory;
|
||||
|
@@ -57,7 +57,7 @@ public class CleverbotIOSession : IChatterBotSession
|
||||
this._user = user;
|
||||
this._httpFactory = factory;
|
||||
|
||||
_nick = new((Func<Task<string>>)GetNick);
|
||||
_nick = new(GetNick);
|
||||
}
|
||||
|
||||
private async Task<string> GetNick()
|
||||
|
@@ -10,20 +10,20 @@ public sealed partial class GamesConfig : ICloneable<GamesConfig>
|
||||
public int Version { get; set; }
|
||||
|
||||
[Comment("Hangman related settings (.hangman command)")]
|
||||
public HangmanConfig Hangman { get; set; } = new HangmanConfig()
|
||||
public HangmanConfig Hangman { get; set; } = new()
|
||||
{
|
||||
CurrencyReward = 0
|
||||
};
|
||||
|
||||
[Comment("Trivia related settings (.t command)")]
|
||||
public TriviaConfig Trivia { get; set; } = new TriviaConfig()
|
||||
public TriviaConfig Trivia { get; set; } = new()
|
||||
{
|
||||
CurrencyReward = 0,
|
||||
MinimumWinReq = 1,
|
||||
};
|
||||
|
||||
[Comment("List of responses for the .8ball command. A random one will be selected every time")]
|
||||
public List<string> EightBallResponses { get; set; } = new List<string>()
|
||||
public List<string> EightBallResponses { get; set; } = new()
|
||||
{
|
||||
"Most definitely yes.",
|
||||
"For sure.",
|
||||
@@ -51,16 +51,16 @@ public sealed partial class GamesConfig : ICloneable<GamesConfig>
|
||||
};
|
||||
|
||||
[Comment("List of animals which will be used for the animal race game (.race)")]
|
||||
public List<RaceAnimal> RaceAnimals { get; set; } = new List<RaceAnimal>()
|
||||
public List<RaceAnimal> RaceAnimals { get; set; } = new()
|
||||
{
|
||||
new RaceAnimal { Icon = "🐼", Name = "Panda" },
|
||||
new RaceAnimal { Icon = "🐻", Name = "Bear" },
|
||||
new RaceAnimal { Icon = "🐧", Name = "Pengu" },
|
||||
new RaceAnimal { Icon = "🐨", Name = "Koala" },
|
||||
new RaceAnimal { Icon = "🐬", Name = "Dolphin" },
|
||||
new RaceAnimal { Icon = "🐞", Name = "Ladybird" },
|
||||
new RaceAnimal { Icon = "🦀", Name = "Crab" },
|
||||
new RaceAnimal { Icon = "🦄", Name = "Unicorn" }
|
||||
new() { Icon = "🐼", Name = "Panda" },
|
||||
new() { Icon = "🐻", Name = "Bear" },
|
||||
new() { Icon = "🐧", Name = "Pengu" },
|
||||
new() { Icon = "🐨", Name = "Koala" },
|
||||
new() { Icon = "🐬", Name = "Dolphin" },
|
||||
new() { Icon = "🐞", Name = "Ladybird" },
|
||||
new() { Icon = "🦀", Name = "Crab" },
|
||||
new() { Icon = "🦄", Name = "Unicorn" }
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -36,8 +36,8 @@ public class GirlRating
|
||||
const int miny = 385;
|
||||
const int length = 345;
|
||||
|
||||
var pointx = (int)(minx + length * (Hot / 10));
|
||||
var pointy = (int)(miny - length * ((Crazy - 4) / 6));
|
||||
var pointx = (int)(minx + (length * (Hot / 10)));
|
||||
var pointy = (int)(miny - (length * ((Crazy - 4) / 6)));
|
||||
|
||||
using (var pointImg = Image.Load(_images.RategirlDot))
|
||||
{
|
||||
|
@@ -40,7 +40,7 @@ public sealed class HangmanGame
|
||||
}
|
||||
|
||||
public State GetState(GuessResult guessResult = GuessResult.NoAction)
|
||||
=> new State(_incorrect.Count,
|
||||
=> new(_incorrect.Count,
|
||||
CurrentPhase,
|
||||
CurrentPhase == Phase.Ended
|
||||
? _word
|
||||
@@ -64,7 +64,7 @@ public sealed class HangmanGame
|
||||
else
|
||||
output[i*2] = '_';
|
||||
|
||||
output[i * 2 + 1] = ' ';
|
||||
output[(i * 2) + 1] = ' ';
|
||||
}
|
||||
|
||||
return new(output);
|
||||
|
@@ -21,10 +21,10 @@ public sealed class NunchiGame : IDisposable
|
||||
public event Func<NunchiGame, (ulong Id, string Name)?, Task> OnRoundEnded; // tuple of the user who failed
|
||||
public event Func<NunchiGame, string, Task> OnGameEnded; // name of the user who won
|
||||
|
||||
private readonly SemaphoreSlim _locker = new SemaphoreSlim(1, 1);
|
||||
private readonly SemaphoreSlim _locker = new(1, 1);
|
||||
|
||||
private HashSet<(ulong Id, string Name)> _participants = new HashSet<(ulong Id, string Name)>();
|
||||
private HashSet<(ulong Id, string Name)> _passed = new HashSet<(ulong Id, string Name)>();
|
||||
private HashSet<(ulong Id, string Name)> _participants = new();
|
||||
private readonly HashSet<(ulong Id, string Name)> _passed = new();
|
||||
|
||||
public ImmutableArray<(ulong Id, string Name)> Participants => _participants.ToImmutableArray();
|
||||
public int ParticipantCount => _participants.Count;
|
||||
|
@@ -9,7 +9,7 @@ public class PollRunner
|
||||
|
||||
public event Func<IUserMessage, IGuildUser, Task> OnVoted;
|
||||
|
||||
private readonly SemaphoreSlim _locker = new SemaphoreSlim(1, 1);
|
||||
private readonly SemaphoreSlim _locker = new(1, 1);
|
||||
|
||||
public PollRunner(DbService db, Poll poll)
|
||||
{
|
||||
|
@@ -74,7 +74,7 @@ public class TicTacToe
|
||||
{
|
||||
for (var j = 0; j < _state.GetLength(1); j++)
|
||||
{
|
||||
sb.Append(_state[i, j] is null ? _numbers[i * 3 + j] : GetIcon(_state[i, j]));
|
||||
sb.Append(_state[i, j] is null ? _numbers[(i * 3) + j] : GetIcon(_state[i, j]));
|
||||
if (j < _state.GetLength(1) - 1)
|
||||
sb.Append("┃");
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ namespace NadekoBot.Modules.Games.Common.Trivia;
|
||||
|
||||
public class TriviaGame
|
||||
{
|
||||
private readonly SemaphoreSlim _guessLock = new SemaphoreSlim(1, 1);
|
||||
private readonly SemaphoreSlim _guessLock = new(1, 1);
|
||||
private readonly IDataCache _cache;
|
||||
private readonly IBotStrings _strings;
|
||||
private readonly DiscordSocketClient _client;
|
||||
@@ -18,9 +18,9 @@ public class TriviaGame
|
||||
private CancellationTokenSource _triviaCancelSource;
|
||||
|
||||
public TriviaQuestion CurrentQuestion { get; private set; }
|
||||
public HashSet<TriviaQuestion> OldQuestions { get; } = new HashSet<TriviaQuestion>();
|
||||
public HashSet<TriviaQuestion> OldQuestions { get; } = new();
|
||||
|
||||
public ConcurrentDictionary<IGuildUser, int> Users { get; } = new ConcurrentDictionary<IGuildUser, int>();
|
||||
public ConcurrentDictionary<IGuildUser, int> Users { get; } = new();
|
||||
|
||||
public bool GameActive { get; private set; }
|
||||
public bool ShouldStopGame { get; private set; }
|
||||
|
@@ -6,11 +6,12 @@ namespace NadekoBot.Modules.Games.Common.Trivia;
|
||||
public class TriviaQuestion
|
||||
{
|
||||
//represents the min size to judge levDistance with
|
||||
private static readonly HashSet<Tuple<int, int>> strictness = new HashSet<Tuple<int, int>> {
|
||||
new Tuple<int, int>(9, 0),
|
||||
new Tuple<int, int>(14, 1),
|
||||
new Tuple<int, int>(19, 2),
|
||||
new Tuple<int, int>(22, 3),
|
||||
private static readonly HashSet<Tuple<int, int>> strictness = new()
|
||||
{
|
||||
new(9, 0),
|
||||
new(14, 1),
|
||||
new(19, 2),
|
||||
new(22, 3),
|
||||
};
|
||||
public const int maxStringLength = 22;
|
||||
|
||||
|
@@ -5,7 +5,7 @@ public class TriviaQuestionPool
|
||||
private readonly IDataCache _cache;
|
||||
private readonly int maxPokemonId;
|
||||
|
||||
private readonly NadekoRandom _rng = new NadekoRandom();
|
||||
private readonly NadekoRandom _rng = new();
|
||||
|
||||
private TriviaQuestion[] Pool => _cache.LocalData.TriviaQuestions;
|
||||
private IReadOnlyDictionary<int, string> Map => _cache.LocalData.PokemonMap;
|
||||
|
Reference in New Issue
Block a user