// Adds items to held list dynamically
                public void AddItem(object o)
                {
                    // Handle contained objects
                    if (o is BaseContainer)
                    {
                        foreach (Item item in ((BaseContainer)o).Items)
                        {
                            AddItem(item);
                        }
                    }

                    // Handle this object
                    HeldItem hi = new HeldItem(o.GetType());

                    // If it has quantity, we want to reflect that in our
                    // instance
                    if (((Item)o).Amount > 0)
                    {
                        hi.m_Count = ((Item)o).Amount;
                    }

                    // Make sure there are no others like this
                    foreach (HeldItem hit in m_Contents)
                    {
                        // It exists, so increment and return
                        if (hit.m_Type == hi.m_Type)
                        {
                            hit.m_Count += hi.m_Count;

                            // Add the reference to this object
                            hit.Ref.Add(o);
                            return;
                        }
                    }

                    // Reference the base object here - this could
                    // provide some nifty future functionality, but for now
                    // is used to check property values
                    hi.Ref.Add(o);

                    // It doesn't exist, so add it
                    m_Contents.Add(hi);
                }
Example #2
0
        // Limitation on the item property

        public override bool Guage(object o, ref ArrayList Fallthroughs)
        {
            if (o == null || !(o is HeldItem))                      // wea: 28/Feb/2007 Added safety check
            {
                return(false);
            }

            // We'll be dealing with a helditem object then
            HeldItem ipi = (HeldItem)o;

            // Limit
            // -1	- Fall through : if the item matches, passes all checks
            // 0	- Require the value to be at least this / require this property
            // 1	- Limit the value to a max of this / only this

            if (ipi.m_Type == ItemType || ipi.m_Type.IsSubclassOf(ItemType))
            {
                PlayerMobile FakeGM = new PlayerMobile();
                FakeGM.AccessLevel = AccessLevel.GameMaster;

                int FailCount = 0;

                foreach (Item item in ipi.Ref)
                {
                    if (Fallthroughs.Contains(item))
                    {
                        continue;                                       // Fallthrough
                    }
                    string PropTest = Properties.GetValue(FakeGM, item, Property);

                    if (PropertyVal != "")
                    {
                        Regex IPMatch = new Regex("= \"*" + PropertyVal, RegexOptions.IgnoreCase);
                        if (IPMatch.IsMatch(PropTest))
                        {
                            switch (Limit)
                            {
                            case -1:
                                // Not required, but has fallthrough and matches so skip to next item reference
                                Fallthroughs.Add(item);
                                continue;

                            case 1:
                                // It's limited to this and has matched, so that's fine
                                continue;

                            case 0:
                                // Required, matched, so fine
                                continue;
                            }
                        }
                        else
                        {
                            switch (Limit)
                            {
                            case -1:
                                // Not required, so don't worry but don't fallthrough either
                                continue;

                            case 1:
                                // It's limited to this and doesn't match, so it fails
                                break;

                            case 0:
                                // Required, not matched so not cool
                                break;
                            }
                        }
                    }
                    else
                    {
                        // Ascertain numeric value
                        string sNum    = "";
                        int    iStrPos = Property.Length + 3;

                        while (PropTest[iStrPos] != ' ')
                        {
                            sNum += PropTest[iStrPos++];
                        }

                        int iCompareTo;

                        try
                        {
                            iCompareTo = Convert.ToInt32(sNum);
                        }
                        catch (Exception exc)
                        {
                            Console.WriteLine("TourneyStoneAddon: Exception - (trying to convert {1} to integer)", exc, sNum);
                            continue;
                        }

                        switch (Limit)
                        {
                        case 0:
                            if (iCompareTo >= Quantity)
                            {
                                continue;
                            }
                            break;

                        case 1:
                            if (iCompareTo <= Quantity)
                            {
                                continue;
                            }
                            break;

                        case -1:
                            if (iCompareTo <= Quantity)
                            {
                                Fallthroughs.Add(item);
                                continue;
                            }
                            break;
                        }
                    }

                    // FAILED!!! Otherwise we would have continued
                    FailCount++;
                }                 // Loop Item


                if (FailCount > 0)
                {
                    ClassNameTranslator cnt = new ClassNameTranslator();
                    Rule.FailTextDyn = string.Format("{0} x {1}", FailCount, cnt.TranslateClass(ipi.m_Type));

                    return(false);
                }
                else
                {
                    return(true);
                }
            }

            return(true);
        }
				// Adds items to held list dynamically
				public void AddItem(object o)
				{
					// Handle contained objects
					if(o is BaseContainer)
						foreach(Item item in ((BaseContainer)o).Items)
							AddItem(item);

					// Handle this object
					HeldItem hi = new HeldItem(o.GetType());

					// If it has quantity, we want to reflect that in our
					// instance
					if( ((Item)o).Amount > 0 )
						hi.m_Count = ((Item)o).Amount;

					// Make sure there are no others like this
					foreach(HeldItem hit in m_Contents)
					{
						// It exists, so increment and return
						if(hit.m_Type == hi.m_Type)
						{
							hit.m_Count+=hi.m_Count;

							// Add the reference to this object
							hit.Ref.Add( o );
							return;
						}
					}

					// Reference the base object here - this could
					// provide some nifty future functionality, but for now
					// is used to check property values
					hi.Ref.Add( o );

					// It doesn't exist, so add it
					m_Contents.Add(hi);
				}