Need to decide where the game loop will be, make controller, etc.
This commit is contained in:
parent
83cdc58672
commit
6d95041b83
3 changed files with 69 additions and 34 deletions
|
|
@ -2,10 +2,17 @@
|
|||
|
||||
public class DisplayCharacters
|
||||
{
|
||||
public static readonly string green = "green";
|
||||
public static readonly string yellow = "yellow";
|
||||
public static readonly string black = "black";
|
||||
|
||||
|
||||
private char letter;
|
||||
public char Letter {
|
||||
get;
|
||||
private set
|
||||
|
||||
public char Letter
|
||||
{
|
||||
get { return letter; }
|
||||
set
|
||||
{
|
||||
// Capital A is 65, to 90, 97-122
|
||||
if (((int)value >= 65 && (int)value <= 90) || ((int)value <= 122 && (int)value >= 97))
|
||||
|
|
@ -14,11 +21,30 @@ public class DisplayCharacters
|
|||
}
|
||||
else
|
||||
{
|
||||
|
||||
throw new ArgumentException("Not a valid letter");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private string colour;
|
||||
|
||||
public string Colour
|
||||
{
|
||||
get { return colour; }
|
||||
set
|
||||
{
|
||||
if (value.ToLower() == "green" || value.ToLower() == "yellow" || value.ToLower() == "black")
|
||||
{
|
||||
colour = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Not a valid colour, needs to be green, black, or yellow");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DisplayCharacters()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@ public class Game
|
|||
public string solution = Words.FiveLetterWords[index];
|
||||
public static bool exit = false;
|
||||
public string attempt;
|
||||
private List<char> attemptList;
|
||||
private DisplayCharacters[] displayArray;
|
||||
private List<char> solutionList;
|
||||
|
||||
public void ValidateFiveLetters(string solutionCheck)
|
||||
|
|
@ -50,28 +50,37 @@ public class Game
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void checking (string tries)
|
||||
public void checking(string tries)
|
||||
{
|
||||
for (int i = 0; i < tries.Length; i++)
|
||||
{
|
||||
if (tries[i] == solution[i])
|
||||
{
|
||||
//Green
|
||||
displayArray[i] = new DisplayCharacters();
|
||||
|
||||
// try
|
||||
// {
|
||||
// displayArray[i].Colour = "blue";
|
||||
// }
|
||||
// catch (ArgumentException e)
|
||||
// {
|
||||
// displayArray[i].Colour = "green";
|
||||
// }
|
||||
displayArray[i].Colour = DisplayCharacters.green;
|
||||
displayArray[i].Letter = tries[i];
|
||||
}
|
||||
else if (solution.Contains(tries[i]))
|
||||
{
|
||||
//Yellow
|
||||
displayArray[i].Colour = DisplayCharacters.yellow;
|
||||
displayArray[i].Letter = tries[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
// black
|
||||
|
||||
displayArray[i].Colour = DisplayCharacters.black;
|
||||
displayArray[i].Letter = tries[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -83,6 +92,6 @@ public class Game
|
|||
|
||||
public Game()
|
||||
{
|
||||
|
||||
displayArray = new DisplayCharacters[5];
|
||||
}
|
||||
}
|
||||
|
|
@ -5,33 +5,33 @@ using Spectre.Console;
|
|||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{ //Make a view class instead of stuffing it here.
|
||||
{
|
||||
//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;
|
||||
|
||||
|
||||
AnsiConsole.Clear();
|
||||
AnsiConsole.Clear();
|
||||
|
||||
string userSelection = AnsiConsole.Prompt(
|
||||
new SelectionPrompt<string>()
|
||||
.Title("Choose play or quit ")
|
||||
.AddChoices
|
||||
(
|
||||
"1. Play Lingo",
|
||||
"2. Quit"
|
||||
)
|
||||
);
|
||||
switch (userSelection)
|
||||
{
|
||||
case "1. Play Lingo":
|
||||
Game game = new Game();
|
||||
string userSelection = AnsiConsole.Prompt(
|
||||
new SelectionPrompt<string>()
|
||||
.Title("Choose play or quit ")
|
||||
.AddChoices
|
||||
(
|
||||
"1. Play Lingo",
|
||||
"2. Quit"
|
||||
)
|
||||
);
|
||||
switch (userSelection)
|
||||
{
|
||||
case "1. Play Lingo":
|
||||
Game game = new Game();
|
||||
|
||||
break;
|
||||
case "2. Quit":
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "2. Quit":
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue