Esempio n. 1
0
        /// <summary>  Return in pieces basing on current prices and needs  /// </summary>
        //override public float getLocalEffectiveDemand(Product product)
        //{
        //    return getLocalEffectiveDemand(product, getWorkForceFulFilling());
        //}

        /// <summary>
        /// per level
        /// </summary>
        internal Procent getEfficiency(bool useBonuses)
        {
            //limit production by smallest factor
            Procent efficencyFactor;
            Procent workforceProcent = GetWorkForceFulFilling();
            Procent inputFactor      = getInputFactor();

            if (inputFactor.isZero() & isJustHiredPeople())
            {
                inputFactor = Procent.HundredProcent.Copy();
            }

            if (inputFactor.isSmallerThan(workforceProcent))
            {
                efficencyFactor = inputFactor;
            }
            else
            {
                efficencyFactor = workforceProcent;
            }
            //float basicEff = efficencyFactor * getLevel();
            //Procent result = new Procent(basicEff);
            //Procent result = new Procent(efficencyFactor);
            if (useBonuses)
            {
                efficencyFactor.set(efficencyFactor.get() * modifierEfficiency.getModifier(this), false);
            }
            return(efficencyFactor);
        }
Esempio n. 2
0
        internal void CalcMarketPrice()
        {
            var isOnsale = IsOnSale();

            if (isOnsale || parent.IsClosed)
            {
                // reduce price
                marketPriceModifier.Subtract(0.001f, false);
                if (marketPriceModifier.isZero())
                {
                    marketPriceModifier.Set(0.001f);
                }
            }
            if (!isOnsale && parent.IsOpen) //rise price
            {
                marketPriceModifier.Add(0.01f);
            }
        }
Esempio n. 3
0
        protected Procent getInputFactor(Procent multiplier)
        {
            if (multiplier.isZero())
            {
                return(Procent.ZeroProcent.Copy());
            }
            if (type.isResourceGathering())
            {
                return(Procent.HundredProcent.Copy());
            }

            List <Storage> reallyNeedResources = new List <Storage>();

            //Storage available;

            // how much we really want
            foreach (Storage input in type.resourceInput)
            {
                reallyNeedResources.Add(input.Copy().Multiply(multiplier));
            }

            // checking if there is enough in market
            //old DSB
            //foreach (Storage input in realInput)
            //{
            //    available = Country.market.HowMuchAvailable(input);
            //    if (available.get() < input.get())
            //        input.set(available);
            //}

            // check if we have enough resources
            foreach (Storage resource in reallyNeedResources)
            {
                Storage haveResource = getInputProductsReserve().getBiggestStorage(resource.Product);
                //if (!getInputProductsReserve().has(resource))
                if (haveResource.isSmallerThan(resource))
                {
                    // what we really have
                    resource.set(haveResource);
                }
            }
            //old last turn consumption checking thing
            //foreach (Storage input in realInput)
            //{
            //    //if (Country.market.getDemandSupplyBalance(input.Product) >= 1f)
            //    //available = input

            //    available = consumedLastTurn.findStorage(input.Product);
            //    if (available == null)
            //        ;// do nothing - pretend there is 100%, it fires only on shownFactory start
            //    else
            //    if (!justHiredPeople && available.get() < input.get())
            //        input.set(available);
            //}
            // checking if there is enough money to pay for
            // doesn't have sense with inputReserv
            //foreach (Storage input in realInput)
            //{
            //    Storage howMuchCan = wallet.HowMuchCanAfford(input);
            //    input.set(howMuchCan.get());
            //}
            var inputFactor = Procent.HundredProcent.Copy();

            // searching lowest factor
            foreach (Storage need in reallyNeedResources)
            {
                Value denominator = type.resourceInput.GetFirstSubstituteStorage(need.Product).Copy().Multiply(multiplier);
                if (denominator.isNotZero())
                {
                    var newfactor = new Procent(need, denominator);
                    if (newfactor.isSmallerThan(inputFactor))
                    {
                        inputFactor = newfactor;
                    }
                }
                else // no resources
                {
                    inputFactor.Set(0f);
                }
            }
            return(inputFactor);
        }
Esempio n. 4
0
        protected Procent getInputFactor(Procent multiplier)
        {
            if (multiplier.isZero())
            {
                return(Procent.ZeroProcent);
            }
            if (getType().isResourceGathering())
            {
                return(Procent.HundredProcent);
            }
            float          inputFactor         = 1;
            List <Storage> reallyNeedResources = new List <Storage>();

            //Storage available;

            // how much we really want
            foreach (Storage input in getType().resourceInput)
            {
                reallyNeedResources.Add(input.multiplyOutside(multiplier));
            }

            // checking if there is enough in market
            //old DSB
            //foreach (Storage input in realInput)
            //{
            //    available = Game.market.HowMuchAvailable(input);
            //    if (available.get() < input.get())
            //        input.set(available);
            //}

            // check if we have enough resources
            foreach (Storage resource in reallyNeedResources)
            {
                Storage haveResource = getInputProductsReserve().getBiggestStorage(resource.getProduct());
                //if (!getInputProductsReserve().has(resource))
                if (haveResource.isSmallerThan(resource))
                {
                    // what we really have
                    resource.set(haveResource);
                }
            }
            //old last turn consumption checking thing
            //foreach (Storage input in realInput)
            //{

            //    //if (Game.market.getDemandSupplyBalance(input.getProduct()) >= 1f)
            //    //available = input

            //    available = consumedLastTurn.findStorage(input.getProduct());
            //    if (available == null)
            //        ;// do nothing - pretend there is 100%, it fires only on shownFactory start
            //    else
            //    if (!justHiredPeople && available.get() < input.get())
            //        input.set(available);
            //}
            // checking if there is enough money to pay for
            // doesn't have sense with inputReserv
            //foreach (Storage input in realInput)
            //{
            //    Storage howMuchCan = wallet.HowMuchCanAfford(input);
            //    input.set(howMuchCan.get());
            //}
            // searching lowest factor
            foreach (Storage need in reallyNeedResources)//todo optimize - convert into for i
            {
                float denominator = getType().resourceInput.getFirstStorage(need.getProduct()).get() * multiplier.get();
                if (denominator != 0f)
                {
                    float newFactor = need.get() / denominator;
                    if (newFactor < inputFactor)
                    {
                        inputFactor = newFactor;
                    }
                }
                else // no resources
                {
                    inputFactor = 0f;
                }
            }
            return(new Procent(inputFactor));
        }