Esempio n. 1
0
        public override async Task ExecuteAsync(CBListPacket packet, ClientSession clientSession)
        {
            var itemssearch = packet.ItemVNumFilter.FirstOrDefault() == 0 ? new List <short>() : packet.ItemVNumFilter;

            var bzlist = await _bazaarHttpClient.GetBazaarLinksAsync(-1, packet.Index, 50, packet.TypeFilter, packet.SubTypeFilter,
                                                                     packet.LevelFilter, packet.RareFilter, packet.UpgradeFilter, null).ConfigureAwait(false);

            var bzlistsearched = bzlist.Where(s => itemssearch !.Contains(s.ItemInstance !.ItemVNum)).ToList();

            //price up price down quantity up quantity down
            var definitivelist = itemssearch.Any() ? bzlistsearched : bzlist;

            definitivelist = packet.OrderFilter switch
            {
                0 => definitivelist
                .OrderBy(s => _items.First(o => o.VNum == s.ItemInstance !.ItemVNum).Name[clientSession.Account.Language])
                .ThenBy(s => s.BazaarItem !.Price)
                .ToList(),
                1 => definitivelist
                .OrderBy(s => _items.First(o => o.VNum == s.ItemInstance !.ItemVNum).Name[clientSession.Account.Language])
                .ThenByDescending(s => s.BazaarItem !.Price)
                .ToList(),
                2 => definitivelist
                .OrderBy(s => _items.First(o => o.VNum == s.ItemInstance !.ItemVNum).Name[clientSession.Account.Language])
                .ThenBy(s => s.BazaarItem !.Amount)
                .ToList(),
                3 => definitivelist
                .OrderBy(s => _items.First(o => o.VNum == s.ItemInstance !.ItemVNum).Name[clientSession.Account.Language])
                .ThenByDescending(s => s.BazaarItem !.Amount)
                .ToList(),
                _ => definitivelist.OrderBy(s => _items.First(o => o.VNum == s.ItemInstance !.ItemVNum).Name[clientSession.Account.Language])
                .ToList()
            };

            await clientSession.SendPacketAsync(new RcbListPacket
            {
                PageIndex = packet.Index,
                Items     = definitivelist
                            .Where(s => ((s.BazaarItem !.DateStart.AddHours(s.BazaarItem.Duration) - SystemTime.Now())
                                         .TotalMinutes > 0) && (s.ItemInstance !.Amount > 0))
                            .Select(bzlink => new RcbListElementPacket
                {
                    AuctionId   = bzlink.BazaarItem !.BazaarItemId,
                    OwnerId     = bzlink.BazaarItem.SellerId,
                    OwnerName   = bzlink.SellerName,
                    ItemId      = bzlink.ItemInstance !.ItemVNum,
                    Amount      = bzlink.ItemInstance.Amount,
                    IsPackage   = bzlink.BazaarItem.IsPackage,
                    Price       = bzlink.BazaarItem.Price,
                    MinutesLeft =
                        (long)(bzlink.BazaarItem.DateStart.AddHours(bzlink.BazaarItem.Duration) - SystemTime.Now())
                        .TotalMinutes,
                    Unknown1 = false,
                    Unknown  = 2,
                    Rarity   = bzlink.ItemInstance.Rare,
                    Upgrade  = bzlink.ItemInstance.Upgrade,
                    EInfo    = new EInfoPacket()
                }).ToList() as List <RcbListElementPacket?>
Esempio n. 2
0
        public override async Task ExecuteAsync(CSListPacket packet, ClientSession clientSession)
        {
            var list   = new List <RcsListPacket.RcsListElementPacket?>();
            var bzlist = await _bazaarHttpClient.GetBazaarLinksAsync(-1, packet.Index, 50, 0, 0, 0, 0, 0,
                                                                     clientSession.Character.CharacterId).ConfigureAwait(false);

            foreach (var bz in bzlist)
            {
                var soldedAmount = bz.BazaarItem !.Amount - bz.ItemInstance !.Amount;
                int amount       = bz.BazaarItem.Amount;
                var isNosbazar   = bz.BazaarItem.MedalUsed;
                var price        = bz.BazaarItem.Price;
                var minutesLeft  = (long)(bz.BazaarItem.DateStart.AddHours(bz.BazaarItem.Duration) - SystemTime.Now())
                                   .TotalMinutes;
                var status = minutesLeft >= 0 ? soldedAmount < amount ? BazaarStatusType.OnSale
                    : BazaarStatusType.Solded : BazaarStatusType.DelayExpired;
                if (status == BazaarStatusType.DelayExpired)
                {
                    minutesLeft =
                        (long)(bz.BazaarItem.DateStart.AddHours(bz.BazaarItem.Duration).AddDays(isNosbazar ? 30 : 7) -
                               SystemTime.Now()).TotalMinutes;
                }

                var info = new EInfoPacket();

                if ((packet.Filter == BazaarStatusType.Default) || (packet.Filter == status))
                {
                    list.Add(new RcsListPacket.RcsListElementPacket
                    {
                        AuctionId          = bz.BazaarItem.BazaarItemId,
                        OwnerId            = bz.BazaarItem.SellerId,
                        ItemId             = bz.ItemInstance.ItemVNum,
                        SoldAmount         = soldedAmount,
                        Amount             = amount,
                        IsPackage          = bz.BazaarItem.IsPackage,
                        Status             = status,
                        Price              = price,
                        MinutesLeft        = minutesLeft,
                        IsSellerUsingMedal = isNosbazar,
                        Unknown            = 0,
                        Rarity             = bz.ItemInstance.Rare,
                        Upgrade            = bz.ItemInstance.Upgrade,
                        EInfo              = info
                    });
                }
            }

            await clientSession.SendPacketAsync(new RcsListPacket
            {
                PageNumber = packet.Index,
                Items      = list
            }).ConfigureAwait(false);
        }