Exemple #1
0
        public static void GetPrice(EliteAPI api, MatchCollection arguments)
        {
            //Array of strings from //command.
            string[] args = Misc.MatchToString(arguments);

            //Current selected item stack check.
            if (args.Length == 2 && args[args.Length - 1].ToLower() == "stack")
            {
                GetPrice(api, true); return;
            }

            //Search terms. Gives us 'Serket Ring' from //price Serket Ring.
            bool   isStack  = false;
            string keywords = string.Join(" ", args.Skip(1));

            if (args.Length >= 2 && args[args.Length - 1].ToLower() == "stack")
            {
                isStack = true;
                Regex r = new Regex(@"\s?stack\s?");
                keywords = r.Replace(keywords, string.Empty);
            }

            Structs.InventoryItem item = XML.GetInvItem(keywords);

            if (item.success)
            {
                uint itemID = item.id;
                GetPrice(api, item, isStack);
            }
            else
            {
                Chat.SendEcho(api, "Couldn't find that item!");
            }
        }
Exemple #2
0
        public static Structs.InventoryItem GetInvItem(string itemName)
        {
            Structs.InventoryItem item = new Structs.InventoryItem();

            try
            {
                XElement itemNode = itemsDoc.Descendants("ffxiah")
                                    .Elements("item")
                                    .Where(x =>
                                           x.Element("en_name").Value == itemName ||
                                           x.Element("log_name_singular").Value == itemName ||
                                           x.Element("log_name_plural").Value == itemName
                                           ).FirstOrDefault();

                item.description = itemNode.Element("en_description").Value;
                item.id          = uint.Parse(itemNode.Element("int_id").Value);
                item.name        = itemNode.Element("en_name").Value;
                item.singleName  = itemNode.Element("log_name_singular").Value;
                item.stackName   = itemNode.Element("log_name_plural").Value;
                item.stackSize   = int.Parse(itemNode.Element("stack_size").Value);
                item.success     = true;
            }
            catch (Exception e)
            {
                item.success = false;
                Console.WriteLine("Couldn't parse by string.");
                Console.WriteLine(e.Message);
            }
            return(item);
        }
Exemple #3
0
        public static void GetPrice(EliteAPI api, bool isStack)
        {
            uint itemID = api.Inventory.SelectedItemId;

            Structs.InventoryItem item = XML.GetInvItem(itemID);

            if (item.success)
            {
                GetPrice(api, item, isStack);
            }
            else
            {
                Chat.SendEcho(api, "Couldn't find that item!");
            }
        }
Exemple #4
0
        public static void GetDesc(EliteAPI api)
        {
            uint itemID = api.Inventory.SelectedItemId;

            Structs.InventoryItem item = XML.GetInvItem(itemID);

            if (!item.success)
            {
                Chat.SendEcho(api, "Couldn't find that item!");
                return;
            }

            //Get page html.
            string itemPage = FFXIAH.baseUrl + itemID;
            string html     = FFXIAH.GetHTML(itemPage, 12);
            string itemName = item.name;
            string desc     = Misc.RegExMatch(html, FFXIAH.RegExs.desc);

            Chat.SendLinkshell(api, itemName + "\n" + desc);
        }
Exemple #5
0
        public static void GetPrice(EliteAPI api, Structs.InventoryItem invItem, bool isStack = false)
        {
            string itemPage = FFXIAH.baseUrl + invItem.id;

            if (isStack)
            {
                itemPage += "/?stack=1";
            }

            //Get page html.
            string html = FFXIAH.GetHTML(itemPage, 12);

            //Get itemSale string so that we have less to sift through.
            string itemSaleStr = Misc.RegExMatch(html, FFXIAH.RegExs.itemSale);
            int    numSales = 0, maxSales;

            //Item isn't EX
            if (itemSaleStr != "null")
            {
                //Get number of sales and server to ensure we're parsing the correct one.
                int serverValue = int.Parse(Misc.RegExMatch(itemSaleStr, FFXIAH.RegExs.server));

                //Verify server is correct before parsing.

                /*if (api.Player.ServerId != serverValue)
                 * {
                 * Chat.SendEcho(api, "Wrong server being parsed!");
                 *  return;
                 * }*/

                numSales = Misc.RegExMatches(itemSaleStr, FFXIAH.RegExs.server).Count;
                maxSales = FFXIAH.maxSales > numSales ? numSales : FFXIAH.maxSales;

                //Store sales
                for (int i = 0; i < maxSales; i++)
                {
                    var         colCount = 0;
                    FFXIAH.Sale sale     = new FFXIAH.Sale();
                    foreach (string regExStr in FFXIAH.RegExs.list)
                    {
                        string matchVal = Misc.RegExMatch(itemSaleStr, regExStr, i);
                        if (colCount == 0)
                        {
                            sale.date = Misc.FromUnixTime(long.Parse(matchVal)).ToShortDateString();
                        }
                        else if (colCount == 1)
                        {
                            sale.seller = matchVal;
                        }
                        else if (colCount == 2)
                        {
                            sale.buyer = matchVal;
                        }
                        else if (colCount == 3)
                        {
                            sale.price = int.Parse(matchVal);
                        }
                        if (colCount == 3)
                        {
                            FFXIAH.sales.Add(sale);
                        }
                        colCount = (colCount + 1) % 4;
                    }
                }
            }

            //Create an xiah item object after all info gathered.
            FFXIAH.Item item = new FFXIAH.Item();

            //Store item info.
            string stockStr = Misc.RegExMatch(html, FFXIAH.RegExs.stock);

            item.stock   = stockStr != "null" ? int.Parse(stockStr) : 0;
            item.isStack = isStack;

            //Print sales list.
            FFXIAH.PrintSales(api, invItem, item, numSales);

            //Clear sales list.
            FFXIAH.sales.Clear();
        }