Skip to content

Commit

Permalink
word search fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacharyPatten committed Dec 12, 2023
1 parent c861969 commit f8e25d6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
26 changes: 13 additions & 13 deletions Projects/Website/Games/Word Search/Word Search.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,26 @@ Here is where "{currentWord}" was hiding.
if (!selections.Remove(cursor))
{
selections.Add(cursor);
selections.Sort();
if (UserFoundTheWord())
{
await Console.Clear();
await RenderBoard();
await Console.Write($"""
}
selections.Sort();
if (UserFoundTheWord())
{
await Console.Clear();
await RenderBoard();
await Console.Write($"""

You found "{currentWord}"! You win!

Controls:
- enter/home: play again
- escape: close game
""");
while (true)
while (true)
{
switch ((await Console.ReadKey(true)).Key)
{
switch ((await Console.ReadKey(true)).Key)
{
case ConsoleKey.Enter or ConsoleKey.Home: goto PlayAgain;
case ConsoleKey.Escape: goto Close;
}
case ConsoleKey.Enter or ConsoleKey.Home: goto PlayAgain;
case ConsoleKey.Escape: goto Close;
}
}
}
Expand All @@ -107,7 +107,7 @@ You found "{currentWord}"! You win!

void InitializeWords()
{
wordArray = Resources.Words!.Select(word => word.ToUpper()).ToArray();
wordArray = Resources.Words!.Where(word => word.Length < board.GetLength(1) && word.Length < board.GetLength(0)).Select(word => word.ToUpper()).ToArray();
}

void InitializeBoard()
Expand Down
2 changes: 1 addition & 1 deletion Projects/Website/Pages/Word Search.razor
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
{
Game = new();
Console = Game.Console;
Console.WindowWidth = 60;
Console.WindowWidth = 50;
Console.WindowHeight = 31;
Console.TriggerRefresh = StateHasChanged;
}
Expand Down
24 changes: 12 additions & 12 deletions Projects/Word Search/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,26 @@ Here is where "{currentWord}" was hiding.
if (!selections.Remove(cursor))
{
selections.Add(cursor);
selections.Sort();
if (UserFoundTheWord())
{
Console.Clear();
RenderBoard();
Console.Write($"""
}
selections.Sort();
if (UserFoundTheWord())
{
Console.Clear();
RenderBoard();
Console.Write($"""

You found "{currentWord}"! You win!

Controls:
- enter/home: play again
- escape: close game
""");
while (true)
while (true)
{
switch (Console.ReadKey(true).Key)
{
switch (Console.ReadKey(true).Key)
{
case ConsoleKey.Enter or ConsoleKey.Home: goto PlayAgain;
case ConsoleKey.Escape: goto Close;
}
case ConsoleKey.Enter or ConsoleKey.Home: goto PlayAgain;
case ConsoleKey.Escape: goto Close;
}
}
}
Expand Down

0 comments on commit f8e25d6

Please sign in to comment.