partial void Merge(UpgradeComponent entity, ItemDTO dto, object state)
        {
            var upgradeComponent = dto.UpgradeComponent;
            if (upgradeComponent == null)
            {
                return;
            }

            var flags = upgradeComponent.Flags;
            if (flags != null)
            {
                entity.UpgradeComponentFlags = this.upgradeComponentFlagCollectionConverter.Convert(flags, upgradeComponent);
            }

            var infusionUpgradeFlags = upgradeComponent.InfusionUpgradeFlags;
            if (infusionUpgradeFlags != null)
            {
                entity.InfusionUpgradeFlags = this.infusionSlotFlagCollectionConverter.Convert(infusionUpgradeFlags, upgradeComponent);
            }

            entity.Suffix = upgradeComponent.Suffix;

            var infixUpgrade = upgradeComponent.InfixUpgrade;
            if (infixUpgrade != null)
            {
                entity.InfixUpgrade = this.infixUpgradeConverter.Convert(infixUpgrade, upgradeComponent);
            }

            entity.Bonuses = upgradeComponent.Bonuses;
        }
Exemplo n.º 2
0
        partial void Merge(Trinket entity, ItemDTO dto, object state)
        {
            var trinket = dto.Trinket;
            if (trinket == null)
            {
                return;
            }

            var infusionSlots = trinket.InfusionSlots;
            if (infusionSlots != null)
            {
                entity.InfusionSlots = this.infusionSlotCollectionConverter.Convert(infusionSlots, trinket);
            }

            var infixUpgrade = trinket.InfixUpgrade;
            if (infixUpgrade != null)
            {
                entity.InfixUpgrade = this.infixUpgradeConverter.Convert(infixUpgrade, trinket);
            }

            int suffixItemId;
            if (int.TryParse(trinket.SuffixItemId, out suffixItemId))
            {
                entity.SuffixItemId = suffixItemId;
            }

            int secondarySuffixItemId;
            if (int.TryParse(trinket.SecondarySuffixItemId, out secondarySuffixItemId))
            {
                entity.SecondarySuffixItemId = secondarySuffixItemId;
            }
        }
Exemplo n.º 3
0
 partial void Merge(GatheringTool entity, ItemDTO dto, object state)
 {
     int defaultSkinId;
     if (int.TryParse(dto.DefaultSkin, out defaultSkinId))
     {
         entity.DefaultSkinId = defaultSkinId;
     }
 }
Exemplo n.º 4
0
        partial void Merge(Weapon entity, ItemDTO dto, object state)
        {
            int defaultSkinId;
            if (int.TryParse(dto.DefaultSkin, out defaultSkinId))
            {
                entity.DefaultSkinId = defaultSkinId;
            }

            var weapon = dto.Weapon;
            if (weapon == null)
            {
                return;
            }

            entity.DamageType = this.damageTypeConverter.Convert(weapon.DamageType, state);

            int minimumPower;
            if (int.TryParse(weapon.MinimumPower, out minimumPower))
            {
                entity.MinimumPower = minimumPower;
            }

            int maximumPower;
            if (int.TryParse(weapon.MaximumPower, out maximumPower))
            {
                entity.MaximumPower = maximumPower;
            }

            int defense;
            if (int.TryParse(weapon.Defense, out defense))
            {
                entity.Defense = defense;
            }

            var infusionSlots = weapon.InfusionSlots;
            if (infusionSlots != null)
            {
                entity.InfusionSlots = this.infusionSlotCollectionConverter.Convert(infusionSlots, weapon);
            }

            var infixUpgrade = weapon.InfixUpgrade;
            if (infixUpgrade != null)
            {
                entity.InfixUpgrade = this.infixUpgradeConverter.Convert(infixUpgrade, weapon);
            }

            int suffixItemId;
            if (int.TryParse(weapon.SuffixItemId, out suffixItemId))
            {
                entity.SuffixItemId = suffixItemId;
            }

            int secondarySuffixItemId;
            if (int.TryParse(weapon.SecondarySuffixItemId, out secondarySuffixItemId))
            {
                entity.SecondarySuffixItemId = secondarySuffixItemId;
            }
        }
        partial void Merge(CraftingRecipeUnlocker entity, ItemDTO dto, object state)
        {
            var consumableDto = dto.Consumable;
            if (consumableDto == null)
            {
                return;
            }

            int recipeId;
            if (int.TryParse(consumableDto.RecipeId, out recipeId))
            {
                entity.RecipeId = recipeId;
            }
        }
Exemplo n.º 6
0
        partial void Merge(DyeUnlocker entity, ItemDTO dto, object state)
        {
            var consumable = dto.Consumable;
            if (consumable == null)
            {
                return;
            }

            int colorId;
            if (int.TryParse(consumable.ColorId, out colorId))
            {
                entity.ColorId = colorId;
            }
        }
Exemplo n.º 7
0
        partial void Merge(SalvageTool entity, ItemDTO dto, object state)
        {
            var tool = dto.Tool;
            if (tool == null)
            {
                return;
            }

            int charges;
            if (int.TryParse(tool.Charges, out charges))
            {
                entity.Charges = charges;
            }
        }
        partial void Merge(ImmediateConsumable entity, ItemDTO dto, object state)
        {
            var consumableDto = dto.Consumable;
            if (consumableDto == null)
            {
                return;
            }

            entity.Effect = consumableDto.Description;
            double duration;
            if (double.TryParse(consumableDto.Duration, out duration))
            {
                entity.Duration = TimeSpan.FromMilliseconds(duration);
            }
        }
Exemplo n.º 9
0
        partial void Merge(Bag entity, ItemDTO dto, object state)
        {
            var bag = dto.Bag;
            if (bag == null)
            {
                return;
            }

            int size;
            if (int.TryParse(bag.Size, out size))
            {
                entity.Size = size;
            }

            int noSellOrSort;
            if (int.TryParse(bag.NoSellOrSort, out noSellOrSort))
            {
                entity.NoSellOrSort = noSellOrSort == 1;
            }
        }
Exemplo n.º 10
0
        partial void Merge(Armor entity, ItemDTO dto, object state)
        {
            int defaultSkinId;
            if (int.TryParse(dto.DefaultSkin, out defaultSkinId))
            {
                entity.DefaultSkinId = defaultSkinId;
            }

            var armor = dto.Armor;
            entity.WeightClass = this.weightClassConverter.Convert(armor.WeightClass, armor);
            int defense;
            if (int.TryParse(armor.Defense, out defense))
            {
                entity.Defense = defense;
            }

            var infusionSlots = armor.InfusionSlots;
            if (infusionSlots != null)
            {
                entity.InfusionSlots = this.infusionSlotCollectionConverter.Convert(infusionSlots, armor);
            }

            var infixUpgrade = armor.InfixUpgrade;
            if (infixUpgrade != null)
            {
                entity.InfixUpgrade = this.infixUpgradeConverter.Convert(infixUpgrade, armor);
            }

            int suffixItemId;
            if (int.TryParse(armor.SuffixItemId, out suffixItemId))
            {
                entity.SecondarySuffixItemId = suffixItemId;
            }

            int secondarySuffixItemId;
            if (int.TryParse(armor.SecondarySuffixItemId, out secondarySuffixItemId))
            {
                entity.SecondarySuffixItemId = secondarySuffixItemId;
            }
        }
Exemplo n.º 11
0
        partial void Merge(Backpack entity, ItemDTO dto, object state)
        {
            int defaultSkinId;
            if (int.TryParse(dto.DefaultSkin, out defaultSkinId))
            {
                entity.DefaultSkinId = defaultSkinId;
            }

            var backpack = dto.Backpack;
            if (backpack == null)
            {
                return;
            }

            var infusionSlots = backpack.InfusionSlots;
            if (infusionSlots != null)
            {
                entity.InfusionSlots = this.infusionSlotCollectionConverter.Convert(infusionSlots, dto);
            }

            var infixUpgrade = backpack.InfixUpgrade;
            if (infixUpgrade != null)
            {
                entity.InfixUpgrade = this.infixUpgradeConverter.Convert(infixUpgrade, dto);
            }

            int suffixItemId;
            if (int.TryParse(backpack.SuffixItemId, out suffixItemId))
            {
                entity.SuffixItemId = suffixItemId;
            }

            int secondarySuffixItemId;
            if (int.TryParse(backpack.SecondarySuffixItemId, out secondarySuffixItemId))
            {
                entity.SecondarySuffixItemId = secondarySuffixItemId;
            }
        }
Exemplo n.º 12
0
        partial void Merge(Item entity, ItemDTO dto, object state)
        {
            ItemChatLink chatLink = new ItemChatLink { Quantity = 1 };
            int itemId;
            if (int.TryParse(dto.ItemId, out itemId))
            {
                entity.ItemId = itemId;
            }

            entity.Name = dto.Name;
            entity.Description = dto.Description;

            int level;
            if (int.TryParse(dto.Level, out level))
            {
                entity.Level = level;
            }

            entity.Rarity = this.itemRarityConverter.Convert(dto.Rarity, dto);

            int vendorValue;
            if (int.TryParse(dto.VendorValue, out vendorValue))
            {
                entity.VendorValue = vendorValue;
            }

            var gameTypes = dto.GameTypes;
            if (gameTypes != null)
            {
                entity.GameTypes = this.gameTypesConverter.Convert(gameTypes, dto);
            }

            var flags = dto.Flags;
            if (flags != null)
            {
                entity.Flags = this.itemFlagsConverter.Convert(flags, dto);
            }

            var restrictions = dto.Restrictions;
            if (restrictions != null)
            {
                entity.Restrictions = this.itemRestrictionsConverter.Convert(restrictions, dto);
            }

            int iconFileId;
            if (int.TryParse(dto.IconFileId, out iconFileId))
            {
                entity.IconFileId = iconFileId;
            }

            // Set the icon file signature
            entity.IconFileSignature = dto.IconFileSignature;

            // Set the icon file URL
            const string IconUrlTemplate = @"https://render.guildwars2.com/file/{0}/{1}.{2}";
            var iconUrl = string.Format(IconUrlTemplate, dto.IconFileSignature, dto.IconFileId, "png");
            entity.IconFileUrl = new Uri(iconUrl, UriKind.Absolute);

            var skinnable = entity as ISkinnable;
            if (skinnable != null)
            {
                int defaultSkinId;
                if (int.TryParse(dto.DefaultSkin, out defaultSkinId))
                {
                    skinnable.DefaultSkinId = defaultSkinId;
                    chatLink.SkinId = defaultSkinId;
                }
            }

            var upgrade = entity as IUpgradable;
            if (upgrade != null)
            {
                chatLink.SuffixItemId = upgrade.SuffixItemId;
                chatLink.SecondarySuffixItemId = upgrade.SecondarySuffixItemId;
            }

            entity.ChatLink = chatLink.ToString();
        }