Exemplo n.º 1
0
        internal void Initialize(IQueryAdapter dbClient)
        {
            this.Categories = new HybridDictionary();
            this.Offers = new HybridDictionary();
            this.FlatOffers = new Dictionary<int, uint>();
            this.EcotronRewards = new List<EcotronReward>();
            this.EcotronLevels = new List<int>();
            this.HabboClubItems = new List<CatalogItem>();

            dbClient.setQuery("SELECT * FROM catalog_pages ORDER BY order_num");
            DataTable table = dbClient.getTable();
            dbClient.setQuery("SELECT * FROM ecotron_rewards ORDER BY reward_level ASC");
            DataTable table2 = dbClient.getTable();
            dbClient.setQuery("SELECT * FROM catalog_items");
            DataTable table3 = dbClient.getTable();
            dbClient.setQuery("SELECT * FROM  `catalog_items` WHERE  `catalog_name` LIKE  '%HABBO_CLUB_VIP%'");
            DataTable table4 = dbClient.getTable();

            if (table3 != null)
            {
                foreach (DataRow dataRow in table3.Rows)
                {
                    if (!string.IsNullOrEmpty(dataRow["item_ids"].ToString()) && !string.IsNullOrEmpty(dataRow["amounts"].ToString()))
                    {
                        int value = Convert.ToInt32(dataRow["page_id"]);
                        string source = dataRow["item_ids"].ToString();
                        dataRow["catalog_name"].ToString();
                        uint id = uint.Parse(dataRow["item_ids"].ToString().Split(';')[0]);
                        Item item = MercuryEnvironment.GetGame().GetItemManager().GetItem(id);

                        if (item != null)
                        {
                            int num;
                            if (!source.Contains(';'))
                            {
                                num = item.FlatId;
                            }
                            else
                            {
                                num = -1;
                            }

                            CatalogItem value2 = new CatalogItem(dataRow);
                            if (value2.GetFirstBaseItem() == null)
                                continue;

                            this.Offers.Add(value2.Id, value2);

                            if (num != -1 && !this.FlatOffers.ContainsKey(num))
                            {
                                this.FlatOffers.Add(num, value2.Id);
                            }
                        }
                    }
                }
            }
            if (table != null)
            {
                foreach (DataRow dataRow2 in table.Rows)
                {
                    bool visible = false;
                    bool enabled = false;
                    bool comingSoon = false;
                    if (dataRow2["visible"].ToString() == "1")
                    {
                        visible = true;
                    }
                    if (dataRow2["enabled"].ToString() == "1")
                    {
                        enabled = true;
                    }
                    this.Categories.Add((int)dataRow2["id"], new CatalogPage((int)dataRow2["id"], (int)dataRow2["parent_id"], (string)dataRow2["code_name"], (string)dataRow2["caption"], visible, enabled, comingSoon, Convert.ToUInt32(dataRow2["min_rank"]), (int)dataRow2["icon_image"], (string)dataRow2["page_layout"], (string)dataRow2["page_headline"], (string)dataRow2["page_teaser"], (string)dataRow2["page_special"], (string)dataRow2["page_text1"], (string)dataRow2["page_text2"], (string)dataRow2["page_text_details"], (string)dataRow2["page_text_teaser"], (string)dataRow2["page_link_description"], (string)dataRow2["page_link_pagename"], (int)dataRow2["order_num"], ref Offers));
                }
            }
            if (table2 != null)
            {
                foreach (DataRow dataRow3 in table2.Rows)
                {
                    this.EcotronRewards.Add(new EcotronReward(Convert.ToUInt32(dataRow3["display_id"]), Convert.ToUInt32(dataRow3["item_id"]), Convert.ToUInt32(dataRow3["reward_level"])));
                    if (!this.EcotronLevels.Contains((int)Convert.ToInt16(dataRow3["reward_level"])))
                    {
                        this.EcotronLevels.Add((int)Convert.ToInt16(dataRow3["reward_level"]));
                    }
                }
            }
            if (table4 != null)
            {
                foreach (DataRow row in table4.Rows)
                {
                    this.HabboClubItems.Add(new CatalogItem(row));
                }
            }

            CachedIndexes = new Dictionary<uint, ServerMessage>();
            for (uint i = 1; i < 9; i++)
            {
                CachedIndexes.Add(i, CatalogPacket.ComposeIndex(i));
            }

        }
Exemplo n.º 2
0
        internal static void ComposeItem(CatalogItem Item, ServerMessage Message)
        {
            Message.AppendUInt(Item.Id);
            Message.AppendString(Item.Name);
            Message.AppendBoolean(false);
            Message.AppendInt32(Item.CreditsCost);
            if (Item.BelCreditsCost > 0)
            {
                Message.AppendInt32(Item.BelCreditsCost);
                Message.AppendInt32(105);
            }
            else
            {
                if (Item.LoyaltyCost > 0)
                {
                    Message.AppendInt32(Item.LoyaltyCost);
                    Message.AppendInt32(105);
                }
                else
                {
                    Message.AppendInt32(Item.DucketsCost);
                    Message.AppendInt32(0);
                }
            }
            Message.AppendBoolean(Item.GetFirstBaseItem().AllowGift);
            checked
            {
                if (Item.Name == "g0 group_product")
                {
                    Message.AppendInt32(0);
                }
                else
                {
                    if (Item.Badge == "")
                    {
                        Message.AppendInt32(Item.Items.Count);
                    }
                    else
                    {
                        if (Item.Name == "room_ad_plus_badge")
                        {
                            Message.AppendInt32(1);
                        }
                        else
                        {
                            Message.AppendInt32(Item.Items.Count + 1);
                        }
                        Message.AppendString("b");
                        Message.AppendString(Item.Badge);
                    }
                }
                foreach (uint current in Item.Items.Keys)
                {
                    if (Item.Name == "g0 group_product")
                    {
                        break;
                    }
                    if (Item.Name != "room_ad_plus_badge")
                    {
                        Message.AppendString(Item.GetBaseItem(current).Type.ToString());
                        Message.AppendInt32(Item.GetBaseItem(current).SpriteId);

                        if (Item.Name.Contains("wallpaper_single") || Item.Name.Contains("floor_single") || Item.Name.Contains("landscape_single"))
                        {
                            string[] array = Item.Name.Split('_');
                            Message.AppendString(array[2]);
                        }
                        else
                        {
                            if (Item.Name.StartsWith("bot_") || Item.GetBaseItem(current).InteractionType == InteractionType.musicdisc)
                            {
                                Message.AppendString(Item.ExtraData);
                            }
                            else
                            {
                                if (Item.Name.StartsWith("poster_"))
                                {
                                    string[] array2 = Item.Name.Split('_');
                                    Message.AppendString(array2[1]);
                                }
                                else
                                {
                                    if (Item.Name.StartsWith("poster "))
                                    {
                                        string[] array3 = Item.Name.Split(' ');
                                        Message.AppendString(array3[1]);
                                    }
                                    else
                                    {
                                        if (Item.songID > 0u && Item.GetBaseItem(current).InteractionType == InteractionType.musicdisc)
                                        {
                                            Message.AppendString(Item.ExtraData);
                                        }
                                        else
                                        {
                                            Message.AppendString(string.Empty);
                                        }
                                    }
                                }
                            }
                        }
                        Message.AppendInt32(Item.Items[current]);
                        Message.AppendBoolean(Item.IsLimited);
                        if (Item.IsLimited)
                        {
                            Message.AppendInt32(Item.LimitedStack);
                            Message.AppendInt32(Item.LimitedStack - Item.LimitedSelled);
                        }
                    }
                    else
                    {
                        Message.AppendString("");
                        Message.AppendInt32(0);
                    }
                }
                Message.AppendInt32(Item.ClubOnly ? 1 : 0);
                if (Item.IsLimited || Item.FirstAmount != 1)
                {
                    Message.AppendBoolean(false);
                    return;
                }
                Message.AppendBoolean(Item.HaveOffer && !Item.IsLimited);
            }
        }