Beispiel #1
0
        public void CalculateUnits(Battalion Battalion)
        {
            if (Battalion.IsExhausted && Battalion.Next != null)
            {
                int requiredUnits = Convert.ToInt32(Math.Ceiling((decimal)Math.Abs(Battalion.AdditionalUnits) / 2));

                int CanUse = Battalion.Next.Remaining > requiredUnits ? requiredUnits : Battalion.Next.Remaining;

                Battalion.Next.Deployed += CanUse;
                Battalion.Required      -= requiredUnits == CanUse ? Battalion.AdditionalUnits  : CanUse;
            }
        }
Beispiel #2
0
        public void CalculateUnits(Battalion Battalion)
        {
            if (Battalion.IsExhausted && Battalion.Previous != null)
            {
                int requiredUnits  = Math.Abs(Battalion.AdditionalUnits * 2);
                int availableUnits = (Battalion.Previous.Remaining / 2) * 2;
                int CanUse         = availableUnits > requiredUnits ? requiredUnits : availableUnits;

                Battalion.Previous.Deployed += CanUse;
                Battalion.Required          -= CanUse / 2;
            }
        }
Beispiel #3
0
        private void WarRules(Battalion defendendBattalion)
        {
            IList <IWarRule> warRules = new List <IWarRule>();
            Func <KeyValuePair <int, Battalion>, bool> findBattalion = p => p.Value.Name.Equals(defendendBattalion.Name);
            Battalion battalion = enemy.Battalions.Where(findBattalion).FirstOrDefault().Value;

            warRules.Add(new PowerRule(battalion));
            warRules.Add(new Like_To_Like_Rule());
            warRules.Add(new SubstitutionWithLowerBattalionRule());
            warRules.Add(new SubstituteWithHigherBattalionRule());
            foreach (var rules in warRules)
            {
                rules.CalculateUnits(defendendBattalion);
            }
        }
Beispiel #4
0
 public PowerRule(Battalion opponent)
 {
     this.opponent = opponent;
 }
Beispiel #5
0
 public void CalculateUnits(Battalion Battalion)
 {
     Battalion.Required = ((int)Math.Ceiling((decimal)this.opponent.Units / 2));
 }