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 long GetMarketingFinancingCostMultiplier(GameEntity product, GameContext gameContext, int financing) { var clientCost = Markets.GetClientAcquisitionCost(product.product.Niche, gameContext); var flow = Marketing.GetClientFlow(gameContext, product.product.Niche); // not released // needs to depend on own size if (financing == 0) { return((long)(clientCost * flow / 10)); } // released if (financing == 1) { return((long)(clientCost * flow)); } // capturing market var audience = Markets.GetAudienceSize(gameContext, product.product.Niche); return((long)(clientCost * audience)); //var marketing = MarketingUtils.GetAudienceReachModifierBasedOnMarketingFinancing(financing); //return Mathf.Pow(marketing, 1.78f); }
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 void InitializeTeamTaskIfNotPending(GameEntity product, int date, GameContext gameContext, TeamTask task) { if (task.IsPending) return; task.StartDate = date; if (task.IsMarketingTask) { var channelId = (task as TeamTaskChannelActivity).ChannelId; var channel = Markets.GetMarketingChannel(gameContext, channelId); if (!Marketing.IsActiveInChannel(product, channelId)) { var cost = Marketing.GetChannelCost(product, channelId); var payer = Companies.GetPayer(product, gameContext); if (Companies.Pay(payer, cost, "Marketing " + channel)) { Marketing.EnableChannelActivity(product, channel); var gain = Marketing.GetChannelClientGain(product, channelId); Marketing.AddClients(product, gain); var duration = Marketing.GetCampaignDuration(product, gain); task.EndDate = date + duration; } } } }
public static int GetBaseAudienceId(GameEntity product) { var infos = Marketing.GetAudienceInfos(); var maxAudience = infos.Count; return(Mathf.Clamp(product.productPositioning.Positioning, 0, maxAudience - 1)); }
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); }
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 IEnumerable <ChannelInfo> GetTheoreticallyPossibleMarketingChannels(GameEntity product) { return (GetAllMarketingChannels(product) .Where(channel => !Marketing.IsActiveInChannel(product, channel.ID)) .Where(c => !product.team.Teams[0].Tasks.Any(t => t.IsPending && t.AreSameTasks(new TeamTaskChannelActivity(c.ID, 0)))) ); }
public static int GetNecessaryAmountOfMarketers(GameEntity e, GameContext gameContext) { var clients = Marketing.GetClients(e); var support = (int)Mathf.Pow(clients / 1000, 0.5f); return(Mathf.Clamp(support, 0, 1000)); }
public static long GetIncomePerSegment(GameEntity company) { int segmentId = 0; var clients = Marketing.GetUsers(company); var incomePerUser = GetIncomePerUser(company, segmentId); return(Convert.ToInt64(clients * incomePerUser)); }
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); }
public static long GetClientLoad(GameEntity product) { long attack = 0; if (product.hasServerAttack) { attack = product.serverAttack.Load; } return(Marketing.GetUsers(product) + attack); // add DDoS multiplier ?? }
public static Func <ChannelInfo, bool> IsCanAffordChannel(GameEntity company, long spareBudget) => c => { var adCost = Marketing.GetChannelCost(company, c.ID); if (adCost == 0) { return(true); } return(spareBudget > adCost); };
public static Func <ChannelInfo, bool> IsCanMaintainChannel(GameEntity company, long spareBudget) => c => { var adCost = Marketing.GetChannelCost(company, c.ID); if (adCost == 0) { return(true); } return(spareBudget > adCost || Marketing.IsActiveInChannel(company, c.ID)); };
internal static float GetIncomeBySegment(GameContext gameContext, GameEntity c, int segmentId) { if (c.isDumping) { return(0); } float unitIncome = GetUnitIncome(gameContext, c, segmentId); long clients = Marketing.GetClients(c); return(clients * unitIncome); }
public static IEnumerable <ChannelInfo> GetMaintainableMarketingChannels(GameEntity product, GameContext gameContext) { var payer = product.isFlagship ? Companies.GetPlayerCompany(gameContext) : product; int periods = product.isFlagship ? 10 * 4 : 1; var profit = Economy.GetProfit(gameContext, payer); var spareBudget = profit; var channels = new List <ChannelInfo>(); var allChannels = GetAllMarketingChannels(product).OrderBy(c => Marketing.GetChannelCost(product, c.ID)).ToList(); var spareBudget2 = Economy.BalanceOf(payer); // spareBudget + if (profit < 0) { spareBudget2 += profit; } for (var i = 0; i < allChannels.Count(); i++) { var c = allChannels[i]; var adCost = Marketing.GetChannelCost(product, c.ID); if (Marketing.IsActiveInChannel(product, c.ID) || adCost == 0) { channels.Add(c); continue; } // 5, cause some channels take too much time to recover if (adCost > spareBudget2) { if (product.isFlagship) { //Debug.Log("not enough money for " + c.ID + " " + Format.Money(adCost * 3) + " spare=" + Format.Money(spareBudget2)); } break; } channels.Add(c); spareBudget2 -= adCost; } return(channels); return(allChannels .Where(IsCanMaintainChannel(product, spareBudget)) ); }
private static List <GoalRequirements> GetInvestmentGoalMillionUsersReqs(InvestmentGoal goal, GameEntity company, GameContext gameContext) { var g = goal as InvestmentGoalMillionUsers; GameEntity product = GetProduct(goal, company, gameContext); return(new List <GoalRequirements> { new GoalRequirements { have = Marketing.GetUsers(product), need = 1_000_000, description = "Users > " + Format.Minify(g.TargetUsersAmount) } });
public static void UpdateMarketRequirements(GameEntity product, GameContext gameContext) { var niche = Markets.Get(gameContext, product.product.Niche); var demand = Products.GetMarketDemand(niche); var newLevel = Products.GetProductLevel(product); if (newLevel > demand) { bool revolution = newLevel - demand > 1; // innovation //var clientChange = GiveInnovationBenefits(product, gameContext, revolution); var brandGain = revolution ? C.REVOLUTION_BRAND_POWER_GAIN : C.INNOVATION_BRAND_POWER_GAIN; Marketing.AddBrandPower(product, brandGain); // notify about innovation var player = Companies.GetPlayerCompany(gameContext); var daughters = Companies.GetDaughtersAmount(player); //if (Companies.IsInPlayerSphereOfInterest(product, gameContext) && Markets.GetCompetitorsAmount(product, gameContext) > 1 && daughters == 1) // NotificationUtils.AddPopup(gameContext, new PopupMessageInnovation(product.company.Id, clientChange)); // && Markets.GetCompetitorsAmount(product, gameContext) > 1 && daughters == 1 if (Companies.IsInPlayerSphereOfInterest(product, gameContext)) { NotificationUtils.AddNotification(gameContext, new NotificationMessageInnovation(product.company.Id, newLevel, revolution, 0, brandGain)); } niche.ReplaceSegment(newLevel); // order matters RemoveTechLeaders(product, gameContext); product.isTechnologyLeader = true; } else if (newLevel == demand) { // if you are techonology leader and you fail to innovate, you will not lose tech leadership if (product.isTechnologyLeader) { return; } RemoveTechLeaders(product, gameContext); } }
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); } }
private static List <GoalRequirements> GetInvestmentGoalMakePrototypeReqs(InvestmentGoal goal, GameEntity company, GameContext gameContext) { GameEntity product = GetProduct(goal, company, gameContext); var loyalty = 5; return(new List <GoalRequirements> { new GoalRequirements { have = (long)Marketing.GetChurnRate(product, gameContext), need = loyalty, reversedCheck = true, description = $"Churn < {loyalty}" } }); }
public static TeamResource GetTaskCost(GameEntity company, TeamTask teamTask, GameContext gameContext) { if (teamTask.IsFeatureUpgrade) { var cost = GetFeatureUpgradeCost(company, teamTask); return new TeamResource(0, 0, 0, cost, 0); } if (teamTask.IsMarketingTask) { var cost = Marketing.GetChannelCost(company, (teamTask as TeamTaskChannelActivity).ChannelId); return new TeamResource(cost); } return new TeamResource(0); }
internal static void ReturnUsersWhenCompanyIsClosed(GameEntity e, GameContext gameContext) { var users = Marketing.GetUsers(e); var niche = Get(gameContext, e.product.Niche); var companies = GetProductsOnMarket(gameContext, e.company.Id); var powers = companies.Sum(c => c.branding.BrandPower + 1) - e.branding.BrandPower; //foreach (var c in companies) //{ // if (c == e) // continue; // var part = (long)((1 + c.branding.BrandPower) * users / powers); // Marketing.AddClients(c, part); //} //Marketing.AddClients(e, -users); }
static void DisableTask(GameEntity product, GameContext gameContext, TeamTask task) { //Debug.Log($"Disabling task {task.ToString()} from {product.company.Name}"); if (task.IsMarketingTask) { var activity = task as TeamTaskChannelActivity; var channel = Markets.GetMarketingChannel(gameContext, activity.ChannelId); Marketing.DisableChannelActivity(product, channel); } if (task.IsFeatureUpgrade) { var activity = task as TeamTaskFeatureUpgrade; //var channel = Markets.GetMarketingChannels(gameContext).First(c => c.marketingChannel.ChannelInfo.ID == activity.ChannelId); //Products.DisableChannelActivity(product, gameContext, channel); } if (task.IsHighloadTask || task.IsSupportTask) { var activity = task as TeamTaskSupportFeature; var upgrades = product.supportUpgrades.Upgrades; var name = activity.SupportFeature.Name; if (upgrades.ContainsKey(name)) { upgrades[name]--; } if (upgrades[name] <= 0) { upgrades.Remove(name); } } }
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)); }
public static GameEntity CreateProduct(GameContext context, GameEntity company, NicheType niche) { company.AddProduct(niche, 0); // positioning int positionings = Markets.GetNichePositionings(niche, context).Count; company.AddProductPositioning(Random.Range(0, positionings)); // development company.AddFeatures(new Dictionary <ProductFeature, int> { [ProductFeature.Acquisition] = 0, [ProductFeature.Monetisation] = 0, [ProductFeature.Retention] = 0 }, 0); company.AddExpertise(Random.Range(1, 4)); company.AddFinancing(new Dictionary <Financing, int> { [Financing.Development] = 0, [Financing.Marketing] = 0, [Financing.Team] = 0 }); // clients var flow = Marketing.GetBaseClientsForNewCompanies(context, niche); var baseClients = Random.Range(0.15f, 0.35f) * flow; company.AddMarketing((long)baseClients); // sphere of interest var industry = Markets.GetIndustry(niche, context); AddFocusNiche(niche, company, context); AddFocusIndustry(industry, company); Investments.SetCompanyGoal(context, company, InvestorGoal.Operationing); return(company); }
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 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); } } }
public static bool IsReleaseableApp(GameEntity product, GameContext gameContext) { var hasCriticalMassOfUsers = Marketing.GetClients(product) >= 500; return(!product.isRelease && hasCriticalMassOfUsers && !Products.IsOutOfMarket(product, gameContext)); }