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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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.GetInvestorById(context, id);
                if (investor.hasCompany)
                {
                    // is managing company
                    if (block > shares)
                    {
                        parent = investor;
                    }
                }
            }

            return(parent);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
 public static GameEntity GetInvestorById(GameContext context, int investorId)
 {
     return(Investments.GetInvestorById(context, investorId));
 }
Esempio n. 7
0
        public static GameEntity GetSelectedInvestor(GameContext gameContext)
        {
            int id = (int)GetScreenData(gameContext)[Balance.MENU_SELECTED_INVESTOR];

            return(Investments.GetInvestorById(gameContext, id));
        }