mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Updated editorconfig to (mostly?) require braces around if/else statements, and applied the new formatting rules
This commit is contained in:
@@ -81,14 +81,15 @@ public sealed class Connect4Game : IDisposable
|
||||
_cs = cs;
|
||||
|
||||
_rng = new();
|
||||
for (var i = 0; i < NUMBER_OF_COLUMNS * NUMBER_OF_ROWS; i++) _gameState[i] = Field.Empty;
|
||||
for (var i = 0; i < NUMBER_OF_COLUMNS * NUMBER_OF_ROWS; i++)
|
||||
_gameState[i] = Field.Empty;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
if (CurrentPhase != Phase.Joining)
|
||||
return;
|
||||
_= Task.Run(async () =>
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(15000);
|
||||
await _locker.WaitAsync();
|
||||
@@ -173,11 +174,13 @@ public sealed class Connect4Game : IDisposable
|
||||
|
||||
var start = NUMBER_OF_ROWS * inputCol;
|
||||
for (var i = start; i < start + NUMBER_OF_ROWS; i++)
|
||||
{
|
||||
if (_gameState[i] == Field.Empty)
|
||||
{
|
||||
_gameState[i] = GetPlayerPiece(userId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//check winnning condition
|
||||
// ok, i'll go from [0-2] in rows (and through all columns) and check upward if 4 are connected
|
||||
@@ -233,7 +236,8 @@ public sealed class Connect4Game : IDisposable
|
||||
EndGame(Result.CurrentPlayerWon, CurrentPlayer.UserId);
|
||||
else
|
||||
continue;
|
||||
else break;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -271,7 +275,8 @@ public sealed class Connect4Game : IDisposable
|
||||
var cur = _gameState[curRow + (curCol * NUMBER_OF_ROWS)];
|
||||
if (cur == first)
|
||||
same++;
|
||||
else break;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (same == 4)
|
||||
@@ -298,7 +303,8 @@ public sealed class Connect4Game : IDisposable
|
||||
var cur = _gameState[curRow + (curCol * NUMBER_OF_ROWS)];
|
||||
if (cur == first)
|
||||
same++;
|
||||
else break;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (same == 4)
|
||||
@@ -311,7 +317,8 @@ public sealed class Connect4Game : IDisposable
|
||||
}
|
||||
|
||||
//check draw? if it's even possible
|
||||
if (_gameState.All(x => x != Field.Empty)) EndGame(Result.Draw, null);
|
||||
if (_gameState.All(x => x != Field.Empty))
|
||||
EndGame(Result.Draw, null);
|
||||
|
||||
if (CurrentPhase != Phase.Ended)
|
||||
{
|
||||
@@ -323,7 +330,7 @@ public sealed class Connect4Game : IDisposable
|
||||
ResetTimer();
|
||||
}
|
||||
|
||||
_= OnGameStateUpdated?.Invoke(this);
|
||||
_ = OnGameStateUpdated?.Invoke(this);
|
||||
return true;
|
||||
}
|
||||
finally { _locker.Release(); }
|
||||
@@ -337,7 +344,7 @@ public sealed class Connect4Game : IDisposable
|
||||
{
|
||||
if (CurrentPhase == Phase.Ended)
|
||||
return;
|
||||
_= OnGameEnded?.Invoke(this, result);
|
||||
_ = OnGameEnded?.Invoke(this, result);
|
||||
CurrentPhase = Phase.Ended;
|
||||
|
||||
if (result == Result.Draw)
|
||||
@@ -359,8 +366,11 @@ public sealed class Connect4Game : IDisposable
|
||||
{
|
||||
var start = NUMBER_OF_ROWS * column;
|
||||
for (var i = start; i < start + NUMBER_OF_ROWS; i++)
|
||||
{
|
||||
if (_gameState[i] == Field.Empty)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,8 @@ public partial class Gambling
|
||||
{
|
||||
if (value is < 0 or > 7)
|
||||
repostCounter = 0;
|
||||
else repostCounter = value;
|
||||
else
|
||||
repostCounter = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,10 +89,11 @@ public partial class Gambling
|
||||
if (ctx.Channel.Id != arg.Channel.Id)
|
||||
return Task.CompletedTask;
|
||||
|
||||
_= Task.Run(async () =>
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
var success = false;
|
||||
if (int.TryParse(arg.Content, out var col)) success = await game.Input(arg.Author.Id, col);
|
||||
if (int.TryParse(arg.Content, out var col))
|
||||
success = await game.Input(arg.Author.Id, col);
|
||||
|
||||
if (success)
|
||||
{
|
||||
@@ -100,7 +102,8 @@ public partial class Gambling
|
||||
}
|
||||
else
|
||||
{
|
||||
if (game.CurrentPhase is Connect4Game.Phase.Joining or Connect4Game.Phase.Ended) return;
|
||||
if (game.CurrentPhase is Connect4Game.Phase.Joining or Connect4Game.Phase.Ended)
|
||||
return;
|
||||
RepostCounter++;
|
||||
if (RepostCounter == 0)
|
||||
try { msg = await ctx.Channel.SendMessageAsync("", embed: (Embed)msg.Embeds.First()); }
|
||||
@@ -185,7 +188,8 @@ public partial class Gambling
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
for (var i = 0; i < Connect4Game.NUMBER_OF_COLUMNS; i++) sb.Append(_numbers[i]);
|
||||
for (var i = 0; i < Connect4Game.NUMBER_OF_COLUMNS; i++)
|
||||
sb.Append(_numbers[i]);
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user