Ejemplo n.º 1
0
        public MethodResult CanCreateCountryCompany(Entity entity, Country country, Citizen loggedCitizen)
        {
            if (country == null)
            {
                return(new MethodResult("Country is not defined!"));
            }

            var policy = (LawAllowHolderEnum)countryRepository.GetCountryPolicySetting(country.ID, pol => pol.CountryCompanyBuildLawAllowHolder);

            if (entity.GetEntityType() != EntityTypeEnum.Citizen)
            {
                return(new MethodResult("Only citizens can create national companies!"));
            }

            if (country.PresidentID == entity.EntityID && policy == LawAllowHolderEnum.Congress)
            {
                return(new MethodResult("Only congress can create companies in your country!"));
            }
            if (congressVotingService.IsCongressman(loggedCitizen, country) && policy == LawAllowHolderEnum.President)
            {
                return(new MethodResult("Only president can create companies in your country!"));
            }

            var neededGold   = ConfigurationHelper.Configuration.CompanyCountryFee;
            var treasureGold = walletService.GetWalletMoney(country.Entity.WalletID, GameHelper.Gold.ID);

            if (treasureGold.Amount < neededGold)
            {
                return(new MethodResult($"Not enough gold to construct company. You need {neededGold} gold and your country only have {treasureGold.Amount} gold"));
            }

            return(MethodResult.Success);
        }
Ejemplo n.º 2
0
        public ActionResult StartVoting(int countryID)
        {
            var entity = SessionHelper.CurrentEntity;

            if (entity.Is(EntityTypeEnum.Citizen) == false)
            {
                return(RedirectBackWithError("You are not a citizen."));
            }

            var citizen = entity.Citizen;
            var country = countryRepository.GetById(countryID);

            if (country == null)
            {
                return(RedirectBackWithError("Country does not exist!"));
            }

            if (congressVotingService.IsCongressman(citizen, country) == false)
            {
                return(RedirectBackWithError("You are not a party member of this country!"));
            }

            if (citizen.Congressmen.First(c => c.CountryID == countryID).LastVotingDay >= GameHelper.CurrentDay)
            {
                AddError("You started voting today!");
                return(RedirectToAction("Votings", new { countryID = countryID }));
            }

            if (country.Congressmen.Count < 3)
            {
                AddWarning("You cannot vote when there is less than 3 congressmen. [Feature will be enabled in release version. You can vote without problems]");
            }


            var votingTypes         = congressVotingRepository.GetVotingTypes();
            var commentRestrictions = congressVotingRepository.GetCommentRestrictions();


            var vm = new CongressStartVotingViewModel(votingTypes, commentRestrictions, country);

            return(View(vm));
        }