Skip to content

Commit f8e25d6

Browse files
committed
word search fixes
1 parent c861969 commit f8e25d6

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

Projects/Website/Games/Word Search/Word Search.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,26 @@ Here is where "{currentWord}" was hiding.
7474
if (!selections.Remove(cursor))
7575
{
7676
selections.Add(cursor);
77-
selections.Sort();
78-
if (UserFoundTheWord())
79-
{
80-
await Console.Clear();
81-
await RenderBoard();
82-
await Console.Write($"""
77+
}
78+
selections.Sort();
79+
if (UserFoundTheWord())
80+
{
81+
await Console.Clear();
82+
await RenderBoard();
83+
await Console.Write($"""
8384
8485
You found "{currentWord}"! You win!
8586
8687
Controls:
8788
- enter/home: play again
8889
- escape: close game
8990
""");
90-
while (true)
91+
while (true)
92+
{
93+
switch ((await Console.ReadKey(true)).Key)
9194
{
92-
switch ((await Console.ReadKey(true)).Key)
93-
{
94-
case ConsoleKey.Enter or ConsoleKey.Home: goto PlayAgain;
95-
case ConsoleKey.Escape: goto Close;
96-
}
95+
case ConsoleKey.Enter or ConsoleKey.Home: goto PlayAgain;
96+
case ConsoleKey.Escape: goto Close;
9797
}
9898
}
9999
}
@@ -107,7 +107,7 @@ You found "{currentWord}"! You win!
107107

108108
void InitializeWords()
109109
{
110-
wordArray = Resources.Words!.Select(word => word.ToUpper()).ToArray();
110+
wordArray = Resources.Words!.Where(word => word.Length < board.GetLength(1) && word.Length < board.GetLength(0)).Select(word => word.ToUpper()).ToArray();
111111
}
112112

113113
void InitializeBoard()

Projects/Website/Pages/Word Search.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
{
4747
Game = new();
4848
Console = Game.Console;
49-
Console.WindowWidth = 60;
49+
Console.WindowWidth = 50;
5050
Console.WindowHeight = 31;
5151
Console.TriggerRefresh = StateHasChanged;
5252
}

Projects/Word Search/Program.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,26 +67,26 @@ Here is where "{currentWord}" was hiding.
6767
if (!selections.Remove(cursor))
6868
{
6969
selections.Add(cursor);
70-
selections.Sort();
71-
if (UserFoundTheWord())
72-
{
73-
Console.Clear();
74-
RenderBoard();
75-
Console.Write($"""
70+
}
71+
selections.Sort();
72+
if (UserFoundTheWord())
73+
{
74+
Console.Clear();
75+
RenderBoard();
76+
Console.Write($"""
7677
7778
You found "{currentWord}"! You win!
7879
7980
Controls:
8081
- enter/home: play again
8182
- escape: close game
8283
""");
83-
while (true)
84+
while (true)
85+
{
86+
switch (Console.ReadKey(true).Key)
8487
{
85-
switch (Console.ReadKey(true).Key)
86-
{
87-
case ConsoleKey.Enter or ConsoleKey.Home: goto PlayAgain;
88-
case ConsoleKey.Escape: goto Close;
89-
}
88+
case ConsoleKey.Enter or ConsoleKey.Home: goto PlayAgain;
89+
case ConsoleKey.Escape: goto Close;
9090
}
9191
}
9292
}

0 commit comments

Comments
 (0)