diff --git a/src/NadekoBot/Modules/Games/Common/Connect4/Connect4.cs b/src/NadekoBot/Modules/Games/Common/Connect4/Connect4.cs index 0b247301..c892d7e0 100644 --- a/src/NadekoBot/Modules/Games/Common/Connect4/Connect4.cs +++ b/src/NadekoBot/Modules/Games/Common/Connect4/Connect4.cs @@ -85,6 +85,8 @@ namespace NadekoBot.Modules.Games.Common.Connect4 public void Initialize() { + if (CurrentPhase != Phase.Joining) + return; var _ = Task.Run(async () => { await Task.Delay(15000).ConfigureAwait(false); @@ -267,6 +269,7 @@ namespace NadekoBot.Modules.Games.Common.Connect4 if (same == 4) { + Console.WriteLine($"Won top left diagonal starting from {row + col * NumberOfRows}"); EndGame(Result.CurrentPlayerWon); break; } @@ -292,6 +295,7 @@ namespace NadekoBot.Modules.Games.Common.Connect4 if (same == 4) { + Console.WriteLine($"Won top right diagonal starting from {row + col * NumberOfRows}"); EndGame(Result.CurrentPlayerWon); break; } @@ -327,6 +331,8 @@ namespace NadekoBot.Modules.Games.Common.Connect4 private void EndGame(Result result) { + if (CurrentPhase == Phase.Ended) + return; var _ = OnGameEnded?.Invoke(this, result); CurrentPhase = Phase.Ended; } @@ -351,6 +357,8 @@ namespace NadekoBot.Modules.Games.Common.Connect4 { OnGameFailedToStart = null; OnGameStateUpdated = null; + OnGameEnded = null; + _playerTimeoutTimer?.Change(Timeout.Infinite, Timeout.Infinite); } } } diff --git a/src/NadekoBot/Modules/Games/Connect4Commands.cs b/src/NadekoBot/Modules/Games/Connect4Commands.cs index 81d03b4f..5a1183c2 100644 --- a/src/NadekoBot/Modules/Games/Connect4Commands.cs +++ b/src/NadekoBot/Modules/Games/Connect4Commands.cs @@ -34,6 +34,10 @@ namespace NadekoBot.Modules.Games Connect4Game game; if ((game = Games.GetOrAdd(Context.Channel.Id, newGame)) != newGame) { + if (game.CurrentPhase != Connect4Game.Phase.Joining) + return; + + newGame.Dispose(); //means game already exists, try to join var joined = await game.Join(Context.User.Id, Context.User.ToString()).ConfigureAwait(false); return; diff --git a/src/NadekoBot/Modules/Utility/StreamRoleCommands.cs b/src/NadekoBot/Modules/Utility/StreamRoleCommands.cs index 7749fbca..e6f38947 100644 --- a/src/NadekoBot/Modules/Utility/StreamRoleCommands.cs +++ b/src/NadekoBot/Modules/Utility/StreamRoleCommands.cs @@ -11,7 +11,6 @@ namespace NadekoBot.Modules.Utility { public partial class Utility { - [NoPublicBot] public class StreamRoleCommands : NadekoSubmodule { [NadekoCommand, Usage, Description, Aliases]