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:
@@ -58,7 +58,7 @@ public class Deck
|
||||
{
|
||||
get
|
||||
{
|
||||
var str = "";
|
||||
var str = string.Empty;
|
||||
|
||||
if (Number <= 10 && Number > 1)
|
||||
{
|
||||
@@ -106,7 +106,7 @@ public class Deck
|
||||
|
||||
public string GetEmojiString()
|
||||
{
|
||||
var str = "";
|
||||
var str = string.Empty;
|
||||
|
||||
str += _regIndicators[this.Number - 1];
|
||||
str += _suitToSuitChar[this.Suit];
|
||||
|
@@ -71,7 +71,7 @@ public class GameStatusEvent : ICurrencyEvent
|
||||
private async void OnTimerTick(object state)
|
||||
{
|
||||
var potEmpty = PotEmptied;
|
||||
List<ulong> toAward = new List<ulong>();
|
||||
var toAward = new List<ulong>();
|
||||
while (_toAward.TryDequeue(out var x))
|
||||
{
|
||||
toAward.Add(x);
|
||||
|
@@ -67,7 +67,7 @@ public class ReactionEvent : ICurrencyEvent
|
||||
private async void OnTimerTick(object state)
|
||||
{
|
||||
var potEmpty = PotEmptied;
|
||||
List<ulong> toAward = new List<ulong>();
|
||||
var toAward = new List<ulong>();
|
||||
while (_toAward.TryDequeue(out var x))
|
||||
{
|
||||
toAward.Add(x);
|
||||
|
@@ -79,7 +79,7 @@ public sealed class Connect4Game : IDisposable
|
||||
_cs = cs;
|
||||
|
||||
_rng = new NadekoRandom();
|
||||
for (int i = 0; i < NumberOfColumns * NumberOfRows; i++)
|
||||
for (var i = 0; i < NumberOfColumns * NumberOfRows; i++)
|
||||
{
|
||||
_gameState[i] = Field.Empty;
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public sealed class Connect4Game : IDisposable
|
||||
return false;
|
||||
|
||||
var start = NumberOfRows * inputCol;
|
||||
for (int i = start; i < start + NumberOfRows; i++)
|
||||
for (var i = start; i < start + NumberOfRows; i++)
|
||||
{
|
||||
if (_gameState[i] == Field.Empty)
|
||||
{
|
||||
@@ -181,12 +181,12 @@ public sealed class Connect4Game : IDisposable
|
||||
//check winnning condition
|
||||
// ok, i'll go from [0-2] in rows (and through all columns) and check upward if 4 are connected
|
||||
|
||||
for (int i = 0; i < NumberOfRows - 3; i++)
|
||||
for (var i = 0; i < NumberOfRows - 3; i++)
|
||||
{
|
||||
if (CurrentPhase == Phase.Ended)
|
||||
break;
|
||||
|
||||
for (int j = 0; j < NumberOfColumns; j++)
|
||||
for (var j = 0; j < NumberOfColumns; j++)
|
||||
{
|
||||
if (CurrentPhase == Phase.Ended)
|
||||
break;
|
||||
@@ -194,7 +194,7 @@ public sealed class Connect4Game : IDisposable
|
||||
var first = _gameState[i + j * NumberOfRows];
|
||||
if (first != Field.Empty)
|
||||
{
|
||||
for (int k = 1; k < 4; k++)
|
||||
for (var k = 1; k < 4; k++)
|
||||
{
|
||||
var next = _gameState[i + k + j * NumberOfRows];
|
||||
if (next == first)
|
||||
@@ -211,12 +211,12 @@ public sealed class Connect4Game : IDisposable
|
||||
}
|
||||
|
||||
// i'll go [0-1] in columns (and through all rows) and check to the right if 4 are connected
|
||||
for (int i = 0; i < NumberOfColumns - 3; i++)
|
||||
for (var i = 0; i < NumberOfColumns - 3; i++)
|
||||
{
|
||||
if (CurrentPhase == Phase.Ended)
|
||||
break;
|
||||
|
||||
for (int j = 0; j < NumberOfRows; j++)
|
||||
for (var j = 0; j < NumberOfRows; j++)
|
||||
{
|
||||
if (CurrentPhase == Phase.Ended)
|
||||
break;
|
||||
@@ -224,7 +224,7 @@ public sealed class Connect4Game : IDisposable
|
||||
var first = _gameState[j + i * NumberOfRows];
|
||||
if (first != Field.Empty)
|
||||
{
|
||||
for (int k = 1; k < 4; k++)
|
||||
for (var k = 1; k < 4; k++)
|
||||
{
|
||||
var next = _gameState[j + (i + k) * NumberOfRows];
|
||||
if (next == first)
|
||||
@@ -239,12 +239,12 @@ public sealed class Connect4Game : IDisposable
|
||||
}
|
||||
|
||||
//need to check diagonal now
|
||||
for (int col = 0; col < NumberOfColumns; col++)
|
||||
for (var col = 0; col < NumberOfColumns; col++)
|
||||
{
|
||||
if (CurrentPhase == Phase.Ended)
|
||||
break;
|
||||
|
||||
for (int row = 0; row < NumberOfRows; row++)
|
||||
for (var row = 0; row < NumberOfRows; row++)
|
||||
{
|
||||
if (CurrentPhase == Phase.Ended)
|
||||
break;
|
||||
@@ -256,7 +256,7 @@ public sealed class Connect4Game : IDisposable
|
||||
var same = 1;
|
||||
|
||||
//top left
|
||||
for (int i = 1; i < 4; i++)
|
||||
for (var i = 1; i < 4; i++)
|
||||
{
|
||||
//while going top left, rows are increasing, columns are decreasing
|
||||
var curRow = row + i;
|
||||
@@ -283,7 +283,7 @@ public sealed class Connect4Game : IDisposable
|
||||
same = 1;
|
||||
|
||||
//top right
|
||||
for (int i = 1; i < 4; i++)
|
||||
for (var i = 1; i < 4; i++)
|
||||
{
|
||||
//while going top right, rows are increasing, columns are increasing
|
||||
var curRow = row + i;
|
||||
@@ -361,7 +361,7 @@ public sealed class Connect4Game : IDisposable
|
||||
private bool IsColumnFull(int column)
|
||||
{
|
||||
var start = NumberOfRows * column;
|
||||
for (int i = start; i < start + NumberOfRows; i++)
|
||||
for (var i = start; i < start + NumberOfRows; i++)
|
||||
{
|
||||
if (_gameState[i] == Field.Empty)
|
||||
return false;
|
||||
|
@@ -84,7 +84,7 @@ public partial class Gambling
|
||||
|
||||
var _ = Task.Run(async () =>
|
||||
{
|
||||
bool success = false;
|
||||
var success = false;
|
||||
if (int.TryParse(arg.Content, out var col))
|
||||
{
|
||||
success = await game.Input(arg.Author.Id, col).ConfigureAwait(false);
|
||||
@@ -181,9 +181,9 @@ public partial class Gambling
|
||||
game.CurrentPhase == Connect4Game.Phase.P2Move)
|
||||
sb.AppendLine(GetText(strs.connect4_player_to_move(Format.Bold(game.CurrentPlayer.Username))));
|
||||
|
||||
for (int i = Connect4Game.NumberOfRows; i > 0; i--)
|
||||
for (var i = Connect4Game.NumberOfRows; i > 0; i--)
|
||||
{
|
||||
for (int j = 0; j < Connect4Game.NumberOfColumns; j++)
|
||||
for (var j = 0; j < Connect4Game.NumberOfColumns; j++)
|
||||
{
|
||||
var cur = game.GameState[i + (j * Connect4Game.NumberOfRows) - 1];
|
||||
|
||||
@@ -197,7 +197,7 @@ public partial class Gambling
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
for (int i = 0; i < Connect4Game.NumberOfColumns; i++)
|
||||
for (var i = 0; i < Connect4Game.NumberOfColumns; i++)
|
||||
{
|
||||
sb.Append(numbers[i]);
|
||||
}
|
||||
|
@@ -136,14 +136,14 @@ public partial class Gambling
|
||||
{
|
||||
Match match;
|
||||
if ((match = fudgeRegex.Match(arg)).Length != 0 &&
|
||||
int.TryParse(match.Groups["n1"].ToString(), out int n1) &&
|
||||
int.TryParse(match.Groups["n1"].ToString(), out var n1) &&
|
||||
n1 > 0 && n1 < 500)
|
||||
{
|
||||
var rng = new NadekoRandom();
|
||||
|
||||
var rolls = new List<char>();
|
||||
|
||||
for (int i = 0; i < n1; i++)
|
||||
for (var i = 0; i < n1; i++)
|
||||
{
|
||||
rolls.Add(_fateRolls[rng.Next(0, _fateRolls.Length)]);
|
||||
}
|
||||
@@ -158,16 +158,16 @@ public partial class Gambling
|
||||
{
|
||||
var rng = new NadekoRandom();
|
||||
if (int.TryParse(match.Groups["n1"].ToString(), out n1) &&
|
||||
int.TryParse(match.Groups["n2"].ToString(), out int n2) &&
|
||||
int.TryParse(match.Groups["n2"].ToString(), out var n2) &&
|
||||
n1 <= 50 && n2 <= 100000 && n1 > 0 && n2 > 0)
|
||||
{
|
||||
if (!int.TryParse(match.Groups["add"].Value, out int add))
|
||||
if (!int.TryParse(match.Groups["add"].Value, out var add))
|
||||
add = 0;
|
||||
if (!int.TryParse(match.Groups["sub"].Value, out int sub))
|
||||
if (!int.TryParse(match.Groups["sub"].Value, out var sub))
|
||||
sub = 0;
|
||||
|
||||
var arr = new int[n1];
|
||||
for (int i = 0; i < n1; i++)
|
||||
for (var i = 0; i < n1; i++)
|
||||
{
|
||||
arr[i] = rng.Next(1, n2 + 1);
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ public partial class Gambling
|
||||
if (num < 1 || num > 10)
|
||||
throw new ArgumentOutOfRangeException(nameof(num));
|
||||
|
||||
Deck cards = guildId is null ? new Deck() : _allDecks.GetOrAdd(ctx.Guild, (s) => new Deck());
|
||||
var cards = guildId is null ? new Deck() : _allDecks.GetOrAdd(ctx.Guild, (s) => new Deck());
|
||||
var images = new List<Image<Rgba32>>();
|
||||
var cardObjects = new List<Deck.Card>();
|
||||
for (var i = 0; i < num; i++)
|
||||
|
@@ -197,7 +197,7 @@ public partial class Gambling : GamblingModule<GamblingService>
|
||||
((SocketGuild)ctx.Guild)?.GetUser(userId)?.ToString() ?? $"{userId}")))
|
||||
.WithOkColor();
|
||||
|
||||
var desc = "";
|
||||
var desc = string.Empty;
|
||||
foreach (var tr in trs)
|
||||
{
|
||||
var type = tr.Amount > 0 ? "🔵" : "🔴";
|
||||
@@ -517,7 +517,7 @@ public partial class Gambling : GamblingModule<GamblingService>
|
||||
|
||||
var (opts, _) = OptionsParser.ParseFrom(new LbOpts(), args);
|
||||
|
||||
List<DiscordUser> cleanRichest = new List<DiscordUser>();
|
||||
var cleanRichest = new List<DiscordUser>();
|
||||
// it's pointless to have clean on dm context
|
||||
if (ctx.Guild is null)
|
||||
{
|
||||
|
@@ -84,7 +84,7 @@ public partial class Gambling
|
||||
#endif
|
||||
public async Task GenCurrency()
|
||||
{
|
||||
bool enabled = _service.ToggleCurrencyGeneration(ctx.Guild.Id, ctx.Channel.Id);
|
||||
var enabled = _service.ToggleCurrencyGeneration(ctx.Guild.Id, ctx.Channel.Id);
|
||||
if (enabled)
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.curgen_enabled).ConfigureAwait(false);
|
||||
|
@@ -31,8 +31,8 @@ public class CurrencyEventsService : INService
|
||||
public async Task<bool> TryCreateEventAsync(ulong guildId, ulong channelId, CurrencyEvent.Type type,
|
||||
EventOptions opts, Func<CurrencyEvent.Type, EventOptions, long, IEmbedBuilder> embed)
|
||||
{
|
||||
SocketGuild g = _client.GetGuild(guildId);
|
||||
SocketTextChannel ch = g?.GetChannel(channelId) as SocketTextChannel;
|
||||
var g = _client.GetGuild(guildId);
|
||||
var ch = g?.GetChannel(channelId) as SocketTextChannel;
|
||||
if (ch is null)
|
||||
return false;
|
||||
|
||||
|
@@ -59,7 +59,7 @@ public partial class Gambling
|
||||
var embed = _eb.Create().WithOkColor()
|
||||
.WithTitle(GetText(strs.shop));
|
||||
|
||||
for (int i = 0; i < theseEntries.Length; i++)
|
||||
for (var i = 0; i < theseEntries.Length; i++)
|
||||
{
|
||||
var entry = theseEntries[i];
|
||||
embed.AddField(
|
||||
@@ -292,8 +292,8 @@ public partial class Gambling
|
||||
Text = itemText
|
||||
};
|
||||
ShopEntry entry;
|
||||
bool rightType = false;
|
||||
bool added = false;
|
||||
var rightType = false;
|
||||
var added = false;
|
||||
using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var entries = new IndexedCollection<ShopEntry>(uow.GuildConfigsForId(ctx.Guild.Id,
|
||||
|
@@ -122,7 +122,7 @@ public partial class Gambling
|
||||
return;
|
||||
//multi vs how many times it occured
|
||||
var dict = new Dictionary<int, int>();
|
||||
for (int i = 0; i < tests; i++)
|
||||
for (var i = 0; i < tests; i++)
|
||||
{
|
||||
var res = SlotMachine.Pull();
|
||||
if (dict.ContainsKey(res.Multiplier))
|
||||
@@ -133,7 +133,7 @@ public partial class Gambling
|
||||
|
||||
var sb = new StringBuilder();
|
||||
const int bet = 1;
|
||||
int payout = 0;
|
||||
var payout = 0;
|
||||
foreach (var key in dict.Keys.OrderByDescending(x => x))
|
||||
{
|
||||
sb.AppendLine($"x{key} occured {dict[key]} times. {dict[key] * 1.0f / tests * 100}%");
|
||||
|
Reference in New Issue
Block a user