Ejemplo n.º 1
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)})";
    }
Ejemplo n.º 2
0
    void RenderProposalStatus(bool willAcceptOffer, long progress, AcquisitionConditions SellerOffer)
    {
        var cost = Economy.CostOf(SelectedCompany, Q);

        Response.text = $"Cash: {Format.Money(SellerOffer.Price)} (Real valuation = {Format.Money(cost)})";

        var o = AcquisitionOffer;

        if (o.Turn == AcquisitionTurn.Seller)
        {
            // ProposalStatus
            Response.text += "\nThey will respond in a month or so";

            //if (!ScheduleUtils.IsTimerRunning(Q))
            //    ProposalStatus.text += Visuals.Negative("Unpause") + " to get their response";
        }
        //else
        //{
        //    //var status = $"{progress}% of owners want to accept your offer";
        //    //var textDescription = willAcceptOffer ? Visuals.Positive("They will accept offer!") : Visuals.Negative("They will not accept offer!");

        //    //ProposalStatus.text = status; // + "\n" + textDescription;
        //}

        ProgressText.text  = progress + "%";
        ProgressText.color = Visuals.GetColorPositiveOrNegative(willAcceptOffer);
    }
Ejemplo n.º 3
0
    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));
        }
    }
        public static GameEntity CreateAcquisitionOffer(GameContext gameContext, int companyId, int buyerInvestorId)
        {
            var offer = gameContext.CreateEntity();

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

            var buyerOffer = new AcquisitionConditions
            {
                Price           = cost,
                ByCash          = cost,
                ByShares        = 0,
                KeepLeaderAsCEO = true
            };

            var sellerOffer = new AcquisitionConditions
            {
                Price           = cost * 4,
                ByCash          = cost * 4,
                ByShares        = 0,
                KeepLeaderAsCEO = true
            };

            offer.AddAcquisitionOffer(companyId, buyerInvestorId, AcquisitionTurn.Buyer, buyerOffer, sellerOffer);

            var playerIsInvestor = GetInvestorById(gameContext, buyerInvestorId).isControlledByPlayer;

            if (playerIsInvestor)
            {
                Debug.Log("Create acquisition offer: " + GetCompanyName(gameContext, companyId));
            }

            return(offer);
        }
Ejemplo n.º 5
0
    void SendNewSellerOffer(GameEntity offer, GameEntity target, int shareholderId)
    {
        var o = offer.acquisitionOffer;

        var newPrice = GetNewPrice(target, shareholderId, o.BuyerOffer);

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

        offer.acquisitionOffer.Turn        = AcquisitionTurn.Buyer;
        offer.acquisitionOffer.SellerOffer = sellerConditions;
        //offer.ReplaceAcquisitionOffer(target.company.Id, shareholderId, AcquisitionTurn.Buyer, o.BuyerOffer, sellerConditions);

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

        if (investor.isControlledByPlayer)
        {
            NotificationUtils.AddPopup(gameContext, new PopupMessageAcquisitionOfferResponse(target.company.Id, shareholderId));
        }
    }
Ejemplo n.º 6
0
        public static GameEntity CreateAcquisitionOffer(GameContext gameContext, GameEntity company, GameEntity buyer)
        {
            var offer = gameContext.CreateEntity();

            var cost = Economy.CostOf(company, gameContext);

            var buyerOffer = new AcquisitionConditions
            {
                Price           = cost,
                ByCash          = cost,
                ByShares        = 0,
                KeepLeaderAsCEO = true
            };

            var sellerOffer = new AcquisitionConditions
            {
                Price           = cost * 4,
                ByCash          = cost * 4,
                ByShares        = 0,
                KeepLeaderAsCEO = true
            };

            offer.AddAcquisitionOffer(company.company.Id, buyer.shareholder.Id, AcquisitionTurn.Buyer, buyerOffer, sellerOffer);

            if (buyer.isControlledByPlayer)
            {
                Debug.Log("Create acquisition offer: " + GetName(company));
            }

            return(offer);
        }
    public void ReplacePreviousAcquisitionOffers(AcquisitionConditions newBuyerOffer, AcquisitionConditions newSellerOffer)
    {
        var index     = GameComponentsLookup.PreviousAcquisitionOffers;
        var component = (PreviousAcquisitionOffersComponent)CreateComponent(index, typeof(PreviousAcquisitionOffersComponent));

        component.BuyerOffer  = newBuyerOffer;
        component.SellerOffer = newSellerOffer;
        ReplaceComponent(index, component);
    }
Ejemplo n.º 8
0
    void RespondToOffers(GameEntity[] offers, int offerCount)
    {
        var sortedOffers = offers.OrderByDescending(o => o.acquisitionOffer.BuyerOffer.Price);

        var maxOffer = sortedOffers.First();

        var maxOfferedPrice = maxOffer.acquisitionOffer.BuyerOffer.Price;

        List <int> toRemove = new List <int>();

        var CompanyId = maxOffer.acquisitionOffer.CompanyId;

        var newSellerOffer = new AcquisitionConditions
        {
            ByCash = maxOfferedPrice,
            Price  = maxOfferedPrice,

            ByShares        = 0,
            KeepLeaderAsCEO = true,
        };

        for (var i = 0; i < offerCount; i++)
        {
            var o     = offers[i];
            var offer = o.acquisitionOffer;

            // increase prices to meet expectations
            var counterOffer = GetNewCounterOffer(o, CompanyId, offer.BuyerId, maxOfferedPrice);

            if (counterOffer.Price < maxOfferedPrice)
            {
                toRemove.Add(offer.BuyerId);
                continue;
            }

            o.ReplaceAcquisitionOffer(
                CompanyId, offer.BuyerId,
                AcquisitionTurn.Buyer,
                counterOffer,
                newSellerOffer);
        }

        foreach (var buyerId in toRemove)
        {
            Companies.RejectAcquisitionOffer(gameContext, CompanyId, buyerId);
        }

        var remainingOffers = Companies.GetAcquisitionOffersToCompany(gameContext, CompanyId);

        if (remainingOffers.Count() == 1)
        {
            Debug.Log("WON IN COMPETITION FOR COMPANY " + Companies.Get(gameContext, CompanyId));
            AcceptOffer(CompanyId, remainingOffers.First().acquisitionOffer.BuyerId);
        }
    }
Ejemplo n.º 9
0
    long GetNewPrice(GameEntity target, int shareholderId, AcquisitionConditions BuyerOffer)
    {
        var cost = Economy.CostOf(target, gameContext);

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

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

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

        return((long)newPrice);
    }
Ejemplo n.º 10
0
    AcquisitionConditions GetBestAcquisitionOffer(GameEntity[] offers, GameEntity target)
    {
        var sortedOffers = offers.OrderByDescending(o => o.acquisitionOffer.BuyerOffer.Price);

        var maxOffer = sortedOffers.First();

        var maxOfferedPrice = maxOffer.acquisitionOffer.BuyerOffer.Price;

        var newSellerOffer = new AcquisitionConditions
        {
            ByCash = maxOfferedPrice,
            Price  = maxOfferedPrice,

            ByShares        = 0,
            KeepLeaderAsCEO = true,
        };

        return(newSellerOffer);
    }
Ejemplo n.º 11
0
    void RenderCashOffer(AcquisitionConditions BuyerOffer, AcquisitionTurn turn)
    {
        var  cost  = Economy.CostOf(SelectedCompany, Q);
        long price = BuyerOffer.Price;

        string overpriceText = "";

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

        Offer.text          = Format.Money(price) + overpriceText;
        CashOfferInput.text = price.ToString();


        Draw(CashOfferInput, turn == AcquisitionTurn.Buyer);
        Draw(CashOfferContainer, turn == AcquisitionTurn.Buyer);
    }
Ejemplo n.º 12
0
    void RenderShareOffer(AcquisitionConditions conditions)
    {
        long price = conditions.Price;

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

        var ourCompanyCost = Economy.CostOf(MyCompany, Q);


        var maxAllowedShareCost = 25 * ourCompanyCost / 100;

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



        Slider.minValue = 0;
        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)})";
    }
Ejemplo n.º 13
0
    public void ReplaceAcquisitionOffer(int newCompanyId, int newBuyerId, AcquisitionTurn newTurn, AcquisitionConditions newBuyerOffer, AcquisitionConditions newSellerOffer)
    {
        var index     = GameComponentsLookup.AcquisitionOffer;
        var component = (AcquisitionOfferComponent)CreateComponent(index, typeof(AcquisitionOfferComponent));

        component.CompanyId   = newCompanyId;
        component.BuyerId     = newBuyerId;
        component.Turn        = newTurn;
        component.BuyerOffer  = newBuyerOffer;
        component.SellerOffer = newSellerOffer;
        ReplaceComponent(index, component);
    }
Ejemplo n.º 14
0
        public static void TweakAcquisitionConditions(GameContext gameContext, int companyId, int buyerInvestorId, AcquisitionConditions newConditions)
        {
            var off = GetAcquisitionOffer(gameContext, companyId, buyerInvestorId);

            off.ReplaceAcquisitionOffer(
                companyId,
                buyerInvestorId,
                off.acquisitionOffer.Turn,
                newConditions,
                off.acquisitionOffer.SellerOffer
                );
        }
Ejemplo n.º 15
0
 public bool IsBetterThan(AcquisitionConditions offer)
 {
     return(this.Price >= offer.Price);
 }
Ejemplo n.º 16
0
        public static void TweakAcquisitionConditions(GameContext gameContext, GameEntity company, GameEntity buyer, AcquisitionConditions newConditions)
        {
            var off = GetAcquisitionOffer(gameContext, company, buyer);

            off.ReplaceAcquisitionOffer(
                company.company.Id,
                buyer.shareholder.Id,
                off.acquisitionOffer.Turn,
                newConditions,
                off.acquisitionOffer.SellerOffer
                );
        }