Пример #1
0
        /// <summary>
        /// Selects the appropriate cs go container to open, user replies with a number corrosponding to the case
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static PaginatedMessage ShowPossibleCases(SocketCommandContext context)
        {
            string botCommandPrefix = CommandGuildPrefixManager.GetGuildCommandPrefix(context);

            //Create pagination entries
            List <string> leftCounter        = new List <string>();
            List <string> filteredContainers = new List <string>();

            //Find containers whose name is not null
            filteredContainers = CsgoUnboxingHandler.csgoContiners.Containers.Where(c => c.Name != null).Select(c => c.Name).ToList();
            //Create a list of ascending numbers to reference each container
            for (int i = 0; i < filteredContainers.Count(); i++)
            {
                leftCounter.Add(i.ToString());
            }

            //Generate pagination
            PaginationConfig paginationConfig = new PaginationConfig
            {
                AuthorName = "CS:GO Containers",
                AuthorURL  = "https://csgostash.com/img/containers/c259.png",

                Description = $"Select a container by typing the appropriate number on the left\nThen use `{botCommandPrefix} cs open` to open cases",

                Field1Header = "Number",
                Field2Header = "Case",
            };

            PaginationManager paginationManager = new PaginationManager();
            var pager = paginationManager.GeneratePaginatedMessage(leftCounter, filteredContainers, paginationConfig);

            return(pager);
        }
        public static PaginatedMessage DisplayUserCsgoInventory(SocketCommandContext context)
        {
            string botCommandPrefix = CommandGuildPrefixManager.GetGuildCommandPrefix(context);

            //Reset fields
            embedFieldsMaster      = new List <string>();
            embedPriceFieldsMaster = new List <string>();

            //Get user skins from xml file
            UserSkinStorageRootobject userSkin = new UserSkinStorageRootobject();

            try
            {
                userSkin = XmlManager.FromXmlFile <UserSkinStorageRootobject>(CoreMethod.GetFileLocation("UserSkinStorage.xml"));
            }
            catch (Exception)
            {
            }

            List <UserSkinEntry> foundUserSkins = new List <UserSkinEntry>();

            //Filter userSkinEntries xml file down to skins belonging to sender
            foreach (var userSkinEntry in userSkin.UserSkinEntries)
            {
                //Filter skin search to those owned by user
                if (userSkinEntry.OwnerID == context.Message.Author.Id)
                {
                    foundUserSkins.Add(new UserSkinEntry {
                        OwnerID = context.Message.Author.Id, ClassId = userSkinEntry.ClassId, UnboxDate = userSkinEntry.UnboxDate
                    });
                }
            }

            //Generate fields
            AddSkinFieldEntry(foundUserSkins);

            //Configurate paginated message
            var paginationConfig = new PaginationConfig
            {
                AuthorName = context.Message.Author.ToString().Substring(0, context.Message.Author.ToString().Length - 5) + " Inventory",
                AuthorURL  = context.Message.Author.GetAvatarUrl(),

                Description = $"To sell items, use `{botCommandPrefix} cs sell [name]` \n To sell all items matching filter, use `{botCommandPrefix} cs sellall [name]`",

                DefaultFieldHeader      = "You do not have any skins",
                DefaultFieldDescription = $"Go unbox some with `{botCommandPrefix} case open`",

                Field1Header = "Item Name",
                Field2Header = "Market Value",
            };

            var paginationManager = new PaginationManager();

            //Generate paginated message
            var pager = paginationManager.GeneratePaginatedMessage(embedFieldsMaster, embedPriceFieldsMaster, paginationConfig);

            return(pager);
        }
        /// <summary>
        /// Initialize Data.
        /// </summary>
        public async Task InitializeData()
        {
            try
            {
                Messenger.Default.Send(new LoadingMessage(true));
                TravelsCount = await myCompanyClient.TravelRequestService.GetAllCount(this.filter, (int)TravelRequestStatus.Approved);

                this.pagConfig = new PaginationConfig(this.travelsCount, PAGESIZE);
                NavigateToPage(this.pagConfig.NumberOfPageSelected);
            }
            catch (Exception)
            {
                CustomDialogMessage message = new CustomDialogMessage(() => { }, StringResources.UnexpectedError, Visibility.Collapsed);
                Messenger.Default.Send <CustomDialogMessage>(message);
            }
        }
        public static PaginatedMessage GetCsgoMarketInventory(SocketCommandContext context, string filterString)
        {
            string botCommandPrefix = CommandGuildPrefixManager.GetGuildCommandPrefix(context);

            //Get skin data
            var rootWeaponSkin = CsgoDataHandler.GetRootWeaponSkin();

            List <string> filteredRootWeaponSkin      = new List <string>();
            List <string> filteredRootWeaponSkinPrice = new List <string>();

            try
            {
                //Filter rootWeaponSkin to those with a price found in rootWeaponSkinPrice
                foreach (var skin in rootWeaponSkin.ItemsList.Values)
                {
                    //If filter string is not null, filter market results by user filter string
                    if ((!string.IsNullOrEmpty(filterString) && skin.Name.ToLower().Contains(filterString.ToLower())) || (string.IsNullOrEmpty(filterString)))
                    {
                        string skinQualityEmote = GetEmoteBySkinRarity(skin.Rarity, skin.WeaponType);

                        //Add skin entry
                        try
                        {
                            Emote emote = Emote.Parse(skinQualityEmote);

                            //Add weapon skin
                            filteredRootWeaponSkin.Add(emote + " " + skin.Name);

                            //Add tax markup for market item
                            long weaponSkinValue = Convert.ToInt64(skin.Price.AllTime.Average);
                            weaponSkinValue += Convert.ToInt64(weaponSkinValue * float.Parse(SettingsManager.RetrieveFromConfigFile("taxRate")));

                            //Add weapon skin price
                            filteredRootWeaponSkinPrice.Add(emote + " " + weaponSkinValue.ToString());
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
            catch (Exception)
            {
            }

            //Configurate paginated message
            var paginationConfig = new PaginationConfig
            {
                AuthorName = "CS:GO Market",
                AuthorURL  = context.Message.Author.GetAvatarUrl(),

                Description = $"Current skin market, to buy skins, use `{botCommandPrefix} cs buy [name]` \n use `{botCommandPrefix} cs market [name]` to filter skins by name \n use `{botCommandPrefix} cs info [name]` to preview skins",

                DefaultFieldHeader      = "Unable to find specified weapon skin!",
                DefaultFieldDescription = $"Broaden your search parameters and try again",

                Field1Header = "Item Name",
                Field2Header = "Price",
            };

            var paginationManager = new PaginationManager();

            //Generate paginated message
            var pager = paginationManager.GeneratePaginatedMessage(filteredRootWeaponSkin, filteredRootWeaponSkinPrice, paginationConfig);

            return(pager);
        }