Esempio n. 1
0
        private static long GiveInnovationBenefits(GameEntity product, GameContext gameContext, bool revolution)
        {
            long sum = 0;

            if (revolution)
            {
                // get your competitor's clients
                var innovatorCompetitors = Markets.GetProductsOnMarket(gameContext, product)
                                           .Where(p => p.isRelease)
                                           .Where(p => p.company.Id != product.company.Id);


                foreach (var p in innovatorCompetitors)
                {
                    var disloyal = Marketing.GetUsers(p) / 15;

                    //Marketing.LoseClients(p, disloyal);
                    //Marketing.AddClients(product, disloyal);

                    sum += disloyal;
                }
            }

            return(sum);
        }
Esempio n. 2
0
        public static GameEntity[] GetDumpingCompetitors(GameContext gameContext, GameEntity niche, GameEntity product)
        {
            var competitors = Markets.GetProductsOnMarket(niche, gameContext);

            var dumpingCompetitors = competitors.Where(p => p.isDumping && p.company.Id != product.company.Id);

            return(dumpingCompetitors.ToArray());
        }
Esempio n. 3
0
        public static float GetSumOfBrandPowers(GameEntity niche, GameContext gameContext)
        {
            var products = Markets.GetProductsOnMarket(niche, gameContext);

            var sumOfBrandPowers = products.Sum(p => p.branding.BrandPower);

            return(sumOfBrandPowers);
        }
Esempio n. 4
0
        private static void RemoveTechLeaders(GameEntity product, GameContext gameContext)
        {
            var players = Markets.GetProductsOnMarket(gameContext, product).ToArray();

            foreach (var p in players)
            {
                p.isTechnologyLeader = false;
            }
        }
        // changes
        public static ProductCompanyResult GetProductCompanyResults(GameEntity product, GameContext gameContext)
        {
            var competitors = Markets.GetProductsOnMarket(gameContext, product);

            long previousMarketSize = 0;
            long currentMarketSize  = 0;

            long prevCompanyClients = 0;
            long currCompanyClients = 0;

            foreach (var c in competitors)
            {
                var last = c.metricsHistory.Metrics.Count - 1;
                var prev = c.metricsHistory.Metrics.Count - 2;

                // company was formed this month
                if (prev < 0)
                {
                    continue;
                }

                var audience = c.metricsHistory.Metrics[prev].AudienceSize;
                var clients  = c.metricsHistory.Metrics[last].AudienceSize;

                previousMarketSize += audience;
                currentMarketSize  += clients;

                if (c.company.Id == product.company.Id)
                {
                    prevCompanyClients = audience;
                    currCompanyClients = clients;
                }
            }

            var prevShare = prevCompanyClients * 100d / (previousMarketSize + 1);
            var Share     = currCompanyClients * 100d / (currentMarketSize + 1);

            return(new ProductCompanyResult
            {
                clientChange = currCompanyClients - prevCompanyClients,
                MarketShareChange = (float)(Share - prevShare),
                ConceptStatus = Products.GetConceptStatus(product, gameContext),
                CompanyId = product.company.Id
            });
        }
Esempio n. 6
0
        internal static IEnumerable <GameEntity> GetCompetitorsOfCompany(GameEntity company, GameContext gameContext)
        {
            IEnumerable <GameEntity> companies;

            if (company.hasProduct)
            {
                companies = Markets.GetProductsOnMarket(gameContext, company);
            }
            else if (IsFinancialStructure(company))
            {
                companies = new GameEntity[0].AsEnumerable();
            }
            else
            {
                companies = Markets.GetNonFinancialCompaniesWithSameInterests(gameContext, company);
            }

            return(companies.Where(p => p.company.Id != company.company.Id));
        }
Esempio n. 7
0
        public static void TryToSpawnCompany(GameEntity niche, GameContext gameContext, MarketState phase, bool inPlayerSphereOfInfluence)
        {
            var segments = GetNichePositionings(niche.niche.NicheType, gameContext);

            var  productsOnMarket = Markets.GetProductsOnMarket(niche, gameContext);
            bool willMakeSameProductWithPlayerFlagship = false;

            GameEntity playerFlagship = null;

            if (inPlayerSphereOfInfluence)
            {
                playerFlagship = Companies.GetPlayerFlagship(gameContext);

                if (niche.niche.NicheType == playerFlagship.product.Niche)
                {
                    willMakeSameProductWithPlayerFlagship = true;
                }
            }

            float intensity = 1f / (1 + segments.Count);

            if (inPlayerSphereOfInfluence)
            {
                intensity = 1f;
            }

            foreach (var s in segments)
            {
                var productsCount = productsOnMarket.Count(p => p.productPositioning.Positioning == s.ID);

                bool willCompeteDirectly = false;

                // increase chances if player has companeis in that segment
                if (inPlayerSphereOfInfluence)
                {
                    if (willMakeSameProductWithPlayerFlagship && Companies.IsDirectCompetitor(playerFlagship, niche, s.ID))
                    {
                        willCompeteDirectly = true;
                    }
                }

                var spawnChance = 0f;


                if (productsCount == 0)
                {
                    spawnChance = 20;
                }
                else if (productsCount == 1)
                {
                    spawnChance = 10;
                }
                else if (productsCount == 2)
                {
                    spawnChance = 5;
                }
                else
                {
                    spawnChance = 1;
                }

                if (willCompeteDirectly)
                {
                    spawnChance *= 10;
                }

                spawnChance *= intensity;

                // take into account competition strength too
                // Noone wants to make a browser, cause Google exists already

                if (Random.Range(0f, 100f) < spawnChance)
                {
                    var leaderFunds = Random.Range(50_000, 300_000);

                    var product = SpawnCompany(niche, gameContext, leaderFunds);
                    Marketing.ChangePositioning(product, gameContext, s.ID, true);

                    // NotificationUtils.SendNewCompetitorPopup(gameContext, niche, product);
                }
            }
        }