Example #1
0
        public override void Parse(Mobile from, string[] arguments, int offset, int size)
        {
            if (size < 1)
            {
                throw new Exception("Invalid condition syntax.");
            }

            m_Conditional = ObjectConditional.ParseDirect(from, arguments, offset, size);
        }
Example #2
0
        public override void ExecuteList(CommandEventArgs e, ArrayList list)
        {
            try
            {
                string[]          args      = e.Arguments;
                ObjectConditional condition = ObjectConditional.Parse(e.Mobile, ref args);

                for (int i = 0; i < list.Count; ++i)
                {
                    if (condition.CheckCondition(list[i]))
                    {
                        AddResponse("True - that object matches the condition.");
                    }
                    else
                    {
                        AddResponse("False - that object does not match the condition.");
                    }
                }
            }
            catch (Exception ex)
            {
                e.Mobile.SendMessage(ex.Message);
            }
        }
Example #3
0
        public bool CheckObjectTypes(Mobile from, BaseCommand command, Extensions ext, out bool items, out bool mobiles)
        {
            items = mobiles = false;

            ObjectConditional cond = ObjectConditional.Empty;

            foreach (BaseExtension check in ext)
            {
                if (check is WhereExtension)
                {
                    cond = (check as WhereExtension).Conditional;

                    break;
                }
            }

            bool condIsItem   = cond.IsItem;
            bool condIsMobile = cond.IsMobile;

            switch (command.ObjectTypes)
            {
            case ObjectTypes.All:
            case ObjectTypes.Both:
            {
                if (condIsItem)
                {
                    items = true;
                }

                if (condIsMobile)
                {
                    mobiles = true;
                }

                break;
            }

            case ObjectTypes.Items:
            {
                if (condIsItem)
                {
                    items = true;
                }
                else if (condIsMobile)
                {
                    from.SendMessage("You may not use a mobile type condition for this command.");
                    return(false);
                }

                break;
            }

            case ObjectTypes.Mobiles:
            {
                if (condIsMobile)
                {
                    mobiles = true;
                }
                else if (condIsItem)
                {
                    from.SendMessage("You may not use an item type condition for this command.");
                    return(false);
                }

                break;
            }
            }

            return(true);
        }