Hangman bug fixed
This commit is contained in:
parent
aa49c5608b
commit
d3ced15d50
@ -44,7 +44,8 @@ namespace NadekoBot.Modules.Games.Commands.Hangman
|
|||||||
.Concat(data.Things)
|
.Concat(data.Things)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex)
|
||||||
|
{
|
||||||
Console.WriteLine(ex);
|
Console.WriteLine(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,55 +151,55 @@ namespace NadekoBot.Modules.Games.Commands.Hangman
|
|||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!(char.IsLetter(msg.Content[0]) || char.IsDigit(msg.Content[0])))// and a letter or a digit
|
if (!(char.IsLetter(msg.Content[0]) || char.IsDigit(msg.Content[0])))// and a letter or a digit
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var guess = char.ToUpperInvariant(msg.Content[0]);
|
var guess = char.ToUpperInvariant(msg.Content[0]);
|
||||||
if (Guesses.Contains(guess))
|
if (Guesses.Contains(guess))
|
||||||
{
|
|
||||||
MessagesSinceLastPost = 0;
|
|
||||||
++Errors;
|
|
||||||
if (Errors < MaxErrors)
|
|
||||||
await GameChannel.SendErrorAsync("Hangman Game", $"{msg.Author.Mention} Letter `{guess}` has already been used.\n" + ScrambledWord + "\n" + GetHangman(),
|
|
||||||
footer: string.Join(" ", Guesses)).ConfigureAwait(false);
|
|
||||||
else
|
|
||||||
await End().ConfigureAwait(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Guesses.Add(guess);
|
|
||||||
|
|
||||||
if (Term.Word.ToUpperInvariant().Contains(guess))
|
|
||||||
{
|
|
||||||
if (GuessedAll)
|
|
||||||
{
|
{
|
||||||
try { await GameChannel.SendConfirmAsync("Hangman Game", $"{msg.Author.Mention} guessed a letter `{guess}`!").ConfigureAwait(false); } catch { }
|
MessagesSinceLastPost = 0;
|
||||||
|
++Errors;
|
||||||
await End().ConfigureAwait(false);
|
if (Errors < MaxErrors)
|
||||||
|
await GameChannel.SendErrorAsync("Hangman Game", $"{msg.Author.Mention} Letter `{guess}` has already been used.\n" + ScrambledWord + "\n" + GetHangman(),
|
||||||
|
footer: string.Join(" ", Guesses)).ConfigureAwait(false);
|
||||||
|
else
|
||||||
|
await End().ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MessagesSinceLastPost = 0;
|
|
||||||
try
|
Guesses.Add(guess);
|
||||||
|
|
||||||
|
if (Term.Word.ToUpperInvariant().Contains(guess))
|
||||||
{
|
{
|
||||||
await GameChannel.SendConfirmAsync("Hangman Game", $"{msg.Author.Mention} guessed a letter `{guess}`!\n" + ScrambledWord + "\n" + GetHangman(),
|
if (GuessedAll)
|
||||||
footer: string.Join(" ", Guesses)).ConfigureAwait(false);
|
{
|
||||||
|
try { await GameChannel.SendConfirmAsync("Hangman Game", $"{msg.Author.Mention} guessed a letter `{guess}`!").ConfigureAwait(false); } catch { }
|
||||||
|
|
||||||
|
await End().ConfigureAwait(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MessagesSinceLastPost = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await GameChannel.SendConfirmAsync("Hangman Game", $"{msg.Author.Mention} guessed a letter `{guess}`!\n" + ScrambledWord + "\n" + GetHangman(),
|
||||||
|
footer: string.Join(" ", Guesses)).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
}
|
}
|
||||||
catch { }
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessagesSinceLastPost = 0;
|
|
||||||
++Errors;
|
|
||||||
if (Errors < MaxErrors)
|
|
||||||
await GameChannel.SendErrorAsync("Hangman Game", $"{msg.Author.Mention} Letter `{guess}` does not exist.\n" + ScrambledWord + "\n" + GetHangman(),
|
|
||||||
footer: string.Join(" ", Guesses)).ConfigureAwait(false);
|
|
||||||
else
|
else
|
||||||
await End().ConfigureAwait(false);
|
{
|
||||||
}
|
MessagesSinceLastPost = 0;
|
||||||
|
++Errors;
|
||||||
|
if (Errors < MaxErrors)
|
||||||
|
await GameChannel.SendErrorAsync("Hangman Game", $"{msg.Author.Mention} Letter `{guess}` does not exist.\n" + ScrambledWord + "\n" + GetHangman(),
|
||||||
|
footer: string.Join(" ", Guesses)).ConfigureAwait(false);
|
||||||
|
else
|
||||||
|
await End().ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) { _log.Warn(ex); }
|
catch (Exception ex) { _log.Warn(ex); }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user