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