当前位置: 首页>>代码示例>>C#>>正文


C# IHub.Resolve方法代码示例

本文整理汇总了C#中IHub.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# IHub.Resolve方法的具体用法?C# IHub.Resolve怎么用?C# IHub.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IHub的用法示例。


在下文中一共展示了IHub.Resolve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessTurn

        public void ProcessTurn(IHub services)
        {
            var personService = services.Resolve<IPersonService>();

            var gameClockService = services.Resolve<IGameClockService>();

            foreach(var person in personService.People.Where(p => !personService.IsRetired(p)))
            {
                if (person.RetirementDate > gameClockService.CurrentDate)
                {
                    continue;
                }

                var currentWorkHistory = person.WorkHistory.FirstOrDefault(wh => !wh.EndDate.HasValue);

                if(currentWorkHistory != null)
                {
                    var employee = currentWorkHistory.Company.GetEmployee(person.Id);

                    if(!employee.IsFounder)
                    {
                        currentWorkHistory.EndDate = gameClockService.CurrentDate;

                        currentWorkHistory.EndingSalary = employee.Salary;
                    }
                }
            }
        }
开发者ID:hyjynx-studios,项目名称:bizio,代码行数:28,代码来源:PersonRetirementProcessor.cs

示例2: ProcessTurn

        public void ProcessTurn(IHub services)
        {
            var companyService = services.Resolve<ICompanyService>();

            var gameClockService = services.Resolve<IGameClockService>();

            foreach(var company in companyService.Companies)
            {
                foreach(var project in company.Projects)
                {
                    if (IsProjectComplete(project))
                    {
                        CompleteProject(company, project);

                        companyService.ProcessTransaction(company, TransactionType.Project, project.Value, $"Completed {project.Definition.Name} project.");

                    }
                    else
                    {
                        var deadline = project.ExtensionDeadline.HasValue ?
                                       project.ExtensionDeadline.Value :
                                       project.Deadline;

                        if (gameClockService.CurrentDate >= deadline)
                        {
                            FailProject(company, project);
                        }
                    }
                }
            }
        }
开发者ID:hyjynx-studios,项目名称:bizio,代码行数:31,代码来源:ProjectProgressProcessor.cs

示例3: GenerateData

        public IEnumerable<IActionData> GenerateData(IHub services, Company company)
        {
            var actionData = new List<IActionData>();

            var recruitAction = company.Actions.FirstOrDefault(a => a.Action.Id == (byte)ActionType.RecruitPerson);

            if (recruitAction.Count == 0)
            {
                return actionData;
            }

            var founder = company.Employees.FirstOrDefault(e => e.IsFounder);

            var configurationService = services.Resolve<IConfigurationService>();

            var fastGrowth = configurationService.GetDecimalValue(ConfigurationKey.FastCompanyGrowthValue, ConfigurationFallbackValue.FastCompanyGrowthValue);

            var growthTarget = founder.Person.GetPersonalityValue(PersonalityAttributeId.DesiredCompanyGrowth);

            var growthImportance = founder.Person.GetPersonalityValue(PersonalityAttributeId.CompanyGrowthImportance);

            var targetNumberOfProspects = fastGrowth * growthTarget;

            var maxDifferential = fastGrowth * (1m - growthImportance);

            var differential = (int)(targetNumberOfProspects - company.Prospects.Count);

            if (differential <= maxDifferential)
            {
                return actionData;
            }

            var personService = services.Resolve<IPersonService>();

            var recruitCount = recruitAction.Count;

            var recruitTargetCount = targetNumberOfProspects - maxDifferential;

            while (recruitCount-- > 0 &&
                 (company.Prospects.Count + actionData.Count) < recruitTargetCount)
            {
                var person = personService.GetUnemployedPerson();

                actionData.Add(new RecruitPersonActionData(person.Id));
            }

            return actionData;
        }
开发者ID:hyjynx-studios,项目名称:bizio,代码行数:48,代码来源:RecruitPersonDataGenerator.cs

示例4: Evaluate

        public OfferResponseReason? Evaluate(IHub services, Company company, Person person, decimal amount)
        {
            var perkService = services.Resolve<IPerkService>();

            var applicablePerkCount = company.Perks.Count(cp => cp.Count > 0 && perkService.DoesPerkApplyTo(cp.Perk, person));

            var personService = services.Resolve<IPersonService>();

            var minimumPerkCount = person.GetPersonalityValue(PersonalityAttributeId.MinimumPerkCount);

            if(minimumPerkCount <= applicablePerkCount)
            {
                return null;
            }

            return OfferResponseReason.Perks;
        }
开发者ID:hyjynx-studios,项目名称:bizio,代码行数:17,代码来源:PerkEvaluator.cs

示例5: ProcessTurn

        public void ProcessTurn(IHub services)
        {
            var personService = services.Resolve<IPersonService>();

            var configurationService = services.Resolve<IConfigurationService>();

            var minimumPersonCount = configurationService.GetIntValue(ConfigurationKey.MinimumPersonCount, ConfigurationFallbackValue.MinimumPersonCount);

            var nonRetiredPersonCount = personService.People.Count(p => !personService.IsRetired(p));

            var numberOfPeopleToGenerate = minimumPersonCount - nonRetiredPersonCount;

            if(numberOfPeopleToGenerate > 0)
            {
                personService.GeneratePeople(numberOfPeopleToGenerate);
            }
        }
开发者ID:hyjynx-studios,项目名称:bizio,代码行数:17,代码来源:GeneratePeopleProcessor.cs

示例6: ProcessEvent

        public override CompanyMessage ProcessEvent(Company company, IActionData eventData, IHub services)
        {
            var data = eventData as MakeOfferActionData;

            var personService = services.Resolve<IPersonService>();

            var companyService = services.Resolve<ICompanyService>();

            var person = personService.GetPerson(data.PersonId);

            var gameClockService = services.Resolve<IGameClockService>();

            var message = new CompanyMessage
            {
                Id = Utilities.InvalidId,
                DateCreated = gameClockService.CurrentDate,
                Status = CompanyMessageStatus.UnRead,
                Source = "Human Resources"
            };

            if (personService.IsUnemployed(person))
            {
                var response = companyService.MakeOffer(company, person, data.OfferValue);

                if (response.DidAccept)
                {
                    message.Subject = "Offer Accepted";

                    message.Message = $"{person.FirstName} {person.LastName} accepted an offer of {data.OfferValue:C}.";
                }
                else
                {
                    message.Subject = "Offer Declined";

                    message.Message = $"{person.FirstName} {person.LastName} declined an offer of {data.OfferValue:C}.";
                }
            }
            else
            {
                message.Subject = "Offer Too Late";

                message.Message = $"{person.FirstName} {person.LastName} recently accepted an offer elsewhere.";
            }

            return message;
        }
开发者ID:hyjynx-studios,项目名称:bizio,代码行数:46,代码来源:MakeOfferAction.cs

示例7: ProcessTurn

        public void ProcessTurn(IHub services)
        {
            var projectService = services.Resolve<IProjectService>();

            var configurationService = services.Resolve<IConfigurationService>();

            var minimumProjectCount = configurationService.GetIntValue(ConfigurationKey.MinimumProjectCount, ConfigurationFallbackValue.MinimumProjectCount);

            var numberOfProjectsToGenerate = minimumProjectCount - projectService.Projects.Count();

            if (numberOfProjectsToGenerate > 0)
            {
                var gameService = services.Resolve<IGameService>();

                projectService.GenerateProjects(gameService.CurrentIndustry, numberOfProjectsToGenerate);
            }
        }
开发者ID:hyjynx-studios,项目名称:bizio,代码行数:17,代码来源:GenerateProjectsProcessor.cs

示例8: ProcessEvent

        public override CompanyMessage ProcessEvent(Company company, IActionData eventData, IHub services)
        {
            var data = eventData as AcceptProjectActionData;

            var projectService = services.Resolve<IProjectService>();

            var project = projectService.GetProject(data.ProjectId);

            var gameClockService = services.Resolve<IGameClockService>();

            var message = new CompanyMessage
            {
                Id = Utilities.InvalidId,
                DateCreated = gameClockService.CurrentDate,
                Source = "Project Management",
                Status = CompanyMessageStatus.UnRead
            };

            if (project != null)
            {
                if (projectService.CanAcceptProject(project, company.Reputation))
                {
                    var companyService = services.Resolve<ICompanyService>();

                    companyService.AcceptProject(company, project);

                    message.Subject = "We got the project!";

                    message.Message = $"We have been granted the {project.Definition.Name} project.";
                }
                else
                {
                    message.Subject = "We did not get the project...";

                    message.Message = $"We were deemed not reputable enough to be granted the {project.Definition.Name} project.";
                }
            }
            else
            {
                message.Subject = "We missed out on the project.";

                message.Message = $"A project we were seeking has been given to another company.";
            }

            return message;
        }
开发者ID:hyjynx-studios,项目名称:bizio,代码行数:46,代码来源:AcceptProjectAction.cs

示例9: ProcessTurn

        public void ProcessTurn(IHub services)
        {
            var companyService = services.Resolve<ICompanyService>();

            foreach(var company in companyService.Companies)
            {
                var accumulations = new Dictionary<int, decimal>();

                foreach (var employee in company.Employees)
                {
                    var allocations = company.Allocations.Where(a => a.Employee == employee);

                    var skillValues = new Dictionary<int, decimal>();

                    var remainingSkillValues = new Dictionary<int, decimal>();

                    foreach (var skill in employee.Person.Skills)
                    {
                        var skillValue = CalculateEmployeeSkillValue(employee, skill);

                        skillValues.Add(skill.SkillDefinition.Id, skillValue);

                        remainingSkillValues.Add(skill.SkillDefinition.Id, skillValue);
                    }

                    foreach (var allocation in allocations)
                    {
                        foreach (var requirement in allocation.Project.Requirements)
                        {
                            if (skillValues.ContainsKey(requirement.SkillDefinition.Id))
                            {
                                var value = allocation.Percent * skillValues[requirement.SkillDefinition.Id];

                                requirement.CurrentValue += value;

                                remainingSkillValues[requirement.SkillDefinition.Id] -= value;
                            }
                        }
                    }

                    foreach (var skill in remainingSkillValues)
                    {
                        if (accumulations.ContainsKey(skill.Key))
                        {
                            accumulations[skill.Key] += skill.Value;
                        }
                        else
                        {
                            accumulations.Add(skill.Key, skill.Value);
                        }
                    }
                }

                ProcessActionAccumulations(company, accumulations);
            }
        }
开发者ID:hyjynx-studios,项目名称:bizio,代码行数:56,代码来源:EmployeeSkillsProcessor.cs

示例10: CanPerformEvent

        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);
            }

            return new ActionExecutionInformation(true);
        }
开发者ID:hyjynx-studios,项目名称:bizio,代码行数:11,代码来源:AdjustAllocationAction.cs

示例11: Evaluate

        public OfferResponseReason? Evaluate(IHub services, Company company, Person person, decimal amount)
        {
            var personService = services.Resolve<IPersonService>();

            var expectedCompensation = personService.CalculateCompensationValue(person);

            if(amount >= expectedCompensation)
            {
                return null;
            }

            return OfferResponseReason.OfferValue;
        }
开发者ID:hyjynx-studios,项目名称:bizio,代码行数:13,代码来源:MoneyEvaluator.cs

示例12: CanPerformEvent

        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 PurchasePerkActionData;

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

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

            if(!perkService.CanPurchasePerk(company, perk, data.Count))
            {
                return new ActionExecutionInformation(false, $"Company {company.Id} cannot purchase {data.Count} of perk {perk.Id}.", company, data);
            }

            return new ActionExecutionInformation(true);
        }
开发者ID:hyjynx-studios,项目名称:bizio,代码行数:22,代码来源:PurchasePerkAction.cs

示例13: ProcessEvent

        public override CompanyMessage ProcessEvent(Company company, IActionData eventData, IHub services)
        {
            var data = eventData as RecruitPersonActionData;

            var personService = services.Resolve<IPersonService>();

            var companyService = services.Resolve<ICompanyService>();

            var person = personService.GetPerson(data.PersonId);

            var gameClockService = services.Resolve<IGameClockService>();

            var message = new CompanyMessage
            {
                Id = Utilities.InvalidId,
                DateCreated = gameClockService.CurrentDate,
                Status = CompanyMessageStatus.UnRead,
                Source = "Human Resources"
            };

            if(personService.IsUnemployed(person))
            {
                companyService.RecruitPerson(company, person);

                message.Subject = "Recruited Candidate";

                message.Message = $"We have successfully recruited {person.FirstName} {person.LastName}.";
            }
            else
            {
                message.Subject = "Missed a Potential Recruit";

                message.Message = $"{person.FirstName} {person.LastName} has been recently employed and cannot be recruited at this time.";
            }

            return message;
        }
开发者ID:hyjynx-studios,项目名称:bizio,代码行数:37,代码来源:RecruitPersonAction.cs

示例14: ProcessEvent

        public override CompanyMessage ProcessEvent(Company company, IActionData eventData, IHub services)
        {
            var data = eventData as InterviewProspectActionData;

            var companyService = services.Resolve<ICompanyService>();

            var prospect = company.GetProspect(data.PersonId);

            var personService = services.Resolve<IPersonService>();

            var gameClockServices = services.Resolve<IGameClockService>();

            var message = new CompanyMessage
            {
                Id = Utilities.InvalidId,
                DateCreated = gameClockServices.CurrentDate,
                Status = CompanyMessageStatus.UnRead,
                Source = "Human Resources"
            };

            if(personService.IsUnemployed(prospect.Person))
            {
                companyService.InterviewProspect(company, prospect);

                message.Subject = "Interview Complete";

                message.Message = $"{prospect.Person.FirstName} {prospect.Person.LastName} has completed a round of interviews.";
            }
            else
            {
                message.Subject = "Prospect Off the Market";

                message.Message = $"{prospect.Person.FirstName} {prospect.Person.LastName} has recently accepted an offer elsewhere.";
            }

            return message;
        }
开发者ID:hyjynx-studios,项目名称:bizio,代码行数:37,代码来源:InterviewProspectAction.cs

示例15: CanPerformEvent

        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);
        }
开发者ID:hyjynx-studios,项目名称:bizio,代码行数:24,代码来源:SellPerkAction.cs


注:本文中的IHub.Resolve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。