Example #1
0
        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
                }
            }
        }
Example #2
0
        public void CanAct_NoopAction_ReturnTrue()
        {
            var subject = new UnitImpl();
            var noop    = new NoopAction();

            Assert.True(subject.CanAttemptAction(noop));
        }
Example #3
0
        public void CanAct_DefaultActions_ReturnTrue()
        {
            var subject = new BUnit(1);

            var noop = new NoopAction();

            Assert.True(subject.CanAttemptAction(noop));
        }