コード例 #1
0
        public static GameEntity CreateAcquisitionOffer(GameContext gameContext, GameEntity company, GameEntity buyer)
        {
            var offer = gameContext.CreateEntity();

            var cost = Economy.CostOf(company, gameContext);

            var buyerOffer = new AcquisitionConditions
            {
                Price           = cost,
                ByCash          = cost,
                ByShares        = 0,
                KeepLeaderAsCEO = true
            };

            var sellerOffer = new AcquisitionConditions
            {
                Price           = cost * 4,
                ByCash          = cost * 4,
                ByShares        = 0,
                KeepLeaderAsCEO = true
            };

            offer.AddAcquisitionOffer(company.company.Id, buyer.shareholder.Id, AcquisitionTurn.Buyer, buyerOffer, sellerOffer);

            if (buyer.isControlledByPlayer)
            {
                Debug.Log("Create acquisition offer: " + GetName(company));
            }

            return(offer);
        }
コード例 #2
0
        public static long GetSharesCost(GameContext context, GameEntity c, GameEntity investor, int shares = -1)
        {
            if (shares == -1)
            {
                shares = GetAmountOfShares(context, c, investor);
            }

            int total = GetTotalShares(c);

            return(Economy.CostOf(c, context) * shares / total);
        }
コード例 #3
0
        public static List <GameEntity> GetSortedCompetitors(GameEntity company, GameContext gameContext, ref int index, bool directCompetitors)
        {
            // first - Strong
            // last - Weak

            var competitors = (directCompetitors ? GetDirectCompetitors(company, gameContext, true) : GetCompetitorsOf(company, gameContext, true))
                              .OrderByDescending(c => Economy.CostOf(c, gameContext))
                              .ToList();

            index = competitors.FindIndex(c => c.company.Id == company.company.Id);

            return(competitors);
        }
コード例 #4
0
        public static List <InvestmentGoal> GetCommonGoals(GameEntity company, GameContext Q)
        {
            var goals = new List <InvestmentGoal>();

            #region data
            bool releasedProduct = company.hasProduct && company.isRelease;

            bool isGroup = !company.hasProduct;

            var  income     = Economy.GetIncome(Q, company);
            bool profitable = Economy.IsProfitable(Q, company);

            bool solidCompany = (releasedProduct || isGroup) && income > 100_000;

            // weaker
            GameEntity weakerCompany = Companies.GetWeakerCompetitor(company, Q, true); // null;

            // stronger
            GameEntity strongerCompany = Companies.GetStrongerCompetitor(company, Q, true); // null;

            #endregion

            if (solidCompany)
            {
                goals.Add(new InvestmentGoalGrowCost(Economy.CostOf(company, Q) * 3 / 2));
                goals.Add(new InvestmentGoalGrowProfit(Economy.GetIncome(Q, company) * 3 / 2));

                //goals.Add(InvestorGoalType.GrowCompanyCost);
                //goals.Add(InvestorGoalType.GrowIncome);

                if (!profitable)
                {
                    goals.Add(new InvestmentGoalBecomeProfitable(Economy.GetIncome(Q, company)));
                    //goals.Add(InvestorGoalType.BecomeProfitable);
                }

                if (strongerCompany != null)
                {
                    goals.Add(new InvestmentGoalOutcompeteByIncome(strongerCompany.company.Id, strongerCompany.company.Name));
                    //goals.Add(new InvestmentGoalOutcompeteByCost(strongerCompany.company.Id, strongerCompany.company.Name));


                    //goals.Add(InvestorGoalType.OutcompeteCompanyByIncome);
                    //goals.Add(InvestorGoalType.OutcompeteCompanyByCost);
                    ////goals.Add(InvestorGoalType.OutcompeteCompanyByUsers);
                }
            }

            return(goals);
        }
コード例 #5
0
        public static long GetMarketSize(GameContext gameContext, NicheType nicheType)
        {
            var products = GetProductsOnMarket(gameContext, nicheType);

            try
            {
                return(products
                       .Sum(p => Economy.CostOf(p, gameContext)));
            }
            catch
            {
                Debug.LogWarning("Get market size of " + Enums.GetFormattedNicheName(nicheType));
            }

            return(0);

            //return products.Select(p => CompanyEconomyUtils.GetProductCompanyBaseCost(gameContext, p.company.Id)).Sum();
        }
コード例 #6
0
        public static void SpawnProposals(GameContext context, GameEntity company)
        {
            long cost = Economy.CostOf(company, context);
            var  date = ScheduleUtils.GetCurrentDate(context);

            var potentialInvestors = GetPotentialInvestors(context, company);

            foreach (var potentialInvestor in potentialInvestors)
            {
                var modifier = 50 + UnityEngine.Random.Range(0, 100);

                long valuation = cost * modifier / 100;

                var max = GetMaxInvestingAmountForInvestorType(potentialInvestor);

                var ShareholderId = potentialInvestor.shareholder.Id;
                var Duration      = 10; // UnityEngine.Random.Range(5, 10);

                // TODO increase offer on early stages
                // or increase company valuation instead!
                var offer = Math.Min(valuation / 20, max);

                //var goal = new InvestmentGoalUnknown(InvestorGoalType.GrowCompanyCost);
                var goal = company.companyGoal.Goals[0];


                var p = new InvestmentProposal
                {
                    Investment       = new Investment(offer, Duration, goal, date),
                    AdditionalShares = (int)GetNewSharesSize(context, company, offer),

                    ShareholderId = ShareholderId,
                    WasAccepted   = false
                };

                // you cannot invest in yourself!
                if (company.hasShareholder && company.shareholder.Id == ShareholderId)
                {
                    continue;
                }

                AddInvestmentProposal(company, p);
            }
        }
コード例 #7
0
        public static List <InvestmentGoal> GetGroupOnlyGoals(GameEntity company, GameContext Q)
        {
            var goals = new List <InvestmentGoal>();

            var groupGoals = new List <InvestorGoalType>
            {
                InvestorGoalType.AcquireCompany,
                InvestorGoalType.DominateSegment, // 50%+ users
                InvestorGoalType.DominateMarket,  // OWN ALL COMPANIES
                InvestorGoalType.BuyBack,
                InvestorGoalType.IPO,
            };

            #region data
            var income = Economy.GetIncome(Q, company);

            bool solidCompany = income > 50_000;


            GameEntity weakerCompany; // null;
            #endregion

            var daughters = Companies.GetDaughterProducts(Q, company);

            if (solidCompany)
            {
                if (daughters.Any())
                {
                    var flagship            = daughters.First();
                    var flagshipCompetitors = Companies.GetDirectCompetitors(flagship, Q, false);

                    if (flagshipCompetitors.Any())
                    {
                        weakerCompany = flagshipCompetitors.OrderByDescending(c => Economy.CostOf(c, Q)).Last();
                    }
                    else
                    {
                        weakerCompany = Companies.GetWeakerCompetitor(company, Q, true);
                    }

                    // if there are weaker companies
                    if (weakerCompany != null)
                    {
                        var acquisitionGoal = new InvestmentGoalAcquireCompany(weakerCompany.company.Id, weakerCompany.company.Name);

                        if (!CanCompleteGoal(company, Q, acquisitionGoal))
                        {
                            goals.Add(acquisitionGoal);
                        }
                    }
                }
            }


            #region DominateSegment
            //if (solidCompany && company.companyFocus.Niches.Count == 1)
            //{
            //    var first = daughters.First();

            //    var positioning = Marketing.GetPositioning(first);

            //    if (Companies.GetMarketShareOfCompanyMultipliedByHundred(company, Q) < 2)
            //    goals.Add(InvestorGoalType.DominateSegment);

            //}
            #endregion

            if (solidCompany && daughters.Length > 2)
            {
                AddOnce(goals, company, new InvestmentGoalDominateMarket(company.companyFocus.Niches.First()));
            }

            if (Completed(company, InvestorGoalType.DominateMarket))
            {
                return(OnlyGoal(new InvestmentGoalBuyBack()));
            }

            return(goals);
        }