Esempio n. 1
0
        internal PlayerItem(Inventory inventory, PlayerItemDto dto)
        {
            var shop = GameServer.Instance.ResourceCache.GetShop();

            ExistsInDatabase = true;
            Inventory        = inventory;
            Id = (ulong)dto.Id;

            var itemInfo = shop.Items.Values.FirstOrDefault(group => group.GetItemInfo(dto.ShopItemInfoId) != null);

            if (itemInfo == null)
            {
                IsInvalid = true;
                Inventory.RemoveInvalid(this);
                return;
            }

            ItemNumber = itemInfo.ItemNumber;

            var priceGroup = shop.Prices.Values.FirstOrDefault(group => group.GetPrice(dto.ShopPriceId) != null);

            if (priceGroup == null)
            {
                IsInvalid = true;
                Inventory.RemoveInvalid(this);
                return;
            }

            var price = priceGroup.GetPrice(dto.ShopPriceId);

            PriceType  = priceGroup.PriceType;
            PeriodType = price.PeriodType;
            Period     = price.Period;
            DaysLeft   = (ushort)dto.DaysLeft;
            Color      = dto.Color;

            var raweffects  = new List <EffectNumber>();
            var effectsText = dto.Effects.Split(",").ToList();

            effectsText.ForEach(eff => { raweffects.Add(new EffectNumber(uint.Parse(eff))); });
            Effects = raweffects.ToArray();
            if (Effects.Length == 0)
            {
                Effects = new EffectNumber[] { 0 }
            }
            ;
            _durability = dto.Durability;
            _count      = (uint)dto.Count;
            if (_count == 0)
            {
                _count = 1;
            }
            _enchantMP   = dto.EnchantMP;
            _enchantLvl  = dto.EnchantLvl;
            PurchaseDate = DateTimeOffset.FromUnixTimeSeconds(dto.PurchaseDate);
        }
Esempio n. 2
0
 internal PlayerItem(Inventory inventory, PlayerItemDto dto)
 {
     ExistsInDatabase = true;
     Inventory        = inventory;
     Id           = (ulong)dto.Id;
     ItemNumber   = dto.ShopItemInfo.ShopItem.Id;
     PriceType    = (ItemPriceType)dto.ShopPrice.PriceGroup.PriceType;
     PeriodType   = (ItemPeriodType)dto.ShopPrice.PeriodType;
     Period       = (ushort)dto.ShopPrice.Period;
     Color        = dto.Color;
     Effect       = dto.Effect;
     PurchaseDate = DateTimeOffset.FromUnixTimeSeconds(dto.PurchaseDate);
     _durability  = dto.Durability;
     _count       = (uint)dto.Count;
 }
Esempio n. 3
0
        internal PlayerItem(Inventory inventory, PlayerItemDto dto)
        {
            var shop = GameServer.Instance.ResourceCache.GetShop();

            ExistsInDatabase = true;
            Inventory        = inventory;
            Id = (ulong)dto.Id;

            var itemInfo = shop.Items.Values.First(group => group.GetItemInfo(dto.ShopItemInfoId) != null);

            ItemNumber = itemInfo.ItemNumber;

            var priceGroup = shop.Prices.Values.First(group => group.GetPrice(dto.ShopPriceId) != null);
            var price      = priceGroup.GetPrice(dto.ShopPriceId);

            PriceType  = priceGroup.PriceType;
            PeriodType = price.PeriodType;
            Period     = price.Period;
            Color      = dto.Color;

            var raweffects  = new List <uint>();
            var effectsText = dto.Effects.Split(",").ToList();

            effectsText.ForEach(eff => { raweffects.Add(uint.Parse(eff)); });
            Effects = raweffects.ToArray();
            if (Effects.Length == 0)
            {
                Effects = new uint[] { 0 }
            }
            ;
            _durability = dto.Durability;
            _count      = (uint)dto.Count;
            if (_count == 0)
            {
                _count = 1;
            }
            PurchaseDate = DateTimeOffset.FromUnixTimeSeconds(dto.PurchaseDate);
        }
Esempio n. 4
0
        internal PlayerItem(Inventory inventory, PlayerItemDto dto)
        {
            var shop = GameServer.Instance.ResourceCache.GetShop();

            ExistsInDatabase = true;
            Inventory        = inventory;
            Id = (ulong)dto.Id;

            var itemInfo = shop.Items.Values.First(group => group.GetItemInfo(dto.ShopItemInfoId) != null);

            ItemNumber = itemInfo.ItemNumber;

            var priceGroup = shop.Prices.Values.First(group => group.GetPrice(dto.ShopPriceId) != null);
            var price      = priceGroup.GetPrice(dto.ShopPriceId);

            PriceType    = priceGroup.PriceType;
            PeriodType   = price.PeriodType;
            Period       = price.Period;
            Color        = dto.Color;
            Effect       = dto.Effect;
            PurchaseDate = DateTimeOffset.FromUnixTimeSeconds(dto.PurchaseDate);
            _durability  = dto.Durability;
            _count       = (uint)dto.Count;
        }