mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
vars and target-typed new
This commit is contained in:
@@ -106,7 +106,7 @@ public sealed class AcrophobiaGame : IDisposable
|
||||
|
||||
var lettersArr = new char[wordCount];
|
||||
|
||||
for (int i = 0; i < wordCount; i++)
|
||||
for (var i = 0; i < wordCount; i++)
|
||||
{
|
||||
var randChar = (char)_rng.Next(65, 91);
|
||||
lettersArr[i] = randChar == 'X' ? (char)_rng.Next(65, 88) : randChar;
|
||||
@@ -160,7 +160,7 @@ public sealed class AcrophobiaGame : IDisposable
|
||||
if (inputWords.Length != StartingLetters.Length) // number of words must be the same as the number of the starting letters
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < StartingLetters.Length; i++)
|
||||
for (var i = 0; i < StartingLetters.Length; i++)
|
||||
{
|
||||
var letter = StartingLetters[i];
|
||||
|
||||
|
@@ -33,7 +33,7 @@ public class PollRunner
|
||||
return false;
|
||||
|
||||
// has to be an integer
|
||||
if (!int.TryParse(msg.Content, out int vote))
|
||||
if (!int.TryParse(msg.Content, out var vote))
|
||||
return false;
|
||||
--vote;
|
||||
if (vote < 0 || vote >= Poll.Answers.Count)
|
||||
|
@@ -250,7 +250,7 @@ public class TicTacToe
|
||||
|
||||
_phase = Phase.Ended;
|
||||
}
|
||||
var reason = "";
|
||||
var reason = string.Empty;
|
||||
|
||||
if (_phase == Phase.Ended) // if user won, stop receiving moves
|
||||
{
|
||||
|
@@ -46,15 +46,15 @@ public class TriviaQuestion
|
||||
return true;
|
||||
}
|
||||
|
||||
int levDistanceClean = CleanAnswer.LevenshteinDistance(cleanGuess);
|
||||
int levDistanceNormal = Answer.LevenshteinDistance(guess);
|
||||
var levDistanceClean = CleanAnswer.LevenshteinDistance(cleanGuess);
|
||||
var levDistanceNormal = Answer.LevenshteinDistance(guess);
|
||||
return JudgeGuess(CleanAnswer.Length, cleanGuess.Length, levDistanceClean)
|
||||
|| JudgeGuess(Answer.Length, guess.Length, levDistanceNormal);
|
||||
}
|
||||
|
||||
private static bool JudgeGuess(int guessLength, int answerLength, int levDistance)
|
||||
{
|
||||
foreach (Tuple<int, int> level in strictness)
|
||||
foreach (var level in strictness)
|
||||
{
|
||||
if (guessLength <= level.Item1 || answerLength <= level.Item1)
|
||||
{
|
||||
|
@@ -105,7 +105,7 @@ public partial class Games
|
||||
.OrderByDescending(x => x.votes)
|
||||
.ToArray();
|
||||
|
||||
for (int i = 0; i < stats.Length; i++)
|
||||
for (var i = 0; i < stats.Length; i++)
|
||||
{
|
||||
var (Index, votes, Text) = stats[i];
|
||||
sb.AppendLine(GetText(strs.poll_result(
|
||||
|
@@ -60,7 +60,7 @@ public class ChatterBotService : IEarlyBehavior
|
||||
if (channel is null)
|
||||
return null;
|
||||
|
||||
if (!ChatterBotGuilds.TryGetValue(channel.Guild.Id, out Lazy<IChatterBotSession> lazyCleverbot))
|
||||
if (!ChatterBotGuilds.TryGetValue(channel.Guild.Id, out var lazyCleverbot))
|
||||
return null;
|
||||
|
||||
cleverbot = lazyCleverbot.Value;
|
||||
@@ -107,7 +107,7 @@ public class ChatterBotService : IEarlyBehavior
|
||||
return false;
|
||||
try
|
||||
{
|
||||
var message = PrepareMessage(usrMsg, out IChatterBotSession cbs);
|
||||
var message = PrepareMessage(usrMsg, out var cbs);
|
||||
if (message is null || cbs is null)
|
||||
return false;
|
||||
|
||||
@@ -115,7 +115,7 @@ public class ChatterBotService : IEarlyBehavior
|
||||
if (!pc.Permissions.CheckPermissions(usrMsg,
|
||||
"cleverbot",
|
||||
"Games".ToLowerInvariant(),
|
||||
out int index))
|
||||
out var index))
|
||||
{
|
||||
if (pc.Verbose)
|
||||
{
|
||||
|
@@ -48,7 +48,7 @@ public partial class Games
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task TypeStop()
|
||||
{
|
||||
if (_service.RunningContests.TryRemove(ctx.Guild.Id, out TypingGame game))
|
||||
if (_service.RunningContests.TryRemove(ctx.Guild.Id, out var game))
|
||||
{
|
||||
await game.Stop().ConfigureAwait(false);
|
||||
return;
|
||||
|
@@ -34,7 +34,7 @@ public partial class Games
|
||||
await _sem.WaitAsync(1000).ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
if (_service.TicTacToeGames.TryGetValue(channel.Id, out TicTacToe game))
|
||||
if (_service.TicTacToeGames.TryGetValue(channel.Id, out var game))
|
||||
{
|
||||
var _ = Task.Run(async () =>
|
||||
{
|
||||
|
@@ -72,7 +72,7 @@ public partial class Games
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Tl()
|
||||
{
|
||||
if (_service.RunningTrivias.TryGetValue(ctx.Guild.Id, out TriviaGame trivia))
|
||||
if (_service.RunningTrivias.TryGetValue(ctx.Guild.Id, out var trivia))
|
||||
{
|
||||
await SendConfirmAsync(GetText(strs.leaderboard), trivia.GetLeaderboard()).ConfigureAwait(false);
|
||||
return;
|
||||
@@ -87,7 +87,7 @@ public partial class Games
|
||||
{
|
||||
var channel = (ITextChannel)ctx.Channel;
|
||||
|
||||
if (_service.RunningTrivias.TryGetValue(channel.Guild.Id, out TriviaGame trivia))
|
||||
if (_service.RunningTrivias.TryGetValue(channel.Guild.Id, out var trivia))
|
||||
{
|
||||
await trivia.StopGame().ConfigureAwait(false);
|
||||
return;
|
||||
|
Reference in New Issue
Block a user