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; } } } }
// float public static Bonus <long> GetBrandChange(GameEntity product, GameContext gameContext) { var conceptStatus = Products.GetConceptStatus(product, gameContext); var isOutOfMarket = conceptStatus == ConceptStatus.Outdated; var isInnovator = conceptStatus == ConceptStatus.Leader; var percent = 10; var baseDecay = product.branding.BrandPower * percent / 100; var isMarketingAggressively = Economy.GetMarketingFinancing(product) == Products.GetMaxFinancing; var isReleased = product.isRelease; var partnershipBonuses = GetPartnershipBonuses(product, gameContext); var isMonopolist = Markets.GetCompetitorsAmount(product, gameContext) == 1; var BrandingChangeBonus = new Bonus <long>("Brand power change") .AppendAndHideIfZero(percent + "% Decay", -(int)baseDecay) .AppendAndHideIfZero("Released", isReleased ? 1 : 0) .AppendAndHideIfZero("MONOPOLY", isMonopolist ? 10 : 0) .AppendAndHideIfZero("Outdated app", isOutOfMarket ? -4 : 0) .AppendAndHideIfZero("Capturing market", isMarketingAggressively ? 6 : 0) .Append("Partnerships", (int)partnershipBonuses) ; return(BrandingChangeBonus); }
public static float GetSumOfBrandPowers(GameEntity niche, GameContext gameContext) { var products = Markets.GetProductsOnMarket(niche, gameContext); var sumOfBrandPowers = products.Sum(p => p.branding.BrandPower); return(sumOfBrandPowers); }
public static int GetNecessaryAmountOfProgrammers(GameEntity e, GameContext gameContext) { var concept = Products.GetProductLevel(e); var niche = Markets.GetNiche(gameContext, e); var complexity = (int)niche.nicheBaseProfile.Profile.AppComplexity; return((int)Mathf.Pow(1 + complexity / 20f, concept)); }
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()); }
public static IEnumerable <GameEntity> GetNonFundCompaniesInterestedInIndustry(GameContext gameContext, IndustryType industry) { var markets = Markets.GetNichesInIndustry(industry, gameContext).Select(m => m.niche.NicheType).ToArray(); return(Companies.GetIndependentCompanies(gameContext) .Where(Companies.IsNotFinancialStructure) .Where(c => Companies.IsInSphereOfInterest(c, markets))); }
public static float GetBrandBasedMarketShare(GameEntity e, GameContext gameContext) { var niche = Markets.GetNiche(gameContext, e); var sumOfBrandPowers = GetSumOfBrandPowers(niche, gameContext); // +1 : avoid division by zero return(e.branding.BrandPower / (sumOfBrandPowers + 1)); }
private static void RemoveTechLeaders(GameEntity product, GameContext gameContext) { var players = Markets.GetProductsOnMarket(gameContext, product).ToArray(); foreach (var p in players) { p.isTechnologyLeader = false; } }
// always positive or equal to zero public static int GetDifferenceBetweenMarketDemandAndAppConcept(GameEntity product, GameContext gameContext) { var niche = Markets.GetNiche(gameContext, product.product.Niche); var demand = GetMarketDemand(niche); var level = GetProductLevel(product); return(demand - level); }
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 void SendNewCompetitorPopup(GameContext gameContext, GameEntity niche, GameEntity product) { var potentialLeader = Markets.GetPotentialMarketLeader(gameContext, niche.niche.NicheType); var hasBiggestPotential = potentialLeader.company.Id == product.company.Id; if (Companies.IsInPlayerSphereOfInterest(product, gameContext) && hasBiggestPotential) { AddPopup(gameContext, new PopupMessageCompanySpawn(product.company.Id)); } }
public static GameEntity AutoGenerateProductCompany(NicheType nicheType, GameContext gameContext) { var playersOnMarket = Markets.GetCompetitorsAmount(nicheType, gameContext); var c = GenerateProductCompany(gameContext, Enums.GetFormattedNicheName(nicheType) + " " + playersOnMarket, nicheType); AutoFillShareholders(gameContext, c, true); //SetFounderAmbitionDueToMarketSize(c, gameContext); return(c); }
public static MarketRequirementsComponent GetMarketRequirementsForCompany(GameContext gameContext, GameEntity c) { if (!c.hasMarketRequirements) { var niche = Markets.Get(gameContext, c); var reqs = Markets.GetMarketRequirements(gameContext, niche); c.AddMarketRequirements(reqs.Features); } return(c.marketRequirements); }
public static void WrapProductWithAdditionalData(GameEntity product, GameContext gameContext) { if (!product.hasNicheSegments) { product.AddNicheSegments(Markets.GetNichePositionings(product.product.Niche, gameContext)); } if (!product.hasNicheBaseProfile) { product.AddNicheBaseProfile(Markets.Get(gameContext, product).nicheBaseProfile.Profile); } Markets.CopyChannelInfosToProductCompany(product, gameContext); }
public static float GetMonetisationModifier(GameContext gameContext, GameEntity c) { var niche = Markets.GetNiche(gameContext, c.product.Niche); var pricingType = niche.nicheBaseProfile.Profile.MonetisationType; var baseValue = GetBaseMonetisationValue(pricingType); var multiplier = GetImprovementMonetisationValue(pricingType); var improvements = c.features.features[ProductFeature.Monetisation]; return(baseValue + improvements * multiplier / 100); }
public static void AttachToGroup(GameContext context, int parentId, int subsidiaryId) { // TODO only possible if independent! var parent = Get(context, parentId); // we cannot attach company to product company if (!IsCompanyGroupLike(parent)) { return; } var daughter = Get(context, subsidiaryId); if (daughter.hasProduct) { AddFocusNiche(daughter.product.Niche, parent, context); var industry = Markets.GetIndustry(daughter.product.Niche, context); AddFocusIndustry(industry, parent); } //Debug.Log("Attach " + daughter.company.Name + " to " + parent.company.Name); var shareholders = new Dictionary <int, BlockOfShares> { { parent.shareholder.Id, new BlockOfShares { amount = 100, InvestorType = InvestorType.Strategic, shareholderLoyalty = 100 } } }; if (daughter.hasShareholders) { daughter.ReplaceShareholders(shareholders); } else { daughter.AddShareholders(shareholders); } daughter.isIndependentCompany = false; }
public static void NotifyAllProductsAboutMarketRequirementsChanges(GameEntity product, GameContext gameContext) { var niche = Markets.Get(gameContext, product); // Calculate changes in market Markets.GetMarketRequirements(gameContext, niche); // Notify var copy = Markets.CopyMarketRequirements(niche.marketRequirements.Features); foreach (var c in Companies.GetDirectCompetitors(product, gameContext, true)) { c.ReplaceMarketRequirements(copy); } }
// Start new Campaign public static void StartNewCampaign(GameContext gameContext, NicheType NicheType, string text) { var startCapital = Markets.GetStartCapital(NicheType, gameContext); var niche = Markets.Get(gameContext, NicheType); var group = PreparePlayerCompany(niche, startCapital, text, gameContext); PrepareMarket(niche, startCapital, gameContext); var flagship = Companies.CreateProductAndAttachItToGroup(gameContext, NicheType, group); Companies.TurnProductToPlayerFlagship(flagship, gameContext, NicheType, group); LoadGameScene(); }
// TODO remove public static void SetFounderAmbitionDueToMarketSize(GameEntity company, GameContext gameContext) { var niche = Markets.GetNiche(gameContext, company.product.Niche); var rating = Markets.GetMarketPotentialRating(niche); var rand = UnityEngine.Random.Range(1f, 2f) * 5; // 5...25 var ambition = 65 + Mathf.Clamp(rating * rand, 0, 30); var CeoId = GetCEOId(company); var ceo = Humans.GetHuman(gameContext, CeoId); Humans.SetTrait(ceo, TraitType.Ambitions, (int)ambition); }
private static float GetPartnershipBonuses(GameEntity product, GameContext gameContext) { var partners = Companies.GetPartnerList(product, gameContext); var industry = Markets.GetIndustry(product.product.Niche, gameContext); float value = 0; foreach (var p in partners) { value += Companies.GetBrandProjectionOnIndustry(p, gameContext, industry); } return(Mathf.Clamp(value, 0, 3)); }
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); } }
// 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 }); }
public static float GetCompanyStrengthInIndustry(GameEntity company, IndustryType industry, GameContext gameContext) { if (company.isManagingCompany) { var daughtersInIndustry = GetDaughterProducts(gameContext, company) .Where(p => Markets.GetIndustry(p.product.Niche, gameContext) == industry); return(daughtersInIndustry .Sum(d => d.branding.BrandPower)); } else { // product company var ind = Markets.GetIndustry(company.product.Niche, gameContext); return(ind == industry ? company.branding.BrandPower : 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)); }
public static long GetBaseClientsForNewCompanies(GameContext gameContext, NicheType nicheType) { var niche = Markets.GetNiche(gameContext, nicheType); var monetisation = niche.nicheBaseProfile.Profile.MonetisationType; switch (monetisation) { case Monetisation.Adverts: return(5000); case Monetisation.Enterprise: return(3); case Monetisation.Paid: return(100); case Monetisation.Service: return(500); case Monetisation.IrregularPaid: return(350); default: return(0); } }
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 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 void AttachToGroup(GameContext context, GameEntity parent, GameEntity daughter) { // TODO only possible if independent! // we cannot attach company to product company if (parent.hasProduct) { return; } if (daughter.hasProduct) { var industry = Markets.GetIndustry(daughter.product.Niche, context); AddFocusNiche(parent, daughter.product.Niche, context); AddFocusIndustry(industry, parent); } // TODO why not make it with transfer shares function? RemoveAllShareholders(context, daughter); AddShares(daughter, parent, 100); SetIndependence(daughter, false); }
public static GameEntity[] GetDumpingCompetitors(GameContext gameContext, GameEntity product) => GetDumpingCompetitors(gameContext, Markets.GetNiche(gameContext, product), product);