public void Execute(UnitActionCollection actionCollection) { foreach (var entry in actionCollection.Actions) { var guid = entry.Key; var action = entry.Value; var unit = State.FindObject(guid) as Unit; if (unit == null) { return; } //If the Unit is technically dead, we will skip it and it should be cleaned up for next round if (unit.ShouldRemove()) { continue; } if (!unit.CanAttemptAction(action)) { action = new NoopAction(); //Defaults to no-op } try { AttemptAction(unit, action); } catch (BadActionException ex) { Log.Error("Failed to execute action due to the following error: ", ex); throw; //TODO: Do we really want to throw errors here? Testing is easier, but that is all } } }
public void CanAct_NoopAction_ReturnTrue() { var subject = new UnitImpl(); var noop = new NoopAction(); Assert.True(subject.CanAttemptAction(noop)); }
public void CanAct_DefaultActions_ReturnTrue() { var subject = new BUnit(1); var noop = new NoopAction(); Assert.True(subject.CanAttemptAction(noop)); }