public PlayerVendorBuyGump( Item i, PlayerVendor vend, VendorItem vi )
            : base(100, 200)
        {
            m_Item = i;
            m_Vendor = vend;
            m_VI = vi;

            string desc = m_VI.Description;

            if ( desc != null && (desc = desc.Trim()).Length == 0 )
                desc = null;

            AddPage( 0 );

            AddBackground( 100, 10, 300, 150, 5054 );

            AddHtmlLocalized( 125, 20, 250, 24, 1019070, false, false ); // You have agreed to purchase:

            if ( desc != null )
                AddLabel( 125, 45, 0, desc );
            else
                AddHtmlLocalized( 125, 45, 250, 24, 1019072, false, false ); // an item without a description

            AddHtmlLocalized( 125, 70, 250, 24, 1019071, false, false ); // for the amount of:
            AddLabel( 125, 95, 0, m_VI.Price.ToString() );

            AddButton( 250, 130, 4005, 4007, 1, GumpButtonType.Reply, 0 );
            AddHtmlLocalized( 282, 130, 100, 24, 1011012, false, false ); // CANCEL

            AddButton( 120, 130, 4005, 4007, 2, GumpButtonType.Reply, 0 );
            AddHtmlLocalized( 152, 130, 100, 24, 1011036, false, false ); // OKAY
        }
		public PlayerVendorBuyGump(PlayerVendor vendor, VendorItem vi)
			: base(100, 200)
		{
			m_Vendor = vendor;
			m_VI = vi;

			AddBackground(100, 10, 300, 150, 5054);

			AddHtmlLocalized(125, 20, 250, 24, 1019070, false, false); // You have agreed to purchase:

			if (!String.IsNullOrEmpty(vi.Description))
			{
				AddLabel(125, 45, 0, vi.Description);
			}
			else
			{
				AddHtmlLocalized(125, 45, 250, 24, 1019072, false, false); // an item without a description
			}

			AddHtmlLocalized(125, 70, 250, 24, 1019071, false, false); // for the amount of:
			AddLabel(125, 95, 0, vi.Price.ToString("#,0"));

			AddButton(250, 130, 4005, 4007, 0, GumpButtonType.Reply, 0);
			AddHtmlLocalized(282, 130, 100, 24, 1011012, false, false); // CANCEL

			AddButton(120, 130, 4005, 4007, 1, GumpButtonType.Reply, 0);
			AddHtmlLocalized(152, 130, 100, 24, 1011036, false, false); // OKAY
		}
Exemple #3
0
 private static IEnumerable<IVendorSearchItem> GetContainedItems(VendorItem vi, Container cont)
 {
     foreach (var item in cont.Items)
     {
         if (item is Container)
         {
             foreach (var contained in GetContainedItems(vi, (Container) item))
             {
                 yield return contained;
             }
         }
         else
             yield return VendorSearchItem.CreateForContainedItem(vi, item);
     }
 }
        public PlayerVendorBuyGump( PlayerVendor vendor, VendorItem vi )
            : base(100, 200)
        {
            m_Vendor = vendor;
            m_VI = vi;

            AddBackground(100, 10, 300, 150, 9270);

            AddHtml(125, 20, 250, 24, "Voce está comprando este item:", false, false); // You have agreed to purchase:

            //if ( !String.IsNullOrEmpty( vi.Description ) )
            //    AddLabel( 125, 45, 0, vi.Description );
            //else
                AddHtml(125, 45, 250, 24, vi.Item.Name, false, false); // an item without a description

            AddHtml(125, 70, 250, 24, "pela quantia de:", false, false); // for the amount of:
            AddHtml(125, 95, 250, 24, vi.Price.ToString() + " Gold", false, false); // for the amount of:
            //AddLabel( 125, 95, 0, vi.Price.ToString() );

            AddButton( 250, 130, 4005, 4007, 0, GumpButtonType.Reply, 0 );
            AddHtml(282, 130, 100, 24, "Cancelar", false, false); // CANCEL

            AddButton( 120, 130, 4005, 4007, 1, GumpButtonType.Reply, 0 );
            AddHtml(152, 130, 100, 24, "Confirmar", false, false); // OKAY
        }
        private VendorItem AddInfo( Item item, Item target )
        {
            int defPrice = 999;
            VendorItem vi;

            if ( item is BaseBook || ( item is Container && item.Items.Count == 0 ) || item is KeyRing )
            {
                defPrice = 0;
            }
            else if ( target != null )
            {
                vi = (VendorItem)m_SellItems[target];

                if ( vi != null && vi.Price > 0 )
                    defPrice = 0;
            }

            vi = new VendorItem( item, defPrice, "" );
            m_SellItems[item] = vi;

            if ( defPrice == 0 )
            {
                for (int i=0;i<item.Items.Count;i++)
                    AddInfo( (Item)item.Items[i], null );
            }

            item.InvalidateProperties();

            return vi;
        }
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            int version = reader.ReadInt();

            switch ( version )
            {
                case 0:
                {
                    m_Owner = reader.ReadMobile();
                    m_BankAccount = reader.ReadInt();
                    m_HoldGold = reader.ReadInt();

                    int count = reader.ReadInt();
                    m_SellItems = new Hashtable();
                    for (int i=0;i<count;i++)
                    {
                        Item item = reader.ReadItem();
                        int p = reader.ReadInt();
                        string d = reader.ReadString();

                        if ( item != null && !item.Deleted )
                            m_SellItems[item] = new VendorItem( item, p, d );
                    }
                    break;
                }
            }

            m_PayTimer = new PayTimer( this );
            m_PayTimer.Start();
            Blessed = true;
        }
Exemple #7
0
 public VendorPricePrompt(PlayerVendor vendor, VendorItem vi, String name)
     : base(vendor, name)
 {
     m_Vendor = vendor;
     m_VI     = vi;
 }
Exemple #8
0
 public VendorPricePrompt(PlayerVendor vendor, VendorItem vi)
 {
     m_Vendor = vendor;
     m_VI     = vi;
 }
		private bool ProcessRestockCharge(RestockCharge mode, VendorItem vi)
		{	// no restock charges for OSI style charges
			if (PricingModel != PricingModel.Commission || vi == null)
				return false;

			if (mode == RestockCharge.Record)
			{
				if (m_memory.ContainsKey(vi.Item) == false)
					m_memory[vi.Item] = new VendorItemMemory();
			}
			else if (mode == RestockCharge.Moved)
			{
				if (m_memory.ContainsKey(vi.Item))
				{	// check to see if we are within the grace period
					VendorItemMemory vim = m_memory[vi.Item] as VendorItemMemory;
					if (vim == null) return false;
					if (DateTime.Now > vim.GracePeriod)
					{	// reset graceperiod
						// one hour grace period
						vim.GracePeriod = DateTime.Now.AddMinutes((double)CoreAI.GracePeriod);
						return true;	// user should be charged
					}
				}
				else
				{	// first time touched after a restart or daily cleanup
					VendorItemMemory vim = new VendorItemMemory();	// grace periods do not span server restarts
					vim.GracePeriod = DateTime.MinValue;			// ensure this item is outside grace period
					m_memory[vi.Item] = vim;						// record it
					return ProcessRestockCharge(mode, vi);			// reenter and process this 'out of grace move'
				}
			}

			// no special action
			return false;
		}
Exemple #10
0
 public VendorPricePrompt( PlayerVendor vendor, VendorItem vi, String name )
     : base(vendor, name)
 {
     m_Vendor = vendor;
     m_VI = vi;
 }
Exemple #11
0
 public static IVendorSearchItem CreateForContainedItem(VendorItem vi, Item item)
 {
     return new VendorSearchItem(item, vi.Price, () => vi.Valid, vi.Vendor, vi.Item.Parent as Container, true);
 }
Exemple #12
0
 public static IVendorSearchItem CreateForItem(VendorItem vi)
 {
     return new VendorSearchItem(vi.Item, vi.Price, () => vi.Valid, vi.Vendor, vi.Item.Parent as Container, false);
 }
		public VendorItem SetVendorItem(Item item, int price, string description)
		{
			RemoveVendorItem(item);

			VendorItem vi = new VendorItem(item, price, description);
			m_SellItems[item] = vi;
			ProcessRestockCharge(RestockCharge.Record, vi);	// record this item for future restocking charges

			item.InvalidateProperties();

			return vi;
		}
			public VendorPricePrompt( PlayerVendor vendor, VendorItem vi )
			{
				m_Vendor = vendor;
				m_VI = vi;
			}
Exemple #15
0
		public static bool CheckMatch(VendorItem vitem, SearchCriteria searchCriteria)
		{
			if(vitem == null)
				return false;
			
			Item item = vitem.Item;

            if (searchCriteria.MinPrice > -1 && vitem.Price < searchCriteria.MinPrice)
				return false;

            if (searchCriteria.MaxPrice > -1 && vitem.Price > searchCriteria.MaxPrice)
				return false;
			
			if (!String.IsNullOrEmpty(searchCriteria.SearchName))
			{
				string name = GetItemName(item);
				
				if(name == null)
				{
                    return false; // TODO? REturn null names?
				}

                if (!CheckKeyword(searchCriteria.SearchName, item) && name.ToLower().IndexOf(searchCriteria.SearchName.ToLower()) < 0)
                {
                    return false;
                }
			}

            if (searchCriteria.SearchType != Layer.Invalid && searchCriteria.SearchType != item.Layer)
			{
				return false;
			}
			
			if(searchCriteria.Details.Count == 0)
				return true;
			
            foreach(SearchDetail detail in searchCriteria.Details)
			{
                object o = detail.Attribute;
                int value = detail.Value;

                if (value == 0)
                    value = 1;

				if(o is AosAttribute)
				{
					AosAttributes attrs = RunicReforging.GetAosAttributes(item);

					if(attrs == null || attrs[(AosAttribute)o] < value)
						return false;
				}
				else if (o is AosWeaponAttribute)
				{
					AosWeaponAttributes attrs = RunicReforging.GetAosWeaponAttributes(item);

                    if ((AosWeaponAttribute)o == AosWeaponAttribute.MageWeapon)
                    {
                        if (attrs == null || attrs[(AosWeaponAttribute)o] == 0 || attrs[(AosWeaponAttribute)o] > Math.Max(0, 30 - value))
                            return false;
                    }
                    else if (attrs == null || attrs[(AosWeaponAttribute)o] < value)
                        return false;
				}
				else if (o is SAAbsorptionAttribute)
				{
					SAAbsorptionAttributes attrs = RunicReforging.GetSAAbsorptionAttributes(item);

                    if (attrs == null || attrs[(SAAbsorptionAttribute)o] < value)
                        return false;
				}
				else if(o is AosArmorAttribute)
				{
					AosArmorAttributes attrs = RunicReforging.GetAosArmorAttributes(item);

                    if (attrs == null || attrs[(AosArmorAttribute)o] < value)
                        return false;
				}
				else if(o is SkillName)
				{
					if(detail.Category != Category.RequiredSkill)
					{
						AosSkillBonuses skillbonuses = RunicReforging.GetAosSkillBonuses(item);

                        if (skillbonuses != null)
                        {
                            bool hasSkill = false;

                            for (int i = 0; i < 5; i++)
                            {
                                SkillName check;
                                double bonus;

                                if (skillbonuses.GetValues(i, out check, out bonus) && check == (SkillName)o && bonus >= value)
                                {
                                    hasSkill = true;
                                    break;
                                }
                            }

                            if (!hasSkill)
                                return false;
                        }
                        else if (item is SpecialScroll && value >= 105)
                        {
                            if (((SpecialScroll)item).Skill != (SkillName)o || ((SpecialScroll)item).Value < value)
                                return false;
                        }
                        else
                        {
                            return false;
                        }
					}
					else if(!(item is BaseWeapon) || ((BaseWeapon)item).DefSkill != (SkillName)o)
					{
						return false;
					}
				}
				else if(o is SlayerName && (!(item is ISlayer) || ((((ISlayer)item).Slayer != (SlayerName)o && ((ISlayer)item).Slayer2 != (SlayerName)o))))
				{
					return false;
				}
                else if (o is TalismanSlayerName && (!(item is BaseTalisman) || ((BaseTalisman)item).Slayer != (TalismanSlayerName)o))
				{
					return false;
				}
                else if (o is AosElementAttribute)
                {
                    if (item is BaseWeapon)
                    {
                        BaseWeapon wep = item as BaseWeapon;

                        if (detail.Category == Category.DamageType)
                        {
                            int phys, fire, cold, pois, nrgy, chaos, direct;
                            wep.GetDamageTypes(null, out phys, out fire, out cold, out pois, out nrgy, out chaos, out direct);

                            switch ((AosElementAttribute)o)
                            {
                                case AosElementAttribute.Physical: if (phys < value) return false; break;
                                case AosElementAttribute.Fire: if (fire < value) return false; break;
                                case AosElementAttribute.Cold: if (cold < value) return false; break;
                                case AosElementAttribute.Poison: if (pois < value) return false; break;
                                case AosElementAttribute.Energy: if (nrgy < value) return false; break;
                                case AosElementAttribute.Chaos: if (chaos < value) return false; break;
                                case AosElementAttribute.Direct: if (direct < value) return false; break;
                            }
                        }
                        else
                        {
                            switch ((AosElementAttribute)o)
                            {
                                case AosElementAttribute.Physical:
                                    if (wep.WeaponAttributes.ResistPhysicalBonus < value) return false;
                                    break;
                                case AosElementAttribute.Fire:
                                    if (wep.WeaponAttributes.ResistFireBonus < value) return false;
                                    break;
                                case AosElementAttribute.Cold:
                                    if (wep.WeaponAttributes.ResistColdBonus < value) return false;
                                    break;
                                case AosElementAttribute.Poison:
                                    if (wep.WeaponAttributes.ResistPoisonBonus < value) return false;
                                    break;
                                case AosElementAttribute.Energy:
                                    if (wep.WeaponAttributes.ResistEnergyBonus < value) return false;
                                    break;
                            }
                        }
                    }
                    else if (item is BaseArmor && detail.Category == Category.Resists)
                    {
                        BaseArmor armor = item as BaseArmor;

                        switch ((AosElementAttribute)o)
                        {
                            case AosElementAttribute.Physical:
                                if (armor.PhysicalResistance < value) return false;
                                break;
                            case AosElementAttribute.Fire:
                                if (armor.FireResistance < value) return false;
                                break;
                            case AosElementAttribute.Cold:
                                if (armor.ColdResistance < value) return false;
                                break;
                            case AosElementAttribute.Poison:
                                if (armor.PoisonResistance < value) return false;
                                break;
                            case AosElementAttribute.Energy:
                                if (armor.EnergyResistance < value) return false;
                                break;
                        }
                    }
                    else if (detail.Category != Category.DamageType)
                    {
                        AosElementAttributes attrs = RunicReforging.GetElementalAttributes(item);

                        if (attrs == null || attrs[(AosElementAttribute)o] < value)
                        {
                            return false;
                        }
                    }
                    else
                    {
                        return false;
                    }


                }
                else if (o is Misc)
                {
                    switch ((Misc)o)
                    {
                        case Misc.ExcludeFel: break;
                        case Misc.GargoyleOnly:
                            if (!IsGargoyle(item))
                                return false;
                            break;
                        case Misc.NotGargoyleOnly:
                            if (IsGargoyle(item))
                                return false;
                            break;
                        case Misc.ElvesOnly:
                            if (!IsElf(item))
                                return false;
                            break;
                        case Misc.NotElvesOnly:
                            if (IsElf(item))
                                return false;
                            break;
                        case Misc.FactionItem:
                            if (!(item is Server.Factions.IFactionItem))
                                return false;
                            break;
                        case Misc.PromotionalToken:
                            if(!(item is PromotionalToken))
                                return false;
                            break;
                        case Misc.Cursed:
                            if (item.LootType != LootType.Cursed)
                                return false;
                            break;
                        case Misc.NotCursed:
                            if (item.LootType == LootType.Cursed)
                                return false;
                            break;
                        case Misc.CannotRepair:
                            if (CheckCanRepair(item))
                                return false;
                            break;
                        case Misc.NotCannotBeRepaired:
                            if (!CheckCanRepair(item))
                                return false;
                            break;
                        case Misc.Brittle:
                            NegativeAttributes neg2 = RunicReforging.GetNegativeAttributes(item);
                            if (neg2 == null || neg2.Brittle == 0)
                                return false;
                            break;
                        case Misc.NotBrittle:
                            NegativeAttributes neg3 = RunicReforging.GetNegativeAttributes(item);
                            if (neg3 != null && neg3.Brittle > 0)
                                return false;
                            break;
                        case Misc.Antique:
                            NegativeAttributes neg4 = RunicReforging.GetNegativeAttributes(item);
                            if (neg4 == null || neg4.Antique == 0)
                                return false;
                            break;
                        case Misc.NotAntique:
                            NegativeAttributes neg5 = RunicReforging.GetNegativeAttributes(item);
                            if (neg5 != null && neg5.Antique > 0)
                                return false;
                            break;
                    }
                }
                else if (o is string)
                {
                    string str = o as string;

                    if (str == "WeaponVelocity" && (!(item is BaseRanged) || ((BaseRanged)item).Velocity < value))
                        return false;

                    if (str == "BalancedWeapon" && (!(item is BaseRanged) || !((BaseRanged)item).Balanced))
                        return false;

                    if (str == "SearingWeapon" && (!(item is BaseWeapon) || !((BaseWeapon)item).SearingWeapon))
                        return false;

                    if (str == "ArtifactRarity")
                    {
                        bool isarty = false;

                        if (item is BaseWeapon && ((BaseWeapon)item).ArtifactRarity > value)
                            isarty = true;

                        else if (item is BaseArmor && ((BaseArmor)item).ArtifactRarity > value)
                            isarty = true;

                        else if (item is BaseClothing && ((BaseClothing)item).ArtifactRarity > value)
                            isarty = true;

                        else if (item is BaseJewel && ((BaseJewel)item).ArtifactRarity > value)
                            isarty = true;

                        else if (item is SimpleArtifact && ((SimpleArtifact)item).ArtifactRarity > value)
                            isarty = true;

                        else if (item is Artifact && ((Artifact)item).ArtifactRarity > value)
                            isarty = true;

                        if (!isarty)
                            return false;
                    }
                }
			}

            return true;
		}
		private VendorItem SetVendorItem( Item item, int price, string description, DateTime created )
		{
			RemoveVendorItem( item );

			VendorItem vi = new VendorItem( item, price, description, created );
			m_SellItems[item] = vi;

			item.InvalidateProperties();

			return vi;
		}
		public override void Deserialize(GenericReader reader)
		{
			base.Deserialize(reader);

			int version = reader.ReadInt();

			switch (version)
			{
				case 2:
					{
						m_PricingModel = (PricingModel)reader.ReadInt();
						goto case 1;
					}
				case 1:
					{

						House = (BaseHouse)reader.ReadItem();
						goto case 0;
					}
				case 0:
					{
						m_Owner = reader.ReadMobile();
						m_BankAccount = reader.ReadInt();
						m_HoldGold = reader.ReadInt();

						int count = reader.ReadInt();
						m_SellItems = new Hashtable();
						for (int i = 0; i < count; i++)
						{
							Item item = reader.ReadItem();
							int p = reader.ReadInt();
							string d = reader.ReadString();

							if (item != null && !item.Deleted)
								m_SellItems[item] = new VendorItem(item, p, d);
						}
						break;
					}
			}

			if (version < 1)
			{

				House = BaseHouse.FindHouseAt(this);
			}

			m_PayTimer = new PayTimer(this);
			m_PayTimer.Start();

			Blessed = false;

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