Beispiel #1
0
        private void WorldFilter_EnterTrade(object sender, EnterTradeEventArgs e)
        {
            WorldObjectCollection players = Core.WorldFilter.GetByObjectClass(ObjectClass.Player);
            int myId = Core.CharacterFilter.Id;

            foreach (WorldObject player in players.Where(k => k.Id != myId))
            {
                if (player.Id == e.TraderId || player.Id == e.TradeeId)
                {
                    TradePartnerName = player.Name;
                    TradePartnerId   = player.Id;
                }
            }
            if (GivingItems != null)
            {
                WorldObjectCollection woc = Core.WorldFilter.GetByOwner(Core.CharacterFilter.Id);
                foreach (WorldObject wo in woc)
                {
                    if (wo.ObjectClass != ObjectClass.Container)
                    {
                        if (GivingItems.Contains(wo.Id))
                        {
                            PendingItemsToTradeAdd.Add(wo);
                        }
                    }
                }
                AddPendingItemsToTrade();
                GivingItems = null;
            }
            else
            {
                if (TradePartnerName != "")
                {
                    SayHelp(TradePartnerName, false, true);
                }
                WorldObjectCollection woc = Core.WorldFilter.GetByOwner(Core.CharacterFilter.Id);
                foreach (WorldObject wo in woc)
                {
                    if (wo.ObjectClass != ObjectClass.Container)
                    {
                        PendingItemsToTradeAdd.Add(wo);
                    }
                }
                AddPendingItemsToTrade();
            }
        }
Beispiel #2
0
        private void HandleTradeCommand(ChatMessage chatMessage)
        {
            bool   show         = false;
            bool   regex        = false;
            bool   number       = false;
            int    numberParsed = -1;
            string command      = chatMessage.ParsedCommand;

            if (chatMessage.ParsedCommand.ToLower() == "show")
            {
                command = "add";
                show    = true;
            }
            else if (command.ToLower() == "xadd")
            {
                command = "add";
                regex   = true;
            }
            if (!show)
            {
                Match match = Regex.Match(chatMessage.ParsedParameters, "^-?\\d+$", RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    if (int.TryParse(chatMessage.ParsedParameters, out numberParsed))
                    {
                        number = true;
                    }
                }
            }
            switch (command.ToLower())
            {
            case "add":
                WorldObjectCollection woc = Core.WorldFilter.GetByOwner(Core.CharacterFilter.Id);
                foreach (WorldObject wo in woc)
                {
                    string itemName = wo.RealName();
                    if (show)
                    {
                        if (wo.ObjectClass != ObjectClass.Container)
                        {
                            PendingItemsToTradeAdd.Add(wo);
                        }
                    }
                    else if (number && wo.Exists(LongValueKey.Value))
                    {
                        int value = wo.Values(LongValueKey.Value);
                        if (numberParsed == value)
                        {
                            PendingItemsToTradeAdd.Add(wo);
                        }
                    }
                    else if (number && wo.Exists(LongValueKey.TotalValue))
                    {
                        int value = wo.Values(LongValueKey.TotalValue);
                        if (numberParsed == value)
                        {
                            PendingItemsToTradeAdd.Add(wo);
                        }
                    }
                    else if (regex)
                    {
                        Match match = Regex.Match(itemName, chatMessage.ParsedParameters, RegexOptions.IgnoreCase);
                        if (match.Success)
                        {
                            if (wo.ObjectClass != ObjectClass.Container)
                            {
                                PendingItemsToTradeAdd.Add(wo);
                            }
                        }
                    }
                    else if (itemName.ToLower().Contains(chatMessage.ParsedParameters.ToLower()))
                    {
                        if (wo.ObjectClass != ObjectClass.Container)
                        {
                            PendingItemsToTradeAdd.Add(wo);
                        }
                    }
                }
                if (PendingItemsToTradeAdd.Count < 1)
                {
                    SendChatCommand($"/t {chatMessage.ChatterName}, no items found");
                }
                AddPendingItemsToTrade();
                break;

            case "clear":
                PendingItemsToTradeAdd2.Clear();
                PendingItemsToTradeAdd.Clear();
                Host.Actions.TradeReset();
                break;
            }
        }