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 class DisplayCharacters
|
||||||
{
|
{
|
||||||
|
public static readonly string green = "green";
|
||||||
|
public static readonly string yellow = "yellow";
|
||||||
|
public static readonly string black = "black";
|
||||||
|
|
||||||
|
|
||||||
private char letter;
|
private char letter;
|
||||||
public char Letter {
|
|
||||||
get;
|
public char Letter
|
||||||
private set
|
{
|
||||||
|
get { return letter; }
|
||||||
|
set
|
||||||
{
|
{
|
||||||
// Capital A is 65, to 90, 97-122
|
// Capital A is 65, to 90, 97-122
|
||||||
if (((int)value >= 65 && (int)value <= 90) || ((int)value <= 122 && (int)value >= 97))
|
if (((int)value >= 65 && (int)value <= 90) || ((int)value <= 122 && (int)value >= 97))
|
||||||
|
|
@ -14,11 +21,30 @@ public class DisplayCharacters
|
||||||
}
|
}
|
||||||
else
|
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 string solution = Words.FiveLetterWords[index];
|
||||||
public static bool exit = false;
|
public static bool exit = false;
|
||||||
public string attempt;
|
public string attempt;
|
||||||
private List<char> attemptList;
|
private DisplayCharacters[] displayArray;
|
||||||
private List<char> solutionList;
|
private List<char> solutionList;
|
||||||
|
|
||||||
public void ValidateFiveLetters(string solutionCheck)
|
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++)
|
for (int i = 0; i < tries.Length; i++)
|
||||||
{
|
{
|
||||||
if (tries[i] == solution[i])
|
if (tries[i] == solution[i])
|
||||||
{
|
{
|
||||||
//Green
|
//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]))
|
else if (solution.Contains(tries[i]))
|
||||||
{
|
{
|
||||||
//Yellow
|
//Yellow
|
||||||
|
displayArray[i].Colour = DisplayCharacters.yellow;
|
||||||
|
displayArray[i].Letter = tries[i];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// black
|
// black
|
||||||
|
displayArray[i].Colour = DisplayCharacters.black;
|
||||||
|
displayArray[i].Letter = tries[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -83,6 +92,6 @@ public class Game
|
||||||
|
|
||||||
public Game()
|
public Game()
|
||||||
{
|
{
|
||||||
|
displayArray = new DisplayCharacters[5];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5,7 +5,8 @@ using Spectre.Console;
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
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.
|
// Game controller could have the game loop? try this.
|
||||||
// Also an input controller, instead of putting it in view or others.
|
// Also an input controller, instead of putting it in view or others.
|
||||||
bool isRunning = true;
|
bool isRunning = true;
|
||||||
|
|
@ -32,6 +33,5 @@ class Program
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue