diff --git a/Lingo/DisplayCharacters.cs b/Lingo/DisplayCharacters.cs new file mode 100644 index 0000000..894b5a2 --- /dev/null +++ b/Lingo/DisplayCharacters.cs @@ -0,0 +1,24 @@ +namespace Lingo; + +public class DisplayCharacters +{ + private char letter; + public char Letter { + get; + private set + { + // Capital A is 65, to 90, 97-122 + if (((int)value >= 65 && (int)value <= 90) || ((int)value <= 122 && (int)value >= 97)) + { + letter = value; + } + else + { + + } + + } + } + + +} \ No newline at end of file diff --git a/Lingo/Game.cs b/Lingo/Game.cs index 334d756..0a813d9 100644 --- a/Lingo/Game.cs +++ b/Lingo/Game.cs @@ -1,23 +1,29 @@ using System.Reflection.Metadata.Ecma335; using System.Security.Cryptography; using Spectre.Console; + namespace Lingo; public class Game { - private int count = 0; + //This should only be the data, not the logic. + public int count = 0; static Random rnd = new Random(); - private static int index = rnd.Next(1, Words.FiveLetterWords.Count); - private static string solution = Words.FiveLetterWords[index]; - private static bool exit = false; - public void validateFiveLetters(string solutionCheck) + public static int index = rnd.Next(1, Words.FiveLetterWords.Count); + public string solution = Words.FiveLetterWords[index]; + public static bool exit = false; + public string attempt; + private List attemptList; + private List solutionList; + + public void ValidateFiveLetters(string solutionCheck) { exit = false; while (exit == false) { if (solutionCheck.Length != 5) { - index = rnd.Next(1, Words.FiveLetterWords.Count); + index = rnd.Next(0, Words.FiveLetterWords.Count); solution = Words.FiveLetterWords[index]; } else @@ -27,14 +33,15 @@ public class Game } } - public void validateFiveLettersAttempt(string attemptCheck) + public void ValidateFiveLettersAttempt(string attemptCheck) { exit = false; while (exit == false) { if (attemptCheck.Length != 5) { - attempt = AnsiConsole.Ask("Your word is not exactly 5 letters. Try again."); + attempt = AnsiConsole.Ask("[red]Your word is not exactly 5 letters. Try again.[/]"); + attemptCheck = attempt; } else { @@ -43,31 +50,39 @@ public class Game } } - public static string attempt = AnsiConsole.Ask("What is your [green]name[/]?"); - private List attemptList; - private List solutionList; - private void createCharList(string solution) + + + + + public void checking (string tries) { - foreach (char c in solution) + for (int i = 0; i < tries.Length; i++) { - solutionList.Add(c); + if (tries[i] == solution[i]) + { + //Green + + } + else if (solution.Contains(tries[i])) + { + //Yellow + } + else + { + // black + + } } } - private void createAttemptCharList(string attempt) + public void askForInput() { - foreach (char c in attempt) - { - attemptList.Add(c); - } + attempt = AnsiConsole.Ask("Enter a 5-letter word"); } - + public Game() { - validateFiveLetters(solution); - validateFiveLettersAttempt(attempt); - createCharList(solution); - createAttemptCharList(attempt); + } } \ No newline at end of file diff --git a/Lingo/Play.cs b/Lingo/Play.cs index af8a332..021eb87 100644 --- a/Lingo/Play.cs +++ b/Lingo/Play.cs @@ -2,10 +2,5 @@ namespace Lingo; public class Play { - public Play() - { - - } - - public int I { get; private set; } + //Put the logic here, methods. Controlling the game loop. } \ No newline at end of file diff --git a/Lingo/Program.cs b/Lingo/Program.cs index 265bc43..56485ae 100644 --- a/Lingo/Program.cs +++ b/Lingo/Program.cs @@ -5,40 +5,33 @@ using Spectre.Console; class Program { static void Main(string[] args) - { - try - { - bool isRunning = true; + { //Make a view class instead of stuffing it here. + // Game controller could have the game loop? try this. + // Also an input controller, instead of putting it in view or others. + bool isRunning = true; - do + + AnsiConsole.Clear(); + + string userSelection = AnsiConsole.Prompt( + new SelectionPrompt() + .Title("Choose play or quit ") + .AddChoices + ( + "1. Play Lingo", + "2. Quit" + ) + ); + switch (userSelection) { - AnsiConsole.Clear(); + case "1. Play Lingo": + Game game = new Game(); - string userSelection = AnsiConsole.Prompt( - new SelectionPrompt() - .Title("Choose play or quit ") - .AddChoices - ( - "1. Play Lingo", - "2. Quit" - ) - ); - switch (userSelection) - { - case "1. Play Lingo": - Game attempt = new Game(); + break; + case "2. Quit": + + break; + } - break; - case "2. Quit": - isRunning = false; - break; - } - } while (isRunning); - } - catch (Exception ex) - { - AnsiConsole.MarkupLine($"[red]Error:[/] {ex.Message}"); - Console.ReadLine(); - } } } \ No newline at end of file diff --git a/Lingo/Words.cs b/Lingo/Words.cs index ab3079e..3682b05 100644 --- a/Lingo/Words.cs +++ b/Lingo/Words.cs @@ -2,7 +2,8 @@ namespace Lingo; public static class Words { - public static readonly List FiveLetterWords = new List + //Readonly collection? Interface + public static List FiveLetterWords = new List { "joust", "swamp", "glint", "prawn", "chide", "stomp", "fleck", "groan", "birch", "thrum", "slunk", "brave", "chops", "twirl", "plank", "snore", "draft", "gloom", "wharf", "spunk",