public static int GetBaseAudienceId(GameEntity product)
        {
            var infos       = Marketing.GetAudienceInfos();
            var maxAudience = infos.Count;

            return(Mathf.Clamp(product.productPositioning.Positioning, 0, maxAudience - 1));
        }
        public static void TurnProductToPlayerFlagship(GameEntity company, GameContext Q, NicheType nicheType, GameEntity parentCompany)
        {
            company.isFlagship = true;
            AttachToPlayer(company);
            company.AddChannelExploration(new Dictionary <int, int>(), new List <int>(), 1);

            // give bad positioning initially
            var infos = Marketing.GetAudienceInfos();

            Marketing.AddClients(company, -50);

            var positionings      = Markets.GetNichePositionings(nicheType, Q);
            var positioningWorths = positionings.OrderBy(Markets.GetPositioningValue);

            // TODO POSITIONING
            var rand           = Random.Range(0, 2);
            var newPositioning = rand < 1 ? 0 : 3; //  positioningWorths.ToArray()[rand].ID;

            // 0 - teens, 3 - old people

            Marketing.ChangePositioning(company, Q, newPositioning);

            Marketing.AddClients(company, 50);

            // give good salary to CEO, so he will not leave company
            var CEO        = Humans.Get(Q, GetCEOId(company));
            var GroupCeoID = GetCEOId(parentCompany);

            CEO.AddPseudoHuman(GroupCeoID);

            // var salary = Teams.GetSalaryPerRating(CEO);
            // Teams.SetJobOffer(CEO, company, new JobOffer(salary), 0, Q);
        }
        public static GameEntity SetMarkets(NicheType nicheType,
                                            int startDate,
                                            int duration,
                                            GameContext gameContext,
                                            MarketProfile settings
                                            )
        {
            var nicheId = GetNicheId(nicheType);

            var clients = GetFullAudience(settings, nicheId);

            var techCost = GetTechCost(settings, nicheId);
            var adCosts  = GetAdCost(settings, nicheId);
            var price    = GetProductPrice(settings, adCosts, nicheId);


            var n = SetNicheCosts(nicheType, price, clients, techCost, adCosts, gameContext);

            Marketing.GetAudienceInfos();

            var positionings = GetStandardPositionings(nicheType);

            var clientsContainer = new Dictionary <int, long>
            {
                [0] = clients
            };

            n.ReplaceNicheSegments(positionings);
            n.ReplaceNicheClientsContainer(clientsContainer);
            n.ReplaceNicheLifecycle(GetYear(startDate), n.nicheLifecycle.Growth, GetYear(duration));
            n.ReplaceNicheBaseProfile(settings);

            return(n);
        }
        public static GameEntity CreateNicheMockup(NicheType niche, GameContext GameContext)
        {
            var e = GameContext.CreateEntity();

            e.AddNiche(
                niche,
                IndustryType.Communications,
                new List <MarketCompatibility>(),
                new List <NicheType>(),
                NicheType.Com_SocialNetwork
                );

            // TODO duplicate in Iteration.cs
            GetMarketRequirements(GameContext, e);


            e.AddNicheCosts(1, 1, 1, 1);
            e.AddNicheBaseProfile(new MarketProfile {
                AppComplexity    = AppComplexity.Average,
                AudienceSize     = AudienceSize.Million,
                NicheSpeed       = NicheSpeed.Year,
                Margin           = Margin.Mid,
                MonetisationType = Monetisation.Service
            });

            var clientGrowthDictionary = new Dictionary <MarketState, int>
            {
                [MarketState.Idle]       = 0,                                // 0
                [MarketState.Innovation] = UnityEngine.Random.Range(1, 3),   // 2-5            Xt
                [MarketState.Trending]   = UnityEngine.Random.Range(3, 10),  // 4 - 10           5Xt
                [MarketState.MassGrowth] = UnityEngine.Random.Range(10, 15), // 7 - 15            10Xt
                [MarketState.Decay]      = UnityEngine.Random.Range(2, 5),   // 2 - 5 // churn      3Xt-22Xt
                [MarketState.Death]      = 0,                                // churn
            };

            e.AddNicheLifecycle(0, clientGrowthDictionary, 0);

            e.AddNicheState(MarketState.Idle, 0);
            UpdateNicheDuration(e);

            var audiences = Marketing.GetAudienceInfos();

            var positionings = audiences.Select(a => new ProductPositioning
            {
                ID            = 0,
                name          = "",
                marketShare   = 100,
                priceModifier = 1f,
                Loyalties     = audiences.Select(ad => UnityEngine.Random.Range(-10, 10)).ToList(),
                isCompetitive = false,
            })
                               .ToList();

            e.AddNicheClientsContainer(new Dictionary <int, long>());
            e.AddNicheSegments(positionings);
            e.AddSegment(0);

            return(e);
        }
        public static float GetMonetizationEfficiency(GameEntity c, int segmentId)
        {
            var audience = Marketing.GetAudienceInfos()[segmentId];

            var audienceBonus = audience.Bonuses.Where(b => b.isMonetisationFeature).Sum(b => b.Max);
            var improvements  = Products.GetMonetisationFeaturesBenefit(c) * (100 + audienceBonus) / 100f;

            return(Mathf.Clamp(improvements, 0, 500));
        }
        public static long GetClientBaseCost(GameEntity c)
        {
            var segments = Marketing.GetAudienceInfos();

            //segments.Sum(s => Economy.GetIncomePerSegment(c, s.ID) *

            return(0);
            //return Marketing.GetClients(c) * 100;
        }
        public static GameEntity CreateProduct(GameContext context, GameEntity product, NicheType nicheType)
        {
            product.AddProduct(nicheType, 0);

            var niche = Markets.Get(context, nicheType);

            // market state
            product.AddNicheState(Markets.GetMarketState(niche), 100);


            // product.AddNicheSegments(Markets.GetNichePositionings(nicheType, context));
            // product.AddNicheBaseProfile(Markets.Get(context, product).nicheBaseProfile.Profile);

            product.AddProductUpgrades(new Dictionary <ProductUpgrade, bool>
            {
                [ProductUpgrade.SimpleConcept] = true,
                [ProductUpgrade.PlatformWeb]   = true,
            });

            // positioning
            var audiences = Marketing.GetAudienceInfos();
            var coreId    = Random.Range(0, audiences.Count);

            product.AddProductPositioning(coreId);

            // development
            product.AddFeatures(new Dictionary <string, float>());
            product.AddSupportUpgrades(new Dictionary <string, int>());
            product.AddExpertise(Random.Range(1, 4));

            Markets.GetMarketRequirementsForCompany(context, product);



            // var serverFeature = Products.GetHighloadFeatures(product)[0];
            // Teams.AddTeamTask(product, ScheduleUtils.GetCurrentDate(context), context, 0, new TeamTaskSupportFeature(serverFeature));

            // clients
            product.AddMarketing(new Dictionary <int, long>());
            product.AddSourceOfClients(new Dictionary <int, long>());
            product.AddCompanyMarketingActivities(new Dictionary <int, long>());

            // Markets.CopyChannelInfosToProductCompany(product, context);

            Marketing.AddClients(product, 50);

            // sphere of interest
            AddFocusNiche(product, nicheType, context);
            AddFocusIndustry(Markets.GetIndustry(nicheType, context), product);

            WrapProductWithAdditionalData(product, context);



            return(product);
        }
        internal static void PrepareMarket(GameEntity niche, long startCapital, GameContext gameContext)
        {
            var segments = Marketing.GetAudienceInfos();

            // spawn competitors
            for (var i = 0; i < 5; i++)
            {
                var funds = Random.Range(20, 50) * startCapital;
                var c     = Markets.SpawnCompany(niche, gameContext, funds);

                var features = Products.GetAllFeaturesForProduct();
                var teams    = Random.Range(3, 9);

                for (var j = 0; j < teams; j++)
                {
                    Teams.AddTeam(c, gameContext, TeamType.CrossfunctionalTeam);
                }

                foreach (var f in features)
                {
                    if (f.FeatureBonus.isRetentionFeature)
                    {
                        Products.ForceUpgradeFeature(c, f.Name, Random.Range(2f, 5f), gameContext);
                    }
                }

                var clients = 50_000d * Mathf.Pow(10, Random.Range(0.87f, 2.9f)) * (i + 1);

                //var positioning = c.productPositioning.Positioning;
                foreach (var s in segments)
                {
                    if (s.ID == Marketing.GetCoreAudienceId(c))
                    {
                        var audience = System.Convert.ToInt64(clients * Random.Range(0.1f, 0.5f));
                        Marketing.AddClients(c, audience);
                    }
                }
            }

            // spawn investors
            for (var i = 0; i < C.AMOUNT_OF_INVESTORS_ON_STARTING_NICHE; i++)
            {
                var fund = Companies.GenerateInvestmentFund(gameContext, RandomUtils.GenerateInvestmentCompanyName(), 500000);
                Companies.AddFocusNiche(fund, niche.niche.NicheType, gameContext);
            }
        }
        public static long GetProductPotential(GameEntity company)
        {
            // judge by potential
            var segmentId = Marketing.GetCoreAudienceId(company);
            var segment   = Marketing.GetAudienceInfos()[segmentId];

            var income = GetBaseIncomeByMonetizationType(company);

            var incomeMultiplier = income * segment.Bonuses.Where(b => b.isMonetisationFeature).Select(b => b.Max).Sum();



            long baseCost = 1_000_000;

            return((long)((double)baseCost * (100f + incomeMultiplier) / 100f));

            var max                 = segment.Size;
            var possiblePortion     = 5;
            var potentialBaseIncome = income * (100f + incomeMultiplier) / 100f;

            return(GetCompanyIncomeBasedCost((long)(potentialBaseIncome * (double)max) * possiblePortion / 1000));
        }
Example #10
0
        public static long GetPositioningValue(ProductPositioning p)
        {
            var infos = Marketing.GetAudienceInfos();
            var worth = 0L;

            int segmentId = 0;

            foreach (var l in p.Loyalties)
            {
                if (l > 0)
                {
                    var segment       = infos[segmentId];
                    var incomePerUser = 1.5f; // Economy.GetIncomePerUser(gameContext, playerFlagship, segmentId)

                    var segmentWorth = (long)(segment.Size * incomePerUser);

                    worth += segmentWorth * (100 + l * 10) / 100;
                }

                segmentId++;
            }

            return(worth);
        }
        public static List <ProductPositioning> GetStandardPositionings(NicheType nicheType)
        {
            // Debug.Log("GetStandardPositionings");
            var audiences = Marketing.GetAudienceInfos();

            var nicheName = Enums.GetFormattedNicheName(nicheType);

            var list = new List <ProductPositioning>();

            var adore = 10;
            var hate  = -20;
            var mass  = 3;

            var like = 7;

            int Kids_ID   = 0;
            int Adults_ID = 1;
            int Family_ID = 2;
            int Old_ID    = 3;

            // focus each audience specifically
            foreach (var a in audiences)
            {
                var index = a.ID;

                var loyalties = audiences.Select(a1 => hate).ToList();

                loyalties[index] = adore;

                list.Add(new ProductPositioning
                {
                    ID = list.Count,

                    name          = nicheName + " for " + a.Name,
                    isCompetitive = false,
                    Loyalties     = loyalties,

                    marketShare   = 100,
                    priceModifier = 1f
                });
            }

            AddPositioning(ref list, "Cool " + nicheName, Kids_ID);
            AddPositioning(ref list, "Trendy " + nicheName, Adults_ID, Kids_ID);
            AddPositioning(ref list, "Corporate " + nicheName, Adults_ID, Family_ID);

            // // focus multiple audiences
            // var randomPositionings = Random.Range(6, 10);
            //
            // //var goodness = Random.Range(hate, adore);
            // for (var i = 0; i < randomPositionings; i++)
            // {
            //     int points = audiences.Count * mass;
            //
            //     List<int> loyalties = new List<int> { };
            //
            //     foreach (var s in audiences)
            //     {
            //         var value = Random.Range(-1, like);
            //
            //         var l = Mathf.Clamp(value, hate, Mathf.Min(points, like));
            //
            //         if (l >= 0)
            //             points -= l;
            //         else
            //             l = hate;
            //
            //         loyalties.Add(l);
            //     }
            //
            //     list.Add(new ProductPositioning
            //     {
            //         ID = list.Count,
            //         name = "RANDOM " + nicheName + " " + i,
            //         Loyalties = loyalties.ToList(),
            //         //Loyalties = audiences.Select(a1 => Random.Range(-10, 4)).ToList(),
            //
            //         isCompetitive = false,
            //         marketShare = 100,
            //         priceModifier = 1f,
            //     });
            // }
            //
            // var maxPositioning = list.Count;
            //
            // // remove positionings for noone
            // list.RemoveAll(p => p.Loyalties.All(l => l < 0));
            //
            // // better than global positioning?
            // list.RemoveAll(p => p.Loyalties.All(l => l >= mass));
            //
            // // better than strictly focused positioning
            // list.RemoveAll(p => p.Loyalties.Count(l => l >= adore) >= 2);
            //
            //
            // take ALL
            list.Add(new ProductPositioning
            {
                ID        = list.Count,
                name      = nicheName + " for EVERYONE",
                Loyalties = audiences.Select(a => mass).ToList(),

                isCompetitive = false,
                marketShare   = 100,
                priceModifier = 1f,
            });

            // foreach (ProductPositioning positioning in list)
            // {
            //     Debug.Log($"Added positioning in niche {nicheName}: " + positioning.name + " #" + positioning.ID);
            // }

            // Debug.Log($"Created {list.Count} positionings");

            return(list);
        }