Пример #1
0
        public MethodResult CanBuildDefenseSystem(Region region, Country country, int quality)
        {
            if (region == null)
            {
                return(new MethodResult("Region does not exist!"));
            }
            if (country == null)
            {
                return(new MethodResult("Country does not exist!"));
            }
            if (region.CountryID != country.ID)
            {
                return(new MethodResult("Region does not belongs to your country!"));
            }

            if (region.DefenseSystemQuality >= quality)
            {
                return(new MethodResult("You cannot construct defense system of this quality here!"));
            }

            var money = new Money(GameHelper.Gold, GetGoldCostForStartingConstruction(quality));

            if (walletService.HaveMoney(country.Entity.WalletID, money) == false)
            {
                return(new MethodResult($"Your country does not have {money.Amount} gold!"));
            }

            if (constructionRepository.AnyConstructionTypeBuildInRegion(region.ID, ProductTypeEnum.DefenseSystem))
            {
                return(new MethodResult("Defense system is already under construction in this region!"));
            }

            return(MethodResult.Success);
        }