상속: IBuyItemInfo
예제 #1
0
        private GenericBuyInfo LookupDisplayObject(object obj)
        {
            IBuyItemInfo[] buyInfo = this.GetBuyInfo();

            for (int i = 0; i < buyInfo.Length; ++i)
            {
                GenericBuyInfo gbi = (GenericBuyInfo)buyInfo[i];

                if (gbi.GetDisplayEntity() == obj)
                {
                    return(gbi);
                }
            }

            return(null);
        }
예제 #2
0
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write((int)1);               // version

            List <SBInfo> sbInfos = this.SBInfos;

            for (int i = 0; sbInfos != null && i < sbInfos.Count; ++i)
            {
                SBInfo sbInfo = sbInfos[i];
                List <GenericBuyInfo> buyInfo = sbInfo.BuyInfo;

                for (int j = 0; buyInfo != null && j < buyInfo.Count; ++j)
                {
                    GenericBuyInfo gbi = (GenericBuyInfo)buyInfo[j];

                    int maxAmount = gbi.MaxAmount;
                    int doubled   = 0;

                    switch (maxAmount)
                    {
                    case  40: doubled = 1; break;

                    case  80: doubled = 2; break;

                    case 160: doubled = 3; break;

                    case 320: doubled = 4; break;

                    case 640: doubled = 5; break;

                    case 999: doubled = 6; break;
                    }

                    if (doubled > 0)
                    {
                        writer.WriteEncodedInt(1 + j * sbInfos.Count + i);
                        writer.WriteEncodedInt(doubled);
                    }
                }
            }

            writer.WriteEncodedInt(0);
        }
예제 #3
0
        public virtual bool OnBuyItems(Mobile buyer, List <BuyItemResponse> list)
        {
            if (!IsActiveSeller)
            {
                return(false);
            }

            if (!buyer.CheckAlive())
            {
                return(false);
            }

            if (!CheckVendorAccess(buyer))
            {
                Say(501522);                   // I shall not treat with scum like thee!
                return(false);
            }

            IBuyItemInfo[]         buyInfo   = this.GetBuyInfo();
            IShopSellInfo[]        info      = GetSellInfo();
            int                    totalCost = 0;
            List <BuyItemResponse> validBuy  = new List <BuyItemResponse>(list.Count);
            Container              cont;
            bool                   bought       = false;
            bool                   fromBank     = false;
            bool                   fullPurchase = true;
            int                    controlSlots = buyer.FollowersMax - buyer.Followers;

            foreach (BuyItemResponse buy in list)
            {
                Serial ser    = buy.Serial;
                int    amount = buy.Amount;

                if (ser.IsItem)
                {
                    Item item = World.FindItem(ser);

                    if (item == null)
                    {
                        continue;
                    }

                    GenericBuyInfo gbi = LookupDisplayObject(item);

                    if (gbi != null)
                    {
                        ProcessSinglePurchase(buy, gbi, validBuy, ref controlSlots, ref fullPurchase, ref totalCost);
                    }
                    else if (item != this.BuyPack && item.IsChildOf(this.BuyPack))
                    {
                        if (amount > item.Amount)
                        {
                            amount = item.Amount;
                        }

                        if (amount <= 0)
                        {
                            continue;
                        }

                        foreach (IShopSellInfo ssi in info)
                        {
                            if (ssi.IsSellable(item))
                            {
                                if (ssi.IsResellable(item))
                                {
                                    totalCost += ssi.GetBuyPriceFor(item) * amount;
                                    validBuy.Add(buy);
                                    break;
                                }
                            }
                        }
                    }
                }
                else if (ser.IsMobile)
                {
                    Mobile mob = World.FindMobile(ser);

                    if (mob == null)
                    {
                        continue;
                    }

                    GenericBuyInfo gbi = LookupDisplayObject(mob);

                    if (gbi != null)
                    {
                        ProcessSinglePurchase(buy, gbi, validBuy, ref controlSlots, ref fullPurchase, ref totalCost);
                    }
                }
            }            //foreach

            if (fullPurchase && validBuy.Count == 0)
            {
                SayTo(buyer, 500190);                   // Thou hast bought nothing!
            }
            else if (validBuy.Count == 0)
            {
                SayTo(buyer, 500187);                   // Your order cannot be fulfilled, please try again.
            }
            if (validBuy.Count == 0)
            {
                return(false);
            }

            bought = buyer.AccessLevel >= AccessLevel.GameMaster;

            cont = buyer.Backpack;
            if (!bought && cont != null)
            {
                if (cont.ConsumeTotal(typeof(Gold), totalCost))
                {
                    bought = true;
                }
                else if (totalCost < 2000)
                {
                    SayTo(buyer, 500192);                       // Begging thy pardon, but thou canst not afford that.
                }
            }

            if (!bought && totalCost >= 2000)
            {
                cont = buyer.FindBankNoCreate();
                if (cont != null && cont.ConsumeTotal(typeof(Gold), totalCost))
                {
                    bought   = true;
                    fromBank = true;
                }
                else
                {
                    SayTo(buyer, 500191);                       //Begging thy pardon, but thy bank account lacks these funds.
                }
            }

            if (!bought)
            {
                return(false);
            }
            else
            {
                buyer.PlaySound(0x32);
            }

            cont = buyer.Backpack;
            if (cont == null)
            {
                cont = buyer.BankBox;
            }

            foreach (BuyItemResponse buy in validBuy)
            {
                Serial ser    = buy.Serial;
                int    amount = buy.Amount;

                if (amount < 1)
                {
                    continue;
                }

                if (ser.IsItem)
                {
                    Item item = World.FindItem(ser);

                    if (item == null)
                    {
                        continue;
                    }

                    GenericBuyInfo gbi = LookupDisplayObject(item);

                    if (gbi != null)
                    {
                        ProcessValidPurchase(amount, gbi, buyer, cont);
                    }
                    else
                    {
                        if (amount > item.Amount)
                        {
                            amount = item.Amount;
                        }

                        foreach (IShopSellInfo ssi in info)
                        {
                            if (ssi.IsSellable(item))
                            {
                                if (ssi.IsResellable(item))
                                {
                                    Item buyItem;
                                    if (amount >= item.Amount)
                                    {
                                        buyItem = item;
                                    }
                                    else
                                    {
                                        buyItem = Mobile.LiftItemDupe(item, item.Amount - amount);

                                        if (buyItem == null)
                                        {
                                            buyItem = item;
                                        }
                                    }

                                    if (cont == null || !cont.TryDropItem(buyer, buyItem, false))
                                    {
                                        buyItem.MoveToWorld(buyer.Location, buyer.Map);
                                    }

                                    break;
                                }
                            }
                        }
                    }
                }
                else if (ser.IsMobile)
                {
                    Mobile mob = World.FindMobile(ser);

                    if (mob == null)
                    {
                        continue;
                    }

                    GenericBuyInfo gbi = LookupDisplayObject(mob);

                    if (gbi != null)
                    {
                        ProcessValidPurchase(amount, gbi, buyer, cont);
                    }
                }
            }            //foreach

            if (fullPurchase)
            {
                if (buyer.AccessLevel >= AccessLevel.GameMaster)
                {
                    SayTo(buyer, true, "I would not presume to charge thee anything.  Here are the goods you requested.");
                }
                else if (fromBank)
                {
                    SayTo(buyer, true, "The total of thy purchase is {0} gold, which has been withdrawn from your bank account.  My thanks for the patronage.", totalCost);
                }
                else
                {
                    SayTo(buyer, true, "The total of thy purchase is {0} gold.  My thanks for the patronage.", totalCost);
                }
            }
            else
            {
                if (buyer.AccessLevel >= AccessLevel.GameMaster)
                {
                    SayTo(buyer, true, "I would not presume to charge thee anything.  Unfortunately, I could not sell you all the goods you requested.");
                }
                else if (fromBank)
                {
                    SayTo(buyer, true, "The total of thy purchase is {0} gold, which has been withdrawn from your bank account.  My thanks for the patronage.  Unfortunately, I could not sell you all the goods you requested.", totalCost);
                }
                else
                {
                    SayTo(buyer, true, "The total of thy purchase is {0} gold.  My thanks for the patronage.  Unfortunately, I could not sell you all the goods you requested.", totalCost);
                }
            }

            return(true);
        }
예제 #4
0
        public virtual void VendorBuy(Mobile from)
        {
            if (!IsActiveSeller)
            {
                return;
            }

            if (!from.CheckAlive())
            {
                return;
            }

            if (!CheckVendorAccess(from))
            {
                Say(501522);                   // I shall not treat with scum like thee!
                return;
            }

            if (DateTime.Now - m_LastRestock > RestockDelay)
            {
                Restock();
            }

            int count = 0;
            List <BuyItemState> list;

            IBuyItemInfo[]  buyInfo  = this.GetBuyInfo();
            IShopSellInfo[] sellInfo = this.GetSellInfo();

            list = new List <BuyItemState>(buyInfo.Length);
            Container cont = this.BuyPack;

            List <ObjectPropertyList> opls = null;

            for (int idx = 0; idx < buyInfo.Length; idx++)
            {
                IBuyItemInfo buyItem = (IBuyItemInfo)buyInfo[idx];

                if (buyItem.Amount <= 0 || list.Count >= 250)
                {
                    continue;
                }

                // NOTE: Only GBI supported; if you use another implementation of IBuyItemInfo, this will crash
                GenericBuyInfo gbi  = (GenericBuyInfo)buyItem;
                IEntity        disp = gbi.GetDisplayEntity();

                list.Add(new BuyItemState(buyItem.Name, cont.Serial, disp == null ? (Serial)0x7FC0FFEE : disp.Serial, buyItem.Price, buyItem.Amount, buyItem.ItemID, buyItem.Hue));
                count++;

                if (opls == null)
                {
                    opls = new List <ObjectPropertyList>();
                }

                if (disp is Item)
                {
                    opls.Add((( Item )disp).PropertyList);
                }
                else if (disp is Mobile)
                {
                    opls.Add((( Mobile )disp).PropertyList);
                }
            }

            List <Item> playerItems = cont.Items;

            for (int i = playerItems.Count - 1; i >= 0; --i)
            {
                if (i >= playerItems.Count)
                {
                    continue;
                }

                Item item = playerItems[i];

                if (item.LastMoved + InventoryDecayTime <= DateTime.Now)
                {
                    item.Delete();
                }
            }

            for (int i = 0; i < playerItems.Count; ++i)
            {
                Item item = playerItems[i];

                int    price = 0;
                string name  = null;

                foreach (IShopSellInfo ssi in sellInfo)
                {
                    if (ssi.IsSellable(item))
                    {
                        price = ssi.GetBuyPriceFor(item);
                        name  = ssi.GetNameFor(item);
                        break;
                    }
                }

                if (name != null && list.Count < 250)
                {
                    list.Add(new BuyItemState(name, cont.Serial, item.Serial, price, item.Amount, item.ItemID, item.Hue));
                    count++;

                    if (opls == null)
                    {
                        opls = new List <ObjectPropertyList>();
                    }

                    opls.Add(item.PropertyList);
                }
            }

            //one (not all) of the packets uses a byte to describe number of items in the list.  Osi = dumb.
            //if ( list.Count > 255 )
            //	Console.WriteLine( "Vendor Warning: Vendor {0} has more than 255 buy items, may cause client errors!", this );

            if (list.Count > 0)
            {
                list.Sort(new BuyItemStateComparer());

                SendPacksTo(from);

                NetState ns = from.NetState;

                if (ns == null)
                {
                    return;
                }

                if (ns.ContainerGridLines)
                {
                    from.Send(new VendorBuyContent6017(list));
                }
                else
                {
                    from.Send(new VendorBuyContent(list));
                }

                from.Send(new VendorBuyList(this, list));

                if (ns.HighSeas)
                {
                    from.Send(new DisplayBuyListHS(this));
                }
                else
                {
                    from.Send(new DisplayBuyList(this));
                }

                from.Send(new MobileStatusExtended(from));                    //make sure their gold amount is sent

                if (opls != null)
                {
                    for (int i = 0; i < opls.Count; ++i)
                    {
                        from.Send(opls[i]);
                    }
                }

                SayTo(from, 500186);                   // Greetings.  Have a look around.
            }
        }
예제 #5
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            LoadSBInfo();

            List <SBInfo> sbInfos = this.SBInfos;

            switch (version)
            {
            case 1:
            {
                int index;

                while ((index = reader.ReadEncodedInt()) > 0)
                {
                    int doubled = reader.ReadEncodedInt();

                    if (sbInfos != null)
                    {
                        index -= 1;
                        int sbInfoIndex  = index % sbInfos.Count;
                        int buyInfoIndex = index / sbInfos.Count;

                        if (sbInfoIndex >= 0 && sbInfoIndex < sbInfos.Count)
                        {
                            SBInfo sbInfo = sbInfos[sbInfoIndex];
                            List <GenericBuyInfo> buyInfo = sbInfo.BuyInfo;

                            if (buyInfo != null && buyInfoIndex >= 0 && buyInfoIndex < buyInfo.Count)
                            {
                                GenericBuyInfo gbi = (GenericBuyInfo)buyInfo[buyInfoIndex];

                                int amount = 20;

                                switch (doubled)
                                {
                                case 1: amount = 40; break;

                                case 2: amount = 80; break;

                                case 3: amount = 160; break;

                                case 4: amount = 320; break;

                                case 5: amount = 640; break;

                                case 6: amount = 999; break;
                                }

                                gbi.Amount = gbi.MaxAmount = amount;
                            }
                        }
                    }
                }

                break;
            }
            }
        }
예제 #6
0
        public static int ComputePriceFor(HouseDeed deed)
        {
            int price = 0;

            /*if (deed is SmallBrickHouseDeed || deed is StonePlasterHouseDeed || deed is FieldStoneHouseDeed || deed is SmallBrickHouseDeed || deed is WoodHouseDeed || deed is WoodPlasterHouseDeed || deed is ThatchedRoofCottageDeed)
             * else if (deed is BrickHouseDeed)
             *      price = 144500;
             * else if (deed is TwoStoryWoodPlasterHouseDeed || deed is TwoStoryStonePlasterHouseDeed)
             *      price = 192400;
             * else if (deed is TowerDeed)
             *      price = 433200;
             * else if (deed is KeepDeed)
             *      price = 665200;
             * else if (deed is CastleDeed)
             *      price = 1022800;
             * else if (deed is LargePatioDeed)
             *      price = 152800;
             * else if (deed is LargeMarbleDeed)
             *      price = 192800;
             * else if (deed is SmallTowerDeed)
             *      price = 88500;
             * else if (deed is LogCabinDeed)
             *      price = 97800;
             * else if (deed is SandstonePatioDeed)
             *      price = 90900;
             * else if (deed is VillaDeed)
             *      price = 136500;
             * else if (deed is StoneWorkshopDeed)
             *      price = 60600;
             * else if (deed is MarbleWorkshopDeed)
             *      price = 60300;
             * else if (deed is StaticDeed) //pla: Allow our static houses to be sold back based on price in blueprint
             * {
             *      price = StaticHouseHelper.GetPrice(((StaticDeed)deed).HouseID);
             *
             *      //check for the failsafe price and if so set to 0 - dont want someone getting 8 million back!
             *      if (price == (int)StaticHouseHelper.Error.PriceError)
             *              price = 0;
             *
             *      // track the error
             *      Misc.Diagnostics.Assert(price != 0, "price == 0");
             * } */

            if (deed is HouseDeed)
            {
                price = deed.Price;
            }

            //check for the failsafe price and if so set to 0 - dont want someone getting 8 million back!
            if (price == (int)StaticHouseHelper.Error.PriceError)
            {
                price = 0;
            }

            // track the error
            Misc.Diagnostics.Assert(price != 0, "price == 0");

            // don't allow repurchase (or sale) of customs on siege. Before we can buy them back, we need to markup the sale price and that's not been done
            // on the player vendors in the special	housing area. (so they will make 300% profit!)
            if (Core.UOSP && !Misc.Diagnostics.Assert(deed is StaticDeed == false, "deed is StaticDeed for sale on siege!"))
            {
                price = 0;
            }

            // Publish 11
            // o) NPC real estate brokers will now buy house deeds back at 20% below the base price of the deed, or the original
            //	price paid when the deed was purchased from a vendor (whichever is lower).
            // o) House deed prices when reselling to real estate agents raised to the correct level on Siege Perilous
            if (!Core.UOAI && !Core.UOAR && !Core.UOMO && Core.Publish < 11)
            {
                return(GenericBuyInfo.ComputeSiegeMarkup(price)); // 100%
            }
            return(AOS.Scale(price, 80));                         // refunds 80% of the purchase price
        }
예제 #7
0
		private GenericBuyInfo LookupDisplayObject(object obj, bool bReturnBunchItem)
		{
			try
			{
				IBuyItemInfo[] buyInfo = this.GetBuyInfo();

				for (int i = 0; i < buyInfo.Length; ++i)
				{
					GenericBuyInfo gbi = buyInfo[i] as GenericBuyInfo;

					if (gbi.GetDisplayObject() == obj)
					{
						return gbi;
					}
					else if (ResourcePool.GetBunchType(gbi.Type) == obj.GetType())
					{
						if (bReturnBunchItem)
						{
							int price = gbi.BunchPrice;
							int amount = (gbi.Amount > 59900) ? 599 : gbi.Amount / 100;
							gbi = new GenericBuyInfo(obj.GetType(), price, amount, gbi.ItemID, 0);
						}

						return gbi;
					}
				}
			}
			catch (Exception exc)
			{
				LogHelper.LogException(exc);
				System.Console.WriteLine("Error with LookupDisplayObject.GetBuyInfo()");
				System.Console.WriteLine(exc.Message);
				System.Console.WriteLine(exc.StackTrace);
			}

			return null;
		}
예제 #8
0
		public virtual void VendorBuy(Mobile from)
		{
			try
			{
				// adam: add new sanity checks
				if (from == null || from.NetState == null)
					return;

				if (!IsActiveSeller)
					return;

				if (!from.CheckAlive())
					return;

				if (DateTime.Now - m_LastRestock > RestockDelay)
					Restock();

				int count = 0;
				ArrayList list;

				// Adam: Catch the exception
				IBuyItemInfo[] buyInfo = null;
				try
				{
					buyInfo = this.GetBuyInfo();
				}
				catch (Exception exc)
				{
					LogHelper.LogException(exc);
					System.Console.WriteLine("Error with GetBuyInfo() :: Please send output to Taran:");
					System.Console.WriteLine(exc.Message);
					System.Console.WriteLine(exc.StackTrace);
					// if buyInfo is null, we can't continue
					throw new ApplicationException("Error with GetBuyInfo()");
				}

				IShopSellInfo[] sellInfo = this.GetSellInfo();

				list = new ArrayList(buyInfo.Length);
				Container cont = this.BuyPack;

				ArrayList opls = new ArrayList();

				for (int idx = 0; idx < buyInfo.Length; idx++)
				{
					IBuyItemInfo buyItem = (IBuyItemInfo)buyInfo[idx];

					if (buyItem.Amount <= 0 || list.Count >= 250)
						continue;

					if (ResourcePool.IsPooledResource(buyItem.Type))
					{
						if (buyItem.Amount / 100 > 0)
						{
							Type bunchtype = ResourcePool.GetBunchType(buyItem.Type);
							if (bunchtype != null)
							{
								int price = buyItem.BunchPrice;
								int amount = (buyItem.Amount > 59900) ? 599 : buyItem.Amount / 100;
								GenericBuyInfo gbi = new GenericBuyInfo(
										bunchtype, price, amount, buyItem.ItemID, 0);
								IEntity disp = gbi.GetDisplayObject() as IEntity;
								//plasma: Implement city tax here, but only if the pool is empty (this prevents tax being applied to BBS sales)
								if (ResourcePool.GetTotalCount(buyItem.Type) == 0)
								{
									KinCityRegion kcr = KinCityRegion.GetKinCityAt(this);
									if (kcr != null && kcr.CityTaxRate > 0.0)
									{
										double tax = price * kcr.CityTaxRate;
										price += (int)Math.Floor(tax);
									}
								}
								list.Add(new BuyItemState(gbi.Name, cont.Serial, disp == null ? (Serial)0x7FC0FFEE : disp.Serial, gbi.Price, gbi.Amount, gbi.ItemID, gbi.Hue));
								count++;

								opls.Add((disp as Item).PropertyList);
							}
						}

						if (buyItem.Amount % 100 > 0)
						{
							
							GenericBuyInfo gbi = (GenericBuyInfo)buyItem;
							IEntity disp = gbi.GetDisplayObject() as IEntity;

							int price = buyItem.Price;
							int amount = buyItem.Amount % 100;

							//plasma: Implement city tax here, but only if the pool is empty (this prevents tax being applied to BBS sales)
							if (ResourcePool.GetTotalCount(buyItem.Type) == 0)
							{
								KinCityRegion kcr = KinCityRegion.GetKinCityAt(this);
								if (kcr != null && kcr.CityTaxRate > 0.0)
								{
									double tax = price * kcr.CityTaxRate;
									price += (int)Math.Floor(tax);
								}
							}
							list.Add(new BuyItemState(buyItem.Name, cont.Serial, disp == null ? (Serial)0x7FC0FFEE : disp.Serial, price, amount, buyItem.ItemID, buyItem.Hue));
							count++;

							if (disp is Item)
								opls.Add((disp as Item).PropertyList);
							else if (disp is Mobile)
								opls.Add((disp as Mobile).PropertyList);
						}

					}
					else
					{
						// NOTE: Only GBI supported; if you use another implementation of IBuyItemInfo, this will crash
						GenericBuyInfo gbi = (GenericBuyInfo)buyItem;
						IEntity disp = gbi.GetDisplayObject() as IEntity;
						//plasma: Implement city tax here												
						KinCityRegion kcr = KinCityRegion.GetKinCityAt(this);
						int price = gbi.Price;
						if (kcr != null && kcr.CityTaxRate > 0.0)
						{
							double tax = buyItem.Price * kcr.CityTaxRate;
							price += (int)Math.Floor(tax);
						}
						list.Add(new BuyItemState(buyItem.Name, cont.Serial, disp == null ? (Serial)0x7FC0FFEE : disp.Serial, price, buyItem.Amount, buyItem.ItemID, buyItem.Hue));
						count++;

						if (disp is Item)
							opls.Add((disp as Item).PropertyList);
						else if (disp is Mobile)
							opls.Add((disp as Mobile).PropertyList);
					}
				}

				ArrayList playerItems = cont.Items;

				for (int i = playerItems.Count - 1; i >= 0; --i)
				{
					if (i >= playerItems.Count)
						continue;

					Item item = (Item)playerItems[i];

					if ((item.LastMoved + InventoryDecayTime) <= DateTime.Now)
						item.Delete();
				}

				for (int i = 0; i < playerItems.Count; ++i)
				{
					Item item = (Item)playerItems[i];

					int price = 0;
					string name = null;

					foreach (IShopSellInfo ssi in sellInfo)
					{
						if (ssi.IsSellable(item))
						{
							price = ssi.GetBuyPriceFor(item);
							name = ssi.GetNameFor(item);
							break;
						}
					}

					if (name != null && list.Count < 250)
					{

						list.Add(new BuyItemState(name, cont.Serial, item.Serial, price, item.Amount, item.ItemID, item.Hue));
						count++;

						opls.Add(item.PropertyList);
					}
				}

				//one (not all) of the packets uses a byte to describe number of items in the list.  Osi = dumb.
				//if ( list.Count > 255 )
				//	Console.WriteLine( "Vendor Warning: Vendor {0} has more than 255 buy items, may cause client errors!", this );

				if (list.Count > 0)
				{
					list.Sort(new BuyItemStateComparer());

					SendPacksTo(from);

					if (from.NetState == null)
						return;

					if (from.NetState.IsPost6017)
						from.Send(new VendorBuyContent6017(list));
					else
						from.Send(new VendorBuyContent(list));

					from.Send(new VendorBuyList(this, list));
					from.Send(new DisplayBuyList(this));
					from.Send(new MobileStatusExtended(from));//make sure their gold amount is sent

					for (int i = 0; i < opls.Count; ++i)
						from.Send(opls[i] as Packet);

					SayTo(from, 500186); // Greetings.  Have a look around.
				}
				else
					SayTo(from, "I'm all out of stock. Please come back later."); // Added to deal with an empty buy list
			}
			catch (Exception exc)
			{
				LogHelper.LogException(exc);
			}
		}
예제 #9
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            LoadSBInfo();

            ArrayList sbInfos = this.SBInfos;

            switch (version)
            {
            case 1:
            {
                int index;

                while ((index = reader.ReadEncodedInt()) > 0)
                {
                    int doubled = reader.ReadEncodedInt();

                    if (sbInfos != null)
                    {
                        index -= 1;
                        int sbInfoIndex  = index % sbInfos.Count;
                        int buyInfoIndex = index / sbInfos.Count;

                        if (sbInfoIndex >= 0 && sbInfoIndex < sbInfos.Count)
                        {
                            SBInfo    sbInfo  = (SBInfo)sbInfos[sbInfoIndex];
                            ArrayList buyInfo = sbInfo.BuyInfo;

                            if (buyInfo != null && buyInfoIndex >= 0 && buyInfoIndex < buyInfo.Count)
                            {
                                GenericBuyInfo gbi = (GenericBuyInfo)buyInfo[buyInfoIndex];

                                int amount = 20;

                                switch (doubled)
                                {
                                case 1: amount = 40; break;

                                case 2: amount = 80; break;

                                case 3: amount = 160; break;

                                case 4: amount = 320; break;

                                case 5: amount = 640; break;

                                case 6: amount = 999; break;
                                }

                                gbi.Amount = gbi.MaxAmount = amount;
                            }
                        }
                    }
                }

                break;
            }
            }

            if (IsParagon)
            {
                IsParagon = false;
            }

            if (Core.AOS && NameHue == 0x35)
            {
                NameHue = -1;
            }

            Timer.DelayCall(TimeSpan.Zero, new TimerCallback(CheckMorph));
        }
예제 #10
0
        public virtual void VendorSell(Mobile from)
        {
            if (!IsActiveBuyer)
            {
                return;
            }

            if (!from.CheckAlive())
            {
                return;
            }

            if (!CheckVendorAccess(from))
            {
                Say(501522);                   // I shall not treat with scum like thee!

                return;
            }

            //TEST: Figure Out Budgets Concept
            if (m_Budgets.ContainsKey(from.Serial))
            {
                /*
                 *              if ( from.AccessLevel >= AccessLevel.GameMaster )
                 *              {
                 *                      SayTo( from, true, "Your current budget is {0}, which resets at {1}",
                 *                              m_Budgets[from.Serial].CurrentBudget, m_Budgets[from.Serial].ResetBudgetAt );
                 *              }
                 */

                if (DateTime.UtcNow < m_Budgets[from.Serial].ResetBudgetAt)
                {
                }

                else
                {
                    m_Budgets[from.Serial].CurrentBudget = 0;
                    m_Budgets[from.Serial].ResetBudgetAt = DateTime.UtcNow + Budget.TimeFrame;
                }
            }

            else
            {
                m_Budgets.Add(from.Serial, new Budget(0, DateTime.UtcNow + Budget.TimeFrame));
            }

            Container pack = from.Backpack;

            if (pack != null)
            {
                IShopSellInfo[] info    = GetSellInfo();
                IBuyItemInfo[]  buyinfo = GetBuyInfo();

                Hashtable table = new Hashtable();

                int numItemsNotCraftedBySeller = 0;

                foreach (IShopSellInfo ssi in info)
                {
                    Item[] items = pack.FindItemsByType(ssi.Types);

                    foreach (Item item in items)
                    {
                        if (item is Container && ((Container)item).Items.Count != 0)
                        {
                            continue;
                        }

                        if (item.IsStandardLoot() && item.Movable && ssi.IsSellable(item))
                        {
                            int price = ssi.GetSellPriceFor(item);

                            for (int idx = 0; idx < buyinfo.Length; idx++)
                            {
                                IBuyItemInfo   buyItem = (IBuyItemInfo)buyinfo[idx];
                                GenericBuyInfo gbi     = (GenericBuyInfo)buyItem;

                                if (item.GetType().IsAssignableFrom(gbi.Type) && !(item is BaseWeapon) && !(item is BaseArmor))
                                {
                                    if (price >= buyItem.Price)
                                    {
                                        price = buyItem.Price - 1;
                                    }
                                }
                            }

                            table[item] = new SellItemState(item, price, ssi.GetNameFor(item));
                        }
                    }
                }

                if (table.Count > 0)
                {
                    SendPacksTo(from);

                    from.Send(new VendorSellList(this, table));
                }

                else
                {
                    Say(true, "You have nothing I would be interested in.");
                }
            }
        }
예제 #11
0
        public virtual void VendorBuy(Mobile from)
        {
            if (!IsActiveSeller)
            {
                return;
            }

            if (!from.CheckAlive())
            {
                return;
            }

            if (!CheckVendorAccess(from))
            {
                Say(501522);                   // I shall not treat with scum like thee!
                return;
            }

            if (DateTime.UtcNow - m_LastRestock > RestockDelay)
            {
                Restock();
            }

            int count = 0;

            List <BuyItemState> list;

            IBuyItemInfo[]  buyInfo  = this.GetBuyInfo();
            IShopSellInfo[] sellInfo = this.GetSellInfo();

            list = new List <BuyItemState>(buyInfo.Length);
            Container cont = this.BuyPack;

            List <ObjectPropertyList> opls = null;

            for (int idx = 0; idx < buyInfo.Length; idx++)
            {
                IBuyItemInfo buyItem = (IBuyItemInfo)buyInfo[idx];

                if (buyItem.Amount <= 0 || list.Count >= 250)
                {
                    continue;
                }

                GenericBuyInfo gbi  = (GenericBuyInfo)buyItem;
                IEntity        disp = gbi.GetDisplayEntity();

                list.Add(new BuyItemState(buyItem.Name, cont.Serial, disp == null ? (Serial)0x7FC0FFEE : disp.Serial, buyItem.Price, buyItem.Amount, buyItem.ItemID, buyItem.Hue));
                count++;

                if (opls == null)
                {
                    opls = new List <ObjectPropertyList>();
                }

                if (disp is Item)
                {
                    opls.Add((( Item )disp).PropertyList);
                }

                else if (disp is Mobile)
                {
                    opls.Add((( Mobile )disp).PropertyList);
                }
            }

            if (list.Count > 0)
            {
                list.Sort(new BuyItemStateComparer());

                SendPacksTo(from);

                NetState ns = from.NetState;

                if (ns == null)
                {
                    return;
                }

                if (ns.ContainerGridLines)
                {
                    from.Send(new VendorBuyContent6017(list));
                }

                else
                {
                    from.Send(new VendorBuyContent(list));
                }

                from.Send(new VendorBuyList(this, list));

                if (ns.HighSeas)
                {
                    from.Send(new DisplayBuyListHS(this));
                }

                else
                {
                    from.Send(new DisplayBuyList(this));
                }

                from.Send(new MobileStatusExtended(from));

                if (opls != null)
                {
                    for (int i = 0; i < opls.Count; ++i)
                    {
                        from.Send(opls[i]);
                    }
                }

                SayTo(from, 500186); // Greetings.  Have a look around.
            }
        }
예제 #12
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            LoadSBInfo();

            List <SBInfo> sbInfos = this.SBInfos;

            switch (version)
            {
            case 2:
            {
                int count = reader.ReadInt();
                for (int i = 0; i < count; ++i)
                {
                    Serial serial = (Serial)reader.ReadInt();
                    Budget budget = Budget.ReadBudget(reader);

                    m_Budgets.Add(serial, budget);
                }

                goto case 1;
            }

            case 1:
            {
                int index;

                while ((index = reader.ReadEncodedInt()) > 0)
                {
                    int doubled = reader.ReadEncodedInt();

                    if (sbInfos != null)
                    {
                        index -= 1;
                        int sbInfoIndex  = index % sbInfos.Count;
                        int buyInfoIndex = index / sbInfos.Count;

                        if (sbInfoIndex >= 0 && sbInfoIndex < sbInfos.Count)
                        {
                            SBInfo sbInfo = sbInfos[sbInfoIndex];
                            List <GenericBuyInfo> buyInfo = sbInfo.BuyInfo;

                            if (buyInfo != null && buyInfoIndex >= 0 && buyInfoIndex < buyInfo.Count)
                            {
                                GenericBuyInfo gbi = (GenericBuyInfo)buyInfo[buyInfoIndex];

                                int amount = 20;

                                switch (doubled)
                                {
                                case 1: amount = 40; break;

                                case 2: amount = 80; break;

                                case 3: amount = 160; break;

                                case 4: amount = 320; break;

                                case 5: amount = 640; break;

                                case 6: amount = 999; break;
                                }

                                gbi.Amount = gbi.MaxAmount = amount;
                            }
                        }
                    }
                }

                break;
            }
            }

            if (IsParagon)
            {
                IsParagon = false;
            }
        }