Ejemplo n.º 1
0
 public void PrepareDefence(IEnumerable <AttackAction> attacksToDefend)
 {
     if (registeredDefences.Any())
     {
         PerformedDefence = CurrentCombatStrategy.PrepareDefence(attacksToDefend, registeredDefences.Where(x => x.IsAvailable));
     }
 }
Ejemplo n.º 2
0
        private DefenceAction SelectDefence(AttackAction attack, IEnumerable <DefenceAction> availableDefences)
        {
            DefenceAction selectedDefence = null;
            List <DefensiveActionData> possibleDefences = attack.ActionData.PossibleDefences;
            int bestDefenceIndex = int.MaxValue, currentIndex;

            foreach (var defence in availableDefences)
            {
                if ((currentIndex = possibleDefences.IndexOf(defence.ActionData)) < bestDefenceIndex)
                {
                    bestDefenceIndex = currentIndex;
                    selectedDefence  = defence;
                }
            }

            return(selectedDefence);
        }