Esempio n. 1
0
        private void changeProductionType()
        {
            var newProductionType = ProductionType.getAllInventedArtisanships(Country).
                                    Where(x => !x.isResourceGathering() && x.basicProduction.Product != Product.Education).Where(x => x.getPossibleProfit().isNotZero()).MaxBy(x => x.getPossibleProfit().Get());

            if (newProductionType != null)
            {
                if (artisansProduction == null ||
                    (artisansProduction != null && newProductionType != artisansProduction.Type))

                {
                    artisansProduction = new ArtisanProduction(newProductionType, Province, this);
                    base.changeProductionType(artisansProduction.Type.basicProduction.Product);
                }
            }
        }
Esempio n. 2
0
        public override void produce()
        {
            // artisan shouldn't work with PE
            if (getCountry().economy.getValue() == Economy.PlannedEconomy)
            {
                artisansProduction = null;
            }
            else
            {
                if (Game.Random.Next(Options.ArtisansChangeProductionRate) == 1
                    )// && (artisansProduction==null
                     //|| (artisansProduction !=null && needsFulfilled.isSmallerThan(Options.ArtisansChangeProductionLevel))))
                {
                    changeProductionType();
                }

                if (artisansProduction != null)
                {
                    if (artisansProduction.isAllInputProductsCollected())
                    {
                        artisansProduction.produce();
                        if (Economy.isMarket.checkIftrue(getCountry()))
                        {
                            sell(getGainGoodsThisTurn());
                            //sentToMarket.set(gainGoodsThisTurn);
                            //storage.setZero();
                            //Game.market.sentToMarket.add(gainGoodsThisTurn);
                        }
                        else if (getCountry().economy.getValue() == Economy.NaturalEconomy)
                        {
                            // send to market?
                            sell(getGainGoodsThisTurn());
                            //sentToMarket.set(gainGoodsThisTurn);
                            //storage.setZero();
                            //Game.market.sentToMarket.add(gainGoodsThisTurn);
                        }
                        else if (getCountry().economy.getValue() == Economy.PlannedEconomy)
                        {
                            storage.sendAll(getCountry().countryStorageSet);
                        }
                    }
                    //else
                    //   changeProductionType();
                }
            }
        }
Esempio n. 3
0
        private void changeProductionType()
        {
            KeyValuePair <FactoryType, float> result = new KeyValuePair <FactoryType, float>(null, 0f);

            foreach (FactoryType factoryType in FactoryType.getAllNonResourceTypes(getCountry()))
            {
                float possibleProfit = factoryType.getPossibleProfit().get();
                if (possibleProfit > result.Value)
                {
                    result = new KeyValuePair <FactoryType, float>(factoryType, possibleProfit);
                }
            }
            if (result.Key != null && (artisansProduction == null || artisansProduction != null && result.Key != artisansProduction.getType()))
            {
                artisansProduction = new ArtisanProduction(result.Key, getProvince(), this);
                base.changeProductionType(artisansProduction.getType().basicProduction.getProduct());
            }
        }
Esempio n. 4
0
 public override void produce()
 {
     // artisan shouldn't work with PE
     if (Country.economy.getValue() == Economy.PlannedEconomy)
     {
         artisansProduction = null;
     }
     else
     {
         Rand.Call(() => checkProfit(), 10);                    // changes production type if needed
         if (Rand.Chance(Options.ArtisansChangeProductionRate)) // check if it's best production type so far
         {
             changeProductionType();
         }
         if (artisansProduction != null)
         {
             //if (artisansProduction.isAllInputProductsCollected())
             {
                 artisansProduction.produce();
                 if (Economy.isMarket.checkIfTrue(Country))
                 {
                     if (getGainGoodsThisTurn().isNotZero())
                     {
                         sell(getGainGoodsThisTurn());
                     }
                 }
                 else if (Country.economy.getValue() == Economy.NaturalEconomy)
                 {
                     // send to market?
                     if (getGainGoodsThisTurn().isNotZero())
                     {
                         sell(getGainGoodsThisTurn());
                     }
                 }
                 else if (Country.economy.getValue() == Economy.PlannedEconomy)
                 {
                     storage.sendAll(Country.countryStorageSet);
                 }
             }
             //else
             //   changeProductionType();
         }
     }
 }
Esempio n. 5
0
 override protected void deleteData()
 {
     base.deleteData();
     artisansProduction = null;
 }
Esempio n. 6
0
 public override void Kill()
 {
     base.Kill();
     artisansProduction = null;
 }