void DecreaseCompanyPrice(GameEntity offer, int targetId, int shareholderId)
    {
        var o = offer.acquisitionOffer;


        var cost = Economy.GetCompanyCost(gameContext, targetId);

        var Kmin    = Companies.GetRandomAcquisitionPriceModifier(targetId, shareholderId);
        var Kbuyer  = o.BuyerOffer.Price * 1f / cost;
        var Kseller = 2 * Kmin - Kbuyer;

        var KsellerRandomised = Kseller * Random.Range(0.85f, 1.15f);

        var newPrice = Mathf.Max(KsellerRandomised, Kmin, Kbuyer) * cost;

        var sellerConditions = new AcquisitionConditions
        {
            Price           = (long)newPrice,
            ByCash          = (long)newPrice,
            ByShares        = 0,
            KeepLeaderAsCEO = o.SellerOffer.KeepLeaderAsCEO
        };


        offer.ReplaceAcquisitionOffer(targetId, shareholderId, AcquisitionTurn.Buyer, o.BuyerOffer, sellerConditions);

        var investor = Investments.GetInvestorById(gameContext, shareholderId);

        if (investor.isControlledByPlayer)
        {
            NotificationUtils.AddPopup(gameContext, new PopupMessageAcquisitionOfferResponse(targetId, shareholderId));
        }
    }
        internal static void SetCompanyGoal(GameContext gameContext, GameEntity company, InvestorGoal investorGoal)
        {
            long measurableGoal = 5000;

            switch (investorGoal)
            {
            case InvestorGoal.Prototype: measurableGoal = 1; break;

            case InvestorGoal.FirstUsers: measurableGoal = 50; break;

            case InvestorGoal.BecomeMarketFit: measurableGoal = -1; break;

            case InvestorGoal.Release: measurableGoal = 1; break;

            case InvestorGoal.BecomeProfitable: measurableGoal = 0; break;

            case InvestorGoal.IPO: measurableGoal = 1; break;

            case InvestorGoal.GrowCompanyCost:
                measurableGoal = Economy.GetCompanyCost(gameContext, company.company.Id) * (100 + Balance.INVESTMENT_GOAL_GROWTH_REQUIREMENT_COMPANY_COST) / 100;
                break;
            }

            company.ReplaceCompanyGoal(investorGoal, measurableGoal);
        }
    AcquisitionConditions GetNewCounterOffer(GameEntity offer, int targetId, int shareholderId, long maxOfferedPrice)
    {
        var cost = Economy.GetCompanyCost(gameContext, targetId);

        var modifier = Companies.GetRandomAcquisitionPriceModifier(targetId, shareholderId);
        var maxPrice = (long)(cost * modifier);  // the max amount, that we want to pay theoretically

        var newPrice = (long)(maxOfferedPrice * Random.Range(1.05f, 5f));

        if (newPrice > maxPrice)
        {
            newPrice = maxPrice;
        }

        var investor = Investments.GetInvestorById(gameContext, shareholderId);
        var balance  = investor.companyResource.Resources.money;

        if (newPrice > balance)
        {
            newPrice = balance;
        }

        return(new AcquisitionConditions
        {
            ByCash = newPrice,
            Price = newPrice,
            ByShares = offer.acquisitionOffer.BuyerOffer.ByShares,
            KeepLeaderAsCEO = offer.acquisitionOffer.BuyerOffer.KeepLeaderAsCEO,
        });
    }
    void Render()
    {
        var c     = Companies.Get(Q, companyId);
        var buyer = Companies.GetInvestorById(Q, buyerId);

        Name.text             = c.company.Name;
        CompanyLink.CompanyId = companyId;
        BuyerLink.CompanyId   = buyer.company.Id;

        Buyer.text = Companies.GetInvestorName(buyer);

        var hasControl = Companies.GetControlInCompany(MyCompany, buyer, Q) > 0;

        Buyer.color = Visuals.GetColorFromString(hasControl ? Colors.COLOR_CONTROL : Colors.COLOR_CONTROL_NO);

        var rating = c.hasProduct ? Markets.GetMarketRating(Q, c.product.Niche): 0;

        NicheStage.SetStars(rating);

        StageHint.SetHint(c.hasProduct ? Markets.GetMarketState(Q, c.product.Niche).ToString() : "");

        Valuation.text = Format.Money(Economy.GetCompanyCost(Q, companyId));

        var offer = Companies.GetAcquisitionOffer(Q, companyId, buyerId);

        //Offer.text = Format.Money(offer.acquisitionOffer.Offer);

        AcceptOffer.SetData(companyId, buyerId);
        RejectOffer.SetData(companyId, buyerId);
    }
Exemple #5
0
    void RenderShareOfferSlider(AcquisitionConditions conditions, long price)
    {
        var ourCompanyCost = Economy.GetCompanyCost(Q, MyCompany);


        var sharePercent        = conditions.ByShares; // ;
        var maxAllowedShareCost = 25 * ourCompanyCost / 100;

        var shareCost = Mathf.Clamp(sharePercent * price / 100, 0, maxAllowedShareCost);

        sharePercent = (int)(shareCost * 100 / price);



        Slider.minValue = 0;
        Slider.maxValue = 100;


        Slider.maxValue = Mathf.Clamp(maxAllowedShareCost * 100 / price, 0, 100);

        var sharePartOfCompany = shareCost * 100 / ourCompanyCost;

        var cash = price - shareCost;

        SharePercentage.text = $"You will pay {Format.Money(cash)} with cash and give {sharePartOfCompany}% of your company shares (worth ${Format.Money(shareCost)})";
    }
Exemple #6
0
 private static GoalRequirements GoalCompanyCost(GameEntity company, GameContext gameContext)
 {
     return(new GoalRequirements
     {
         have = Economy.GetCompanyCost(gameContext, company.company.Id),
         need = company.companyGoal.MeasurableGoal
     });
 }
Exemple #7
0
    public void Render()
    {
        var groups = Companies.GetGroupCompanies(Q)
                     .OrderByDescending(g => Economy.GetCompanyCost(Q, g.company.Id))
                     .ToArray();

        SetItems(groups, GrowthFilterQuarterly.Quarterly);
    }
Exemple #8
0
    void RenderOffer()
    {
        long Cost = Economy.GetCompanyCost(Q, SelectedCompany.company.Id);

        long offer           = proposal.Offer;
        long futureShareSize = offer * 100 / (offer + Cost);

        Offer.text = $"${Format.Minify(offer)} for {futureShareSize}% of our company";
    }
Exemple #9
0
    public override void ViewRender()
    {
        base.ViewRender();

        if (!HasCompany)
        {
            return;
        }

        var name = SelectedCompany.company.Name;

        Title.text = $"Integrate \"{name}\" to our corporation";

        bool willAcceptOffer = Companies.IsCompanyWillAcceptCorporationOffer(Q, SelectedCompany.company.Id, MyCompany.shareholder.Id);

        var progress = Companies.GetCorporationOfferProgress(Q, SelectedCompany.company.Id, MyCompany.shareholder.Id);

        Progress.text = Visuals.Colorize(progress + "%", willAcceptOffer);


        // TODO DIVIDE BY ZERO
        var ourCost = Economy.GetCompanyCost(Q, MyCompany);

        if (ourCost == 0)
        {
            ourCost = 1;
        }
        var targetCost = Economy.GetCompanyCost(Q, SelectedCompany);

        var sizeComparison = targetCost * 100 / ourCost;

        var futureShares = targetCost * 100 / (targetCost + ourCost);

        OurValuation.text    = Format.Money(ourCost);
        TargetValuation.text = $"{Format.Money(targetCost)} ({sizeComparison}% compared to us)";

        bool willStayIndependent = KeepAsIndependent.isOn;

        var isTargetTooBig    = targetCost * 100 > ourCost * 15;
        var tooSmallToAcquire = isTargetTooBig ? Visuals.Negative("This company costs more than 15% of our corporation, so they won't join us.") : "";

        OfferNote.text = $"{tooSmallToAcquire}\n\nCompany {name} will be <b>Fully</b> integrated to our company.\n\n" +
                         $"Their shareholders will own {futureShares} % of our corporation";
        //if (willStayIndependent)
        //{
        //}
        //else
        //{
        //    OfferNote.text = $"Company {name} will be <b>Partially</b> integrated to our company." +
        //        $"\n\nThey will be able to leave whenever they want." +
        //        $"\nTheir shareholders won't receive our shares." +
        //        $"\n\nOur company will get +1 Brand power for all products in Communications industry." +
        //        $"\n\n{name} will get ";
        //}
    }
Exemple #10
0
    void RenderNewCorporationRequirements(PopupMessageCorporationRequirements popup)
    {
        var cost = Economy.GetCompanyCost(Q, popup.companyId);
        var goal = Balance.CORPORATION_REQUIREMENTS_COMPANY_COST;

        RenderUniversalPopup(
            "You cannot create a corporation :(",
            $"Your company costs {Format.Money(cost)}, but needs to cost at least {Format.Money(goal)} to become a corporation",
            typeof(ClosePopupCancel)
            );
    }
Exemple #11
0
    public override void ViewRender()
    {
        base.ViewRender();

        var daughters = Companies.GetDaughterCompanies(Q, MyCompany.company.Id)
                        //.OrderBy(d => CompanyStatisticsUtils.GetIncomeGrowthAbsolute(d, 12))
                        .OrderByDescending(d => Economy.GetCompanyCost(Q, d.company.Id))
                        .ToArray();

        SetItems(daughters);
    }
Exemple #12
0
 void SaveProductCompanyMetrics(GameEntity e, int date)
 {
     CompanyStatisticsUtils.AddMetrics(gameContext, e, new MetricsInfo
     {
         Date         = date,
         AudienceSize = Marketing.GetClients(e),
         Income       = Economy.GetCompanyIncome(gameContext, e),
         Profit       = Economy.GetProfit(gameContext, e),
         Valuation    = Economy.GetCompanyCost(gameContext, e)
     });
 }
Exemple #13
0
 private void SaveGroupCompanyMetrics(GameEntity e, int date)
 {
     CompanyStatisticsUtils.AddMetrics(gameContext, e, new MetricsInfo
     {
         Date         = date,
         AudienceSize = 0,
         Income       = Economy.GetCompanyIncome(gameContext, e),
         Profit       = Economy.GetProfit(gameContext, e),
         Valuation    = Economy.GetCompanyCost(gameContext, e)
     });
 }
Exemple #14
0
    GameEntity[] GetOwnings()
    {
        var arr = Companies.GetDaughterCompanies(Q, ObservableCompany.company.Id)
                  .OrderByDescending(c => Economy.GetCompanyCost(Q, c.company.Id))
                  .ToArray();

        //if (SortingOrder)
        //    Array.Reverse(arr);

        return(arr);
    }
    public override void ViewRender()
    {
        base.ViewRender();

        var c         = SelectedCompany;
        var companyId = c.company.Id;

        CompanyCost.text = RenderCosts(Economy.GetCompanyCost(Q, companyId));

        RenderBaseCosts(companyId, c);
    }
Exemple #16
0
    GameEntity[] GetCompetingCompanies()
    {
        var niches = MyCompany.companyFocus.Niches;

        return(Markets.GetNonFinancialCompaniesWithSameInterests(Q, MyCompany)
               .OrderByDescending(c => Economy.GetCompanyCost(Q, c))
               .ToArray());

        ////niches.Select()
        //return CompanyUtils.GetAIManagingCompanies(GameContext)
        //    .OrderByDescending(c => CompanyEconomyUtils.GetCompanyCost(GameContext, c))
        //    .ToArray();
    }
    void SendAcquisitionOffer(GameEntity buyer, GameEntity target, GameContext gameContext)
    {
        var cost = Economy.GetCompanyCost(gameContext, target.company.Id) * Random.Range(1, 10) / 2;

        if (!Companies.IsEnoughResources(buyer, cost))
        {
            return;
        }

        Debug.Log("AI.SendAcquisitionOffer: " + buyer.company.Name + " wants " + target.company.Name);

        Companies.SendAcquisitionOffer(gameContext, target.company.Id, buyer.shareholder.Id, cost);
    }
    public override void Execute()
    {
        var cost = Economy.GetCompanyCost(Q, MyCompany);
        var goal = Balance.CORPORATION_REQUIREMENTS_COMPANY_COST;

        if (cost < goal)
        {
            NotificationUtils.AddPopup(Q, new PopupMessageCorporationRequirements(MyCompany.company.Id));
        }
        else
        {
            Companies.PromoteToCorporation(MyCompany, Q);

            Navigate(ScreenMode.CorporationScreen);
        }
    }
        public static bool IsShareholderWillAcceptAcquisitionOffer(AcquisitionOfferComponent ackOffer, int shareholderId, GameContext gameContext)
        {
            var cost = Economy.GetCompanyCost(gameContext, ackOffer.CompanyId);

            var company  = Get(gameContext, ackOffer.CompanyId);
            var investor = GetInvestorById(gameContext, shareholderId);

            var  container       = GetInvestorOpinionAboutAcquisitionOffer(ackOffer, investor, company, gameContext);
            bool willAcceptOffer = container.Sum() >= 0; // ackOffer.Offer > cost * modifier;


            bool isBestOffer = true; // when competing with other companies
            var  offers      = GetAcquisitionOffersToCompany(gameContext, ackOffer.CompanyId);

            var baseDesireToSellCompany = GetBaseDesireToSellShares(gameContext, company, shareholderId, investor.shareholder.InvestorType);
            var wantsToSellShares       = true || baseDesireToSellCompany == 1;

            return(wantsToSellShares && willAcceptOffer && isBestOffer);
        }
    public void Render()
    {
        if (entity == null)
        {
            return;
        }

        SetProductCompanyTableView();

        CompanyName.text = entity.company.Name;

        SetPanelColor();

        Cost.text = "$" + Format.MinifyToInteger(Economy.GetCompanyCost(Q, entity.company.Id));


        RenderValuationGrowth();

        GetComponent <LinkToProjectView>().CompanyId = entity.company.Id;
    }
    List <ReportData> GetGroupList()
    {
        var groups = Companies.GetGroupCompanies(gameContext)
                     .OrderByDescending(g => Economy.GetCompanyCost(gameContext, g.company.Id))
                     .ToArray();

        var List = new List <ReportData>();

        for (var i = 0; i < groups.Length; i++)
        {
            var g = groups[i];

            List.Add(new ReportData
            {
                Cost          = Economy.GetCompanyCost(gameContext, g.company.Id),
                ShareholderId = g.shareholder.Id,
                position      = i
            });
        }

        return(List);
    }
    List <ReportData> GetProductList()
    {
        var products = Companies.GetProductCompanies(gameContext)
                       .OrderByDescending(p => Economy.GetCompanyCost(gameContext, p.company.Id))
                       .ToArray();

        var List = new List <ReportData>();

        for (var i = 0; i < products.Length; i++)
        {
            var p  = products[i];
            var id = p.company.Id;

            List.Add(new ReportData
            {
                Cost          = Economy.GetCompanyCost(gameContext, id),
                ShareholderId = id,
                position      = i
            });
        }

        return(List);
    }
Exemple #23
0
    void RenderOffer(bool willAcceptOffer)
    {
        var acquisitionOffer = AcquisitionOffer;

        if (acquisitionOffer == null)
        {
            return;
        }

        var  conditions = acquisitionOffer.BuyerOffer;
        var  seller     = acquisitionOffer.SellerOffer;
        long price      = conditions.Price;


        var    cost          = Economy.GetCompanyCost(Q, SelectedCompany.company.Id);
        string overpriceText = "";

        if (price > cost)
        {
            var overprice = Mathf.Ceil(price * 10 / cost);
            overpriceText = $"  ({(overprice / 10)}x)";
        }

        Offer.text       = Format.Money(price) + overpriceText;
        SellerPrice.text = Format.Money(seller.Price);



        var showInputField = acquisitionOffer.Turn == AcquisitionTurn.Buyer;

        CashOfferInput.gameObject.SetActive(showInputField);
        CashOfferInput.text = price.ToString();

        SharesOfferInput.text = conditions.ByShares.ToString();

        RenderShareOfferSlider(conditions, price);
    }
    public override string RenderValue()
    {
        var cost = Economy.GetCompanyCost(Q, SelectedCompany);

        return($"ECONOMY ({Format.MinifyMoney(cost)})");
    }
Exemple #25
0
 public override string RenderValue()
 {
     return(Format.Money(Economy.GetCompanyCost(Q, SelectedCompany.company.Id)));
 }
    private void RenderCompanyCost(GameEntity e)
    {
        var cost = Economy.GetCompanyCost(Q, e.company.Id);

        ShareCostLabel.text = Format.Money(cost);
    }
 private static bool IsCanTakeIPOGoal(GameEntity company, GameContext gameContext, InvestorGoal nextGoal)
 {
     return(nextGoal == InvestorGoal.GrowCompanyCost && Economy.GetCompanyCost(gameContext, company.company.Id) > Balance.IPO_REQUIREMENTS_COMPANY_COST / 2);
 }
    public override string RenderValue()
    {
        var rank = Economy.GetCompanyCost(Q, MyCompany);

        return($"{Format.Money(rank)}");
    }
Exemple #29
0
    void RenderCompanyEconomy()
    {
        var cost = Economy.GetCompanyCost(Q, SelectedCompany.company.Id);

        CompanyValuation.text = Format.Money(cost);
    }
Exemple #30
0
    public override string RenderValue()
    {
        var cost = Economy.GetCompanyCost(Q, MyCompany);

        return(Visuals.Link($"Head company: {MyCompany.company.Name} ({Format.Money(cost)})"));
    }