-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
81 lines (54 loc) · 2.31 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// See https://aka.ms/new-console-template for more information
using System.IO;
namespace Consodle
{
internal class Program
{
private static void Main(string[] args)
{
int guessNum = 0;
string playerGuess;
string fileName = @"wordlist.txt";
gameArray gameBoard = new gameArray();
bool gameWinner = false;
gameBoard.printGameBoard();
while (guessNum <= 5 && !gameWinner)
{
Console.Write("Please enter a guess: ");
playerGuess = Console.ReadLine()!.ToLower();
while (playerGuess.Length != 5 || String.IsNullOrEmpty(playerGuess) || !File.ReadAllText(fileName).Contains(playerGuess))
{
if (playerGuess.Length != 5 || String.IsNullOrEmpty(playerGuess))
{
Console.Write("Invalid Guess, please try again: ");
playerGuess = Console.ReadLine()!;
}
else
{
Console.Write("Word not in word list, please try again: ");
playerGuess = Console.ReadLine()!;
}
}
gameBoard.addGuess(guessNum, playerGuess);
gameBoard.checkGuess(guessNum);
gameBoard.printGameBoard();
//Prints the scoreboard array, which keeps track of correct and incorrect guesses. Debugging only.
//gameBoard.printScoreBoard();
//Prints the current status of the game. True means player has won, false keeps going. Debugging only
//Console.WriteLine(gameBoard.checkForWin(guessNum).ToString());
gameWinner = gameBoard.checkForWin(guessNum);
guessNum++;
}
if (gameWinner)
{
Console.WriteLine("Congrats, you win!");
}
else
{
Console.WriteLine("Sorry, you did not guess the word. Today's word was: ");
gameBoard.printTodayWord();
Console.WriteLine("Better luck next time!");
}
}
}
}