Example #1
0
        private void load()
        {
            _shops = new SortedList <int, ND_shop>();

            Teleports = new NDTeleport();

            ItemTable itable = ItemTable.getInstance();

            {
                XElement xml = XElement.Parse(File.ReadAllText(@"scripts\buylists.xml"));
                foreach (var shops in xml.Elements("shops"))
                {
                    foreach (var shopp in shops.Elements("shop"))
                    {
                        ND_shop shop = new ND_shop();
                        shop.id  = int.Parse(shopp.Element("npc").Value);
                        shop.mod = double.Parse(shopp.Element("mod").Value);

                        foreach (var selllist in shopp.Elements("selllist"))
                        {
                            ND_shopList slist = new ND_shopList();
                            slist.id = short.Parse(selllist.Attribute("id").Value);

                            string items = selllist.Element("item").Value;
                            items = items.Replace("\n", "").Replace(" ", "");

                            foreach (string i in items.Split(','))
                            {
                                ItemTemplate it = itable.getItem(Convert.ToInt32(i));
                                if (it != null)
                                {
                                    slist.items.Add(new ND_shopItem(it));
                                }
                                else
                                {
                                    CLogger.error("NpcData: cant find item to trade " + i + " on npc " + shop.id);
                                }
                            }

                            shop.lists.Add(slist.id, slist);
                        }

                        _shops.Add(shop.id, shop);
                    }
                }
            }

            CLogger.info("NpcData: loaded " + _shops.Count + " merchants.");
            //CLogger.info("NpcData: loaded " + _mults.Count + " multisell lists.");
        }
Example #2
0
        private void Load()
        {
            Shops = new SortedList <int, NDShop>();

            _teleports = new NDTeleport();

            ItemTable itable = ItemTable.Instance;

            {
                XElement xml = XElement.Parse(File.ReadAllText(@"scripts\buylists.xml"));
                foreach (XElement shops in xml.Elements("shops"))
                {
                    foreach (XElement shopp in shops.Elements("shop"))
                    {
                        NDShop   shop       = new NDShop();
                        XElement npcElement = shopp.Element("npc");
                        if (npcElement != null)
                        {
                            shop.Id = int.Parse(npcElement.Value);
                        }
                        XElement modElement = shopp.Element("mod");
                        if (modElement != null)
                        {
                            shop.Mod = double.Parse(modElement.Value);
                        }

                        foreach (XElement selllist in shopp.Elements("selllist"))
                        {
                            NdShopList slist = new NdShopList
                            {
                                Id = short.Parse(selllist.Attribute("id").Value)
                            };

                            XElement itemElement = selllist.Element("item");
                            if (itemElement != null)
                            {
                                string items = itemElement.Value;
                                items = items.Replace("\n", string.Empty).Replace(" ", string.Empty);

                                foreach (string i in items.Split(','))
                                {
                                    ItemTemplate it = itable.GetItem(Convert.ToInt32(i));
                                    if (it != null)
                                    {
                                        slist.Items.Add(new NDShopItem(it));
                                    }
                                    else
                                    {
                                        Log.Error($"NpcData: cant find item to trade {i} on npc {shop.Id}");
                                    }
                                }
                            }

                            shop.Lists.Add(slist.Id, slist);
                        }

                        Shops.Add(shop.Id, shop);
                    }
                }
            }

            Log.Info($"NpcData: loaded {Shops.Count} merchants.");
            //CLogger.info($"NpcData: loaded {_mults.Count} multisell lists.");
        }