Esempio n. 1
0
 /// <summary>
 /// Do checks outside
 /// </summary>
 public void sell(Storage what)
 {
     sentToMarket.add(what);
     //countryStorageSet.subtract(what);
     countryStorageSet.subtractNoStatistic(what); // to avoid getting what in "howMuchUsed" statistics
     Game.market.sentToMarket.add(what);
 }
Esempio n. 2
0
 internal void upgrade(Agent byWhom)
 {
     upgrading = true;
     constructionNeeds.add(getUpgradeNeeds().getCopy());
     if (byWhom.getCountry().economy.getValue() != Economy.PlannedEconomy)
     {
         byWhom.payWithoutRecord(this, Game.market.getCost(getUpgradeNeeds()));
     }
 }
Esempio n. 3
0
        public void consume(Country owner)
        {
            var needs = getRealNeeds(owner);

            float   shortage        = 0f;
            Storage realConsumption = Storage.EmptyProduct;

            foreach (var need in needs)
            {
                if (owner.countryStorageSet.has(need))
                {
                    if (need.isAbstractProduct())
                    {
                        // convertToBiggestStorageProduct here are duplicated in this.getConsumptionProcent() (getBiggestStorage())
                        realConsumption = owner.countryStorageSet.convertToBiggestStorage(need);
                    }
                    else
                    {
                        realConsumption = need;
                    }
                    if (realConsumption.isNotZero())
                    {
                        owner.consumeFromCountryStorage(realConsumption, owner);
                        //owner.countryStorageSet.subtract(realConsumption);
                        consumption.add(realConsumption);
                    }
                }
                else
                {
                    shortage += need.get();
                }
            }

            float moraleChange = getConsumptionProcent(Product.Food, owner).get() - morale.get();

            moraleChange = Mathf.Clamp(moraleChange, Options.ArmyMaxMoralChangePerTic * -1f, Options.ArmyMaxMoralChangePerTic);
            if (morale.get() + moraleChange < 0)
            {
                morale.set(0f);
            }
            else
            {
                morale.add(moraleChange);
            }
            if (this.origin.popType == PopType.Soldiers && morale.isBiggerThan(origin.loyalty))
            {
                morale.set(origin.loyalty);
            }

            if (morale.isBiggerThan(Procent.HundredProcent))
            {
                morale.set(1f);
            }
            //if (getPopUnit().loyalty.isSmallerThan(Options.PopMinLoyaltyToMobilizeForGovernment))
            //    getCountry().demobilize(x => x.getPopUnit() == this);
        }
Esempio n. 4
0
        override public List <Storage> getRealAllNeeds()
        {
            StorageSet res = new StorageSet();

            foreach (var item in allArmies)
            {
                res.add(item.getNeeds());
            }
            return(res.getContainer());
        }
Esempio n. 5
0
        public StorageSet getNeeds()
        {
            StorageSet res = new StorageSet();

            foreach (var item in personal)
            {
                res.add(item.Value.getRealNeeds(getOwner().getPlaceDejure()));
            }
            return(res);
        }
Esempio n. 6
0
        private StorageSet getConsumption()
        {
            var consumption = new StorageSet();

            foreach (var item in personal)
            {
                consumption.add(item.Value.getConsumption());
            }


            //    Procent res = new Procent(0f);
            //int calculatedSize = 0;
            //foreach (var item in personal)
            //{
            //    res.addPoportionally(calculatedSize, item.Value.getSize(), item.Value.getConsumption());
            //    calculatedSize += item.Value.getSize();
            //}
            //return res;
            return(consumption);
        }
Esempio n. 7
0
 // Do I use where need to? Yes, I do. It goes to Market.Buy()
 public void consumeFromMarket(Storage what)
 {
     consumed.add(what);
     consumedInMarket.add(what);
     Game.market.sentToMarket.subtract(what);
 }