예제 #1
0
 internal static ServerMessage PurchaseOk(CatalogItem itemCatalog, Dictionary<Item, uint> items,
     int clubLevel = 1)
 {
     return PurchaseOk(itemCatalog.Id, itemCatalog.Name, itemCatalog.CreditsCost, items, clubLevel,
         itemCatalog.DiamondsCost,
         itemCatalog.DucketsCost, itemCatalog.IsLimited, itemCatalog.LimitedStack, itemCatalog.LimitedSelled);
 }
예제 #2
0
        /// <summary>
        ///     Composes the item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="message">The message.</param>
        internal static void ComposeItem(CatalogItem item, ServerMessage message)
        {
            message.AppendInteger(item.Id);
            message.AppendString(item.Name, true);
            message.AppendBool(false);
            message.AppendInteger(item.CreditsCost);

            if (item.DiamondsCost > 0)
            {
                message.AppendInteger(item.DiamondsCost);
                message.AppendInteger(105);
            }
            else
            {
                message.AppendInteger(item.DucketsCost);
                message.AppendInteger(0);
            }
            message.AppendBool(item.GetFirstBaseItem().AllowGift);

            switch (item.Name)
            {
                case "g0 group_product":
                    message.AppendInteger(0);
                    break;

                case "room_ad_plus_badge":
                    message.AppendInteger(1);
                    message.AppendString("b");
                    message.AppendString("RADZZ");
                    break;

                default:
                    if (item.Name.StartsWith("builders_club_addon_") || item.Name.StartsWith("builders_club_time_"))
                        message.AppendInteger(0);
                    else if (item.Badge == "")
                        message.AppendInteger(item.Items.Count);
                    else
                    {
                        message.AppendInteger(item.Items.Count + 1);
                        message.AppendString("b");
                        message.AppendString(item.Badge);
                    }
                    break;
            }
            foreach (var baseItem in item.Items.Keys)
            {
                if (item.Name == "g0 group_product" || item.Name.StartsWith("builders_club_addon_") ||
                    item.Name.StartsWith("builders_club_time_"))
                    break;
                if (item.Name == "room_ad_plus_badge")
                {
                    message.AppendString("");
                    message.AppendInteger(0);
                }
                else
                {
                    message.AppendString(baseItem.Type.ToString());
                    message.AppendInteger(baseItem.SpriteId);

                    if (item.Name.Contains("wallpaper_single") || item.Name.Contains("floor_single") ||
                        item.Name.Contains("landscape_single"))
                    {
                        var array = item.Name.Split('_');
                        message.AppendString(array[2]);
                    }
                    else if (item.Name.StartsWith("bot_") || baseItem.InteractionType == Interaction.MusicDisc ||
                             item.GetFirstBaseItem().Name == "poster")
                        message.AppendString(item.ExtraData);
                    else if (item.Name.StartsWith("poster_"))
                    {
                        var array2 = item.Name.Split('_');
                        message.AppendString(array2[1]);
                    }
                    else if (item.Name.StartsWith("poster "))
                    {
                        var array3 = item.Name.Split(' ');
                        message.AppendString(array3[1]);
                    }
                    else if (item.SongId > 0u && baseItem.InteractionType == Interaction.MusicDisc)
                        message.AppendString(item.ExtraData);
                    else
                        message.AppendString(string.Empty);

                    message.AppendInteger(item.Items[baseItem]);
                    message.AppendBool(item.IsLimited);
                    if (!item.IsLimited)
                        continue;
                    message.AppendInteger(item.LimitedStack);
                    message.AppendInteger(item.LimitedStack - item.LimitedSelled);
                }
            }
            message.AppendInteger(item.ClubOnly ? 1 : 0);

            if (item.IsLimited || item.FirstAmount != 1)
            {
                message.AppendBool(false);
                return;
            }

            message.AppendBool(item.HaveOffer && !item.IsLimited);
        }
예제 #3
0
        /// <summary>
        ///     Initializes the specified database client.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal void Initialize(IQueryAdapter dbClient)
        {
            Categories = new HybridDictionary();
            Offers = new HybridDictionary();
            FlatOffers = new Dictionary<int, uint>();
            EcotronRewards = new List<EcotronReward>();
            EcotronLevels = new List<int>();
            HabboClubItems = new List<CatalogItem>();

            dbClient.SetQuery("SELECT * FROM catalog_items ORDER BY order_num ASC");
            var table = dbClient.GetTable();
            dbClient.SetQuery("SELECT * FROM catalog_pages ORDER BY order_num ASC");
            var table2 = dbClient.GetTable();
            dbClient.SetQuery("SELECT * FROM catalog_ecotron ORDER BY reward_level ASC");
            var table3 = dbClient.GetTable();
            dbClient.SetQuery("SELECT * FROM catalog_items WHERE specialName LIKE 'HABBO_CLUB_VIP%'");
            var table4 = dbClient.GetTable();

            if (table != null)
            {
                foreach (DataRow dataRow in table.Rows)
                {
                    if (string.IsNullOrEmpty(dataRow["item_names"].ToString()) ||
                        string.IsNullOrEmpty(dataRow["amounts"].ToString()))
                        continue;

                    var source = dataRow["item_names"].ToString();
                    var firstItem = dataRow["item_names"].ToString().Split(';')[0];

                    Item item;

                    if (!Azure.GetGame().GetItemManager().GetItem(firstItem, out item))
                        continue;

                    var num = !source.Contains(';') ? item.FlatId : -1;
                    if (!dataRow.IsNull("specialName"))
                        item.PublicName = (string)dataRow["specialName"];

                    var catalogItem = new CatalogItem(dataRow, item.PublicName);

                    if (catalogItem.GetFirstBaseItem() == null)
                        continue;

                    Offers.Add(catalogItem.Id, catalogItem);

                    if (num != -1 && !FlatOffers.ContainsKey(num))
                        FlatOffers.Add(num, catalogItem.Id);
                }
            }

            if (table2 != null)
            {
                foreach (DataRow dataRow2 in table2.Rows)
                {
                    var visible = false;
                    var enabled = false;

                    if (dataRow2["visible"].ToString() == "1")
                        visible = true;
                    if (dataRow2["enabled"].ToString() == "1")
                        enabled = true;

                    Categories.Add(Convert.ToInt32(dataRow2["id"]),
                        new CatalogPage(Convert.ToUInt32(dataRow2["id"]), short.Parse(dataRow2["parent_id"].ToString()),
                            (string)dataRow2["code_name"], (string)dataRow2["caption"], visible, enabled, false,
                            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 (table3 != null)
            {
                foreach (DataRow dataRow3 in table3.Rows)
                {
                    EcotronRewards.Add(new EcotronReward(Convert.ToUInt32(dataRow3["display_id"]),
                        Convert.ToUInt32(dataRow3["item_id"]), Convert.ToUInt32(dataRow3["reward_level"])));

                    if (!EcotronLevels.Contains(Convert.ToInt16(dataRow3["reward_level"])))
                        EcotronLevels.Add(Convert.ToInt16(dataRow3["reward_level"]));
                }
            }

            if (table4 != null)
            {
                foreach (DataRow row in table4.Rows)
                    HabboClubItems.Add(new CatalogItem(row,
                        row.IsNull("specialName") ? "Habbo VIP" : (string)row["specialName"]));
            }
        }