コード例 #1
0
        public T GetValueForCiv(ICivilization civ)
        {
            var retval = DataForExtraction.UnitaryValue;

            var policyBonuses = SocialPolicyCanon.GetPolicyBonusesForCiv(civ);

            var policyValues = policyBonuses.Select(bonuses => DataForExtraction.PolicyExtractor(bonuses));

            if (policyValues.Any())
            {
                retval = DataForExtraction.Aggregator(retval, policyValues.Aggregate(DataForExtraction.Aggregator));
            }

            if (DataForExtraction.GlobalBuildingExtractor != null)
            {
                var citiesOf = CityPossessionCanon.GetPossessionsOfOwner(civ);

                var buildingsOf = citiesOf.SelectMany(
                    city => BuildingPossessionCanon.GetPossessionsOfOwner(city)
                    ).ToList();

                foreach (var building in buildingsOf)
                {
                    retval = DataForExtraction.Aggregator(
                        retval, DataForExtraction.GlobalBuildingExtractor(building.Template)
                        );
                }
            }

            return(retval);
        }
コード例 #2
0
        public T GetValueForCity(ICity city)
        {
            T retval = default(T);

            var cityOwner = CityPossessionCanon.GetOwnerOfPossession(city);

            var ownerCapital = CapitalCityCanon.GetCapitalOfCiv(cityOwner);

            if (city == ownerCapital)
            {
                IEnumerable <T> capitalValues = SocialPolicyCanon
                                                .GetPolicyBonusesForCiv(cityOwner)
                                                .Select(bonuses => DataForExtraction.PolicyCapitalBonusesExtractor(bonuses));

                if (capitalValues.Any())
                {
                    retval = DataForExtraction.Aggregator(
                        retval, capitalValues.Aggregate(DataForExtraction.Aggregator)
                        );
                }
            }

            IEnumerable <T> cityValues = SocialPolicyCanon
                                         .GetPolicyBonusesForCiv(cityOwner)
                                         .Select(bonuses => DataForExtraction.PolicyCityBonusesExtractor(bonuses));

            if (cityValues.Any())
            {
                retval = DataForExtraction.Aggregator(
                    retval, cityValues.Aggregate(DataForExtraction.Aggregator)
                    );
            }

            if (DataForExtraction.BuildingLocalBonusesExtractor != null)
            {
                foreach (var building in BuildingPossessionCanon.GetPossessionsOfOwner(city))
                {
                    retval = DataForExtraction.Aggregator(
                        retval, DataForExtraction.BuildingLocalBonusesExtractor(building.Template)
                        );
                }
            }

            if (DataForExtraction.BuildingGlobalBonusesExtractor != null)
            {
                foreach (var building in GetGlobalBuildings(cityOwner))
                {
                    retval = DataForExtraction.Aggregator(
                        retval, DataForExtraction.BuildingGlobalBonusesExtractor(building.Template)
                        );
                }
            }

            return(DataForExtraction.Aggregator(DataForExtraction.UnitaryValue, retval));
        }
コード例 #3
0
        public T GetValueForUnit(IUnit unit)
        {
            T retval = DataForExtraction.UnitaryValue;

            var unitOwner = UnitPossessionCanon.GetOwnerOfPossession(unit);

            foreach (var bonuses in SocialPolicyCanon.GetPolicyBonusesForCiv(unitOwner))
            {
                retval = DataForExtraction.Aggregator(retval, DataForExtraction.PolicyBonusesExtractor(bonuses));
            }

            return(retval);
        }