private static ItemType TypeFromItem(XmlItemBase item, ItemGroup group) { ItemType ret; var type = group.ToString(); // If there is a type with the same name as the group, take that if (Enum.TryParse(type, out ret)) { return(ret); } // Each jewel base has its own type. if (Enum.TryParse(item.Name.Replace(" Jewel", "Jewel"), out ret)) { return(ret); } // Types of armour groups. if (item.Strength > 0) { type += "Armour"; } if (item.Dexterity > 0) { type += "Evasion"; } if (item.Intelligence > 0) { type += "EnergyShield"; } // Special case for when all of Str, Dex and Int are 0 if (type == group.ToString()) { type += "ArmourEvasionEnergyShield"; } if (!Enum.TryParse(type, out ret)) { throw new ArgumentException($"Type {type} parsed from the given base item and group does not exist"); } return(ret); }