Ejemplo n.º 1
0
        /// <summary>
        /// For artisans. Not including salary
        /// </summary>
        public MoneyView getPossibleProfit(Market market)
        {
            if (market
                .
                getDemandSupplyBalance(
                    basicProduction
                    .
                    Product, false) == Options.MarketZeroDSB)
            {
                return(new MoneyView(0)); // no demand for result product
            }
            MoneyView income = market.getCost(basicProduction);

            if (hasInput())
            {
                // change to minimal hire limits
                foreach (Storage inputProduct in resourceInput)
                {
                    if (!market.isAvailable(inputProduct.Product))
                    {
                        return(new MoneyView(0));// inputs are unavailable
                    }
                }
                return(income.Copy().Subtract(market.getCost(resourceInput), false));
            }
            return(income);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Makes sure that pops consume product in cheap-first order
        /// </summary>
        public static void sortNeeds(Market market)
        {
            foreach (var item in allPopTypes)
            {
                item.everyDayNeeds.Sort(delegate(Storage x, Storage y)
                {
                    return(market.getCost(x).Get().CompareTo(market.getCost(y).Get()));
                });

                item.luxuryNeeds.Sort(delegate(Storage x, Storage y)
                {
                    return(market.getCost(x).Get().CompareTo(market.getCost(y).Get()));
                });
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///Returns new value
        /// </summary>
        public MoneyView GetBuildCost(Market market)
        {
            Money result = market.getCost(GetBuildNeeds()).Copy();

            result.Add(Options.factoryMoneyReservePerLevel);
            return(result);
        }
Ejemplo n.º 4
0
 public static void sortSubstitutes(Market market)
 {
     foreach (var item in All().Where(x => x.isAbstract()))
     //if (item.isTradable())
     // Abstract are always invented and not gold
     {
         item.substitutes.Sort(delegate(Product x, Product y)
         {
             //if (x == null && y == null) return 0;
             //else
             //if (x.PartName == null) return -1;
             //else if (y.PartName == null) return 1;
             //else
             return(market.getCost(x).Get().CompareTo(market.getCost(y).Get()));
         });
     }
 }