Making progress on initial functions
This commit is contained in:
parent
f6264d9098
commit
3d335d32c4
@ -11,12 +11,24 @@ namespace EduNetworkBuilder
|
||||
{
|
||||
Network StartingState = null;
|
||||
public List<NetworkAction> NetActions = new List<NetworkAction>();
|
||||
NetworkAction CurrentNetAction = null;
|
||||
|
||||
public void RegisterNet(Network starting)
|
||||
{
|
||||
//Get name from network
|
||||
//See if that
|
||||
CurrentNetAction = new NetworkAction(starting);
|
||||
}
|
||||
|
||||
public void Add(ActionClass What)
|
||||
{
|
||||
if(CurrentNetAction == null)
|
||||
{
|
||||
Network start = NB.GetNetwork();
|
||||
if (start == null) return;//Do nothing
|
||||
CurrentNetAction = new NetworkAction(start);
|
||||
}
|
||||
CurrentNetAction.Add(What);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return true if we already have a solved state for this network
|
||||
/// </summary>
|
||||
@ -25,23 +37,55 @@ namespace EduNetworkBuilder
|
||||
public bool AlreadyHaveNet(Network starting)
|
||||
{
|
||||
//Look up the network to see if we have it already
|
||||
return AlreadyHaveNet(starting.PuzzleName);
|
||||
return AlreadyHaveNet(NameFromNet(starting));
|
||||
}
|
||||
public bool AlreadyHaveNet(string starting)
|
||||
{
|
||||
//Look up the network to see if we have it already
|
||||
foreach(NetworkAction NA in NetActions)
|
||||
{
|
||||
if (NA.NetworkName == starting) return true;
|
||||
}
|
||||
NetworkAction NA = GetActionlistFromName(starting);
|
||||
if (NA != null) return true; //one exists
|
||||
return false;
|
||||
}
|
||||
public NetworkAction GetActionlistFromNet(Network starting)
|
||||
{
|
||||
return GetActionlistFromName(NameFromNet(starting));
|
||||
}
|
||||
public NetworkAction GetActionlistFromName(string starting)
|
||||
{
|
||||
foreach (NetworkAction NA in NetActions)
|
||||
{
|
||||
if (NA.NetworkName == starting) return NA;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private string NameFromNet(Network theNet)
|
||||
{
|
||||
return theNet.PuzzleName;
|
||||
}
|
||||
}
|
||||
|
||||
public class NetworkAction
|
||||
{
|
||||
public string NetworkName = "";
|
||||
public List<ActionClass> Actions = new List<ActionClass>();
|
||||
public NetworkAction(string Name)
|
||||
{
|
||||
NetworkName = Name;
|
||||
Actions.Clear();
|
||||
}
|
||||
public NetworkAction(Network Start)
|
||||
{
|
||||
if (Start == null)
|
||||
Start = NB.GetNetwork();
|
||||
if (Start != null)
|
||||
NetworkName = Start.PuzzleName;
|
||||
else
|
||||
NetworkName = "Empty";
|
||||
Actions.Clear();
|
||||
}
|
||||
public void Add(ActionClass What)
|
||||
{
|
||||
Actions.Add(What);
|
||||
}
|
||||
}
|
||||
|
||||
public class ActionClass
|
||||
|
Loading…
Reference in New Issue
Block a user