Beispiel #1
0
        public CompanyDto(Company company)
        {
            Id = company.Id;

            Name = company.Name;

            Money = company.Money;

            InitialAccuracy = company.InitialAccuracy;

            UserId = company.UserId;

            RivalId = company.Rival?.Id;

            Actions = company.Actions.Select(a => new CompanyActionDto(a));

            Allocations = company.Allocations.Select(a => new AllocationDto(a));

            Employees = company.Employees.Select(e => new EmployeeDto(e));

            Messages = company.Messages.Select(m => new CompanyMessageDto(m));

            Perks = company.Perks.Select(p => new CompanyPerkDto(p));

            Projects = company.Projects.Select(p => new ProjectDto(p));

            Prospects = company.Prospects.Select(p => new ProspectDto(p));

            Reputation = new ReputationDto(company.Reputation);

            Transactions = company.Transactions.Select(t => new TransactionDto(t));
        }
        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);
        }
        protected void CompleteProject(Company company, Project project)
        {
            if (project.ExtensionDeadline.HasValue)
            {
                project.Result = ProjectResult.CompletedWithExtension;
            }
            else
            {
                project.Result = ProjectResult.Completed;
            }

            EarnReputation(company, project.ReputationRequired, project.Result.Value);
        }
Beispiel #4
0
        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;
        }
        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;
        }
        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;
        }
        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;
        }
Beispiel #8
0
        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;
        }
        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 AdjustSalaryActionData;

            if (data.Salary < 0)
            {
                return new ActionExecutionInformation(false, $"Cannot have a negative employee value.", company, data.Salary);
            }

            return new ActionExecutionInformation(true);
        }
        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);
        }
        public OfferResponseReason? Evaluate(IHub services, Company company, Person person, decimal amount)
        {
            var configurationService = services.Resolve<IConfigurationService>();

            var fastCompanyGrowth = configurationService.GetIntValue(ConfigurationKey.FastCompanyGrowthValue, ConfigurationFallbackValue.FastCompanyGrowthValue);

            var weight = Math.Min((decimal)company.Prospects.Count / (decimal)fastCompanyGrowth, 1m);

            var desiredGrowth = person.GetPersonalityValue(PersonalityAttributeId.DesiredCompanyGrowth);

            var importance = person.GetPersonalityValue(PersonalityAttributeId.CompanyGrowthImportance);

            var differential = Math.Abs(desiredGrowth - weight) * importance;

            var maxDifferential = configurationService.GetDecimalValue(ConfigurationKey.CompanyGrowthMaxDifferential, ConfigurationFallbackValue.CompanyGrowthMaxDifferential);

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

            return OfferResponseReason.CompanyGrowth;
        }
        protected void EarnReputation(Company company, StarCategory projectWeight, ProjectResult projectResult)
        {
            var resultValue = 0;

            switch(projectResult)
            {
                case ProjectResult.Completed:
                    resultValue = 2;
                    break;
                case ProjectResult.CompletedWithExtension:
                    resultValue = 1;
                    break;
            }

            var weightValue = (int)projectWeight - 1;

            checked
            {
                company.Reputation.EarnedStars += weightValue * resultValue;

                company.Reputation.PossibleStars += weightValue * 2;
            }
        }
Beispiel #13
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 MakeOfferActionData;

            if(company.Money < data.OfferValue)
            {
                return new ActionExecutionInformation(false, $"Company {company.Id} does not have {data.OfferValue:C} for this offer.", company, data);
            }

            if (data.OfferValue < 0)
            {
                return new ActionExecutionInformation(false, $"Cannot offer negative amounts of money.", company, data);
            }

            return new ActionExecutionInformation(true);
        }
        public OfferResponseReason? Evaluate(IHub services, Company company, Person person, decimal amount)
        {
            var configurationService = services.Resolve<IConfigurationService>();

            var largeCompanySize = configurationService.GetIntValue(ConfigurationKey.LargeCompanySize, ConfigurationFallbackValue.LargeCompanySize);

            var weight = Math.Min((decimal)company.Employees.Count / (decimal)largeCompanySize, 1m);

            var desiredSize = person.GetPersonalityValue(PersonalityAttributeId.DesiredCompanySize);

            var importance = person.GetPersonalityValue(PersonalityAttributeId.CompanySizeImportance);

            var differential = Math.Abs(desiredSize - weight) * importance;

            var maxDifferential = configurationService.GetDecimalValue(ConfigurationKey.CompanySizeMaxDifferential, ConfigurationFallbackValue.CompanySizeMaxDifferential);

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

            return OfferResponseReason.CompanySize;
        }
        public OfferResponseReason? Evaluate(IHub services, Company company, Person person, decimal amount)
        {
            var workload = 0m;

            if (company.Employees.Any())
            {
                workload = (decimal)company.Projects.Count / (decimal)company.Employees.Count;
            }

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

            var minWorkload = person.GetPersonalityValue(PersonalityAttributeId.MinimumDesiredEmployeeWorkload);

            var maxWorkload = person.GetPersonalityValue(PersonalityAttributeId.MaximumDesiredEmployeeWorkload);

            if (workload >= minWorkload &&
                workload <= maxWorkload)
            {
                return null;
            }

            return OfferResponseReason.EmployeeWorkload;
        }
        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;
        }
        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;
        }
        public override CompanyMessage ProcessEvent(Company company, IActionData eventData, IHub services)
        {
            var data = eventData as PurchasePerkActionData;

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

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

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

            companyService.PurchasePerk(company, perk, data.Count);

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

            return new CompanyMessage
            {
                Id = Utilities.InvalidId,
                DateCreated = gameClockService.CurrentDate,
                Status = CompanyMessageStatus.UnRead,
                Source = "Finance",
                Subject = "Purchase Made",
                Message = $"Purchased {data.Count} {perk.Name} perks."
            };
        }
Beispiel #19
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);
        }
        public override CompanyMessage ProcessEvent(Company company, IActionData eventData, IHub services)
        {
            var data = eventData as AdjustSalaryActionData;

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

            var employee = company.GetEmployee(data.PersonId);

            var previousSalary = employee.Salary;

            companyService.AdjustSalary(company, employee, data.Salary);

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

            return new CompanyMessage
            {
                Id = Utilities.InvalidId,
                DateCreated = gameClockService.CurrentDate,
                Status = CompanyMessageStatus.UnRead,
                Source = "Human Resources",
                Subject = "Employee Salary Adjustment",
                Message = $"{employee.Person.FirstName} {employee.Person.LastName}'s salary has been adjust from {previousSalary:C} to {employee.Salary:C}."
            };
        }
        public OfferResponseReason? Evaluate(IHub services, Company company, Person person, decimal amount)
        {
            // Create a flag table of the optional skills this person has
            var skills = person.Skills.Where(s => !s.SkillDefinition.IsMandatory)
                                      .ToDictionary(s => s.SkillDefinition, s => false);

            foreach(var project in company.Projects)
            {
                foreach(var requirement in project.Requirements)
                {
                    if(skills.ContainsKey(requirement.SkillDefinition))
                    {
                        skills[requirement.SkillDefinition] = true;
                    }
                }
            }

            var relevance = 1m;

            if (skills.Count > 0)
            {
                relevance = (decimal)skills.Count(s => s.Value) / (decimal)skills.Count;
            }

            var minRelevance = person.GetPersonalityValue(PersonalityAttributeId.MinimumDesiredRelevance);

            var maxRelevance = person.GetPersonalityValue(PersonalityAttributeId.MaximumDesiredRelevance);

            if(minRelevance <= relevance &&
               relevance <= maxRelevance)
            {
                return null;
            }

            return OfferResponseReason.Relevance;
        }
        public override CompanyMessage ProcessEvent(Company company, IActionData eventData, IHub services)
        {
            var data = eventData as AdjustAllocationActionData;

            var employee = company.GetEmployee(data.PersonId);

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

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

            companyService.AdjustAllocation(company, employee, project, data.Percentage, data.Role);

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

            return new CompanyMessage
            {
                Id = Utilities.InvalidId,
                DateCreated = gameClockService.CurrentDate,
                Status = CompanyMessageStatus.UnRead,
                Source = "Project Management",
                Subject = "Employee has been reallocated.",
                Message = $"{employee.Person.FirstName} {employee.Person.LastName} has been directed to work on {project.Definition.Name} {data.Percentage:P} in a {data.Role} role."
            };
        }
 public OfferResponse EvaluateOffer(Company company, Person person, decimal amount)
 {
     return new OfferResponse(new List<OfferResponseReason>(), 0);
 }
 public bool CanPerformAction(Company company, ActionType turnActionType)
 {
     throw new NotImplementedException();
 }
 public IEnumerable<IActionData> GetActionData(Company company)
 {
     return Enumerable.Empty<IActionData>();
 }
 public abstract ActionExecutionInformation CanPerformEvent(Company company, IActionData eventData, IHub services);
        protected void FailProject(Company company, Project project)
        {
            project.Result = ProjectResult.Failed;

            EarnReputation(company, project.ReputationRequired, project.Result.Value);
        }
 public void InterviewProspect(Company company, Prospect prospect)
 {
     throw new NotImplementedException();
 }
 public abstract CompanyMessage ProcessEvent(Company company, IActionData eventData, IHub services);
 public void FireEmployee(Company company, Employee employee)
 {
 }