示例#1
0
        public override void consumeNeeds()
        {
            base.consumeNeeds();
            if (artisansProduction != null)
            {
                PayWithoutRecord(artisansProduction, Cash);

                // take loan if don't have enough money to buy inputs
                if (Country.Invented(Invention.Banking) && !artisansProduction.isAllInputProductsCollected() &&
                    artisansProduction.Type.getPossibleProfit().isNotZero())
                {
                    var needs = artisansProduction.getRealAllNeeds();
                    if (!artisansProduction.CanAfford(needs))
                    {
                        var loanSize = World.market.getCost(needs); // takes little more than really need, could be fixed
                        Bank.GiveCredit(this, loanSize);
                        PayWithoutRecord(artisansProduction, Cash);
                    }
                }

                artisansProduction.consumeNeeds();
                artisansProduction.PayWithoutRecord(this, artisansProduction.Cash);

                // consuming made in artisansProduction.consumeNeeds()
                // here is data transferring
                // todo rework data transferring from artisans?
                getConsumedInMarket().Add(artisansProduction.getConsumedInMarket());
                getConsumed().Add(artisansProduction.getConsumed());
                getConsumedLastTurn().Add(artisansProduction.getConsumedLastTurn());
            }
        }
示例#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();
                }
            }
        }