Example #1
0
        private static int GetSupportableUnitsCount(Dictionary<CombatUnitType, int> units, CombatUnitType unitType, int unitCount)
        {
            if (unitType.SupportableByTypes == null)
                return 0;

            var supportTypes = units.Where(u => unitType.SupportableByTypes.Contains(u.Key.Type));

            if (supportTypes != null && supportTypes.Count() > 0)
                return Math.Min(supportTypes.Sum(u => u.Value), unitCount);

            return 0;
        }
Example #2
0
        public CombatUnitType ToCombatUnitType()
        {
            var type = GetTypeForUnitName(Name);

            var res = new CombatUnitType(Attack, Defense, Cost, type);

            if (!String.IsNullOrEmpty(SupportableByTypes))
            {
                IList<ValidCombatUnitTypes> supportTypes = new List<ValidCombatUnitTypes>();

                foreach (var supportTypeName in SupportableByTypes.Split(','))
                    supportTypes.Add(GetTypeForUnitName(supportTypeName));

                res.SupportableByTypes = supportTypes;
            }

            if (!String.IsNullOrEmpty(OnHitReplaceWithType))
            {
                res.OnHitReplaceWithType = GetTypeForUnitName(OnHitReplaceWithType);
            }

            return res;
        }