Exemple #1
0
 private void AddAction(BaseAction action)
 {
     if (action != null)
     {
         PendingActions.Add(action);
     }
 }
        public static BaseAction ValidateAction(BaseAction action)
        {
            var resultAction = CheckOutcomeConditions(action);
            resultAction = CheckIncomeConditions(resultAction);

            return resultAction;
        }
 private static BaseAction CheckOutcomeConditions(BaseAction action)
 {
     BaseAction result = action;
     if (action.Source.Conditions == null) return result;
     foreach (ICondition condition in action.Source.Conditions.OrderBy(x => x.Priority))
         result = condition.TransformOutcomeAction(result);
     return result;
 }
Exemple #4
0
 public void Observe(BaseAction action, World world)
 {
     foreach (var gameEvent in Events)
     {
         if (gameEvent.Condition(action, world))
         {
             gameEvent.Reaction();
         }
     }
 }
Exemple #5
0
 public virtual BaseAction TransformOutcomeAction(BaseAction action)
 {
     return action;
 }
Exemple #6
0
 public abstract BaseAction TransformOutcomeAction(BaseAction action);
 private static BaseAction CheckIncomeConditions(BaseAction action)
 {
     var resultAction = action;
     if (resultAction as ISingleTargetAffecter == null) return action;
     return (action as ISingleTargetAffecter).Target.Conditions.OrderBy(x => x.Priority).Aggregate(resultAction, (current, condition) => condition.TransformIncomeAction(current));
 }