Exemplo n.º 1
0
        public static ListingData ToDb(this MarketListingItem item, DateTime reportTime, int world)
        {
            var result = new ListingData();
            {
                result.ReportTime = reportTime;
                result.World = world;
                result.ListingId = item.ListingId;
                result.RetainerId = item.RetainerId;
                result.OwnerId = item.OwnerId;
                result.ArtisanId = item.ArtisanId;
                result.UnitPrice = item.UnitPrice;
                result.TotalTax = item.TotalTax;
                result.Quantity = item.Quantity;
                result.ItemId = item.ItemId;
                result.UpdateTime = item.UpdateTime;
                result.ContainerId = item.ContainerId;
                result.SlotId = item.SlotId;
                result.Condition = item.Condition;
                result.SpiritBond = item.SpiritBond;
                result.Materia1 = item.Materia1;
                result.Materia2 = item.Materia2;
                result.Materia3 = item.Materia3;
                result.Materia4 = item.Materia4;
                result.Materia5 = item.Materia5;
                result.RetainerName = item.RetainerName;
                result.PlayerName = item.PlayerName;
                result.IsHq = item.IsHq == 1;
                result.MateriaCount = item.MateriaCount;
                result.OnMannequin = item.OnMannequin == 1;
                result.RetainerLoc = item.RetainerLocation;
                result.DyeId = item.DyeId;
            }

            return result;
        }
Exemplo n.º 2
0
        public static ListingData FromResultItem(MarketListingItem item, DateTime time, int zone, int world)
        {
            var materia = new int[item.MateriaCount];

            do
            {
                if (item.MateriaCount == 0)
                {
                    break;
                }
                materia[0] = item.Materia1;

                if (item.MateriaCount == 1)
                {
                    break;
                }
                materia[1] = item.Materia2;

                if (item.MateriaCount == 2)
                {
                    break;
                }
                materia[2] = item.Materia3;

                if (item.MateriaCount == 3)
                {
                    break;
                }
                materia[3] = item.Materia4;

                if (item.MateriaCount == 4)
                {
                    break;
                }
                materia[4] = item.Materia5;
            } while (false);

            return(new ListingData
            {
                ItemId = item.ItemId,
                IsHq = item.IsHq != 0,
                Materia = materia,
                UnitPrice = item.UnitPrice,
                Quantity = item.Quantity,
                Tax = item.TotalTax,
                Retainer = item.RetainerName,
                Artisan = item.ArtisanName,
                OnMannequin = item.OnMannequin != 0,
                PlayerName = item.PlayerName,
                RetainerLocation = item.RetainerLocation,
                DyeId = item.DyeId,
                ListingTime = Helper.UnixTimeStampToDateTime(item.UpdateTime),
                UpdateTime = time,
                Zone = zone,
                World = world,
            });
        }
Exemplo n.º 3
0
 private static bool CheckListing(MarketListingItem item)
 {
     return(item != null &&
            item.ItemId > 0 &&
            item.RetainerId != 0 &&
            item.IsHq < 2 &&
            item.OnMannequin < 2 &&
            item.ListingId != 0 &&
            item.OwnerId != 0 &&
            item.UnitPrice > 0 &&
            item.Quantity > 0 &&
            item.Quantity <= GlobalConfig.MARKET_COUNT_THRESHOLD &&
            item.UnitPrice <= GlobalConfig.MARKET_PRICE_THRESHOLD / item.Quantity && // no overflow
            item.TotalTax <= item.UnitPrice * item.Quantity / 10 &&
            IsValidInGameName(item.PlayerName) &&
            IsValidInGameName(item.RetainerName, false));
 }
Exemplo n.º 4
0
        public static ListingResponseItem FromDb(this ListingData item, string artisanName)
        {
            var result = new MarketListingItem();
            {
                result.ListingId = 0;
                result.RetainerId = 0;
                result.OwnerId = 0;
                result.ArtisanId = 0;
                result.ArtisanName = artisanName;
                result.UnitPrice = item.UnitPrice;
                result.TotalTax = item.TotalTax;
                result.Quantity = item.Quantity;
                result.ItemId = item.ItemId;
                result.UpdateTime = 0;
                result.ContainerId = 0;
                result.SlotId = 0;
                result.Condition = item.Condition;
                result.SpiritBond = item.SpiritBond;
                result.Materia1 = item.Materia1;
                result.Materia2 = item.Materia2;
                result.Materia3 = item.Materia3;
                result.Materia4 = item.Materia4;
                result.Materia5 = item.Materia5;
                result.RetainerName = item.RetainerName;
                result.PlayerName = item.PlayerName;
                result.IsHq = item.IsHq ? (byte)1 : (byte)0;
                result.MateriaCount = (byte)item.MateriaCount;
                result.OnMannequin = item.OnMannequin ? (byte)1 : (byte)0;
                result.RetainerLocation = (byte)item.RetainerLoc;
                result.DyeId = item.DyeId;
            }

            return new ListingResponseItem
            {
                ReportTime = item.ReportTime,
                WorldId = item.World,
                RawItem = result
            };
        }