public static void BuyCompany(GameContext gameContext, int companyId, int buyerInvestorId, long offer) { // can afford acquisition var inv = Investments.GetInvestorById(gameContext, buyerInvestorId); if (!IsEnoughResources(inv, offer)) { return; } var target = Get(gameContext, companyId); var shareholders = GetShareholders(target); int[] array = new int[shareholders.Keys.Count]; shareholders.Keys.CopyTo(array, 0); foreach (var shareholderId in array) { BuyShares(gameContext, companyId, buyerInvestorId, shareholderId, shareholders[shareholderId].amount, offer, true); } RemoveAllPartnerships(target, gameContext); RemoveAcquisitionOffer(gameContext, companyId, buyerInvestorId); target.isIndependentCompany = false; NotifyAboutAcquisition(gameContext, buyerInvestorId, companyId, offer); }
public static GameEntity GetParentCompany(GameContext context, GameEntity company) { if (company.isIndependentCompany) { return(null); } var shares = 0; var shareholders = company.shareholders.Shareholders; GameEntity parent = null; foreach (var shareholder in shareholders) { var id = shareholder.Key; var block = shareholder.Value.amount; var investor = Investments.GetInvestor(context, id); if (investor.hasCompany) { // is managing company if (block > shares) { parent = investor; } } } return(parent); }
public static void AddShares(GameContext gameContext, GameEntity company, int investorId, int amountOfShares) { var shareholders = company.shareholders.Shareholders; var shareholder = Investments.GetInvestorById(gameContext, investorId).shareholder; if (IsInvestsInCompany(company, investorId)) { var prev = shareholders[investorId]; shareholders[investorId] = new BlockOfShares { amount = prev.amount + amountOfShares, InvestorType = prev.InvestorType, shareholderLoyalty = prev.shareholderLoyalty, }; } else { // new investor shareholders[investorId] = new BlockOfShares { amount = amountOfShares, InvestorType = shareholder.InvestorType, shareholderLoyalty = 100, }; } ReplaceShareholders(company, shareholders); }
public static GameEntity[] GetPotentialInvestors(GameContext gameContext, int companyId) { var investors = gameContext.GetEntities(GameMatcher.Shareholder); var c = Get(gameContext, companyId); return(Array.FindAll(investors, s => Investments.IsInvestorSuitable(s, c))); }
public static GameEntity GenerateInvestmentFund(GameContext context, string name, long money) { var c = CreateCompany(context, name, CompanyType.FinancialGroup); Investments.BecomeInvestor(context, c, money); return(c); }
public static GameEntity GenerateCompanyGroup(GameContext context, string name) { var c = CreateCompany(context, name, CompanyType.Group); c.isManagingCompany = true; Investments.BecomeInvestor(context, c, 0); return(c); }
public static bool IsDaughterOf(GameEntity parent, GameEntity daughter) { if (!parent.hasShareholder) { Companies.Log(daughter, $"FALSELY CALLED IS_DAUGHTER_OF on companies: possible parent={parent.company.Name}, possible daughter={daughter.company.Name}"); return(false); } return(Investments.IsInvestsInCompany(parent, daughter)); // IsInvestsInCompany(daughter, parent.shareholder.Id); }
public static long GetFounderExitDesire(GameEntity startup, int shareholderId, GameContext gameContext) { var founder = Investments.GetInvestor(gameContext, shareholderId); var ambition = Humans.GetFounderAmbition(founder.humanSkills.Traits, Humans.GetRating(founder)); if (ambition == Ambition.EarnMoney) { return(C.COMPANY_DESIRE_TO_SELL_YES); } return(C.COMPANY_DESIRE_TO_SELL_NO); }
public static long GetFounderExitDesire(GameEntity startup, int shareholderId, GameContext gameContext) { var founder = Investments.GetInvestorById(gameContext, shareholderId); var ambitions = founder.humanSkills.Traits[TraitType.Ambitions]; var ambition = Humans.GetFounderAmbition(ambitions); if (ambition == Ambition.EarnMoney) { return(Balance.COMPANY_DESIRE_TO_SELL_YES); } return(Balance.COMPANY_DESIRE_TO_SELL_NO); }
internal static GameEntity PreparePlayerCompany(GameEntity niche, long startCapital, string text, GameContext gameContext) { var company = Companies.GenerateCompanyGroup(gameContext, text); company.ReplaceCorporateCulture(Companies.GetPlayerCorporateCulture()); Companies.SetResources(company, startCapital, "start capital"); Companies.PlayAs(company, gameContext); Investments.SetGrowthStyle(company, CompanyGrowthStyle.None); Investments.SetVotingStyle(company, VotingStyle.None); Investments.SetExitStrategy(company, InvestorInterest.None); Companies.AutoFillShareholders(gameContext, company, true); return(company); }
public static List <CompanyHolding> GetPersonalHoldings(GameContext context, int shareholderId, bool recursively) { List <CompanyHolding> companyHoldings = new List <CompanyHolding>(); var investments = Investments.GetInvestmentsOf(context, shareholderId); foreach (var investment in investments) { var holding = new CompanyHolding { companyId = investment.company.Id, control = GetShareSize(context, investment.company.Id, shareholderId), holdings = recursively ? GetCompanyHoldings(context, investment.company.Id, recursively) : new List <CompanyHolding>() }; companyHoldings.Add(holding); } return(companyHoldings); }
public static void AutoFillShareholders(GameContext gameContext, GameEntity c, bool founderOnly) { var founder = c.cEO.HumanId; var shareholder = Humans.Get(gameContext, founder); Investments.BecomeInvestor(gameContext, shareholder, 100000); AddShares(c, shareholder, 500); if (founderOnly) { return; } for (var i = 0; i < UnityEngine.Random.Range(1, 5); i++) { var investor = Investments.GetRandomInvestmentFund(gameContext); AddShares(c, investor, 100); } }
public static void DecreaseShares(GameContext gameContext, GameEntity company, int investorId, int amountOfShares) { var shareholders = company.shareholders.Shareholders; var shareholder = Investments.GetInvestorById(gameContext, investorId).shareholder; var prev = shareholders[investorId]; if (amountOfShares >= prev.amount) { // needs to be deleted RemoveShareholder(company, investorId); return; } shareholders[investorId] = new BlockOfShares { amount = prev.amount - amountOfShares, InvestorType = prev.InvestorType, shareholderLoyalty = prev.shareholderLoyalty }; ReplaceShareholders(company, shareholders); }
public static void JoinCorporation(GameContext gameContext, int companyId, int buyerInvestorId) { var target = Get(gameContext, companyId); var corporation = Investments.GetCompanyByInvestorId(gameContext, buyerInvestorId); var shareholders = GetShareholders(target); int[] array = new int[shareholders.Keys.Count]; var corporationCost = Economy.GetCompanyCost(gameContext, corporation); var targetCost = Economy.GetCompanyCost(gameContext, target); var corporationShares = Companies.GetTotalShares(gameContext, companyId); var emitedShares = corporationShares * targetCost / corporationCost; // give shares in corporation to shareholders of integratable company foreach (var shareholderId in array) { var percentOfSharesInPreviousCompany = GetShareSize(gameContext, companyId, shareholderId); var newShare = emitedShares * percentOfSharesInPreviousCompany / 100; AddShares(gameContext, corporation, shareholderId, (int)newShare); Debug.Log($"investor {GetInvestorName(gameContext, shareholderId)} will get {(int)newShare} shares of corporation {corporation.company.Name}"); } foreach (var shareholderId in array) { RemoveShareholder(target, shareholderId); } AddShareholder(gameContext, companyId, buyerInvestorId, 100); target.isIndependentCompany = false; NotifyAboutCorporateAcquisition(gameContext, buyerInvestorId, companyId); }
public static void ApplyGroupInvestmentsToProfitBonus(GameEntity c, GameContext context, Bonus <long> bonus) { if (!Companies.IsGroup(c)) { return; } var holdings = Investments.GetHoldings(c, context, true); bool isOnlyHolding = holdings.Count == 1; foreach (var h in holdings) { var b = GetProfit(context, h.company, true); if (isOnlyHolding) { // render full description foreach (var d in b.bonusDescriptions) { if (d.HideIfZero) { bonus.AppendAndHideIfZero(d.Name, d.Value); } else { bonus.Append(d.Name, d.Value); } } } else { // general info is enough bonus.Append(h.company.company.Name, b.Sum()); } } }
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); }
private static long GetGroupMaintenance(GameContext context, GameEntity company) { return(Investments.GetHoldings(company, context, true) .Sum(h => h.control * GetMaintenance(context, h.company) / 100)); }
public static bool IsInvestsInCompany(GameEntity company, int investorId) { return(Investments.IsInvestsInCompany(investorId, company)); //return company.shareholders.Shareholders.ContainsKey(investorId); }
public static bool IsInvestsInCompany(GameEntity company, GameEntity investor) => Investments.IsInvestsInCompany(investor, company);
public static void AddMoneyToInvestor(GameContext context, int investorId, long sum) { Investments.AddMoneyToInvestor(context, investorId, sum); }
public static long OnGoalCompletion(GameEntity startup, InvestorType investorType) { bool goalCompleted = !Investments.IsInvestorSuitableByGoal(investorType, startup.companyGoal.InvestorGoal); return(goalCompleted ? Balance.COMPANY_DESIRE_TO_SELL_YES : Balance.COMPANY_DESIRE_TO_SELL_NO); }
public static GameEntity GetInvestorById(GameContext context, int investorId) { return(Investments.GetInvestor(context, investorId)); }
public static GameEntity GetSelectedInvestor(GameContext gameContext) { var id = GetScreenParameter(gameContext, C.MENU_SELECTED_INVESTOR); return(Investments.GetInvestor(gameContext, (int)id)); }
public static GameEntity GetSelectedInvestor(GameContext gameContext) { int id = (int)GetScreenData(gameContext)[Balance.MENU_SELECTED_INVESTOR]; return(Investments.GetInvestorById(gameContext, id)); }
public static long GetInvestorCapitalCost(GameContext gameContext, GameEntity human) { var holdings = Investments.GetHoldings(human, gameContext, false); return(Economy.GetHoldingsCost(gameContext, holdings)); }
public static long GetHoldingsCost(GameContext context, GameEntity entity) => GetHoldingsCost(context, Investments.GetHoldings(entity, context, true));
public static int GenerateInvestorId(GameContext context) { return(Investments.GenerateInvestorId(context)); }
private static long GetGroupIncome(GameContext context, GameEntity e) { return(Investments.GetHoldings(e, context, true) .Sum(h => h.control * GetIncome(context, h.company) / 100)); }
public static GameEntity[] GetDaughters(GameEntity c, GameContext context) { return(Investments.GetOwnings(c, context)); }