public void WritePage(CatalogPage Page, int TreeSize) { base.WriteBoolean(Page.Visible); base.WriteInteger(Page.Icon); base.WriteInteger(Page.Id); base.WriteString(Page.PageLink); base.WriteString(Page.Caption); base.WriteInteger(Page.ItemOffers.Count); foreach (int i in Page.ItemOffers.Keys) { base.WriteInteger(i); } base.WriteInteger(TreeSize); }
public bool TryGetPage(int pageId, out CatalogPage page) => _pages.TryGetValue(pageId, out page);
public bool TryGetPage(int pageId, out CatalogPage page) { return(this._pages.TryGetValue(pageId, out page)); }
public bool TryGetPage(int pageId, out CatalogPage page) { return this._pages.TryGetValue(pageId, out page); }
public CatalogPageComposer(CatalogPage Page, string CataMode) : base(ServerPacketHeader.CatalogPageMessageComposer) { base.WriteInteger(Page.Id); base.WriteString(CataMode); base.WriteString(Page.Template); base.WriteInteger(Page.PageStrings1.Count); foreach (string s in Page.PageStrings1) { base.WriteString(s); } base.WriteInteger(Page.PageStrings2.Count); foreach (string s in Page.PageStrings2) { base.WriteString(s); } if (!Page.Template.Equals("frontpage") && !Page.Template.Equals("club_buy")) { base.WriteInteger(Page.Items.Count); foreach (CatalogItem Item in Page.Items.Values) { base.WriteInteger(Item.Id); base.WriteString(Item.Name); base.WriteBoolean(false);//IsRentable base.WriteInteger(Item.CostCredits); if (Item.CostDiamonds > 0) { base.WriteInteger(Item.CostDiamonds); base.WriteInteger(5); // Diamonds } else { base.WriteInteger(Item.CostPixels); base.WriteInteger(0); // Type of PixelCost } base.WriteBoolean(ItemUtility.CanGiftItem(Item)); if (Item.Data.InteractionType == InteractionType.DEAL) { foreach (CatalogDeal Deal in Page.Deals.Values) { base.WriteInteger(Deal.ItemDataList.Count);//Count foreach (CatalogItem DealItem in Deal.ItemDataList.ToList()) { base.WriteString(DealItem.Data.Type.ToString()); base.WriteInteger(DealItem.Data.SpriteId); base.WriteString(""); base.WriteInteger(1); base.WriteBoolean(false); } base.WriteInteger(0);//club_level base.WriteBoolean(ItemUtility.CanSelectAmount(Item)); } } else { base.WriteInteger(string.IsNullOrEmpty(Item.Badge) ? 1 : 2);//Count 1 item if there is no badge, otherwise count as 2. { if (!string.IsNullOrEmpty(Item.Badge)) { base.WriteString("b"); base.WriteString(Item.Badge); } base.WriteString(Item.Data.Type.ToString()); if (Item.Data.Type.ToString().ToLower() == "b") { //This is just a badge, append the name. base.WriteString(Item.Data.ItemName); } else { base.WriteInteger(Item.Data.SpriteId); if (Item.Data.InteractionType == InteractionType.WALLPAPER || Item.Data.InteractionType == InteractionType.FLOOR || Item.Data.InteractionType == InteractionType.LANDSCAPE) { base.WriteString(Item.Name.Split('_')[2]); } else if (Item.Data.InteractionType == InteractionType.BOT)//Bots { CatalogBot CatalogBot = null; if (!PlusEnvironment.GetGame().GetCatalog().TryGetBot(Item.ItemId, out CatalogBot)) base.WriteString("hd-180-7.ea-1406-62.ch-210-1321.hr-831-49.ca-1813-62.sh-295-1321.lg-285-92"); else base.WriteString(CatalogBot.Figure); } else if (Item.ExtraData != null) { base.WriteString(Item.ExtraData != null ? Item.ExtraData : string.Empty); } base.WriteInteger(Item.Amount); base.WriteBoolean(Item.IsLimited); // IsLimited if (Item.IsLimited) { base.WriteInteger(Item.LimitedEditionStack); base.WriteInteger(Item.LimitedEditionStack - Item.LimitedEditionSells); } } base.WriteInteger(0); //club_level base.WriteBoolean(ItemUtility.CanSelectAmount(Item)); } } } } else base.WriteInteger(0); base.WriteInteger(-1); base.WriteBoolean(false); }
public void Init(ItemDataManager ItemDataManager) { if (this._pages.Count > 0) { this._pages.Clear(); } if (this._bundles.Count > 0) { this._bundles.Clear(); } if (this._botPresets.Count > 0) { this._botPresets.Clear(); } if (this._items.Count > 0) { this._items.Clear(); } if (this._deals.Count > 0) { this._deals.Clear(); } using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `id`,`item_id`,`catalog_name`,`cost_credits`,`cost_pixels`,`cost_diamonds`,`amount`,`page_id`,`limited_sells`,`limited_stack`,`offer_active`,`extradata`,`badge`,`offer_id` FROM `catalog_items`"); DataTable CatalogueItems = dbClient.getTable(); if (CatalogueItems != null) { foreach (DataRow Row in CatalogueItems.Rows) { if (Convert.ToInt32(Row["amount"]) <= 0) { continue; } int ItemId = Convert.ToInt32(Row["id"]); int PageId = Convert.ToInt32(Row["page_id"]); int BaseId = Convert.ToInt32(Row["item_id"]); int OfferId = Convert.ToInt32(Row["offer_id"]); ItemData Data = null; if (!ItemDataManager.GetItem(BaseId, out Data)) { log.Error("Não foi possível carregar o item " + ItemId + " no catalogo, nenhum registro de móveis encontrado."); continue; } if (!this._items.ContainsKey(PageId)) { this._items[PageId] = new Dictionary <int, CatalogItem>(); } if (OfferId != -1 && !this._itemOffers.ContainsKey(OfferId)) { this._itemOffers.Add(OfferId, PageId); } var Item = new CatalogItem(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["item_id"]), Data, Convert.ToString(Row["catalog_name"]), Convert.ToInt32(Row["page_id"]), Convert.ToInt32(Row["cost_credits"]), Convert.ToInt32(Row["cost_pixels"]), Convert.ToInt32(Row["cost_diamonds"]), Convert.ToInt32(Row["amount"]), Convert.ToInt32(Row["limited_sells"]), Convert.ToInt32(Row["limited_stack"]), PlusEnvironment.EnumToBool(Row["offer_active"].ToString()), Convert.ToString(Row["extradata"]), Convert.ToString(Row["badge"]), Convert.ToInt32(Row["offer_id"])); this._items[PageId].Add(Item.Id, Item); } } dbClient.SetQuery("SELECT `id`,`item_id`,`catalog_name`,`cost_credits`,`cost_pixels`,`cost_diamonds`,`amount`,`page_id`,`limited_sells`,`limited_stack`,`offer_active`,`extradata`,`badge`,`offer_id` FROM `catalog_items` WHERE `catalog_name` LIKE 'HABBO_CLUB_VIP%'"); DataTable HoloRPClubItems = dbClient.getTable(); if (HoloRPClubItems != null) { foreach (DataRow Row in HoloRPClubItems.Rows) { if (Convert.ToInt32(Row["amount"]) <= 0) { continue; } int ItemId = Convert.ToInt32(Row["id"]); int PageId = Convert.ToInt32(Row["page_id"]); int BaseId = Convert.ToInt32(Row["item_id"]); int OfferId = Convert.ToInt32(Row["offer_id"]); ItemData Data = null; if (!ItemDataManager.GetItem(BaseId, out Data)) { log.Error("Não foi possível carregar o item " + ItemId + ", no catalogo, nenhum registro de móveis encontrado."); continue; } var Item = new CatalogItem(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["item_id"]), Data, Row.IsNull("catalog_name") ? "HabboRPG Clube" : Convert.ToString(Row["catalog_name"]), Convert.ToInt32(Row["page_id"]), Convert.ToInt32(Row["cost_credits"]), Convert.ToInt32(Row["cost_pixels"]), Convert.ToInt32(Row["cost_diamonds"]), Convert.ToInt32(Row["amount"]), Convert.ToInt32(Row["limited_sells"]), Convert.ToInt32(Row["limited_stack"]), PlusEnvironment.EnumToBool(Row["offer_active"].ToString()), Convert.ToString(Row["extradata"]), Convert.ToString(Row["badge"]), Convert.ToInt32(Row["offer_id"])); if (!this._clubitems.Contains(Item)) { this._clubitems.Add(Item); } } } dbClient.SetQuery("SELECT * FROM `catalog_deals`"); DataTable GetDeals = dbClient.getTable(); if (GetDeals != null) { foreach (DataRow Row in GetDeals.Rows) { int Id = Convert.ToInt32(Row["id"]); int PageId = Convert.ToInt32(Row["page_id"]); string Items = Convert.ToString(Row["items"]); string Name = Convert.ToString(Row["name"]); int Credits = Convert.ToInt32(Row["cost_credits"]); int Pixels = Convert.ToInt32(Row["cost_pixels"]); if (!this._deals.ContainsKey(PageId)) { this._deals[PageId] = new Dictionary <int, CatalogDeal>(); } CatalogDeal Deal = new CatalogDeal(Id, PageId, Items, Name, Credits, Pixels, ItemDataManager); this._deals[PageId].Add(Deal.Id, Deal); } } dbClient.SetQuery("SELECT * FROM `catalog_pages` ORDER BY `order_num`"); DataTable CatalogPages = dbClient.getTable(); if (CatalogPages != null) { foreach (DataRow Row in CatalogPages.Rows) { int Id = Convert.ToInt32(Row["id"]); int ParentId = Convert.ToInt32(Row["parent_id"]); bool Enabled = PlusEnvironment.EnumToBool(Row["enabled"].ToString()); string Name = Row["caption"].ToString(); string PageLink = Row["page_link"].ToString(); int Icon = Convert.ToInt32(Row["icon_image"]); int MinRank = Convert.ToInt32(Row["min_rank"]); int MinVIP = Convert.ToInt32(Row["min_vip"]); bool Visible = PlusEnvironment.EnumToBool(Row["visible"].ToString()); string Layout = Row["page_layout"].ToString(); string Strings1 = Row["page_strings_1"].ToString(); string Strings2 = Row["page_strings_2"].ToString(); Dictionary <int, CatalogItem> Items = this._items.ContainsKey(Id) ? this._items[Id] : new Dictionary <int, CatalogItem>(); Dictionary <int, CatalogDeal> Deals = this._deals.ContainsKey(Id) ? this._deals[Id] : new Dictionary <int, CatalogDeal>(); CatalogPage NewPage = new CatalogPage(Id, ParentId, Enabled, Name, PageLink, Icon, MinRank, MinVIP, Visible, Layout, Strings1, Strings2, Items, Deals, ref this._itemOffers); if (!this._pages.ContainsKey(Id)) { this._pages.Add(Id, NewPage); } } } dbClient.SetQuery("SELECT * FROM `catalog_pages_bundles`"); DataTable CatalogBundles = dbClient.getTable(); if (CatalogBundles != null) { foreach (DataRow Row in CatalogBundles.Rows) { int Id = Convert.ToInt32(Row["id"]); string Title = Row["title"].ToString(); string Image = Row["image"].ToString(); string Link = Row["link"].ToString(); CatalogBundle NewBundle = new CatalogBundle(Id, Title, Image, Link); if (!this._bundles.ContainsKey(Id)) { this._bundles.Add(Id, NewBundle); } } } dbClient.SetQuery("SELECT `id`,`name`,`figure`,`motto`,`gender`,`ai_type` FROM `catalog_bot_presets`"); DataTable bots = dbClient.getTable(); if (bots != null) { foreach (DataRow Row in bots.Rows) { this._botPresets.Add(Convert.ToInt32(Row[0]), new CatalogBot(Convert.ToInt32(Row[0]), Convert.ToString(Row[1]), Convert.ToString(Row[2]), Convert.ToString(Row[3]), Convert.ToString(Row[4]), Convert.ToString(Row[5]))); } } this._petRaceManager.Init(); this._clothingManager.Init(); } //log.Info("Catalog Manager -> LOADED"); }