Ejemplo n.º 1
0
        public override ActionExecutionInformation CanPerformEvent(Company company, IActionData eventData, IHub services)
        {
            var companyService = services.Resolve<ICompanyService>();

            if(!companyService.CanPerformAction(company, Type))
            {
                return new ActionExecutionInformation(false, $"Company {company.Id} cannot perform turn action {Type}.", company);
            }

            var data = eventData as SellPerkActionData;

            var perkService = services.Resolve<IPerkService>();

            var perk = perkService.GetPerk(data.PerkId);

            var companyPerk = company.GetPerk(perk);

            if(companyPerk.Count < data.Count)
            {
                return new ActionExecutionInformation(false, $"Company {company.Id} cannot sell {data.Count} perks (ID: {perk.Id}).", perk, company);
            }

            return new ActionExecutionInformation(true);
        }