public static void FillMarket(GameEntity niche, GameContext gameContext) { var phase = GetMarketState(niche); if (phase == MarketState.Death) { return; } var date = ScheduleUtils.GetCurrentDate(gameContext); var isReadyToBeOpen = niche.nicheLifecycle.OpenDate < date; if (!isReadyToBeOpen) { return; } var nicheType = niche.niche.NicheType; var playersOnMarket = 0; // GetCompetitorsAmount(nicheType, gameContext); // don't spawn companies on innovation phase if has companies already //if (phase == MarketState.Innovation && playersOnMarket > 0) // return; bool isInPlayerSphereOfInfluence = Companies.IsInPlayerSphereOfInterest(niche.niche.NicheType, gameContext); TryToSpawnCompany(niche, gameContext, phase, isInPlayerSphereOfInfluence); }
/// <summary> /// Adding simple cooldown has it's own style /// ex: $"company-{product.company.Id}-upgradeFeature-{featureName}"; /// $"entity-{Id}-actionType-{attributes}"; /// </summary> /// <param name="gameContext"></param> /// <param name="name"></param> /// <param name="duration"></param> public static void AddSimpleCooldown(GameContext gameContext, string name, int duration) { var date = ScheduleUtils.GetCurrentDate(gameContext); AddSimpleCooldown(gameContext, name, new SimpleCooldown { StartDate = date, EndDate = date + duration }); }
public static void SendJobOffer(HumanFF worker, JobOffer jobOffer, GameEntity company, GameContext gameContext) { var offer = new ExpiringJobOffer { JobOffer = jobOffer, CompanyId = company.company.Id, DecisionDate = ScheduleUtils.GetCurrentDate(gameContext) + 30, HumanId = worker.HumanComponent.Id }; AddOrReplaceOffer(company, worker, offer); }
internal static GameEntity AddTimedAction(GameContext gameContext, CompanyTask companyTask, int duration) { if (HasTask(gameContext, companyTask)) { return(null); } var e = gameContext.CreateEntity(); var start = ScheduleUtils.GetCurrentDate(gameContext); e.AddTimedAction(false, companyTask, start, duration, start + duration); return(e); }
public static bool IsAppropriateStartNiche(GameEntity niche, GameContext gameContext) { var profile = niche.nicheBaseProfile.Profile; var phase = GetMarketState(niche); var isOpened = ScheduleUtils.GetCurrentDate(gameContext) >= niche.nicheLifecycle.OpenDate; var isPerspective = phase == MarketState.Idle || phase == MarketState.Innovation || phase == MarketState.Trending; var isCheap = profile.AppComplexity < AppComplexity.Hard; var isBig = profile.AudienceSize == AudienceSize.Global; // GetMarketPotentialRating(niche) > 3; return(isPerspective && isOpened && isCheap && !isBig); }
public static void ApplyInvestmentsToProfitBonus(GameEntity c, GameContext context, Bonus <long> bonus) { //var investmentTaker = c.isFlagship ? Companies.GetManagingCompanyOf(c, context) : c; var investmentTaker = c; var date = ScheduleUtils.GetCurrentDate(context); if (investmentTaker.shareholders.Shareholders.Count > 1) { var investments = investmentTaker.shareholders.Shareholders.Values .Select(v => v.Investments.Where(z => WillPayInvestmentRightNow(z, date)).Select(z => z.Portion).Sum()) .Sum(); bonus.AppendAndHideIfZero("Investments", investments); } }
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); } }
public static TeamResource GetProductCompanyResourceChange(GameEntity company, GameContext gameContext) { long money = GetProfit(gameContext, company); var ideas = Products.GetExpertiseGain(company); var upgrades = 0; var date = ScheduleUtils.GetCurrentDate(gameContext); if (ScheduleUtils.IsPeriodicalMonthEnd(date)) { upgrades = Products.GetIterationMonthlyGain(company); } return(new TeamResource( upgrades, 0, 0, ideas, money )); }