Example #1
0
        int PurchaseDM(World world, TradeGood good)
        {
            int purchase = int.MinValue;
            int sale     = int.MinValue;


            foreach (var item in good.PurchaseDMs)
            {
                if (world.ContainsRemark(item.Tag))
                {
                    purchase = Math.Max(purchase, item.Bonus);
                }
            }

            foreach (var item in good.SaleDMs)
            {
                if (world.ContainsRemark(item.Tag))
                {
                    sale = Math.Max(sale, item.Bonus);
                }
            }

            if (purchase == int.MinValue)
            {
                purchase = 0;
            }
            if (sale == int.MinValue)
            {
                sale = 0;
            }
            return(purchase - sale);
        }
Example #2
0
 int SaleDM(World world, TradeGood good)
 {
     return -PurchaseDM(world, good);
 }
Example #3
0
        int PurchaseDM(World world, TradeGood good)
        {
            int purchase = int.MinValue;
            int sale = int.MinValue;


            foreach (var item in good.PurchaseDMs)
                if (world.ContainsRemark(item.Tag))
                    purchase = Math.Max(purchase, item.Bonus);

            foreach (var item in good.SaleDMs)
                if (world.ContainsRemark(item.Tag))
                    sale = Math.Max(sale, item.Bonus);

            if (purchase == int.MinValue)
                purchase = 0;
            if (sale == int.MinValue)
                sale = 0;
            return purchase - sale;
        }
Example #4
0
        private void AddTradeGood(World origin, Dice random, IList<TradeOffer> result, TradeGood good, bool advancedMode, int brokerScore)
        {
            if (string.IsNullOrEmpty(good.Tons))
                throw new ArgumentException("good.Tons is empty for " + good.Name);


            if (good.BasePrice == 0) //special case
            {
                var detail = good.ChooseRandomDetail(random);
                var lot = new TradeOffer()
                {
                    Type = good.Name,
                    Subtype = random.Choose(detail.NameList),
                    Tons = Math.Max(1, random.D(detail.Tons)),
                    BasePrice = detail.Price * 1000,
                    PurchaseDM = PurchaseDM(origin, good)
                };

                int roll;
                lot.PriceModifier = PurchasePriceModifier(random, lot.PurchaseDM, brokerScore, out roll);
                lot.Roll = roll;


                result.Add(lot);
            }
            else if (!advancedMode)
            {
                var lot = new TradeOffer()
                {
                    Type = good.Name,
                    Subtype = null,
                    Tons = random.D(good.Tons),
                    BasePrice = good.BasePrice * 1000,
                    PurchaseDM = PurchaseDM(origin, good)
                };

                int roll;
                lot.PriceModifier = PurchasePriceModifier(random, lot.PurchaseDM, brokerScore, out roll);
                lot.Roll = roll;

                result.Add(lot);
            }
            else
            {
                var tonsRemaining = random.D(good.Tons);
                while (tonsRemaining > 0)
                {
                    var detail = good.ChooseRandomDetail(random);
                    var lot = new TradeOffer()
                    {
                        Type = good.Name,
                        Subtype = random.Choose(detail.NameList),
                        Tons = Math.Min(tonsRemaining, random.D(detail.Tons)),
                        BasePrice = detail.Price * 1000,
                        PurchaseDM = PurchaseDM(origin, good)
                    };

                    int roll;
                    lot.PriceModifier = PurchasePriceModifier(random, lot.PurchaseDM, brokerScore, out roll);
                    lot.Roll = roll;


                    result.Add(lot);

                    tonsRemaining -= lot.Tons;
                }
            }
        }
Example #5
0
 int SaleDM(World world, TradeGood good)
 {
     return(-PurchaseDM(world, good));
 }
Example #6
0
        private void AddTradeGood(World origin, Dice random, IList <TradeOffer> result, TradeGood good, bool advancedMode, int brokerScore)
        {
            if (string.IsNullOrEmpty(good.Tons))
            {
                throw new ArgumentException("good.Tons is empty for " + good.Name);
            }


            if (good.BasePrice == 0) //special case
            {
                var detail = good.ChooseRandomDetail(random);
                var lot    = new TradeOffer()
                {
                    Type       = good.Name,
                    Subtype    = random.Choose(detail.NameList),
                    Tons       = Math.Max(1, random.D(detail.Tons)),
                    BasePrice  = detail.Price * 1000,
                    PurchaseDM = PurchaseDM(origin, good)
                };

                int roll;
                lot.PriceModifier = PurchasePriceModifier(random, lot.PurchaseDM, brokerScore, out roll);
                lot.Roll          = roll;


                result.Add(lot);
            }
            else if (!advancedMode)
            {
                var lot = new TradeOffer()
                {
                    Type       = good.Name,
                    Subtype    = null,
                    Tons       = random.D(good.Tons),
                    BasePrice  = good.BasePrice * 1000,
                    PurchaseDM = PurchaseDM(origin, good)
                };

                int roll;
                lot.PriceModifier = PurchasePriceModifier(random, lot.PurchaseDM, brokerScore, out roll);
                lot.Roll          = roll;

                result.Add(lot);
            }
            else
            {
                var tonsRemaining = random.D(good.Tons);
                while (tonsRemaining > 0)
                {
                    var detail = good.ChooseRandomDetail(random);
                    var lot    = new TradeOffer()
                    {
                        Type       = good.Name,
                        Subtype    = random.Choose(detail.NameList),
                        Tons       = Math.Min(tonsRemaining, random.D(detail.Tons)),
                        BasePrice  = detail.Price * 1000,
                        PurchaseDM = PurchaseDM(origin, good)
                    };

                    int roll;
                    lot.PriceModifier = PurchasePriceModifier(random, lot.PurchaseDM, brokerScore, out roll);
                    lot.Roll          = roll;


                    result.Add(lot);

                    tonsRemaining -= lot.Tons;
                }
            }
        }