diff --git a/EduNetworkBuilder/ActionClass.cs b/EduNetworkBuilder/ActionClass.cs index 9a14279..752ccb0 100644 --- a/EduNetworkBuilder/ActionClass.cs +++ b/EduNetworkBuilder/ActionClass.cs @@ -11,12 +11,24 @@ namespace EduNetworkBuilder { Network StartingState = null; public List NetActions = new List(); + 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); + } + /// /// Return true if we already have a solved state for this network /// @@ -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 Actions = new List(); + 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