Added drawing of the hints

This commit is contained in:
2022-10-13 07:39:44 +02:00
parent 76daa4782d
commit 9b255c8ed9
5 changed files with 247 additions and 23 deletions
+38 -4
View File
@@ -8,6 +8,7 @@ namespace NonoGramme
{
internal class Line
{
private static Random rnd = new Random();
private Tile[] _data;
private int _length;
private List<int> _hints;
@@ -18,17 +19,47 @@ namespace NonoGramme
public Line(Tile[] states) {
//This method will create a new Line wich can then be edited
Data = states;
RecalculateHints();
}
public Line(int length)
{
//This method will just create the Line but totally empty
Data = new Tile[length];
for (int i = 0; i< length; i++)
Length = length;
Data = new Tile[Length];
for (int i = 0; i< Length; i++)
{
Data[i] = new Tile();
}
RecalculateHints();
}
public string GetHorizontalHints()
{
string result = "";
int counter = 0;
foreach (int hint in Hints)
{
counter++;
if (counter != Hints.Count)
{
result += hint + ",";
}
else
{
result += hint;
}
}
return result;
}
public string GetVerticalHints()
{
string result = "";
foreach (int hint in Hints)
{
result += hint + Environment.NewLine;
}
return result;
}
public void Edit(int index, Tile.State state)
{
Data[index].CurrentState = state;
@@ -39,8 +70,11 @@ namespace NonoGramme
//This will have to be done, for now its just a placeholder
//TO REMOVE !!
Hints = new List<int>();
Hints.Add(1);
Hints.Add(3);
int count = rnd.Next(1, Data.Count()-1);
for (int i = 0;i < count;i++)
{
Hints.Add(rnd.Next(1, Data.Count()-1));
}
}
}
}