Beispiel #1
0
        /// <summary>
        /// checks inside. Wouldn't pay if can't. Takes credits from bank
        /// Register moneyIncomethisTurn, pays tax. Returns true if was able pay
        /// </summary>
        public bool pay(Agent incomeReceiver, Value howMuch, bool showMessageAboutNegativeValue = true)
        {
            if (howMuch.isNotZero())
            {
                if (payWithoutRecord(incomeReceiver, howMuch, showMessageAboutNegativeValue))
                {
                    Value howMuchPayReally = howMuch.Copy();
                    incomeReceiver.moneyIncomethisTurn.Add(howMuchPayReally);
                    if (incomeReceiver is Market) // Market wouldn't pay taxes cause it's abstract entity
                    {
                        return(true);
                    }
                    Agent payer = this;

                    if (payer is Market == false && //&& incomeReceiver is Market == false
                        payer.GetCountry() != incomeReceiver.GetCountry() &&
                        payer is Factory)    // pay taxes in enterprise jurisdiction only if it's factory
                    {
                        var payed = payer.GetCountry().TakeIncomeTaxFrom(incomeReceiver, howMuchPayReally, false);
                        howMuchPayReally.subtract(payed);//and reduce taxable base
                    }

                    // in rest cases only pops pay taxes
                    var popReceiver = incomeReceiver as PopUnit;
                    if (popReceiver != null)
                    {
                        incomeReceiver.GetCountry().TakeIncomeTaxFrom(popReceiver, howMuchPayReally, popReceiver.popType.isPoorStrata());
                    }
                    //else // if it's not Pop than it should by dividends from enterprise..
                    //{
                    //    //var countryPayer = incomeReceiver as Country;
                    //    //if (countryPayer != null)
                    //        incomeReceiver.GetCountry().TakeIncomeTaxFrom(incomeReceiver, howMuchPayReally, false);
                    //}
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
 /// <summary>
 ///checks outside
 /// </summary>
 //internal bool giveMoneyIf(Consumer taker, Value howMuch)
 //{
 //
 //        Value needLoan = howMuch.subtractOutside(taker.cash);
 //        if (this.canGiveMoney(taker, needLoan))
 //        {
 //            this.giveMoney(taker, needLoan);
 //            return true;
 //        }
 //
 //    return false;
 //}
 /// <summary>
 /// Gives credit. Checks inside. Just wouldn't give money if can't
 /// </summary>
 internal bool giveLackingMoney(Agent taker, ReadOnlyValue sum)
 {
     if (taker.GetCountry().Invented(Invention.Banking))// find money in bank?
     {
         Value lackOfSum = sum.Copy().subtract(taker.cash);
         if (canGiveMoney(taker, lackOfSum))
         {
             giveMoney(taker, lackOfSum);
             return(true);
         }
     }
     return(false);
 }
Beispiel #3
0
 /// <summary>
 /// Doesn't care about builder reforms
 /// </summary>
 internal bool canBuildNewFactory(Province where, Agent investor)
 {
     if (where.hasFactory(this))
     {
         return(false);
     }
     if (isResourceGathering() && basicProduction.getProduct() != where.getResource()
         //|| !where.GetCountry().isInvented(basicProduction.getProduct())
         || !investor.GetCountry().Invented(this)
         //|| isManufacture() && !investor.GetCountry().Invented(Invention.Manufactures)
         //|| (basicProduction.getProduct() == Product.Cattle && !investor.GetCountry().Invented(Invention.Domestication))
         || !allowsForeignInvestments.checkIftrue(investor, where)
         )
     {
         return(false);
     }
     return(true);
 }