private static void ApplyCEOLoyalty(GameEntity company, TeamInfo team, GameContext gameContext,
                                            ref Bonus <int> bonus, GameEntity worker, WorkerRole role)
        {
            bool hasCeo = HasMainManagerInTeam(company.team.Teams[0]);

            bonus.AppendAndHideIfZero("No CEO", hasCeo ? 0 : -4);

            var manager = GetMainManagerRole(team);
            var lead    = GetWorkerByRole(manager, team, gameContext);

            if (lead == null)
            {
                bonus.Append($"No {Humans.GetFormattedRole(manager)} in team", -4);
            }
            else
            {
                var CEORating    = Humans.GetRating(lead);
                var workerRating = Humans.GetRating(worker);

                if (CEORating < workerRating)
                {
                    bonus.Append($"Incompetent leader (leader rating less than {workerRating})", -1);
                }
            }
        }
        public static void ApplyProductEconomyToProfitBonus(GameEntity c, GameContext context, Bonus <long> bonus)
        {
            if (!c.hasProduct)
            {
                return;
            }

            // ** income **
            // * base income
            // * investments

            // ** expenses **
            // * teams
            // * managers
            // * marketing
            // * servers

            // income
            bonus.Append("Product income", GetProductIncome(c));

            // expenses
            var maintenance = GetProductCompanyMaintenance(c, true);

            foreach (var m in maintenance.bonusDescriptions)
            {
                if (m.HideIfZero)
                {
                    bonus.AppendAndHideIfZero(m.Name, -m.Value);
                }
                else
                {
                    bonus.Append(m.Name, -m.Value);
                }
            }
        }
Esempio n. 3
0
        public static Bonus <float> ApplyChurnRateFromFeatures(Bonus <float> baseRate, GameContext gameContext, GameEntity c)
        {
            var reqs = Markets.GetMarketRequirementsForCompany(gameContext, c);

            var requirements = reqs.Features;
            var features     = Products.GetAllFeaturesForProduct();

            for (var i = 0; i < requirements.Count; i++)
            {
                var f = features[i];

                var featureName = f.Name;
                var rating      = Products.GetFeatureRating(c, featureName);

                var marketRequirements = reqs; // Markets.GetMarketRequirementsForCompany(gameContext, c);

                var currentBestRating = marketRequirements.Features[i];
                if (rating == 0 && currentBestRating > 0 && f.IsRetentionFeature)
                {
                    //baseRate.Append("Lacks feature " + featureName, 1);
                    continue;
                }

                if (f.IsRetentionFeature)
                {
                    var diff = marketRequirements.Features[i] - rating;

                    bool best = diff == 0;
                    if (!best)
                    {
                        baseRate.AppendAndHideIfZero(featureName + " outdated (-" + (int)diff + ")", (int)diff * 1f);
                    }
                    else
                    {
                        baseRate.AppendAndHideIfZero("Best in " + featureName, -6);
                    }
                }

                if (f.IsMonetizationFeature && Products.IsUpgradedFeature(c, featureName))
                {
                    baseRate.AppendAndHideIfZero("MONETISATION: " + featureName, 5);
                }
            }

            return(baseRate);
        }
        public static Bonus <int> GetLoyaltyChangeBonus(HumanFF worker, TeamInfo team,
                                                        Dictionary <CorporatePolicy, int> culture, GameEntity company)
        {
            var bonus = new Bonus <int>("Loyalty");

            bonus.Append("Base value", 1);

            var loyaltyBuff = team.ManagerTasks.Count(t => t == ManagerTask.ImproveAtmosphere);

            bonus.AppendAndHideIfZero("Manager focus on atmosphere", loyaltyBuff);

            var role = worker.WorkerComponent.WorkerRole;

            // TODO: if is CEO in own project, morale loss is zero or very low
            bonus.AppendAndHideIfZero("IS FOUNDER", worker.WorkerComponent.WorkerRole == WorkerRole.CEO ? 5 : 0);

            // same role workers
            //ApplyDuplicateWorkersLoyalty(company, team, gameContext, ref bonus, worker, role);

            // salary
            ApplyLowSalaryLoyalty(company, ref bonus, worker);

            // incompetent leader
            //ApplyCEOLoyalty(company, team, gameContext, ref bonus, worker, role);

            // no possibilities to grow
            var rating = Humans.GetRating(worker);
            var max    = 70;

            if (role != WorkerRole.CEO)
            {
                bonus.AppendAndHideIfZero($"Outgrown company (skill >= {max})", rating >= max ? -3 : 0);
            }

            bonus.AppendAndHideIfZero("Too many leaders", Humans.HasTrait(worker, Trait.Leader) && team.TooManyLeaders ? -2 : 0);

            if (team.isManagedBadly)
            {
                bonus.Append("Terrible management", -3);
            }

            // bonus.AppendAndHideIfZero(hu)
            return(bonus);
        }
        private static void ApplyDuplicateWorkersLoyalty(GameEntity company, TeamInfo team, GameContext gameContext,
                                                         ref Bonus <int> bonus, GameEntity worker, WorkerRole role)
        {
            var  roles = team.Managers.Select(h => h.WorkerComponent.WorkerRole);
            bool hasDuplicateWorkers = roles.Count(r => r == role) > 1;

            if (hasDuplicateWorkers)
            {
                bonus.AppendAndHideIfZero("Too many " + Humans.GetFormattedRole(role) + "'s", -10);
            }
        }
Esempio n. 6
0
        public static long GetBaseDesireToSellShares(GameContext gameContext, GameEntity company, int shareholderId, InvestorType investorType)
        {
            bool isProduct = company.hasProduct;

            var bonusContainer = new Bonus <long>("Desire to sell");

            bonusContainer.Append("Base", -1);

            bonusContainer.AppendAndHideIfZero("Is young company", IsYoungCompany(company) ? -10 : 0);

            if (isProduct)
            {
                bonusContainer.AppendAndHideIfZero("By investor type", GetDesireToSellStartupByInvestorType(company, investorType, shareholderId, gameContext));
            }
            else
            {
                bonusContainer.AppendAndHideIfZero("By investor type", GetDesireToSellGroupByInvestorType(company, investorType, shareholderId, gameContext));
            }

            return((long)bonusContainer.Sum());
        }
Esempio n. 7
0
        // TODO <float>
        public static Bonus <long> GetInvestorOpinionBonus(GameContext gameContext, GameEntity company, GameEntity investor)
        {
            var description = new Bonus <long>("Investor opinion");

            if (IsInvestsInCompany(investor, company))
            {
                description.AppendAndHideIfZero("Invests already", 35);
            }

            description.Append("Same goals", 25);

            return(description);
        }
Esempio n. 8
0
        public static Bonus <long> GetAudienceGrowthBonus(GameEntity product)
        {
            var bonus = new Bonus <long>("Audience Growth");

            foreach (var channelId in product.companyMarketingActivities.Channels.Keys)
            {
                var gain = GetChannelClientGain(product, channelId);

                bonus.AppendAndHideIfZero("Channel " + channelId, gain);
            }

            return(bonus);
        }
Esempio n. 9
0
        public static Bonus <float> GetFeatureRatingCap(GameEntity product, TeamInfo team, GameContext gameContext)
        {
            var productManager = Teams.GetWorkerInRole(team, WorkerRole.ProductManager, gameContext);

            var bonus = new Bonus <float>("Max feature lvl");

            bonus.Append("Base", 3f);
            bonus.AppendAndHideIfZero("Development Team", team.TeamType == TeamType.DevelopmentTeam ? 1f : 0);

            if (productManager != null)
            {
                // ... 5f
                var addedCap = 6 * Humans.GetRating(productManager) / 100f;

                bonus.AppendAndHideIfZero("Product Manager", addedCap);
            }

            // var culture = Companies.GetOwnCulture(Companies.GetManagingCompanyOf(product, gameContext));
            //
            // var cultureBonus = (10 - culture[CorporatePolicy.DoOrDelegate]) * 0.2f;
            // var cultureBonus2 = (culture[CorporatePolicy.DecisionsManagerOrTeam]) * 0.4f;
            //
            // bonus.Append("Corporate culture Do or Delegate", cultureBonus);
            // bonus.Append("Corporate culture Structure", cultureBonus2);


            //bool hasMainManager = Teams.HasMainManagerInTeam(team, gameContext, product);
            //if (hasMainManager)
            //{
            //    var focus = team.ManagerTasks.Count(t => t == ManagerTask.Polishing);
            //    cap += focus * 0.4f;
            //}

            bonus.Cap(0, 10);

            return(bonus);

            //return Mathf.Clamp(cap, 0, 10);
        }
Esempio n. 10
0
    Bonus <long> GetProfitDescriptionFull()
    {
        var bonus = new Bonus <long>("Balance change")
                    .Append("Income", Economy.GetIncome(Q, company));

        var prodMnt = Economy.GetProductCompanyMaintenance(company, true);

        foreach (var p in prodMnt.bonusDescriptions)
        {
            bonus.AppendAndHideIfZero(p.Name, -p.Value);
        }

        return(bonus);
    }
        public static void ApplyInvestmentsToProfitBonus(GameEntity c, GameContext context, Bonus <long> bonus)
        {
            //var investmentTaker = c.isFlagship ? Companies.GetManagingCompanyOf(c, context) : c;
            var investmentTaker = c;

            var date = ScheduleUtils.GetCurrentDate(context);

            if (investmentTaker.shareholders.Shareholders.Count > 1)
            {
                var investments = investmentTaker.shareholders.Shareholders.Values
                                  .Select(v => v.Investments.Where(z => WillPayInvestmentRightNow(z, date)).Select(z => z.Portion).Sum())
                                  .Sum();

                bonus.AppendAndHideIfZero("Investments", investments);
            }
        }
        // resulting costs
        public static Bonus <long> GetProductCompanyMaintenance(GameEntity e, bool isBonus)
        {
            var bonus = new Bonus <long>("Maintenance")
                        .Append("Team", GetManagersCost(e))
            ;

            // team tasks
            foreach (var t in e.team.Teams[0].Tasks)
            {
                if (!t.IsPending)
                {
                    bonus.AppendAndHideIfZero(t.GetPrettyName(), GetTeamTaskCost(e, t));
                }
            }

            return(bonus);
        }
        public static void ApplyGroupInvestmentsToProfitBonus(GameEntity c, GameContext context, Bonus <long> bonus)
        {
            if (!Companies.IsGroup(c))
            {
                return;
            }

            var holdings = Investments.GetHoldings(c, context, true);

            bool isOnlyHolding = holdings.Count == 1;

            foreach (var h in holdings)
            {
                var b = GetProfit(context, h.company, true);

                if (isOnlyHolding)
                {
                    // render full description
                    foreach (var d in b.bonusDescriptions)
                    {
                        if (d.HideIfZero)
                        {
                            bonus.AppendAndHideIfZero(d.Name, d.Value);
                        }
                        else
                        {
                            bonus.Append(d.Name, d.Value);
                        }
                    }
                }
                else
                {
                    // general info is enough
                    bonus.Append(h.company.company.Name, b.Sum());
                }
            }
        }
        public static Bonus <float> GetOpinionAboutOffer(HumanFF worker, ExpiringJobOffer newOffer)
        {
            bool willNeedToLeaveCompany = worker.WorkerComponent.companyId != newOffer.CompanyId;

            var bonus = new Bonus <float>("Opinion about offer");

            // scenarios
            // 1 - unemployed
            // 2 - employed, same company
            // 3 - employed, recruiting
            // 4 - !founder

            if (!Humans.IsEmployed(worker))
            {
                return(bonus.Append("Salary", newOffer.JobOffer.Salary > GetSalaryPerRating(worker) ? 1 : -1));
            }

            int loyaltyBonus         = (worker.HumanCompanyRelationshipComponent.Morale - 50) / 10;
            int desireToLeaveCompany = 0;

            if (willNeedToLeaveCompany)
            {
                // it's not easy to recruit worker from other company
                desireToLeaveCompany -= 5;

                // and if your worker loves stability...
                if (Humans.HasTrait(worker, Trait.Loyal))
                {
                    desireToLeaveCompany -= 5;
                }

                // but if your worker loves new challenges...
                if (Humans.HasTrait(worker, Trait.NewChallenges))
                {
                    desireToLeaveCompany += 10;
                }

                if (desireToLeaveCompany > 0)
                {
                    bonus.AppendAndHideIfZero("Wants to leave company", desireToLeaveCompany);
                }
                else
                {
                    bonus.AppendAndHideIfZero("Wants to stay in company", desireToLeaveCompany);
                }

                bonus.Append("Loyalty to company", -loyaltyBonus);
            }
            else
            {
                // prolongation of contract
                bonus.Append("Loyalty to company", loyaltyBonus);
            }

            long newSalary = newOffer.JobOffer.Salary;

            long salary;

            salary = (long)Mathf.Max(Humans.GetCurrentOffer(worker).JobOffer.Salary, 1);

            float salaryRatio;

            salaryRatio = (newSalary - salary) * 1f / salary;
            salaryRatio = Mathf.Clamp(salaryRatio, -5, 5);

            bonus.Append("Salary", salaryRatio);


            return(bonus);
        }