public PurchaseOKComposer(CatalogItem Item, Item BaseItem) : base(ServerPacketHeader.PurchaseOKMessageComposer) { base.WriteInteger(BaseItem.ItemId); base.WriteString(BaseItem.Name); base.WriteBoolean(false); base.WriteInteger(Item.CreditsCost); base.WriteInteger(Item.DucketsCost); base.WriteInteger(Item.BelCreditsCost); base.WriteBoolean(true); base.WriteInteger(1); base.WriteString(BaseItem.Type.ToString().ToLower()); base.WriteInteger(BaseItem.SpriteId); base.WriteString(""); base.WriteInteger(1); base.WriteInteger(0); base.WriteString(""); base.WriteInteger(1); }
public void SerializeItem(CatalogItem Item) { uint offerId; if (Item.GetBaseItem(Item.BaseId).FlatId != -1) offerId = Convert.ToUInt32(Item.GetBaseItem(Item.BaseId).FlatId); else offerId = Item.Id; base.WriteInteger(offerId); base.WriteString(Item.Name); base.WriteBoolean(false); //IsRentable base.WriteInteger(Item.CreditsCost); if (Item.BelCreditsCost > 0) { base.WriteInteger(Item.BelCreditsCost); base.WriteInteger(105); } else { base.WriteInteger(Item.DucketsCost); base.WriteInteger(0); // } base.WriteBoolean(false); // Can gift if (Item.Badge == "") { base.WriteInteger(Item.Items.Count); } else { base.WriteInteger(Item.Items.Count + 1); base.WriteString("b"); base.WriteString(Item.Badge); } foreach (uint i in Item.Items) { base.WriteString(Item.GetBaseItem(i).Type.ToString()); if (Item.GetBaseItem(i).Type.ToString().ToLower() == "b") { base.WriteString("RADZZ"); //base.WriteInteger(0); } else { base.WriteInteger(Item.GetBaseItem(i).SpriteId); // extradata if (Item.Name.Contains("wallpaper_single") || Item.Name.Contains("floor_single") || Item.Name.Contains("landscape_single")) { string[] Analyze = Item.Name.Split('_'); base.WriteString(Analyze[2]); } else if (Item.Name.Contains("rentable_bot")) { base.WriteString(Item.ExtraData); } else if (Item.songID > 0 && Item.GetBaseItem(i).InteractionType == InteractionType.musicdisc) { base.WriteString(Item.songID.ToString()); } else { base.WriteString(string.Empty); } base.WriteInteger(Item.Amount); base.WriteBoolean(Item.IsLimited); // IsLimited if (Item.IsLimited) { base.WriteInteger(Item.LimitedStack); base.WriteInteger(Item.LimitedStack - Item.LimitedSelled); } } base.WriteInteger(0); // club_level if (Item.IsLimited || Item.Amount != 1 || Item.Name.ToLower().StartsWith("cf_") || Item.Name.ToLower().StartsWith("cfc_")) base.WriteBoolean(false); // IsOffer else base.WriteBoolean(Item.HaveOffer && !Item.IsLimited); } }
internal void Initialize(IQueryAdapter dbClient) { Pages = new Dictionary<int, CatalogPage>(); EcotronRewards = new List<EcotronReward>(); EcotronLevels = new List<int>(); CatalogFlatOffers = new Dictionary<int, int>(); CatalogItemOffers = new Dictionary<int, CatalogItem>(); gifts = new Hashtable(); dbClient.setQuery("SELECT * FROM catalog_pages ORDER BY order_num"); DataTable Data = dbClient.getTable(); dbClient.setQuery("SELECT * FROM ecotron_rewards ORDER BY reward_level ASC"); DataTable EcoData = dbClient.getTable(); Hashtable CataItems = new Hashtable(); dbClient.setQuery("SELECT id,item_ids,catalog_name,cost_credits,cost_belcredits,cost_duckets,amount,page_id,song_id,limited_sells,limited_stack,offer_active,extradata,vip,badge,flat_id FROM catalog_items"); DataTable CatalogueItems = dbClient.getTable(); BotPresets = new Dictionary<uint, CatalogBots>(); dbClient.setQuery("SELECT * FROM catalog_bot_presets"); DataTable bots = dbClient.getTable(); uint itemId; int pageId; int flatId; CatalogItem item; if (CatalogueItems != null) { foreach (DataRow Row in CatalogueItems.Rows) { if (string.IsNullOrEmpty(Row["item_ids"].ToString()) || (int)Row["amount"] <= 0) { continue; } pageId = Convert.ToInt32(Row["page_id"]); itemId = Convert.ToUInt32(Row["item_ids"]); if (!(SilverwaveEnvironment.GetGame().GetItemManager().GetItem(itemId) == null)) flatId = SilverwaveEnvironment.GetGame().GetItemManager().GetItem(itemId).FlatId; else continue; item = new CatalogItem(Row); CataItems.Add(Convert.ToUInt32(Row["id"]), item); if (flatId != -1 && !CatalogFlatOffers.ContainsKey(flatId) && !CatalogItemOffers.ContainsKey(flatId)) { CatalogFlatOffers.Add(flatId, pageId); CatalogItemOffers.Add(flatId, item); } } } if (Data != null) { foreach (DataRow Row in Data.Rows) { Boolean Visible = false; Boolean Enabled = false; Boolean ComingSoon = false; if (Row["visible"].ToString() == "1") { Visible = true; } if (Row["enabled"].ToString() == "1") { Enabled = true; } Pages.Add((int)Row["id"], new CatalogPage((int)Row["id"], (int)Row["parent_id"], (string)Row["caption"], Visible, Enabled, ComingSoon, Convert.ToUInt32(Row["min_rank"]), SilverwaveEnvironment.EnumToBool(Row["club_only"].ToString()), (int)Row["icon_color"], (int)Row["icon_image"], (string)Row["page_layout"], (string)Row["page_headline"], (string)Row["page_teaser"], (string)Row["page_special"], (string)Row["page_text1"], (string)Row["page_text2"], (string)Row["page_text_details"], (string)Row["page_text_teaser"], (string)Row["page_link_description"], (string)Row["page_link_pagename"], (int)Row["min_sub"], ref CataItems, ref CatalogFlatOffers)); } } if (EcoData != null) { foreach (DataRow Row in EcoData.Rows) { EcotronRewards.Add(new EcotronReward(Convert.ToUInt32(Row["display_id"]), Convert.ToUInt32(Row["item_id"]), Convert.ToUInt32(Row["reward_level"]))); if (!EcotronLevels.Contains(Convert.ToInt16(Row["reward_level"]))) EcotronLevels.Add(Convert.ToInt16(Row["reward_level"])); } } if (bots != null) { foreach (DataRow Row in bots.Rows) { BotPresets.Add(Convert.ToUInt32(Row[0]), new CatalogBots(Convert.ToUInt32(Row[0]), (string)Row[1], (string)Row[2], (string)Row[4], (string)Row[3])); } } RestackByFrontpage(); }