예제 #1
0
 public PremiumMarketItem(dynamic data)
 {
     MarketId                 = data.market_id;
     Section                  = (MeretMarketSection)data.section;
     BannerId                 = data.banner_id ?? 0;
     BonusQuantity            = data.bonus_quantity;
     Category                 = (MeretMarketCategory)data.category;
     Duration                 = data.duration;
     Flag                     = (MeretMarketItemFlag)data.flag;
     ItemId                   = data.item_id;
     ItemName                 = data.item_name;
     JobRequirement           = (JobFlag)data.job_requirement;
     MaxLevelRequirement      = data.max_level_requirement;
     MinLevelRequirement      = data.min_level_requirement;
     PCCafe                   = data.pc_cafe;
     ParentMarketId           = data.parent_market_id;
     PromoBannerBeginTime     = data.promo_banner_begin_time;
     PromoBannerEndTime       = data.promo_banner_end_time;
     PromoFlag                = (MeretMarketPromoFlag)data.promo_flag;
     PromoName                = data.promo_name;
     Quantity                 = data.quantity;
     Rarity                   = data.rarity;
     RequiredAchievementGrade = data.required_achievement_grade;
     RequiredAchievementId    = data.required_achievement_id;
     RestockUnavailable       = data.restock_unavailable;
     Price                    = data.price;
     SalePrice                = data.sale_price;
     SellBeginTime            = data.sell_begin_time;
     SellEndTime              = data.sell_end_time;
     ShowSaleTime             = data.show_sale_time;
     TokenType                = (MeretMarketCurrencyType)data.token_type;
     SalesCount               = data.sales_count;
     CreationTimestamp        = data.creation_time;
     AdditionalQuantities     = new();
 }
예제 #2
0
    protected override List <MeretMarketCategoryMetadata> Parse()
    {
        List <MeretMarketCategoryMetadata> categories = new();

        foreach (PackFileEntry entry in Resources.XmlReader.Files)
        {
            if (!entry.Name.StartsWith("table/na/meratmarketcategory"))
            {
                continue;
            }

            XmlDocument document = Resources.XmlReader.GetXmlDocument(entry);
            foreach (XmlNode node in document.DocumentElement.ChildNodes)
            {
                if (node.Name != "category")
                {
                    continue;
                }

                MeretMarketSection section = (MeretMarketSection)int.Parse(node.Attributes["id"].Value);

                foreach (XmlNode tabNode in node)
                {
                    MeretMarketCategoryMetadata metadata = new()
                    {
                        Section    = section,
                        CategoryId = int.Parse(tabNode.Attributes["id"].Value)
                    };

                    foreach (XmlNode subTabNode in tabNode.ChildNodes)
                    {
                        MeretMarketCategoryMetadata subTab = new()
                        {
                            Section    = section,
                            CategoryId = int.Parse(subTabNode.Attributes["id"].Value)
                        };
                        if (subTabNode.Attributes["category"] is not null)
                        {
                            List <string> itemCategories = new();
                            itemCategories.AddRange(subTabNode.Attributes["category"].Value.Split(",").ToList());
                            subTab.ItemCategories = itemCategories;
                            metadata.ItemCategories.AddRange(itemCategories);
                        }

                        categories.Add(subTab);
                    }

                    categories.Add(metadata);
                }
            }
        }

        return(categories);
    }
}
    public IEnumerable <PremiumMarketItem> FindAllByCategory(MeretMarketSection section, MeretMarketCategory category, GenderFlag gender, JobFlag jobFlag, string searchString)
    {
        List <PremiumMarketItem> items   = new();
        IEnumerable <dynamic>    results = QueryFactory.Query(TableName).Get();

        if (section != MeretMarketSection.All)
        {
            results = QueryFactory.Query(TableName).Where("section", (int)section).Get();
        }

        foreach (dynamic data in results)
        {
            if (category != MeretMarketCategory.None && (MeretMarketCategory)data.category != category)
            {
                continue;
            }

            if (data.parent_market_id != 0)
            {
                continue;
            }
            PremiumMarketItem meretMarketItem = ReadMeretMarketItem(data);

            if (!meretMarketItem.ItemName.ToLower().Contains(searchString.ToLower()))
            {
                continue;
            }

            List <Job> jobs = ItemMetadataStorage.GetRecommendJobs(meretMarketItem.ItemId);
            if (!JobHelper.CheckJobFlagForJob(jobs, jobFlag))
            {
                continue;
            }

            if (!MeretMarketHelper.CheckGender(gender, meretMarketItem.ItemId))
            {
                continue;
            }

            if (meretMarketItem.BannerId != 0)
            {
                meretMarketItem.Banner = DatabaseManager.Banners.FindById(meretMarketItem.BannerId);
            }

            items.Add(meretMarketItem);
        }

        return(items);
    }
예제 #4
0
    private static void HandleOpenShop(GameSession session, PacketReader packet)
    {
        MeretMarketCategory category = (MeretMarketCategory)packet.ReadInt();
        GenderFlag          gender   = (GenderFlag)packet.ReadByte();
        JobFlag             job      = (JobFlag)packet.ReadInt();
        MeretMarketSort     sortBy   = (MeretMarketSort)packet.ReadByte();
        string searchString          = packet.ReadUnicodeString();
        int    startPage             = packet.ReadInt();

        packet.ReadInt(); // repeat page?
        MeretMarketSection section = ReadMarketSection(packet.ReadByte());

        packet.ReadByte();
        byte itemsPerPage = packet.ReadByte();

        MeretMarketTab metadata = MeretMarketCategoryMetadataStorage.GetTabMetadata(section, (int)category);

        if (metadata is null)
        {
            return;
        }

        List <MeretMarketItem> items = new();

        switch (section)
        {
        case MeretMarketSection.UgcMarket:
            items.AddRange(GameServer.UgcMarketManager.FindItems(metadata.ItemCategories, gender, job, searchString));
            break;

        case MeretMarketSection.PremiumMarket:
        case MeretMarketSection.RedMeretMarket:
            items.AddRange(DatabaseManager.MeretMarket.FindAllByCategory(section, category, gender, job, searchString));
            break;
        }

        int totalItems = items.Count;

        items = MeretMarketHelper.MarketItemsSorted(items, sortBy);
        items = MeretMarketHelper.TakeLimit(items, startPage, itemsPerPage);

        session.Send(MeretMarketPacket.LoadShopCategory(items, totalItems));
    }