connect4 bugfixes
This commit is contained in:
parent
ec7f69f1c0
commit
47125ed687
@ -85,6 +85,8 @@ namespace NadekoBot.Modules.Games.Common.Connect4
|
|||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
|
if (CurrentPhase != Phase.Joining)
|
||||||
|
return;
|
||||||
var _ = Task.Run(async () =>
|
var _ = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await Task.Delay(15000).ConfigureAwait(false);
|
await Task.Delay(15000).ConfigureAwait(false);
|
||||||
@ -267,6 +269,7 @@ namespace NadekoBot.Modules.Games.Common.Connect4
|
|||||||
|
|
||||||
if (same == 4)
|
if (same == 4)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine($"Won top left diagonal starting from {row + col * NumberOfRows}");
|
||||||
EndGame(Result.CurrentPlayerWon);
|
EndGame(Result.CurrentPlayerWon);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -292,6 +295,7 @@ namespace NadekoBot.Modules.Games.Common.Connect4
|
|||||||
|
|
||||||
if (same == 4)
|
if (same == 4)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine($"Won top right diagonal starting from {row + col * NumberOfRows}");
|
||||||
EndGame(Result.CurrentPlayerWon);
|
EndGame(Result.CurrentPlayerWon);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -327,6 +331,8 @@ namespace NadekoBot.Modules.Games.Common.Connect4
|
|||||||
|
|
||||||
private void EndGame(Result result)
|
private void EndGame(Result result)
|
||||||
{
|
{
|
||||||
|
if (CurrentPhase == Phase.Ended)
|
||||||
|
return;
|
||||||
var _ = OnGameEnded?.Invoke(this, result);
|
var _ = OnGameEnded?.Invoke(this, result);
|
||||||
CurrentPhase = Phase.Ended;
|
CurrentPhase = Phase.Ended;
|
||||||
}
|
}
|
||||||
@ -351,6 +357,8 @@ namespace NadekoBot.Modules.Games.Common.Connect4
|
|||||||
{
|
{
|
||||||
OnGameFailedToStart = null;
|
OnGameFailedToStart = null;
|
||||||
OnGameStateUpdated = null;
|
OnGameStateUpdated = null;
|
||||||
|
OnGameEnded = null;
|
||||||
|
_playerTimeoutTimer?.Change(Timeout.Infinite, Timeout.Infinite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,10 @@ namespace NadekoBot.Modules.Games
|
|||||||
Connect4Game game;
|
Connect4Game game;
|
||||||
if ((game = Games.GetOrAdd(Context.Channel.Id, newGame)) != newGame)
|
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
|
//means game already exists, try to join
|
||||||
var joined = await game.Join(Context.User.Id, Context.User.ToString()).ConfigureAwait(false);
|
var joined = await game.Join(Context.User.Id, Context.User.ToString()).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
|
@ -11,7 +11,6 @@ namespace NadekoBot.Modules.Utility
|
|||||||
{
|
{
|
||||||
public partial class Utility
|
public partial class Utility
|
||||||
{
|
{
|
||||||
[NoPublicBot]
|
|
||||||
public class StreamRoleCommands : NadekoSubmodule<StreamRoleService>
|
public class StreamRoleCommands : NadekoSubmodule<StreamRoleService>
|
||||||
{
|
{
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
|
Loading…
Reference in New Issue
Block a user