public void Init(ItemDataManager ItemDataManager) { if (_pages.Count > 0) { _pages.Clear(); } if (_botPresets.Count > 0) { _botPresets.Clear(); } if (_items.Count > 0) { _items.Clear(); } if (_deals.Count > 0) { _deals.Clear(); } if (_promotions.Count > 0) { _promotions.Clear(); } using (var 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`"); var CatalogueItems = dbClient.GetTable(); if (CatalogueItems != null) { foreach (DataRow Row in CatalogueItems.Rows) { if (Convert.ToInt32(Row["amount"]) <= 0) { continue; } var ItemId = Convert.ToInt32(Row["id"]); var PageId = Convert.ToInt32(Row["page_id"]); var BaseId = Convert.ToInt32(Row["item_id"]); var OfferId = Convert.ToInt32(Row["offer_id"]); ItemData Data = null; if (!ItemDataManager.GetItem(BaseId, out Data)) { log.Error("Couldn't load Catalog Item " + ItemId + ", no furniture record found."); continue; } if (!_items.ContainsKey(PageId)) { _items[PageId] = new Dictionary <int, CatalogItem>(); } if (OfferId != -1 && !_itemOffers.ContainsKey(OfferId)) { _itemOffers.Add(OfferId, PageId); } _items[PageId] .Add(Convert.ToInt32(Row["id"]), 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"]))); } } dbClient.SetQuery("SELECT `id`, `items`, `name`, `room_id` FROM `catalog_deals`"); var GetDeals = dbClient.GetTable(); if (GetDeals != null) { foreach (DataRow Row in GetDeals.Rows) { var Id = Convert.ToInt32(Row["id"]); var Items = Convert.ToString(Row["items"]); var Name = Convert.ToString(Row["name"]); var RoomId = Convert.ToInt32(Row["room_id"]); var Deal = new CatalogDeal(Id, Items, Name, RoomId, ItemDataManager); if (!_deals.ContainsKey(Id)) { _deals.Add(Deal.Id, Deal); } } } dbClient.SetQuery( "SELECT `id`,`parent_id`,`caption`,`page_link`,`visible`,`enabled`,`min_rank`,`min_vip`,`icon_image`,`page_layout`,`page_strings_1`,`page_strings_2` FROM `catalog_pages` ORDER BY `order_num`"); var CatalogPages = dbClient.GetTable(); if (CatalogPages != null) { foreach (DataRow Row in CatalogPages.Rows) { _pages.Add(Convert.ToInt32(Row["id"]), new CatalogPage(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["parent_id"]), Row["enabled"].ToString(), Convert.ToString(Row["caption"]), Convert.ToString(Row["page_link"]), Convert.ToInt32(Row["icon_image"]), Convert.ToInt32(Row["min_rank"]), Convert.ToInt32(Row["min_vip"]), Row["visible"].ToString(), Convert.ToString(Row["page_layout"]), Convert.ToString(Row["page_strings_1"]), Convert.ToString(Row["page_strings_2"]), _items.ContainsKey(Convert.ToInt32(Row["id"])) ? _items[Convert.ToInt32(Row["id"])] : new Dictionary <int, CatalogItem>(), ref _itemOffers)); } } dbClient.SetQuery("SELECT `id`,`name`,`figure`,`motto`,`gender`,`ai_type` FROM `catalog_bot_presets`"); var bots = dbClient.GetTable(); if (bots != null) { foreach (DataRow Row in bots.Rows) { _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]))); } } dbClient.SetQuery("SELECT * FROM `catalog_promotions`"); var GetPromotions = dbClient.GetTable(); if (GetPromotions != null) { foreach (DataRow Row in GetPromotions.Rows) { if (!_promotions.ContainsKey(Convert.ToInt32(Row["id"]))) { _promotions.Add(Convert.ToInt32(Row["id"]), new CatalogPromotion(Convert.ToInt32(Row["id"]), Convert.ToString(Row["title"]), Convert.ToString(Row["image"]), Convert.ToInt32(Row["unknown"]), Convert.ToString(Row["page_link"]), Convert.ToInt32(Row["parent_id"]))); } } } _petRaceManager.Init(); _clothingManager.Init(); } log.Info("Catalog Manager -> LOADED"); }
public bool TryGetDeal(int dealId, out CatalogDeal deal) => _deals.TryGetValue(dealId, out deal);
public void Init(ItemDataManager ItemDataManager) { if (this._pages.Count > 0) this._pages.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("Couldn't load Catalog Item " + ItemId + ", no furniture record found."); 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); this._items[PageId].Add(Convert.ToInt32(Row["id"]), 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"]))); } } 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 `id`,`parent_id`,`caption`,`page_link`,`visible`,`enabled`,`min_rank`,`min_vip`,`icon_image`,`page_layout`,`page_strings_1`,`page_strings_2` FROM `catalog_pages` ORDER BY `order_num`"); DataTable CatalogPages = dbClient.getTable(); if (CatalogPages != null) { foreach (DataRow Row in CatalogPages.Rows) { this._pages.Add(Convert.ToInt32(Row["id"]), new CatalogPage(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["parent_id"]), Row["enabled"].ToString(), Convert.ToString(Row["caption"]), Convert.ToString(Row["page_link"]), Convert.ToInt32(Row["icon_image"]), Convert.ToInt32(Row["min_rank"]), Convert.ToInt32(Row["min_vip"]), Row["visible"].ToString(), Convert.ToString(Row["page_layout"]), Convert.ToString(Row["page_strings_1"]), Convert.ToString(Row["page_strings_2"]), this._items.ContainsKey(Convert.ToInt32(Row["id"])) ? this._items[Convert.ToInt32(Row["id"])] : new Dictionary<int, CatalogItem>(), this._deals.ContainsKey(Convert.ToInt32(Row["id"])) ? this._deals[Convert.ToInt32(Row["id"])] : new Dictionary<int, CatalogDeal>(), ref this._itemOffers)); } } 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"); }
public bool TryGetDeal(int dealId, out CatalogDeal deal) { return(this._deals.TryGetValue(dealId, out deal)); }
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"); }