centralize passed/failed tracking

This commit is contained in:
Tim Young 2018-10-05 13:00:04 -05:00
parent eec743d9c6
commit aa78fa5aca

View File

@ -62,10 +62,13 @@ namespace EduNetworkBuilder
{
UserActions.Add(What);
}
public void RegisterReplayPassed()
public void RegisterReplayPassed(string networkname = "")
{
if (UserActions == null) return;
NetworkAction NA = UserActions.GetCurrentNetAction();
NetworkAction NA;
if (networkname == "")
NA = UserActions.GetCurrentNetAction();
else NA = UserActions.FindAction(networkname);
if (NA != null)
{
NA.SetPassed();
@ -73,10 +76,13 @@ namespace EduNetworkBuilder
if (PuzzlesFailed.Contains(NA.NetworkName)) PuzzlesFailed.Remove(NA.NetworkName);
}
}
public void RegisterReplayFailed()
public void RegisterReplayFailed(string networkname = "")
{
if (UserActions == null) return;
NetworkAction NA = UserActions.GetCurrentNetAction();
NetworkAction NA;
if (networkname == "")
NA = UserActions.GetCurrentNetAction();
else NA = UserActions.FindAction(networkname);
if (NA != null)
{
NA.SetFailed();
@ -234,6 +240,7 @@ namespace EduNetworkBuilder
public bool HasPassed(string networkname)
{
if (UserActions == null) return false;
if (PuzzlesPassed.Contains(networkname)) return true;
NetworkAction NA = UserActions.FindAction(networkname);
if (NA == null) return false;
return NA.HasPassed;
@ -241,21 +248,19 @@ namespace EduNetworkBuilder
public bool HasFailed(string networkname)
{
if (UserActions == null) return false;
if (PuzzlesFailed.Contains(networkname)) return true;
NetworkAction NA = UserActions.FindAction(networkname);
if (NA == null) return false;
return NA.HasFailed;
}
public void SetPassed(string networkname)
{
if (UserActions == null) return;
NetworkAction NA = UserActions.FindAction(networkname);
NA.SetPassed();
RegisterReplayPassed(networkname);
}
public void SetFailed(string networkname)
{
if (UserActions == null) return;
NetworkAction NA = UserActions.FindAction(networkname);
NA.SetFailed();
RegisterReplayFailed(networkname);
}
public bool CheckIfDone(string PuzzleName)
{