本文整理汇总了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;
}
}
}
}
示例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);
}
}
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}