Exemple #1
0
        public static List <GoodItem> GetGoods(List <CartGoods> ShopCart, out int GoldPrice, out int CashPrice)
        {
            GoldPrice = 0;
            CashPrice = 0;
            List <GoodItem> items = new List <GoodItem>();

            if (ShopCart.Count == 0)
            {
                return(items);
            }
            lock (ShopBuyableList)
            {
                for (int i = 0; i < ShopBuyableList.Count; i++)
                {
                    GoodItem good = ShopBuyableList[i];
                    for (int i2 = 0; i2 < ShopCart.Count; i2++)
                    {
                        CartGoods CartGood = ShopCart[i2];
                        if (CartGood.GoodId == good.id)
                        {
                            items.Add(good);
                            if (CartGood.BuyType == 1)
                            {
                                GoldPrice += good.price_gold;
                            }
                            else if (CartGood.BuyType == 2)
                            {
                                CashPrice += good.price_cash;
                            }
                        }
                    }
                }
            }
            return(items);
        }
Exemple #2
0
 private static byte[] GetMatchingData(int maximum, int page, ref int count, List <GoodItem> list)
 {
     count = 0;
     using (PacketWriter Writer = new PacketWriter())
     {
         for (int i = page * maximum; i < list.Count; i++)
         {
             GoodItem good = list[i];
             Writer.WriteD(good.id);
             Writer.WriteD(good.item.id);
             Writer.WriteD(good.item.count);
             if (++count == maximum)
             {
                 break;
             }
         }
         return(Writer.memorystream.ToArray());
     }
 }
Exemple #3
0
 private static byte[] GetItemsData(int maximum, int page, ref int count, List <GoodItem> list)
 {
     count = 0;
     using (PacketWriter Writer = new PacketWriter())
     {
         for (int i = page * maximum; i < list.Count; i++)
         {
             GoodItem good = list[i];
             Writer.WriteD(good.item.id);
             Writer.WriteC((byte)good.auth_type);
             Writer.WriteC((byte)good.buy_type2);
             Writer.WriteC((byte)good.buy_type3);
             Writer.WriteC((byte)good.title);
             if (++count == maximum)
             {
                 break;
             }
         }
         return(Writer.memorystream.ToArray());
     }
 }
Exemple #4
0
 private static byte[] GetGoodsData(int maximum, int page, ref int count, List <GoodItem> list)
 {
     count = 0;
     using (PacketWriter Writer = new PacketWriter())
     {
         for (int i = page * maximum; i < list.Count; i++)
         {
             GoodItem good = list[i];
             Writer.WriteD(good.id);
             Writer.WriteC(1);
             Writer.WriteC((byte)(good.visibility == 4 ? 4 : 1));
             //Flag1 = Show icon + Buy option | Flag2 = UNK | Flag4 = Show icon + No buy option
             Writer.WriteD(good.price_gold);
             Writer.WriteD(good.price_cash);
             Writer.WriteC((byte)good.tag);
             if (++count == maximum)
             {
                 break;
             }
         }
         return(Writer.memorystream.ToArray());
     }
 }
Exemple #5
0
 public static void Load()
 {
     try
     {
         using (NpgsqlConnection connection = new NpgsqlConnection(SQLManager.ConnectionString))
             using (NpgsqlCommand command = connection.CreateCommand())
             {
                 connection.Open();
                 command.CommandText = "SELECT * FROM shop";
                 using (NpgsqlDataReader data = command.ExecuteReader())
                 {
                     while (data.Read())
                     {
                         GoodItem good = new GoodItem
                         {
                             id         = data.GetInt32(0),
                             price_gold = data.GetInt32(3),
                             price_cash = data.GetInt32(4),
                             auth_type  = data.GetInt32(6), //1 = unidade 2 = dias
                             buy_type2  = data.GetInt32(7),
                             buy_type3  = data.GetInt32(8),
                             tag        = data.GetInt32(9),
                             title      = data.GetInt32(10),//0= Sem titulo Id do Slot=requer titulo
                             visibility = data.GetInt32(11)
                         };
                         good.item.SetItemId(data.GetInt32(1));
                         good.item.name  = data.GetString(2);
                         good.item.count = data.GetInt32(5);
                         ShopAllList.Add(good);
                         if (good.visibility != 2 && good.visibility != 4)
                         {
                             ShopBuyableList.Add(good);
                         }
                         if (!ShopUniqueList.ContainsKey(good.item.id) && good.auth_type > 0)
                         {
                             ShopUniqueList.TryAdd(good.item.id, good);
                             if (good.visibility == 4)
                             {
                                 set4p++;
                             }
                         }
                     }
                     LoadDataMatching1Goods(); //Pccafe 0
                     LoadDataMatching2();      //Pccafe basic/premium
                     LoadDataItems();
                     data.Close();
                     connection.Close();
                 }
             }
         if (set4p > 0)
         {
             Logger.Informations($" [ShopManager] Loaded {set4p} itens invisíveis com ícones liberados.");
         }
     }
     catch (Exception ex)
     {
         Logger.Exception(ex);
     }
     //XIEMIELE();
     //CreateJsonShop();
 }
Exemple #6
0
        public static void XIEMIELE()
        {
            SortedList <int, ItemInfo> items = new SortedList <int, ItemInfo>();
            int           counttt            = 0;
            XmlTextWriter TW = new XmlTextWriter(Directory.GetCurrentDirectory() + "/UserFileList.xml", Encoding.UTF8);

            TW.WriteStartDocument();
            TW.Formatting = Formatting.Indented;
            TW.WriteStartElement("list");
            for (int i = 0; i < ShopAllList.Count; i++)
            {
                GoodItem good = ShopAllList[i];
                string   tag  = "NULL";
                if (good.tag == 0)
                {
                    tag = "DEFAULT";
                }
                else if (good.tag == 1)
                {
                    tag = "NEW";
                }
                else if (good.tag == 2)
                {
                    tag = "HOT";
                }
                else if (good.tag == 3)
                {
                    tag = "EVENT";
                }
                else if (good.tag == 4)
                {
                    tag = "PCCAFE";
                }
                else if (good.tag == 5)
                {
                    tag = "SALE";
                }
                else if (good.tag == 6)
                {
                    tag = "SET";
                }
                string visibleType = "NULL";
                if (good.visibility == 0)
                {
                    visibleType = "VISIVEL E ICONES";
                }
                else if (good.visibility == 1)
                {
                    visibleType = "SET PRIMARY";
                }
                else if (good.visibility == 2)
                {
                    visibleType = "INVISIVEL";
                }
                else if (good.visibility == 3)
                {
                    visibleType = "SET ITENS";
                }
                else if (good.visibility == 4)
                {
                    visibleType = "APENAS ICONES";
                }
                ItemInfo info = new ItemInfo();
                info.ItemName  = good.item.name;
                info.GoodId    = i;
                info.ItemId    = good.item.id;
                info.PriceGold = good.price_gold;
                info.PriceCash = good.price_cash;
                if (good.auth_type == 0)
                {
                    if (good.item.count > 500)
                    {
                        info.Count = good.item.count / 60 / 60 / 24;
                    }
                    else
                    {
                        info.Count = good.item.count;
                    }
                    info.BuyType = "SET";
                }
                else if (good.auth_type == 1)
                {
                    info.Count   = good.item.count;
                    info.BuyType = "UNIDADE";
                }
                else if (good.auth_type == 2)
                {
                    info.BuyType = "DIAS";
                    info.Count   = good.item.count / 60 / 60 / 24;
                }
                info.Tag        = tag;
                info.Title      = good.title;
                info.Visibility = visibleType;

                if (!items.ContainsKey(info.ItemId))
                {
                    items.Add(info.ItemId, info);
                }
                counttt++;
            }
            foreach (ItemInfo info in items.Values)
            {
                if (info.BuyType == "DIAS")
                {
                    TW.WriteStartElement("file");
                    TW.WriteAttributeString("GoodId", "", info.GoodId.ToString());
                    TW.WriteAttributeString("PriceGold", "", info.PriceGold.ToString());
                    TW.WriteAttributeString("PriceCash", "", info.PriceCash.ToString());
                    TW.WriteAttributeString("BuyType", "", info.BuyType);
                    TW.WriteAttributeString("Count", "", info.Count.ToString());
                    TW.WriteAttributeString("Tag", "", info.Tag.ToString());
                    TW.WriteAttributeString("Title", "", info.Title.ToString());
                    TW.WriteAttributeString("Visibility", "", info.Visibility.ToString());
                    TW.WriteAttributeString("ItemId", "", info.ItemId.ToString());
                    TW.WriteAttributeString("ItemName", "", info.ItemName.ToString());
                    TW.WriteEndElement();
                }
                else
                {
                    TW.WriteStartElement("file");
                    TW.WriteAttributeString("GoodId", "", info.GoodId.ToString());
                    TW.WriteAttributeString("PriceGold", "", info.PriceGold.ToString());
                    TW.WriteAttributeString("PriceCash", "", info.PriceCash.ToString());
                    TW.WriteAttributeString("BuyType", "", info.BuyType);
                    TW.WriteAttributeString("Count", "", info.Count.ToString());
                    TW.WriteAttributeString("Tag", "", info.Tag.ToString());
                    TW.WriteAttributeString("Title", "", info.Title.ToString());
                    TW.WriteAttributeString("Visibility", "", info.Visibility.ToString());
                    TW.WriteAttributeString("ItemId", "", info.ItemId.ToString());
                    TW.WriteAttributeString("ItemName", "", info.ItemName.ToString());
                    TW.WriteEndElement();
                }
                TW.WriteEndElement();
                TW.Close();
            }
            Logger.Warning("counttt: " + counttt);
        }