示例#1
0
		/// <summary>
		/// Load the Attribute from the XmlNode.
		/// </summary>
		/// <param name="objNode">XmlNode to load.</param>
		public void Load(XmlNode objNode)
		{
			_strAbbrev = objNode["name"].InnerText;
			_intMetatypeMin = Convert.ToInt32(objNode["metatypemin"].InnerText);
			_intMetatypeMax = Convert.ToInt32(objNode["metatypemax"].InnerText);
			_intMetatypeAugMax = Convert.ToInt32(objNode["metatypeaugmax"].InnerText);
		    
            objNode.TryGetField("base", out _intBase);
		    objNode.TryGetField("karma", out _intKarma);
            
            Value = Convert.ToInt32(objNode["value"].InnerText);
			_intAugModifier = Convert.ToInt32(objNode["augmodifier"].InnerText);

            if (_intBase == 0)
                _intBase = Value;
		}
示例#2
0
		/// <summary>
		/// Create a Quality from an XmlNode and return the TreeNodes for it.
		/// </summary>
		/// <param name="objXmlQuality">XmlNode to create the object from.</param>
		/// <param name="objCharacter">Character object the Quality will be added to.</param>
		/// <param name="objQualitySource">Source of the Quality.</param>
		/// <param name="objNode">TreeNode to populate a TreeView.</param>
		/// <param name="objWeapons">List of Weapons that should be added to the Character.</param>
		/// <param name="objWeaponNodes">List of TreeNodes to represent the Weapons added.</param>
		/// <param name="strForceValue">Force a value to be selected for the Quality.</param>
		public virtual void Create(XmlNode objXmlQuality, Character objCharacter, QualitySource objQualitySource, TreeNode objNode, List<Weapon> objWeapons, List<TreeNode> objWeaponNodes, string strForceValue = "")
		{
			_strName = objXmlQuality["name"].InnerText;
            if (objXmlQuality["metagenetic"] != null)
            {
                _strMetagenetic = objXmlQuality["metagenetic"].InnerText;
            }
			// Check for a Variable Cost.
			if (objXmlQuality["karma"].InnerText.StartsWith("Variable"))
			{
					int intMin = 0;
					int intMax = 0;
					string strCost = objXmlQuality["karma"].InnerText.Replace("Variable(", string.Empty).Replace(")", string.Empty);
					if (strCost.Contains("-"))
					{
						string[] strValues = strCost.Split('-');
						intMin = Convert.ToInt32(strValues[0]);
						intMax = Convert.ToInt32(strValues[1]);
					}
					else
						intMin = Convert.ToInt32(strCost.Replace("+", string.Empty));

					if (intMin != 0 || intMax != 0)
					{
						frmSelectNumber frmPickNumber = new frmSelectNumber();
						if (intMax == 0)
							intMax = 1000000;
						frmPickNumber.Minimum = intMin;
						frmPickNumber.Maximum = intMax;
						frmPickNumber.Description = LanguageManager.Instance.GetString("String_SelectVariableCost").Replace("{0}", DisplayNameShort);
						frmPickNumber.AllowCancel = false;
						frmPickNumber.ShowDialog();
						_intBP = frmPickNumber.SelectedValue;
					}
			}
			else
			{ 
                _intBP = Convert.ToInt32(objXmlQuality["karma"].InnerText);
            }
            if (objXmlQuality["lp"] != null)
            {
                _intLP = Convert.ToInt32(objXmlQuality["lp"].InnerText);
            }
			_objQualityType = ConvertToQualityType(objXmlQuality["category"].InnerText);
			_objQualitySource = objQualitySource;
			if (objXmlQuality["print"] != null)
			{
				if (objXmlQuality["print"].InnerText == "no")
					_blnPrint = false;
			}
			if (objXmlQuality["implemented"] != null)
			{
				if (objXmlQuality["implemented"].InnerText == "False")
					_blnImplemented = false;
			}
			if (objXmlQuality["contributetolimit"] != null)
			{
				if (objXmlQuality["contributetolimit"].InnerText == "no")
					_blnContributeToLimit = false;
			}
			_strSource = objXmlQuality["source"].InnerText;
			_strPage = objXmlQuality["page"].InnerText;
			if (objXmlQuality["mutant"] != null)
				_strMutant = "yes";

			if (_objQualityType == QualityType.LifeModule)
			{
				objXmlQuality.TryGetField("stage", out _stage);
			}

            if(objXmlQuality["id"] != null)
                _qualiyGuid = Guid.Parse(objXmlQuality["id"].InnerText);

			if (GlobalOptions.Instance.Language != "en-us")
			{
				XmlDocument objXmlDocument = XmlManager.Instance.Load("qualities.xml");
				XmlNode objQualityNode = objXmlDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + _strName + "\"]");
				if (objQualityNode != null)
				{
					if (objQualityNode["translate"] != null)
						_strAltName = objQualityNode["translate"].InnerText;
					if (objQualityNode["altpage"] != null)
						_strAltPage = objQualityNode["altpage"].InnerText;
				}
			}

			// Add Weapons if applicable.
			if (objXmlQuality.InnerXml.Contains("<addweapon>"))
			{
				XmlDocument objXmlWeaponDocument = XmlManager.Instance.Load("weapons.xml");

				// More than one Weapon can be added, so loop through all occurrences.
				foreach (XmlNode objXmlAddWeapon in objXmlQuality.SelectNodes("addweapon"))
				{
					XmlNode objXmlWeapon = objXmlWeaponDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + objXmlAddWeapon.InnerText + "\" and starts-with(category, \"Quality\")]");

					TreeNode objGearWeaponNode = new TreeNode();
					Weapon objGearWeapon = new Weapon(objCharacter);
					objGearWeapon.Create(objXmlWeapon, objCharacter, objGearWeaponNode, null, null, null);
					objGearWeaponNode.ForeColor = SystemColors.GrayText;
					objWeaponNodes.Add(objGearWeaponNode);
					objWeapons.Add(objGearWeapon);

					_guiWeaponID = Guid.Parse(objGearWeapon.InternalId);
				}
			}

			if (objXmlQuality.InnerXml.Contains("<naturalweapons>"))
            {
				foreach (XmlNode objXmlNaturalWeapon in objXmlQuality["naturalweapons"].SelectNodes("naturalweapon"))
				{
					TreeNode objGearWeaponNode = new TreeNode();
					Weapon objWeapon = new Weapon(_objCharacter);
					objWeapon.Name = objXmlNaturalWeapon["name"].InnerText;
					objWeapon.Category = LanguageManager.Instance.GetString("Tab_Critter");
					objWeapon.WeaponType = "Melee";
					objWeapon.Reach = Convert.ToInt32(objXmlNaturalWeapon["reach"].InnerText);
					objWeapon.Damage = objXmlNaturalWeapon["damage"].InnerText; ;
					objWeapon.AP = objXmlNaturalWeapon["ap"].InnerText; ;
					objWeapon.Mode = "0";
					objWeapon.RC = "0";
					objWeapon.Concealability = 0;
					objWeapon.Avail = "0";
					objWeapon.Cost = 0;
					objWeapon.UseSkill = objXmlNaturalWeapon["useskill"].InnerText;
					objWeapon.Source = objXmlNaturalWeapon["source"].InnerText;
					objWeapon.Page = objXmlNaturalWeapon["page"].InnerText;
					objGearWeaponNode.ForeColor = SystemColors.GrayText;
					objGearWeaponNode.Text = objWeapon.Name;
					objGearWeaponNode.Tag = objWeapon.InternalId;
					objWeaponNodes.Add(objGearWeaponNode);

					_objCharacter.Weapons.Add(objWeapon);
				}
			}

			// If the item grants a bonus, pass the information to the Improvement Manager.
			if (objXmlQuality.InnerXml.Contains("<bonus>"))
			{
				ImprovementManager objImprovementManager = new ImprovementManager(objCharacter);
				objImprovementManager.ForcedValue = strForceValue;
				if (!objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Quality, _guiID.ToString(), objXmlQuality["bonus"], false, 1, DisplayNameShort))
				{
					_guiID = Guid.Empty;
					return;
				}
				if (objImprovementManager.SelectedValue != "")
				{
					_strExtra = objImprovementManager.SelectedValue;
					objNode.Text += " (" + objImprovementManager.SelectedValue + ")";
				}
			}

			// Metatype Qualities appear as grey text to show that they cannot be removed.
			if (objQualitySource == QualitySource.Metatype || objQualitySource == QualitySource.MetatypeRemovable)
				objNode.ForeColor = SystemColors.GrayText;

			objNode.Text = DisplayName;
			objNode.Tag = InternalId;
		}
示例#3
0
 public void Load(XmlNode objXmlData)
 {
     objXmlData.TryGetField("name", out name);
     objXmlData.TryGetField("category", out category);
     foreach (XmlNode objXmlLevel in objXmlData.SelectNodes("effects/level"))
     {
         clsDrugEffect objDrugEffect = new clsDrugEffect();
         foreach (XmlNode objXmlEffect in objXmlLevel.SelectNodes("*"))
         {
             string effectName;
             int effectValue;
             objXmlEffect.TryGetField("name", out effectName, null);
             objXmlEffect.TryGetField("value", out effectValue, 1);
             switch (objXmlEffect.Name)
             {
                 case "attribute":
                     if (effectName != null)
                         objDrugEffect.attributes[effectName] = effectValue;
                     break;
                 case "limit":
                     if (effectName != null)
                         objDrugEffect.limits[effectName] = effectValue;
                     break;
                 case "quality":
                     objDrugEffect.qualities.Add(objXmlEffect.InnerText);
                     break;
                 case "info":
                     objDrugEffect.infos.Add(objXmlEffect.InnerText);
                     break;
                 case "initiative":
                     objDrugEffect.ini = int.Parse(objXmlEffect.InnerText);
                     break;
                 case "initiativedice":
                     objDrugEffect.iniDice = int.Parse(objXmlEffect.InnerText);
                     break;
                 case "crashdamage":
                     objDrugEffect.crashDamage = int.Parse(objXmlEffect.InnerText);
                     break;
                 case "speed":
                     objDrugEffect.speed = int.Parse(objXmlEffect.InnerText);
                     break;
                 case "duration":
                     objDrugEffect.duration = int.Parse(objXmlEffect.InnerText);
                     break;
                 default:
                     Log.Warning(info: string.Format("Unknown drug effect %s in component %s", objXmlEffect.Name, effectName));
                     break;
             }
         }
         effects.Add(objDrugEffect);
     }
     objXmlData.TryGetField("availability", out availability);
     objXmlData.TryGetField("cost", out cost);
     objXmlData.TryGetField("rating", out addictionRating);
     objXmlData.TryGetField("threshold", out addictionThreshold);
     objXmlData.TryGetField("source", out source);
     objXmlData.TryGetField("page", out page);
 }
示例#4
0
        public void Load(XmlNode node)
        {
            node.TryGetField("name", out _name);
            Type = node["type"].InnerText;
            node.TryGetField(GlobalOptions.Instance.Language, out _translated);

            LoadSuggestedSpecializations(_name);
        }
示例#5
0
        /// <summary>
        /// Load the Gear from the XmlNode.
        /// </summary>
        /// <param name="objNode">XmlNode to load.</param>
        public new void Load(XmlNode objNode, bool blnCopy = false)
        {
            _guiID = Guid.Parse(objNode["guid"].InnerText);
            _strName = objNode["name"].InnerText;
            _strCategory = objNode["category"].InnerText;
            objNode.TryGetField("armorcapacity", out _strArmorCapacity).ToString();
            _intMaxRating = Convert.ToInt32(objNode["maxrating"].InnerText);
            _intRating = Convert.ToInt32(objNode["rating"].InnerText);
            _intQty = Convert.ToInt32(objNode["qty"].InnerText);
            _strAvail = objNode["avail"].InnerText;
            _strCost = objNode["cost"].InnerText;
            _strExtra = objNode["extra"].InnerText;
            objNode.TryGetField("overclocked", out _strOverclocked);
            objNode.TryGetField("bonded", out _blnBonded);
            objNode.TryGetField("equipped", out _blnEquipped);
            objNode.TryGetField("homenode", out _blnHomeNode);
            _nodBonus = objNode["bonus"];
            _strSource = objNode["source"].InnerText;
            objNode.TryGetField("page", out _strPage);
            _intDeviceRating = Convert.ToInt32(objNode["devicerating"].InnerText);
            objNode.TryGetField("attack", out _intAttack);
            objNode.TryGetField("sleaze", out _intSleaze);
            objNode.TryGetField("dataprocessing", out _intDataProcessing);
            objNode.TryGetField("firewall", out _intFirewall);
            objNode.TryGetField("gearname", out _strGearName);

            if (objNode.InnerXml.Contains("<gear>"))
            {
                XmlNodeList nodChildren = objNode.SelectNodes("children/gear");
                foreach (XmlNode nodChild in nodChildren)
                {
                    switch (nodChild["category"].InnerText)
                    {
                        case "Commlinks":
                        case "Commlink Accessories":
                        case "Cyberdecks":
                        case "Rigger Command Consoles":
                            Commlink objCommlink = new Commlink(_objCharacter);
                            objCommlink.Load(nodChild, blnCopy);
                            objCommlink.Parent = this;
                            _objChildren.Add(objCommlink);
                            break;
                        default:
                            Gear objGear = new Gear(_objCharacter);
                            objGear.Load(nodChild, blnCopy);
                            objGear.Parent = this;
                            _objChildren.Add(objGear);
                            break;
                    }
                }
            }
            objNode.TryGetField("location", out _strLocation);
            objNode.TryGetField("notes", out _strNotes);
            objNode.TryGetField("discountedcost", out _blnDiscountCost);
            objNode.TryGetField("active", out _blnActiveCommlink);

            if (GlobalOptions.Instance.Language != "en-us")
            {
                XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
                XmlNode objGearNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + _strName + "\"]");
                if (objGearNode != null)
                {
                    if (objGearNode["translate"] != null)
                        _strAltName = objGearNode["translate"].InnerText;
                    if (objGearNode["altpage"] != null)
                        _strAltPage = objGearNode["altpage"].InnerText;
                }

                if (_strAltName.StartsWith("Stacked Focus"))
                    _strAltName = _strAltName.Replace("Stacked Focus", LanguageManager.Instance.GetString("String_StackedFocus"));

                objGearNode = objXmlDocument.SelectSingleNode("/chummer/categories/category[. = \"" + _strCategory + "\"]");
                if (objGearNode != null)
                {
                    if (objGearNode.Attributes["translate"] != null)
                        _strAltCategory = objGearNode.Attributes["translate"].InnerText;
                }

                if (_strAltCategory.StartsWith("Stacked Focus"))
                    _strAltCategory = _strAltCategory.Replace("Stacked Focus", LanguageManager.Instance.GetString("String_StackedFocus"));
            }

            if (blnCopy)
            {
                _guiID = Guid.NewGuid();
                _strLocation = string.Empty;
                _blnHomeNode = false;
            }
        }
示例#6
0
        /// <summary>
        /// Load the CharacterAttribute from the XmlNode.
        /// </summary>
        /// <param name="objNode">XmlNode to load.</param>
        public void Load(XmlNode objNode, bool blnCopy = false)
        {
            _guiID = Guid.Parse(objNode["guid"].InnerText);
            _strName = objNode["name"].InnerText;
            _strCategory = objNode["category"].InnerText;
            _strA = objNode["armor"].InnerText;
            _strAvail = objNode["avail"].InnerText;
            _strCost = objNode["cost"].InnerText;
            _strSource = objNode["source"].InnerText;
            objNode.TryGetField("armoroverride", out _strO);
            objNode.TryGetField("armorcapacity", out _strArmorCapacity);
            objNode.TryGetField("rating", out _intRating);
            objNode.TryGetField("maxrating", out _intMaxRating);
            objNode.TryGetField("page", out _strPage);
            objNode.TryGetField("armorname", out _strArmorName);
            objNode.TryGetField("equipped", out _blnEquipped);
            objNode.TryGetField("extra", out _strExtra);
            objNode.TryGetField("damage", out _intDamage);
            objNode.TryGetField("location", out _strLocation);
            objNode.TryGetField("notes", out _strNotes);
            objNode.TryGetField("discountedcost", out _blnDiscountCost);
            try
            {
                _nodBonus = objNode["bonus"];
            }
            catch { }
            if (objNode.InnerXml.Contains("armormods"))
            {
                XmlNodeList nodMods = objNode.SelectNodes("armormods/armormod");
                foreach (XmlNode nodMod in nodMods)
                {
                    ArmorMod objMod = new ArmorMod(_objCharacter);
                    objMod.Load(nodMod, blnCopy);
                    objMod.Parent = this;
                    _lstArmorMods.Add(objMod);
                }
            }
            if (objNode.InnerXml.Contains("gears"))
            {
                XmlNodeList nodGears = objNode.SelectNodes("gears/gear");
                foreach (XmlNode nodGear in nodGears)
                {
                    switch (nodGear["category"].InnerText)
                    {
                        case "Commlinks":
                        case "Commlink Accessories":
                        case "Cyberdecks":
                        case "Rigger Command Consoles":
                            Commlink objCommlink = new Commlink(_objCharacter);
                            objCommlink.Load(nodGear, blnCopy);
                            _lstGear.Add(objCommlink);
                            break;
                        default:
                            Gear objGear = new Gear(_objCharacter);
                            objGear.Load(nodGear, blnCopy);
                            _lstGear.Add(objGear);
                            break;
                    }
                }
            }

            if (GlobalOptions.Instance.Language != "en-us")
            {
                XmlDocument objXmlArmorDocument = XmlManager.Instance.Load("armor.xml");
                XmlNode objArmorNode = objXmlArmorDocument.SelectSingleNode("/chummer/armors/armor[name = \"" + _strName + "\"]");
                if (objArmorNode != null)
                {
                    if (objArmorNode["translate"] != null)
                        _strAltName = objArmorNode["translate"].InnerText;
                    if (objArmorNode["altpage"] != null)
                        _strAltPage = objArmorNode["altpage"].InnerText;
                }

                objArmorNode = objXmlArmorDocument.SelectSingleNode("/chummer/categories/category[. = \"" + _strCategory + "\"]");
                if (objArmorNode != null)
                {
                    if (objArmorNode.Attributes["translate"] != null)
                        _strAltCategory = objArmorNode.Attributes["translate"].InnerText;
                }
            }

            if (blnCopy)
            {
                _guiID = Guid.NewGuid();
                _strLocation = string.Empty;
            }
        }
示例#7
0
		/// <summary>
		/// Load the Contact from the XmlNode.
		/// </summary>
		/// <param name="objNode">XmlNode to load.</param>
		public void Load(XmlNode objNode)
		{
			_strName = objNode["name"].InnerText;
            try
            {
                _strRole = objNode["role"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strLocation = objNode["location"].InnerText;
            }
            catch
            {
            }
            _intConnection = Convert.ToInt32(objNode["connection"].InnerText);
			_intLoyalty = Convert.ToInt32(objNode["loyalty"].InnerText);
            _objContactType = ConvertToContactType(objNode["type"].InnerText);
			try
			{
				_strFileName = objNode["file"].InnerText;
			}
			catch
			{
			}
			try
			{
				_strRelativeName = objNode["relative"].InnerText;
			}
			catch
			{
			}
			try
			{
				_strNotes = objNode["notes"].InnerText;
			}
			catch
			{
			}
			try
			{
				_strGroupName = objNode["groupname"].InnerText;
			}
			catch
			{
			}
			try
			{
				_objColour = Color.FromArgb(Convert.ToInt32(objNode["colour"].InnerText));
			}
			catch
			{
			}
			try
			{
				_blnFree = Convert.ToBoolean(objNode["free"].InnerText);
			}
			catch
			{
			}
            try
		    {
		        _blnIsGroup = Convert.ToBoolean(objNode["group"].InnerText);
		    }
		    catch
		    {
		    }
		    try
		    {
		        _strUnique = objNode["guid"].InnerText;
		    }
		    catch
		    {
		    }


			if (objNode["readonly"] != null) _readonly = true;
		    objNode.TryGetField("mademan", out _blnMadeMan);
		}
示例#8
0
		/// <summary>
		/// Load the Attribute from the XmlNode.
		/// </summary>
		/// <param name="objNode">XmlNode to load.</param>
		public void Load(XmlNode objNode)
		{
            _guiID = Guid.Parse(objNode["guid"].InnerText);
            _strName = objNode["name"].InnerText;
			objNode.TryGetField("displayname", out _strDisplayName);
		}
示例#9
0
        /// <summary>
        /// Load the Vehicle from the XmlNode.
        /// </summary>
        /// <param name="objNode">XmlNode to load.</param>
        public void Load(XmlNode objNode, bool blnCopy = false)
        {
            _guiID = Guid.Parse(objNode["guid"].InnerText);
            _strName = objNode["name"].InnerText;
            _strCategory = objNode["category"].InnerText;
            //Some vehicles have different Offroad Handling speeds. If so, we want to split this up for use with mods and such later.
            if (objNode["handling"].InnerText.Contains('/'))
            {
                _intHandling = Convert.ToInt32(objNode["handling"].InnerText.Split('/')[0]);
                _intOffroadHandling = Convert.ToInt32(objNode["handling"].InnerText.Split('/')[1]);
            }
            else
            {
                _intHandling = Convert.ToInt32(objNode["handling"].InnerText);
                if (objNode.InnerXml.Contains("offroadhandling"))
                {
                    _intOffroadHandling = Convert.ToInt32(objNode["offroadhandling"].InnerText);
                }
            }
            _intAccel = Convert.ToInt32(objNode["accel"].InnerText);
            objNode.TryGetField("seats", out _intSeats);
            _intSpeed = Convert.ToInt32(objNode["speed"].InnerText);
            _intPilot = Convert.ToInt32(objNode["pilot"].InnerText);
            _intBody = Convert.ToInt32(objNode["body"].InnerText);
            _intArmor = Convert.ToInt32(objNode["armor"].InnerText);
            _intSensor = Convert.ToInt32(objNode["sensor"].InnerText);
            objNode.TryGetField("devicerating", out _intDeviceRating);
            _strAvail = objNode["avail"].InnerText;
            _strCost = objNode["cost"].InnerText;
            objNode.TryGetField("addslots", out _intAddSlots);
            objNode.TryGetField("modslots", out _intModSlots);
            _strSource = objNode["source"].InnerText;
            objNode.TryGetField("page", out _strPage);
            objNode.TryGetField("matrixcmfilled", out _intMatrixCMFilled);
            objNode.TryGetField("physicalcmfilled", out _intPhysicalCMFilled);
            objNode.TryGetField("vehiclename", out _strVehicleName);
            objNode.TryGetField("homenode", out _blnHomeNode);

            if (GlobalOptions.Instance.Language != "en-us")
            {
                XmlDocument objXmlDocument = XmlManager.Instance.Load("vehicles.xml");
                XmlNode objVehicleNode = objXmlDocument.SelectSingleNode("/chummer/vehicles/vehicle[name = \"" + _strName + "\"]");
                if (objVehicleNode != null)
                {
                    if (objVehicleNode["translate"] != null)
                        _strAltName = objVehicleNode["translate"].InnerText;
                    if (objVehicleNode["altpage"] != null)
                        _strAltPage = objVehicleNode["altpage"].InnerText;
                }

                objVehicleNode = objXmlDocument.SelectSingleNode("/chummer/categories/category[. = \"" + _strCategory + "\"]");
                if (objVehicleNode != null)
                {
                    if (objVehicleNode.Attributes["translate"] != null)
                        _strAltCategory = objVehicleNode.Attributes["translate"].InnerText;
                }
            }

            if (objNode.InnerXml.Contains("<mods>"))
            {
                XmlNodeList nodChildren = objNode.SelectNodes("mods/mod");
                foreach (XmlNode nodChild in nodChildren)
                {
                    VehicleMod objMod = new VehicleMod(_objCharacter);
                    objMod.Load(nodChild, blnCopy);
                    _lstVehicleMods.Add(objMod);
                }
            }

            if (objNode.InnerXml.Contains("<gears>"))
            {
                XmlNodeList nodChildren = objNode.SelectNodes("gears/gear");
                foreach (XmlNode nodChild in nodChildren)
                {
                    switch (nodChild["category"].InnerText)
                    {
                        case "Commlinks":
                        case "Commlink Accessories":
                        case "Cyberdecks":
                        case "Rigger Command Consoles":
                            Commlink objCommlink = new Commlink(_objCharacter);
                            objCommlink.Load(nodChild, blnCopy);
                            _lstGear.Add(objCommlink);
                            break;
                        default:
                            Gear objGear = new Gear(_objCharacter);
                            objGear.Load(nodChild, blnCopy);
                            _lstGear.Add(objGear);
                            break;
                    }
                }
            }

            if (objNode.InnerXml.Contains("<weapons>"))
            {
                XmlNodeList nodChildren = objNode.SelectNodes("weapons/weapon");
                foreach (XmlNode nodChild in nodChildren)
                {
                    Weapon objWeapon = new Weapon(_objCharacter);
                    objWeapon.Load(nodChild, blnCopy);
                    objWeapon.VehicleMounted = true;
                    if (objWeapon.UnderbarrelWeapons.Count > 0)
                    {
                        foreach (Weapon objUnderbarrel in objWeapon.UnderbarrelWeapons)
                            objUnderbarrel.VehicleMounted = true;
                    }
                    _lstWeapons.Add(objWeapon);
                }
            }

            objNode.TryGetField("notes", out _strNotes);
            objNode.TryGetField("dealerconnection", out _blnDealerConnectionDiscount);

            if (objNode["locations"] != null)
            {
                // Locations.
                foreach (XmlNode objXmlLocation in objNode.SelectNodes("locations/location"))
                {
                    _lstLocations.Add(objXmlLocation.InnerText);
                }
            }

            if (blnCopy)
            {
                _guiID = Guid.NewGuid();
                _blnHomeNode = false;
            }
        }
示例#10
0
        /// <summary>
        /// Load the CharacterAttribute from the XmlNode.
        /// </summary>
        /// <param name="objNode">XmlNode to load.</param>
        /// <param name="blnCopy">Whether another node is being copied.</param>
        public void Load(XmlNode objNode, bool blnCopy = false)
        {
            _guiID = Guid.Parse(objNode["guid"].InnerText);
            _strName = objNode["name"].InnerText;
            _strMount = objNode["mount"].InnerText;
            _strRC = objNode["rc"].InnerText;
            objNode.TryGetField("rating", out _intRating,0);
            objNode.TryGetField("rcgroup", out _intRCGroup, 0);
            objNode.TryGetField("accuracy", out _intAccuracy, 0);
            objNode.TryGetField("rating", out _intRating, 0);
            objNode.TryGetField("rating", out _intRating, 0);
            objNode.TryGetField("conceal", out _strConceal, "0");
            objNode.TryGetField("rcdeployable", out _blnDeployable);
            _strAvail = objNode["avail"].InnerText;
            _strCost = objNode["cost"].InnerText;
            _blnIncludedInWeapon = Convert.ToBoolean(objNode["included"].InnerText);
            objNode.TryGetField("installed", out _blnInstalled, true);
            try
            {
                _nodAllowGear = objNode["allowgear"];
            }
            catch
            {
            }
            _strSource = objNode["source"].InnerText;

            objNode.TryGetField("page", out _strPage, "0");
            objNode.TryGetField("dicepool", out _strDicePool, "0");

            if (objNode.InnerXml.Contains("ammoslots"))
            {
                objNode.TryGetField("ammoslots", out _intAmmoSlots, 0);  //TODO: Might work if 0 -> 1
            }

            if (objNode.InnerXml.Contains("<gears>"))
            {
                XmlNodeList nodChildren = objNode.SelectNodes("gears/gear");
                foreach (XmlNode nodChild in nodChildren)
                {
                    switch (nodChild["category"].InnerText)
                    {
                        case "Commlinks":
                        case "Commlink Accessories":
                        case "Cyberdecks":
                        case "Rigger Command Consoles":
                            Commlink objCommlink = new Commlink(_objCharacter);
                            objCommlink.Load(nodChild, blnCopy);
                            _lstGear.Add(objCommlink);
                            break;
                        default:
                            Gear objGear = new Gear(_objCharacter);
                            objGear.Load(nodChild, blnCopy);
                            _lstGear.Add(objGear);
                            break;
                    }
                }
            }
            objNode.TryGetField("notes", out _strNotes, "");
            objNode.TryGetField("discountedcost", out _blnDiscountCost, false);

            if (GlobalOptions.Instance.Language != "en-us")
            {
                XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");
                XmlNode objAccessoryNode = objXmlDocument.SelectSingleNode("/chummer/accessories/accessory[name = \"" + _strName + "\"]");
                if (objAccessoryNode != null)
                {
                    if (objAccessoryNode["translate"] != null)
                        _strAltName = objAccessoryNode["translate"].InnerText;
                    if (objAccessoryNode["altpage"] != null)
                        _strAltPage = objAccessoryNode["altpage"].InnerText;
                }
            }
            if (objNode["damage"] != null)
            {
                _strDamage = objNode["damage"].InnerText;
            }
            if (objNode["damagetype"] != null)
            {
                _strDamageType = objNode["damagetype"].InnerText;
            }
            if (objNode["damagereplace"] != null)
            {
                _strDamageReplace = objNode["damagereplace"].InnerText;
            }
            if (objNode["firemode"] != null)
            {
                _strFireMode = objNode["firemode"].InnerText;
            }
            if (objNode["firemodereplace"] != null)
            {
                _strFireModeReplace = objNode["firemodereplace"].InnerText;
            }

            if (objNode["ap"] != null)
            {
                _strAP = objNode["ap"].InnerText;
            }
            if (objNode["apreplace"] != null)
            {
                _strAPReplace = objNode["apreplace"].InnerText;
            }
            objNode.TryGetField("accessorycostmultiplier", out _intAccessoryCostMultiplier);
            objNode.TryGetField("addmode", out _strAddMode);
            objNode.TryGetField("fullburst", out _intFullBurst,0);
            objNode.TryGetField("suppressive", out _intSuppressive,0);
            objNode.TryGetField("rangebonus", out _intRangeBonus,0);
            objNode.TryGetField("extra", out _strExtra,"");
            objNode.TryGetField("ammobonus", out _intAmmoBonus,0);

            if (blnCopy)
            {
                _guiID = Guid.NewGuid();
            }
        }
示例#11
0
        /// Create a Weapon Accessory from an XmlNode and return the TreeNodes for it.
        /// <param name="objXmlAccessory">XmlNode to create the object from.</param>
        /// <param name="objNode">TreeNode to populate a TreeView.</param>
        /// <param name="strMount">Mount slot that the Weapon Accessory will consume.</param>
        /// <param name="intRating">Rating of the Weapon Accessory.</param>
        public void Create(XmlNode objXmlAccessory, TreeNode objNode, string strMount, int intRating)
        {
            _strName = objXmlAccessory["name"].InnerText;
            _strMount = strMount;
            _intRating = intRating;
            _strAvail = objXmlAccessory["avail"].InnerText;
            _strCost = objXmlAccessory["cost"].InnerText;
            _strSource = objXmlAccessory["source"].InnerText;
            _strPage = objXmlAccessory["page"].InnerText;
            _nodAllowGear = objXmlAccessory["allowgear"];
            objXmlAccessory.TryGetField("rc", out _strRC, "");
            objXmlAccessory.TryGetField("rcdeployable", out _blnDeployable);
            objXmlAccessory.TryGetField("rcgroup", out _intRCGroup);
            objXmlAccessory.TryGetField("conceal", out _strConceal, "");
            objXmlAccessory.TryGetField("ammoslots", out _intAmmoSlots);
            objXmlAccessory.TryGetField("ammoreplace", out _strAmmoReplace, "");
            objXmlAccessory.TryGetField("accuracy", out _intAccuracy);
            objXmlAccessory.TryGetField("dicepool", out _strDicePool,"");
            objXmlAccessory.TryGetField("damagetype", out _strDamageType,"");
            objXmlAccessory.TryGetField("damage", out _strDamage, "");
            objXmlAccessory.TryGetField("damagereplace", out _strDamageReplace, "");
            objXmlAccessory.TryGetField("firemode", out _strFireMode, "");
            objXmlAccessory.TryGetField("firemodereplace", out _strFireModeReplace, "");
            objXmlAccessory.TryGetField("ap", out _strAP,"");
            objXmlAccessory.TryGetField("apreplace", out _strAPReplace,"");
            objXmlAccessory.TryGetField("addmode", out _strAddMode,"");
            objXmlAccessory.TryGetField("fullburst", out _intFullBurst);
            objXmlAccessory.TryGetField("suppressive", out _intSuppressive);
            objXmlAccessory.TryGetField("rangebonus", out _intRangeBonus);
            objXmlAccessory.TryGetField("extra", out _strExtra, "");
            objXmlAccessory.TryGetField("ammobonus", out _intAmmoBonus);
            objXmlAccessory.TryGetField("accessorycostmultiplier", out _intAccessoryCostMultiplier);

            if (GlobalOptions.Instance.Language != "en-us")
            {
                XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");
                XmlNode objAccessoryNode = objXmlDocument.SelectSingleNode("/chummer/accessories/accessory[name = \"" + _strName + "\"]");
                if (objAccessoryNode != null)
                {
                    if (objAccessoryNode["translate"] != null)
                        _strAltName = objAccessoryNode["translate"].InnerText;
                    if (objAccessoryNode["altpage"] != null)
                        _strAltPage = objAccessoryNode["altpage"].InnerText;
                }
            }

            objNode.Text = DisplayName;
            objNode.Tag = _guiID.ToString();
        }
示例#12
0
        /// <summary>
        /// Create a Quality from an XmlNode and return the TreeNodes for it.
        /// </summary>
        /// <param name="objXmlQuality">XmlNode to create the object from.</param>
        /// <param name="objCharacter">Character object the Quality will be added to.</param>
        /// <param name="objQualitySource">Source of the Quality.</param>
        /// <param name="objNode">TreeNode to populate a TreeView.</param>
        /// <param name="objWeapons">List of Weapons that should be added to the Character.</param>
        /// <param name="objWeaponNodes">List of TreeNodes to represent the Weapons added.</param>
        /// <param name="strForceValue">Force a value to be selected for the Quality.</param>
        public virtual void Create(XmlNode objXmlQuality, Character objCharacter, QualitySource objQualitySource, TreeNode objNode, List<Weapon> objWeapons, List<TreeNode> objWeaponNodes, string strForceValue = "")
        {
            _strName = objXmlQuality["name"].InnerText;
            if (objXmlQuality["metagenetic"] != null)
            {
                _strMetagenetic = objXmlQuality["metagenetic"].InnerText;
            }
            if (objXmlQuality["karma"] != null)
            {
                _intBP = Convert.ToInt32(objXmlQuality["karma"].InnerText);
            }
            if (objXmlQuality["lp"] != null)
            {
                _intLP = Convert.ToInt32(objXmlQuality["lp"].InnerText);
            }
            _objQualityType = ConvertToQualityType(objXmlQuality["category"].InnerText);
            _objQualitySource = objQualitySource;
            if (objXmlQuality["print"] != null)
            {
                if (objXmlQuality["print"].InnerText == "no")
                    _blnPrint = false;
            }
            if (objXmlQuality["contributetolimit"] != null)
            {
                if (objXmlQuality["contributetolimit"].InnerText == "no")
                    _blnContributeToLimit = false;
            }
            _strSource = objXmlQuality["source"].InnerText;
            _strPage = objXmlQuality["page"].InnerText;
            if (objXmlQuality["mutant"] != null)
                _strMutant = "yes";

            if (_objQualityType == QualityType.LifeModule)
            {
                objXmlQuality.TryGetField("stage", out _stage);
            }

            if(objXmlQuality["id"] != null)
                _qualiyGuid = Guid.Parse(objXmlQuality["id"].InnerText);

            if (GlobalOptions.Instance.Language != "en-us")
            {
                XmlDocument objXmlDocument = XmlManager.Instance.Load("qualities.xml");
                XmlNode objQualityNode = objXmlDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + _strName + "\"]");
                if (objQualityNode != null)
                {
                    if (objQualityNode["translate"] != null)
                        _strAltName = objQualityNode["translate"].InnerText;
                    if (objQualityNode["altpage"] != null)
                        _strAltPage = objQualityNode["altpage"].InnerText;
                }
            }

            // Add Weapons if applicable.
            if (objXmlQuality.InnerXml.Contains("<addweapon>"))
            {
                XmlDocument objXmlWeaponDocument = XmlManager.Instance.Load("weapons.xml");

                // More than one Weapon can be added, so loop through all occurrences.
                foreach (XmlNode objXmlAddWeapon in objXmlQuality.SelectNodes("addweapon"))
                {
                    XmlNode objXmlWeapon = objXmlWeaponDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + objXmlAddWeapon.InnerText + "\" and starts-with(category, \"Quality\")]");

                    TreeNode objGearWeaponNode = new TreeNode();
                    Weapon objGearWeapon = new Weapon(objCharacter);
                    objGearWeapon.Create(objXmlWeapon, objCharacter, objGearWeaponNode, null, null, null);
                    objGearWeaponNode.ForeColor = SystemColors.GrayText;
                    objWeaponNodes.Add(objGearWeaponNode);
                    objWeapons.Add(objGearWeapon);

                    _guiWeaponID = Guid.Parse(objGearWeapon.InternalId);
                }
            }

            // If the item grants a bonus, pass the information to the Improvement Manager.
            if (objXmlQuality.InnerXml.Contains("<bonus>"))
            {
                ImprovementManager objImprovementManager = new ImprovementManager(objCharacter);
                objImprovementManager.ForcedValue = strForceValue;
                if (!objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Quality, _guiID.ToString(), objXmlQuality["bonus"], false, 1, DisplayNameShort))
                {
                    _guiID = Guid.Empty;
                    return;
                }
                if (objImprovementManager.SelectedValue != "")
                {
                    _strExtra = objImprovementManager.SelectedValue;
                    objNode.Text += " (" + objImprovementManager.SelectedValue + ")";
                }
            }

            // Metatype Qualities appear as grey text to show that they cannot be removed.
            if (objQualitySource == QualitySource.Metatype || objQualitySource == QualitySource.MetatypeRemovable)
                objNode.ForeColor = SystemColors.GrayText;

            objNode.Text = DisplayName;
            objNode.Tag = InternalId;
        }
示例#13
0
        /// <summary>
        /// Load the VehicleMod from the XmlNode.
        /// </summary>
        /// <param name="objNode">XmlNode to load.</param>
        public void Load(XmlNode objNode, bool blnCopy = false)
        {
            _guiID = Guid.Parse(objNode["guid"].InnerText);
            _strName = objNode["name"].InnerText;
            _strCategory = objNode["category"].InnerText;
            _strLimit = objNode["limit"].InnerText;
            _strSlots = objNode["slots"].InnerText;
            _intRating = Convert.ToInt32(objNode["rating"].InnerText);
            _strMaxRating = objNode["maxrating"].InnerText;
            objNode.TryGetField("weaponmountcategories", out _strWeaponMountCategories);
            objNode.TryGetField("response", out _intResponse);
            objNode.TryGetField("system", out _intSystem);
            objNode.TryGetField("firewall", out _intFirewall);
            objNode.TryGetField("signal", out _intSignal);
            objNode.TryGetField("pilot", out _intPilot);
            objNode.TryGetField("page", out _strPage);
            _strAvail = objNode["avail"].InnerText;
            _strCost = objNode["cost"].InnerText;
            _strSource = objNode["source"].InnerText;
            _blnIncludeInVehicle = Convert.ToBoolean(objNode["included"].InnerText);
            objNode.TryGetField("installed", out _blnInstalled);
            objNode.TryGetField("subsystems", out _strSubsystems);

            if (objNode.InnerXml.Contains("<weapons>"))
            {
                XmlNodeList nodChildren = objNode.SelectNodes("weapons/weapon");
                foreach (XmlNode nodChild in nodChildren)
                {
                    Weapon objWeapon = new Weapon(_objCharacter);
                    objWeapon.Load(nodChild, blnCopy);
                    _lstVehicleWeapons.Add(objWeapon);
                }
            }
            if (objNode.InnerXml.Contains("<cyberwares>"))
            {
                XmlNodeList nodChildren = objNode.SelectNodes("cyberwares/cyberware");
                foreach (XmlNode nodChild in nodChildren)
                {
                    Cyberware objCyberware = new Cyberware(_objCharacter);
                    objCyberware.Load(nodChild, blnCopy);
                    _lstCyberware.Add(objCyberware);
                }
            }

            try
            {
                _nodBonus = objNode["bonus"];
            }
            catch
            {
            }
            objNode.TryGetField("notes", out _strNotes);
            objNode.TryGetField("discountedcost", out _blnDiscountCost);
            objNode.TryGetField("extra", out _strExtra);

            if (GlobalOptions.Instance.Language != "en-us")
            {
                XmlDocument objXmlDocument = XmlManager.Instance.Load("vehicles.xml");
                XmlNode objModNode = objXmlDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + _strName + "\"]");
                if (objModNode != null)
                {
                    if (objModNode["translate"] != null)
                        _strAltName = objModNode["translate"].InnerText;
                    if (objModNode["altpage"] != null)
                        _strAltPage = objModNode["altpage"].InnerText;
                }

                objModNode = objXmlDocument.SelectSingleNode("/chummer/categories/category[. = \"" + _strCategory + "\"]");
                if (objModNode != null)
                {
                    if (objModNode.Attributes["translate"] != null)
                        _strAltCategory = objModNode.Attributes["translate"].InnerText;
                }
            }

            if (blnCopy)
            {
                _guiID = Guid.NewGuid();
            }
        }
示例#14
0
        /// Create a Vehicle Modification from an XmlNode and return the TreeNodes for it.
        /// <param name="objXmlMod">XmlNode to create the object from.</param>
        /// <param name="objNode">TreeNode to populate a TreeView.</param>
        /// <param name="intRating">Selected Rating for the Gear.</param>
        public void Create(XmlNode objXmlMod, TreeNode objNode, int intRating)
        {
            _strName = objXmlMod["name"].InnerText;
            _strCategory = objXmlMod["category"].InnerText;
            objXmlMod.TryGetField("limit", out _strLimit);
            objXmlMod.TryGetField("slots", out _strSlots);
            if (intRating != 0)
            {
                _intRating = Convert.ToInt32(intRating);
            }
            if (objXmlMod["rating"] != null)
                _strMaxRating = objXmlMod["rating"].InnerText;
            else
                _strMaxRating = "0";
            objXmlMod.TryGetField("response", out _intResponse);
            objXmlMod.TryGetField("system", out _intSystem);
            objXmlMod.TryGetField("firewall", out _intFirewall);
            objXmlMod.TryGetField("signal", out _intSignal);
            objXmlMod.TryGetField("pilot", out _intPilot);
            objXmlMod.TryGetField("weaponmountcategories", out _strWeaponMountCategories);
            // Add Subsytem information if applicable.
            if (objXmlMod.InnerXml.Contains("subsystems"))
            {
                string strSubsystem = "";
                foreach (XmlNode objXmlSubsystem in objXmlMod.SelectNodes("subsystems/subsystem"))
                {
                    strSubsystem += objXmlSubsystem.InnerText + ",";
                }
                _strSubsystems = strSubsystem;
            }
            _strAvail = objXmlMod["avail"].InnerText;

            // Check for a Variable Cost.
            if (objXmlMod["cost"] != null)
            {
                if (objXmlMod["cost"].InnerText.StartsWith("Variable"))
                {
                    int intMin = 0;
                    int intMax = 0;
                    string strCost = objXmlMod["cost"].InnerText.Replace("Variable(", string.Empty).Replace(")", string.Empty);
                    if (strCost.Contains("-"))
                    {
                        string[] strValues = strCost.Split('-');
                        intMin = Convert.ToInt32(strValues[0]);
                        intMax = Convert.ToInt32(strValues[1]);
                    }
                    else
                        intMin = Convert.ToInt32(strCost.Replace("+", string.Empty));

                    if (intMin != 0 || intMax != 0)
                    {
                        frmSelectNumber frmPickNumber = new frmSelectNumber();
                        if (intMax == 0)
                            intMax = 1000000;
                        frmPickNumber.Minimum = intMin;
                        frmPickNumber.Maximum = intMax;
                        frmPickNumber.Description = LanguageManager.Instance.GetString("String_SelectVariableCost").Replace("{0}", DisplayNameShort);
                        frmPickNumber.AllowCancel = false;
                        frmPickNumber.ShowDialog();
                        _strCost = frmPickNumber.SelectedValue.ToString();
                    }
                }
                else
                    _strCost = objXmlMod["cost"].InnerText;
            }

            _strSource = objXmlMod["source"].InnerText;
            _strPage = objXmlMod["page"].InnerText;
            if (objXmlMod["bonus"] != null)
                _nodBonus = objXmlMod["bonus"];

            if (GlobalOptions.Instance.Language != "en-us")
            {
                XmlDocument objXmlDocument = XmlManager.Instance.Load("vehicles.xml");
                XmlNode objModNode = objXmlDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + _strName + "\"]");
                if (objModNode != null)
                {
                    if (objModNode["translate"] != null)
                        _strAltName = objModNode["translate"].InnerText;
                    if (objModNode["altpage"] != null)
                        _strAltPage = objModNode["altpage"].InnerText;
                }

                objModNode = objXmlDocument.SelectSingleNode("/chummer/categories/category[. = \"" + _strCategory + "\"]");
                if (objModNode != null)
                {
                    if (objModNode.Attributes["translate"] != null)
                        _strAltCategory = objModNode.Attributes["translate"].InnerText;
                }
            }

            objNode.Text = DisplayName;
            objNode.Tag = _guiID.ToString();
        }
示例#15
0
		/// <summary>
		/// Load the Attribute from the XmlNode.
		/// </summary>
		/// <param name="objNode">XmlNode to load.</param>
		public virtual void Load(XmlNode objNode)
		{
			_guiID = Guid.Parse(objNode["guid"].InnerText);
			_strName = objNode["name"].InnerText;
			_strExtra = objNode["extra"].InnerText;
			_intBP = Convert.ToInt32(objNode["bp"].InnerText);
			//_blnImplemented = Convert.ToBoolean(objNode["implemented"].InnerText);

			objNode.TryPreserveField("implemented", ref _blnImplemented);
			_blnContributeToLimit = Convert.ToBoolean(objNode["contributetolimit"].InnerText);
			_blnPrint = Convert.ToBoolean(objNode["print"].InnerText);
			_objQualityType = ConvertToQualityType(objNode["qualitytype"].InnerText);
			_objQualitySource = ConvertToQualitySource(objNode["qualitysource"].InnerText);
            try
            {
                _strMetagenetic = objNode["metagenetic"].InnerText;
            }
            catch 
            {
            }
			try
			{
				_strMutant = objNode["mutant"].InnerText;
			}
			catch
			{
			}
			_strSource = objNode["source"].InnerText;
			_strPage = objNode["page"].InnerText;
			_nodBonus = objNode["bonus"];
			try
			{
				_guiWeaponID = Guid.Parse(objNode["weaponguid"].InnerText);
			}
			catch
			{
			}
			try
			{
				_strNotes = objNode["notes"].InnerText;
			}
			catch
			{
			}

			if (_objQualityType == QualityType.LifeModule)
			{
				objNode.TryGetField("stage", out _stage);
			}
			if (objNode["id"] != null)
			{
				Guid.TryParse(objNode["id"].InnerText, out _qualiyGuid);
			}

			if (GlobalOptions.Instance.Language != "en-us")
			{
				XmlDocument objXmlDocument = XmlManager.Instance.Load("qualities.xml");
				XmlNode objQualityNode = objXmlDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + _strName + "\"]");
				if (objQualityNode != null)
				{
					if (objQualityNode["translate"] != null)
						_strAltName = objQualityNode["translate"].InnerText;
					if (objQualityNode["altpage"] != null)
						_strAltPage = objQualityNode["altpage"].InnerText;
				}
			}
		}
示例#16
0
		/// <summary>
		/// Load the Attribute from the XmlNode.
		/// </summary>
		/// <param name="objNode">XmlNode to load.</param>
		public void Load(XmlNode objNode)
		{
			string strId;
			if (objNode.TryGetField("id", out strId))
			{
				Id = Guid.Parse(strId);
			}
			_strName = objNode["name"].InnerText;
			_strSkillGroup = objNode["skillgroup"].InnerText;
			_strSkillCategory = objNode["skillcategory"].InnerText;
			_blnIsGrouped = Convert.ToBoolean(objNode["grouped"].InnerText);
            _blnDefault = Convert.ToBoolean(objNode["default"].InnerText);
			_intRating = Convert.ToInt32(objNode["rating"].InnerText);
			bool basefail = false;
            try
            {
                _intBase = Convert.ToInt32(objNode["base"].InnerText);
            }
            catch
            {
                _intBase = _intRating;
	            basefail = true;
            }
            try
            {
                _intKarma = Convert.ToInt32(objNode["karma"].InnerText);
            }
            catch
            {
                _intKarma = 0;
            }

			if (!basefail)
			{
				if (_intRating != _intKarma + _intBase)
				{
					_intBase = _intRating - _intKarma;
				}
			}

            _intFreeLevels = Convert.ToInt32(objNode["freelevels"].InnerText);
            _intRatingMaximum = Convert.ToInt32(objNode["ratingmax"].InnerText);
			_blnKnowledgeSkill = Convert.ToBoolean(objNode["knowledge"].InnerText);
			try
			{
				_blnExoticSkill = Convert.ToBoolean(objNode["exotic"].InnerText);
			}
			catch
			{
			}
            try
            {
                _blnBuyWithKarma = Convert.ToBoolean(objNode["buywithkarma"].InnerText);
            }
            catch
            {
            }
            if (objNode["spec"].InnerText.Contains("Hold-Outs"))
				objNode["spec"].InnerText = "Holdouts";
			_strSkillSpec = objNode["spec"].InnerText;

            if (_strSkillSpec != "")
            {
                SkillSpecialization objSpec = new SkillSpecialization(_strSkillSpec);
                _lstSpecializations.Add(objSpec);
                _strSkillSpec = "";
            }

			_blnAllowDelete = Convert.ToBoolean(objNode["allowdelete"].InnerText);
			_strAttribute = objNode["attribute"].InnerText;
            if (objNode.InnerXml.Contains("skillspecializations"))
            {
                XmlNodeList nodSpecializations = objNode.SelectNodes("skillspecializations/skillspecialization");
                foreach (XmlNode nodSpecialization in nodSpecializations)
                {
                    SkillSpecialization objSpec = new SkillSpecialization("");
                    objSpec.Load(nodSpecialization);
                    _lstSpecializations.Add(objSpec);
                }
            }
            try
			{
				_strSource = objNode["source"].InnerText;
				_strPage = objNode["page"].InnerText;
			}
			catch
			{
			}

			if (objNode["folded"] != null)
			{
				foreach (XmlNode foldNode in objNode["folded"].ChildNodes)
				{
					Skill s = new Skill(_objCharacter);
					s.Load(foldNode);

					_fold.Add(s);
				}
			}
		}
示例#17
0
        /// Create a Lifestyle from an XmlNode and return the TreeNodes for it.
        /// <param name="objXmlLifestyle">XmlNode to create the object from.</param>
        /// <param name="objNode">TreeNode to populate a TreeView.</param>
        public void Create(XmlNode objXmlLifestyle, TreeNode objNode)
        {
            _strName = objXmlLifestyle["name"].InnerText;
            _intCost = Convert.ToInt32(objXmlLifestyle["cost"].InnerText);
            _intDice = Convert.ToInt32(objXmlLifestyle["dice"].InnerText);
            _intMultiplier = Convert.ToInt32(objXmlLifestyle["multiplier"].InnerText);
            _strSource = objXmlLifestyle["source"].InnerText;
            _strPage = objXmlLifestyle["page"].InnerText;
            if (!objXmlLifestyle.TryGetField<Guid>("id", Guid.TryParse, out _sourceID))
            {
                Log.Warning(new object[] { "Missing id field for lifestyle xmlnode", objXmlLifestyle});

                if (System.Diagnostics.Debugger.IsAttached)
                    System.Diagnostics.Debugger.Break();
            }

            objNode.Text = DisplayName;
            objNode.Tag = _guiID;
        }
示例#18
0
        /// <summary>
        /// Load the CharacterAttribute from the XmlNode.
        /// </summary>
        /// <param name="objNode">XmlNode to load.</param>
        public void Load(XmlNode objNode, bool blnCopy = false)
        {
            //Can't out property and no backing field
            Guid source;
            if (objNode.TryGetField<Guid>("sourceid", Guid.TryParse, out source))
            {
                SourceID = source;
            }

            objNode.TryGetField<Guid>("guid", Guid.TryParse, out _guiID);

            //If not present something gone totaly wrong, throw something
            if
                (
                !objNode.TryGetField("name", out _strName) ||
                !objNode.TryGetField("cost", out _intCost) ||
                !objNode.TryGetField("dice", out _intDice) ||
                !objNode.TryGetField("multiplier", out _intMultiplier) ||
                !objNode.TryGetField("months", out _intMonths)
                )
            {
                throw new ArgumentNullException("One or more of name, cost, dice, multiplier or months is missing");
            }

            objNode.TryGetField("area", out _intArea);
            objNode.TryGetField("security", out _intSecurity);
            objNode.TryGetField("comforts", out _intComforts);
            objNode.TryGetField("roommates", out _intRoommates);
            objNode.TryGetField("percentage", out _intPercentage);
            objNode.TryGetField("lifestylename", out _strLifestyleName);
            if (!objNode.TryGetField("purchased", out _blnPurchased))
            {
                throw new ArgumentNullException("purchased");
            }

            if (objNode.TryGetField("baselifestyle", out _strBaseLifestyle))
            {
                if (_strBaseLifestyle == "Middle")
                    _strBaseLifestyle = "Medium";
            }

            if (!objNode.TryGetField("source", out _strSource))
            {
                throw new ArgumentNullException("source");
            }
            objNode.TryGetField("trustfund", out _blnTrustFund);
            objNode.TryGetField("page", out _strPage);

            // Lifestyle Qualities
            XmlNodeList objXmlNodeList = objNode.SelectNodes("lifestylequalities/lifestylequality");
            foreach (XmlNode objXmlQuality in objXmlNodeList)
            {
                LifestyleQuality objQuality = new LifestyleQuality(_objCharacter);
                objQuality.Load(objXmlQuality);
                _lstLifestyleQualities.Add(objQuality);
            }

            // Free Grids provided by the Lifestyle
            objXmlNodeList = objNode.SelectNodes("freegrids/lifestylequality");
            foreach (XmlNode objXmlQuality in objXmlNodeList)
            {
                LifestyleQuality objQuality = new LifestyleQuality(_objCharacter);
                objQuality.Load(objXmlQuality);
                _lstLifestyleQualities.Add(objQuality);
            }

            objNode.TryGetField("notes", out _strNotes);

            String strtemp;
            if (objNode.TryGetField("type", out strtemp))
            {
                _objType = ConverToLifestyleType(strtemp);
            }

            try
            {
                _strNotes = objNode["notes"].InnerText;
            }
            catch
            {
            }

            try
            {
                _objType = ConverToLifestyleType(objNode["type"].InnerText);
            }
            catch
            {
            }

            if (blnCopy)
            {
                _guiID = Guid.NewGuid();
                _intMonths = 0;
            }
        }
示例#19
0
        /// Create a Commlink from an XmlNode and return the TreeNodes for it.
        /// <param name="objXmlGear">XmlNode to create the object from.</param>
        /// <param name="objCharacter">Character the Gear is being added to.</param>
        /// <param name="objNode">TreeNode to populate a TreeView.</param>
        /// <param name="intRating">Gear Rating.</param>
        /// <param name="blnAddImprovements">Whether or not Improvements should be added to the character.</param>
        /// <param name="blnCreateChildren">Whether or not child Gear should be created.</param>
        public void Create(XmlNode objXmlGear, Character objCharacter, TreeNode objNode, int intRating, bool blnAddImprovements = true, bool blnCreateChildren = true)
        {
            _strName = objXmlGear["name"].InnerText;
            _strCategory = objXmlGear["category"].InnerText;
            _strAvail = objXmlGear["avail"].InnerText;
            objXmlGear.TryGetField("cost", out _strCost);
            objXmlGear.TryGetField("cost3", out _strCost3, "");
            objXmlGear.TryGetField("cost6", out _strCost6, "");
            objXmlGear.TryGetField("cost10", out _strCost10, "");
            objXmlGear.TryGetField("armorcapacity", out _strArmorCapacity);
            _nodBonus = objXmlGear["bonus"];
            _intMaxRating = Convert.ToInt32(objXmlGear["rating"].InnerText);
            _intRating = intRating;
            _strSource = objXmlGear["source"].InnerText;
            _strPage = objXmlGear["page"].InnerText;
            _intDeviceRating = Convert.ToInt32(objXmlGear["devicerating"].InnerText);

            _intAttack = Convert.ToInt32(objXmlGear["attack"].InnerText);
            _intSleaze= Convert.ToInt32(objXmlGear["sleaze"].InnerText);
            _intDataProcessing = Convert.ToInt32(objXmlGear["dataprocessing"].InnerText);
            _intFirewall = Convert.ToInt32(objXmlGear["firewall"].InnerText);

            if (GlobalOptions.Instance.Language != "en-us")
            {
                XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
                XmlNode objGearNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + _strName + "\"]");
                if (objGearNode != null)
                {
                    if (objGearNode["translate"] != null)
                        _strAltName = objGearNode["translate"].InnerText;
                    if (objGearNode["altpage"] != null)
                        _strAltPage = objGearNode["altpage"].InnerText;
                }

                if (_strAltName.StartsWith("Stacked Focus"))
                    _strAltName = _strAltName.Replace("Stacked Focus", LanguageManager.Instance.GetString("String_StackedFocus"));

                objGearNode = objXmlDocument.SelectSingleNode("/chummer/categories/category[. = \"" + _strCategory + "\"]");
                if (objGearNode != null)
                {
                    if (objGearNode.Attributes["translate"] != null)
                        _strAltCategory = objGearNode.Attributes["translate"].InnerText;
                }

                if (_strAltCategory.StartsWith("Stacked Focus"))
                    _strAltCategory = _strAltCategory.Replace("Stacked Focus", LanguageManager.Instance.GetString("String_StackedFocus"));
            }

            string strSource = _guiID.ToString();

            objNode.Text = DisplayNameShort;
            objNode.Tag = _guiID.ToString();

            // If the item grants a bonus, pass the information to the Improvement Manager.
            if (objXmlGear["bonus"] != null)
            {
                ImprovementManager objImprovementManager;
                if (blnAddImprovements)
                    objImprovementManager = new ImprovementManager(objCharacter);
                else
                    objImprovementManager = new ImprovementManager(null);

                if (!objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Gear, strSource, objXmlGear["bonus"], false, 1, DisplayNameShort))
                {
                    _guiID = Guid.Empty;
                    return;
                }
                if (objImprovementManager.SelectedValue != "")
                {
                    _strExtra = objImprovementManager.SelectedValue;
                    objNode.Text += " (" + objImprovementManager.SelectedValue + ")";
                }
            }

            // Check to see if there are any child elements.
            if (objXmlGear.InnerXml.Contains("<gears>") && blnCreateChildren)
            {
                // Create Gear using whatever information we're given.
                foreach (XmlNode objXmlChild in objXmlGear.SelectNodes("gears/gear"))
                {
                    Gear objChild = new Gear(_objCharacter);
                    TreeNode objChildNode = new TreeNode();
                    objChild.Name = objXmlChild["name"].InnerText;
                    objChild.Category = objXmlChild["category"].InnerText;
                    objChild.Avail = "0";
                    objChild.Cost = "0";
                    objChild.Source = _strSource;
                    objChild.Page = _strPage;
                    objChild.Parent = this;
                    _objChildren.Add(objChild);

                    objChildNode.Text = objChild.DisplayName;
                    objChildNode.Tag = objChild.InternalId;
                    objNode.Nodes.Add(objChildNode);
                    objNode.Expand();
                }

                XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml");
                CreateChildren(objXmlGearDocument, objXmlGear, this, objNode, objCharacter, blnCreateChildren);
            }

            // Add the Copy Protection and Registration plugins to the Matrix program. This does not apply if Unwired is not enabled, Hacked is selected, or this is a Suite being added (individual programs will add it to themselves).
            if (blnCreateChildren)
            {
                if ((_strCategory == "Matrix Programs" || _strCategory == "Skillsofts" || _strCategory == "Autosofts" || _strCategory == "Autosofts, Agent" || _strCategory == "Autosofts, Drone") && objCharacter.Options.BookEnabled("UN") && !_strName.StartsWith("Suite:"))
                {
                    XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");

                    if (_objCharacter.Options.AutomaticCopyProtection)
                    {
                        Gear objPlugin1 = new Gear(_objCharacter);
                        TreeNode objPlugin1Node = new TreeNode();
                        objPlugin1.Create(objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Copy Protection\"]"), objCharacter, objPlugin1Node, _intRating, null, null);
                        if (_intRating == 0)
                            objPlugin1.Rating = 1;
                        objPlugin1.Avail = "0";
                        objPlugin1.Cost = "0";
                        objPlugin1.Cost3 = "0";
                        objPlugin1.Cost6 = "0";
                        objPlugin1.Cost10 = "0";
                        objPlugin1.Capacity = "[0]";
                        objPlugin1.Parent = this;
                        _objChildren.Add(objPlugin1);
                        objNode.Nodes.Add(objPlugin1Node);
                    }

                    if (_objCharacter.Options.AutomaticRegistration)
                    {
                        Gear objPlugin2 = new Gear(_objCharacter);
                        TreeNode objPlugin2Node = new TreeNode();
                        objPlugin2.Create(objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Registration\"]"), objCharacter, objPlugin2Node, 0, null, null);
                        objPlugin2.Avail = "0";
                        objPlugin2.Cost = "0";
                        objPlugin2.Cost3 = "0";
                        objPlugin2.Cost6 = "0";
                        objPlugin2.Cost10 = "0";
                        objPlugin2.Capacity = "[0]";
                        objPlugin2.Parent = this;
                        _objChildren.Add(objPlugin2);
                        objNode.Nodes.Add(objPlugin2Node);
                        objNode.Expand();
                    }

                    if ((objCharacter.Metatype == "A.I." || objCharacter.MetatypeCategory == "Technocritters" || objCharacter.MetatypeCategory == "Protosapients"))
                    {
                        Gear objPlugin3 = new Gear(_objCharacter);
                        TreeNode objPlugin3Node = new TreeNode();
                        objPlugin3.Create(objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Ergonomic\"]"), objCharacter, objPlugin3Node, 0, null, null);
                        objPlugin3.Avail = "0";
                        objPlugin3.Cost = "0";
                        objPlugin3.Cost3 = "0";
                        objPlugin3.Cost6 = "0";
                        objPlugin3.Cost10 = "0";
                        objPlugin3.Capacity = "[0]";
                        objPlugin3.Parent = this;
                        _objChildren.Add(objPlugin3);
                        objNode.Nodes.Add(objPlugin3Node);

                        Gear objPlugin4 = new Gear(_objCharacter);
                        TreeNode objPlugin4Node = new TreeNode();
                        objPlugin4.Create(objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Optimization\" and category = \"Program Options\"]"), objCharacter, objPlugin4Node, _intRating, null, null);
                        if (_intRating == 0)
                            objPlugin4.Rating = 1;
                        objPlugin4.Avail = "0";
                        objPlugin4.Cost = "0";
                        objPlugin4.Cost3 = "0";
                        objPlugin4.Cost6 = "0";
                        objPlugin4.Cost10 = "0";
                        objPlugin4.Capacity = "[0]";
                        objPlugin4.Parent = this;
                        _objChildren.Add(objPlugin4);
                        objNode.Nodes.Add(objPlugin4Node);
                        objNode.Expand();
                    }
                }
            }
        }
示例#20
0
        private bool ProcessBonus(Improvement.ImprovementSource objImprovementSource, ref string strSourceName,
			bool blnConcatSelectedValue,
			int intRating, string strFriendlyName, XmlNode bonusNode, string strUnique)
        {
            Log.Info("Has Child Nodes");
            // Add an Attribute.
            if (bonusNode.LocalName == ("addattribute"))
            {
                Log.Info("addattribute");
                if (bonusNode["name"].InnerText == "MAG")
                {
                    _objCharacter.MAGEnabled = true;
                    Log.Info("Calling CreateImprovement for MAG");
                    CreateImprovement("MAG", objImprovementSource, strSourceName, Improvement.ImprovementType.Attribute,
                        "enableattribute", 0, 0);
                }
                else if (bonusNode["name"].InnerText == "RES")
                {
                    _objCharacter.RESEnabled = true;
                    Log.Info("Calling CreateImprovement for RES");
                    CreateImprovement("RES", objImprovementSource, strSourceName, Improvement.ImprovementType.Attribute,
                        "enableattribute", 0, 0);
                }
            }

            // Enable a special tab.
            if (bonusNode.LocalName == ("enabletab"))
            {
                Log.Info("enabletab");
                foreach (XmlNode objXmlEnable in bonusNode.ChildNodes)
                {
                    switch (objXmlEnable.InnerText)
                    {
                        case "magician":
                            _objCharacter.MagicianEnabled = true;
                            Log.Info("magician");
                            CreateImprovement("Magician", objImprovementSource, strSourceName, Improvement.ImprovementType.SpecialTab,
                                "enabletab", 0, 0);
                            break;
                        case "adept":
                            _objCharacter.AdeptEnabled = true;
                            Log.Info("adept");
                            CreateImprovement("Adept", objImprovementSource, strSourceName, Improvement.ImprovementType.SpecialTab,
                                "enabletab",
                                0, 0);
                            break;
                        case "technomancer":
                            _objCharacter.TechnomancerEnabled = true;
                            Log.Info("technomancer");
                            CreateImprovement("Technomancer", objImprovementSource, strSourceName, Improvement.ImprovementType.SpecialTab,
                                "enabletab", 0, 0);
                            break;
                        case "critter":
                            _objCharacter.CritterEnabled = true;
                            Log.Info("critter");
                            CreateImprovement("Critter", objImprovementSource, strSourceName, Improvement.ImprovementType.SpecialTab,
                                "enabletab", 0, 0);
                            break;
                        case "initiation":
                            _objCharacter.InitiationEnabled = true;
                            Log.Info("initiation");
                            CreateImprovement("Initiation", objImprovementSource, strSourceName, Improvement.ImprovementType.SpecialTab,
                                "enabletab", 0, 0);
                            break;
                    }
                }
            }

            // Select Restricted (select Restricted items for Fake Licenses).
            if (bonusNode.LocalName == ("selectrestricted"))
            {
                Log.Info("selectrestricted");
                frmSelectItem frmPickItem = new frmSelectItem();
                frmPickItem.Character = _objCharacter;
                if (_strForcedValue != string.Empty)
                    frmPickItem.ForceItem = _strForcedValue;
                frmPickItem.AllowAutoSelect = false;
                frmPickItem.ShowDialog();

                // Make sure the dialogue window was not canceled.
                if (frmPickItem.DialogResult == DialogResult.Cancel)
                {
                    Rollback();
                    _strForcedValue = "";
                    _strLimitSelection = "";
                    return false;
                }

                _strSelectedValue = frmPickItem.SelectedItem;
                if (blnConcatSelectedValue)
                    strSourceName += " (" + _strSelectedValue + ")";

                Log.Info("_strSelectedValue = " + _strSelectedValue);
                Log.Info("strSourceName = " + strSourceName);

                // Create the Improvement.
                Log.Info("Calling CreateImprovement");
                CreateImprovement(frmPickItem.SelectedItem, objImprovementSource, strSourceName,
                    Improvement.ImprovementType.Restricted, strUnique);
            }

            if (bonusNode.LocalName == "cyberseeker")
            {
                //Check if valid attrib
                if (new string[] {"BOD", "AGI", "STR", "REA", "LOG", "CHA", "INT", "WIL", "BOX"}.Any(x => x == bonusNode.InnerText))
                {
                    CreateImprovement(bonusNode.InnerText, objImprovementSource, strSourceName, Improvement.ImprovementType.Seeker, strUnique,0,0,0,0,0,0);

                }
                else
                {
                    Utils.BreakIfDebug();
                }

            }

            // Select a Skill.
            if (bonusNode.LocalName == ("selectskill"))
            {
                //TODO this don't work
                Log.Info("selectskill");
                if (_strForcedValue == "+2 to a Combat Skill")
                    _strForcedValue = "";

                Log.Info("_strSelectedValue = " + _strSelectedValue);
                Log.Info("_strForcedValue = " + _strForcedValue);

                // Display the Select Skill window and record which Skill was selected.
                frmSelectSkill frmPickSkill = new frmSelectSkill(_objCharacter);
                if (strFriendlyName != "")
                    frmPickSkill.Description = LanguageManager.Instance.GetString("String_Improvement_SelectSkillNamed")
                        .Replace("{0}", strFriendlyName);
                else
                    frmPickSkill.Description = LanguageManager.Instance.GetString("String_Improvement_SelectSkill");

                Log.Info("selectskill = " + bonusNode.OuterXml.ToString());
                if (bonusNode.OuterXml.Contains("skillgroup"))
                    frmPickSkill.OnlySkillGroup = bonusNode.Attributes["skillgroup"].InnerText;
                else if (bonusNode.OuterXml.Contains("skillcategory"))
                    frmPickSkill.OnlyCategory = bonusNode.Attributes["skillcategory"].InnerText;
                else if (bonusNode.OuterXml.Contains("excludecategory"))
                    frmPickSkill.ExcludeCategory = bonusNode.Attributes["excludecategory"].InnerText;
                else if (bonusNode.OuterXml.Contains("limittoskill"))
                    frmPickSkill.LimitToSkill = bonusNode.Attributes["limittoskill"].InnerText;
                else if (bonusNode.OuterXml.Contains("limittoattribute"))
                    frmPickSkill.LinkedAttribute = bonusNode.Attributes["limittoattribute"].InnerText;

                if (_strForcedValue != "")
                {
                    frmPickSkill.OnlySkill = _strForcedValue;
                    frmPickSkill.Opacity = 0;
                }
                frmPickSkill.ShowDialog();

                // Make sure the dialogue window was not canceled.
                if (frmPickSkill.DialogResult == DialogResult.Cancel)
                {
                    Rollback();
                    _strForcedValue = "";
                    _strLimitSelection = "";
                    return false;
                }

                bool blnAddToRating = false;
                if (bonusNode["applytorating"] != null)
                {
                    if (bonusNode["applytorating"].InnerText == "yes")
                        blnAddToRating = true;
                }

                _strSelectedValue = frmPickSkill.SelectedSkill;
                if (blnConcatSelectedValue)
                    strSourceName += " (" + _strSelectedValue + ")";

                Log.Info("_strSelectedValue = " + _strSelectedValue);
                Log.Info("strSourceName = " + strSourceName);

                // Find the selected Skill.
                foreach (Skill objSkill in _objCharacter.SkillsSection.Skills)
                {
                    if (frmPickSkill.SelectedSkill.Contains("Exotic Melee Weapon") ||
                        frmPickSkill.SelectedSkill.Contains("Exotic Ranged Weapon") ||
                        frmPickSkill.SelectedSkill.Contains("Pilot Exotic Vehicle"))
                    {
                        if (objSkill.Name + " (" + objSkill.Specialization + ")" == frmPickSkill.SelectedSkill)
                        {
                            // We've found the selected Skill.
                            if (bonusNode.InnerXml.Contains("val"))
                            {
                                Log.Info("Calling CreateImprovement");
                                CreateImprovement(objSkill.Name + " (" + objSkill.Specialization + ")", objImprovementSource, strSourceName,
                                    Improvement.ImprovementType.Skill, strUnique, ValueToInt(bonusNode["val"].InnerText, intRating), 1,
                                    0, 0, 0, 0, "", blnAddToRating);
                            }

                            if (bonusNode.InnerXml.Contains("max"))
                            {
                                Log.Info("Calling CreateImprovement");
                                CreateImprovement(objSkill.Name + " (" + objSkill.Specialization + ")", objImprovementSource, strSourceName,
                                    Improvement.ImprovementType.Skill, strUnique, 0, 1, 0,
                                    ValueToInt(bonusNode["max"].InnerText, intRating), 0, 0, "", blnAddToRating);
                            }
                        }
                    }
                    else
                    {
                        if (objSkill.Name == frmPickSkill.SelectedSkill)
                        {
                            // We've found the selected Skill.
                            if (bonusNode.InnerXml.Contains("val"))
                            {
                                Log.Info("Calling CreateImprovement");
                                CreateImprovement(objSkill.Name, objImprovementSource, strSourceName, Improvement.ImprovementType.Skill,
                                    strUnique,
                                    ValueToInt(bonusNode["val"].InnerText, intRating), 1, 0, 0, 0, 0, "", blnAddToRating);
                            }

                            if (bonusNode.InnerXml.Contains("max"))
                            {
                                Log.Info("Calling CreateImprovement");
                                CreateImprovement(objSkill.Name, objImprovementSource, strSourceName, Improvement.ImprovementType.Skill,
                                    strUnique,
                                    0, 1, 0, ValueToInt(bonusNode["max"].InnerText, intRating), 0, 0, "", blnAddToRating);
                            }
                        }
                    }
                }
            }

            // Select a Skill Group.
            if (bonusNode.LocalName == ("selectskillgroup"))
            {
                Log.Info("selectskillgroup");
                string strExclude = "";
                if (bonusNode.Attributes["excludecategory"] != null)
                    strExclude = bonusNode.Attributes["excludecategory"].InnerText;

                frmSelectSkillGroup frmPickSkillGroup = new frmSelectSkillGroup();
                if (strFriendlyName != "")
                    frmPickSkillGroup.Description =
                        LanguageManager.Instance.GetString("String_Improvement_SelectSkillGroupName").Replace("{0}", strFriendlyName);
                else
                    frmPickSkillGroup.Description = LanguageManager.Instance.GetString("String_Improvement_SelectSkillGroup");

                Log.Info("_strForcedValue = " + _strForcedValue);
                Log.Info("_strLimitSelection = " + _strLimitSelection);

                if (_strForcedValue != "")
                {
                    frmPickSkillGroup.OnlyGroup = _strForcedValue;
                    frmPickSkillGroup.Opacity = 0;
                }

                if (strExclude != string.Empty)
                    frmPickSkillGroup.ExcludeCategory = strExclude;

                frmPickSkillGroup.ShowDialog();

                // Make sure the dialogue window was not canceled.
                if (frmPickSkillGroup.DialogResult == DialogResult.Cancel)
                {
                    Rollback();

                    _strForcedValue = "";
                    _strLimitSelection = "";
                    return false;
                }

                bool blnAddToRating = false;
                if (bonusNode["applytorating"] != null)
                {
                    if (bonusNode["applytorating"].InnerText == "yes")
                        blnAddToRating = true;
                }

                _strSelectedValue = frmPickSkillGroup.SelectedSkillGroup;

                Log.Info("_strSelectedValue = " + _strSelectedValue);
                Log.Info("strSourceName = " + strSourceName);

                if (bonusNode.SelectSingleNode("bonus") != null)
                {
                    Log.Info("Calling CreateImprovement");
                    CreateImprovement(_strSelectedValue, objImprovementSource, strSourceName, Improvement.ImprovementType.SkillGroup,
                        strUnique, ValueToInt(bonusNode["bonus"].InnerText, intRating), 1, 0, 0, 0, 0, strExclude,
                        blnAddToRating);
                }
                else
                {
                    Log.Info("Calling CreateImprovement");
                    CreateImprovement(_strSelectedValue, objImprovementSource, strSourceName, Improvement.ImprovementType.SkillGroup,
                        strUnique, 0, 0, 0, 1, 0, 0, strExclude,
                        blnAddToRating);
                }
            }

            if (bonusNode.LocalName == ("selectattributes"))
            {
                foreach (XmlNode objXmlAttribute in bonusNode.SelectNodes("selectattribute"))
                {
                    Log.Info("selectattribute");
                    // Display the Select Attribute window and record which Skill was selected.
                    frmSelectAttribute frmPickAttribute = new frmSelectAttribute();
                    if (strFriendlyName != "")
                        frmPickAttribute.Description =
                            LanguageManager.Instance.GetString("String_Improvement_SelectAttributeNamed").Replace("{0}", strFriendlyName);
                    else
                        frmPickAttribute.Description = LanguageManager.Instance.GetString("String_Improvement_SelectAttribute");

                    // Add MAG and/or RES to the list of Attributes if they are enabled on the form.
                    if (_objCharacter.MAGEnabled)
                        frmPickAttribute.AddMAG();
                    if (_objCharacter.RESEnabled)
                        frmPickAttribute.AddRES();

                    Log.Info("selectattribute = " + bonusNode.OuterXml.ToString());

                    if (objXmlAttribute.InnerXml.Contains("<attribute>"))
                    {
                        List<string> strValue = new List<string>();
                        foreach (XmlNode objSubNode in objXmlAttribute.SelectNodes("attribute"))
                            strValue.Add(objSubNode.InnerText);
                        frmPickAttribute.LimitToList(strValue);
                    }

                    if (bonusNode.InnerXml.Contains("<excludeattribute>"))
                    {
                        List<string> strValue = new List<string>();
                        foreach (XmlNode objSubNode in objXmlAttribute.SelectNodes("excludeattribute"))
                            strValue.Add(objSubNode.InnerText);
                        frmPickAttribute.RemoveFromList(strValue);
                    }

                    // Check to see if there is only one possible selection because of _strLimitSelection.
                    if (_strForcedValue != "")
                        _strLimitSelection = _strForcedValue;

                    Log.Info("_strForcedValue = " + _strForcedValue);
                    Log.Info("_strLimitSelection = " + _strLimitSelection);

                    if (_strLimitSelection != "")
                    {
                        frmPickAttribute.SingleAttribute(_strLimitSelection);
                        frmPickAttribute.Opacity = 0;
                    }

                    frmPickAttribute.ShowDialog();

                    // Make sure the dialogue window was not canceled.
                    if (frmPickAttribute.DialogResult == DialogResult.Cancel)
                    {
                        Rollback();
                        _strForcedValue = "";
                        return false;
                    }

                    _strSelectedValue = frmPickAttribute.SelectedAttribute;
                    if (blnConcatSelectedValue)
                        strSourceName += " (" + _strSelectedValue + ")";

                    Log.Info("_strSelectedValue = " + _strSelectedValue);
                    Log.Info("strSourceName = " + strSourceName);

                    // Record the improvement.
                    int intMin = 0;
                    int intAug = 0;
                    int intMax = 0;
                    int intAugMax = 0;

                    // Extract the modifiers.
                    if (objXmlAttribute.InnerXml.Contains("min"))
                        intMin = Convert.ToInt32(objXmlAttribute["min"].InnerText);
                    if (objXmlAttribute.InnerXml.Contains("val"))
                        intAug = Convert.ToInt32(objXmlAttribute["val"].InnerText);
                    if (objXmlAttribute.InnerXml.Contains("max"))
                        intMax = Convert.ToInt32(objXmlAttribute["max"].InnerText);
                    if (objXmlAttribute.InnerXml.Contains("aug"))
                        intAugMax = Convert.ToInt32(objXmlAttribute["aug"].InnerText);

                    string strAttribute = frmPickAttribute.SelectedAttribute;

                    if (objXmlAttribute["affectbase"] != null)
                        strAttribute += "Base";

                    Log.Info("Calling CreateImprovement");
                    CreateImprovement(strAttribute, objImprovementSource, strSourceName, Improvement.ImprovementType.Attribute,
                        strUnique,
                        0, 1, intMin, intMax, intAug, intAugMax);
                }
            }

            // Select an CharacterAttribute.
            if (bonusNode.LocalName == ("selectattribute"))
            {
                Log.Info("selectattribute");
                // Display the Select Attribute window and record which Skill was selected.
                frmSelectAttribute frmPickAttribute = new frmSelectAttribute();
                if (strFriendlyName != "")
                    frmPickAttribute.Description =
                        LanguageManager.Instance.GetString("String_Improvement_SelectAttributeNamed").Replace("{0}", strFriendlyName);
                else
                    frmPickAttribute.Description = LanguageManager.Instance.GetString("String_Improvement_SelectAttribute");

                // Add MAG and/or RES to the list of Attributes if they are enabled on the form.
                if (_objCharacter.MAGEnabled)
                    frmPickAttribute.AddMAG();
                if (_objCharacter.RESEnabled)
                    frmPickAttribute.AddRES();

                Log.Info("selectattribute = " + bonusNode.OuterXml.ToString());

                if (bonusNode.InnerXml.Contains("<attribute>"))
                {
                    List<string> strValue = new List<string>();
                    foreach (XmlNode objXmlAttribute in bonusNode.SelectNodes("attribute"))
                        strValue.Add(objXmlAttribute.InnerText);
                    frmPickAttribute.LimitToList(strValue);
                }

                if (bonusNode.InnerXml.Contains("<excludeattribute>"))
                {
                    List<string> strValue = new List<string>();
                    foreach (XmlNode objXmlAttribute in bonusNode.SelectNodes("excludeattribute"))
                        strValue.Add(objXmlAttribute.InnerText);
                    frmPickAttribute.RemoveFromList(strValue);
                }

                // Check to see if there is only one possible selection because of _strLimitSelection.
                if (_strForcedValue != "")
                    _strLimitSelection = _strForcedValue;

                Log.Info("_strForcedValue = " + _strForcedValue);
                Log.Info("_strLimitSelection = " + _strLimitSelection);

                if (_strLimitSelection != "")
                {
                    frmPickAttribute.SingleAttribute(_strLimitSelection);
                    frmPickAttribute.Opacity = 0;
                }

                frmPickAttribute.ShowDialog();

                // Make sure the dialogue window was not canceled.
                if (frmPickAttribute.DialogResult == DialogResult.Cancel)
                {
                    Rollback();
                    _strForcedValue = "";
                    return false;
                }

                _strSelectedValue = frmPickAttribute.SelectedAttribute;
                if (blnConcatSelectedValue)
                    strSourceName += " (" + _strSelectedValue + ")";

                Log.Info("_strSelectedValue = " + _strSelectedValue);
                Log.Info("strSourceName = " + strSourceName);

                // Record the improvement.
                int intMin = 0;
                int intAug = 0;
                int intMax = 0;
                int intAugMax = 0;

                // Extract the modifiers.
                if (bonusNode.InnerXml.Contains("min"))
                    intMin = ValueToInt(bonusNode["min"].InnerXml, intRating);
                if (bonusNode.InnerXml.Contains("val"))
                    intAug = ValueToInt(bonusNode["val"].InnerXml, intRating);
                if (bonusNode.InnerXml.Contains("max"))
                    intMax = ValueToInt(bonusNode["max"].InnerXml, intRating);
                if (bonusNode.InnerXml.Contains("aug"))
                    intAugMax = ValueToInt(bonusNode["aug"].InnerXml, intRating);

                string strAttribute = frmPickAttribute.SelectedAttribute;

                if (bonusNode["affectbase"] != null)
                    strAttribute += "Base";

                Log.Info("Calling CreateImprovement");
                CreateImprovement(strAttribute, objImprovementSource, strSourceName, Improvement.ImprovementType.Attribute,
                    strUnique,
                    0, 1, intMin, intMax, intAug, intAugMax);
            }

            // Select a Limit.
            if (bonusNode.LocalName == ("selectlimit"))
            {
                Log.Info("selectlimit");
                // Display the Select Limit window and record which Limit was selected.
                frmSelectLimit frmPickLimit = new frmSelectLimit();
                if (strFriendlyName != "")
                    frmPickLimit.Description = LanguageManager.Instance.GetString("String_Improvement_SelectLimitNamed")
                        .Replace("{0}", strFriendlyName);
                else
                    frmPickLimit.Description = LanguageManager.Instance.GetString("String_Improvement_SelectLimit");

                Log.Info("selectlimit = " + bonusNode.OuterXml.ToString());

                if (bonusNode.InnerXml.Contains("<limit>"))
                {
                    List<string> strValue = new List<string>();
                    foreach (XmlNode objXmlAttribute in bonusNode.SelectNodes("limit"))
                        strValue.Add(objXmlAttribute.InnerText);
                    frmPickLimit.LimitToList(strValue);
                }

                if (bonusNode.InnerXml.Contains("<excludelimit>"))
                {
                    List<string> strValue = new List<string>();
                    foreach (XmlNode objXmlAttribute in bonusNode.SelectNodes("excludelimit"))
                        strValue.Add(objXmlAttribute.InnerText);
                    frmPickLimit.RemoveFromList(strValue);
                }

                // Check to see if there is only one possible selection because of _strLimitSelection.
                if (_strForcedValue != "")
                    _strLimitSelection = _strForcedValue;

                Log.Info("_strForcedValue = " + _strForcedValue);
                Log.Info("_strLimitSelection = " + _strLimitSelection);

                if (_strLimitSelection != "")
                {
                    frmPickLimit.SingleLimit(_strLimitSelection);
                    frmPickLimit.Opacity = 0;
                }

                frmPickLimit.ShowDialog();

                // Make sure the dialogue window was not canceled.
                if (frmPickLimit.DialogResult == DialogResult.Cancel)
                {
                    Rollback();
                    _strForcedValue = "";
                    return false;
                }

                _strSelectedValue = frmPickLimit.SelectedLimit;
                if (blnConcatSelectedValue)
                    strSourceName += " (" + _strSelectedValue + ")";

                // Record the improvement.
                int intMin = 0;
                int intAug = 0;
                int intMax = 0;
                int intAugMax = 0;

                // Extract the modifiers.
                if (bonusNode.InnerXml.Contains("min"))
                    intMin = ValueToInt(bonusNode["min"].InnerXml, intRating);
                if (bonusNode.InnerXml.Contains("val"))
                    intAug = ValueToInt(bonusNode["val"].InnerXml, intRating);
                if (bonusNode.InnerXml.Contains("max"))
                    intMax = ValueToInt(bonusNode["max"].InnerXml, intRating);
                if (bonusNode.InnerXml.Contains("aug"))
                    intAugMax = ValueToInt(bonusNode["aug"].InnerXml, intRating);

                string strLimit = frmPickLimit.SelectedLimit;

                if (bonusNode["affectbase"] != null)
                    strLimit += "Base";

                Log.Info("_strSelectedValue = " + _strSelectedValue);
                Log.Info("strSourceName = " + strSourceName);

                LimitModifier objLimitMod = new LimitModifier(_objCharacter);
                // string strBonus = bonusNode["value"].InnerText;
                int intBonus = intAug;
                string strName = strFriendlyName;
                TreeNode nodTemp = new TreeNode();
                Improvement.ImprovementType objType = Improvement.ImprovementType.PhysicalLimit;

                switch (strLimit)
                {
                    case "Mental":
                        {
                            objType = Improvement.ImprovementType.MentalLimit;
                            break;
                        }
                    case "Social":
                        {
                            objType = Improvement.ImprovementType.SocialLimit;
                            break;
                        }
                    default:
                        {
                            objType = Improvement.ImprovementType.PhysicalLimit;
                            break;
                        }
                }

                Log.Info("Calling CreateImprovement");
                CreateImprovement(strLimit, objImprovementSource, strSourceName, objType, strFriendlyName, intBonus, 0, intMin,
                    intMax,
                    intAug, intAugMax);
            }

            // Select an CharacterAttribute to use instead of the default on a skill.
            if (bonusNode.LocalName == ("swapskillattribute"))
            {
                Log.Info("swapskillattribute");
                // Display the Select Attribute window and record which Skill was selected.
                frmSelectAttribute frmPickAttribute = new frmSelectAttribute();
                if (strFriendlyName != "")
                    frmPickAttribute.Description =
                        LanguageManager.Instance.GetString("String_Improvement_SelectAttributeNamed").Replace("{0}", strFriendlyName);
                else
                    frmPickAttribute.Description = LanguageManager.Instance.GetString("String_Improvement_SelectAttribute");

                List<string> strValue = new List<string>();
                strValue.Add("LOG");
                strValue.Add("WIL");
                strValue.Add("INT");
                strValue.Add("CHA");
                strValue.Add("EDG");
                strValue.Add("MAG");
                strValue.Add("RES");
                frmPickAttribute.RemoveFromList(strValue);

                Log.Info("swapskillattribute = " + bonusNode.OuterXml.ToString());

                if (bonusNode.InnerXml.Contains("<attribute>"))
                {
                    List<string> strLimitValue = new List<string>();
                    foreach (XmlNode objXmlAttribute in bonusNode.SelectNodes("attribute"))
                        strLimitValue.Add(objXmlAttribute.InnerText);
                    frmPickAttribute.LimitToList(strLimitValue);
                }

                // Check to see if there is only one possible selection because of _strLimitSelection.
                if (_strForcedValue != "")
                    _strLimitSelection = _strForcedValue;

                Log.Info("_strForcedValue = " + _strForcedValue);
                Log.Info("_strLimitSelection = " + _strLimitSelection);

                if (_strLimitSelection != "")
                {
                    frmPickAttribute.SingleAttribute(_strLimitSelection);
                    frmPickAttribute.Opacity = 0;
                }

                frmPickAttribute.ShowDialog();

                // Make sure the dialogue window was not canceled.
                if (frmPickAttribute.DialogResult == DialogResult.Cancel)
                {
                    Rollback();
                    _strForcedValue = "";
                    _strLimitSelection = "";
                    return false;
                }

                _strSelectedValue = frmPickAttribute.SelectedAttribute;
                if (blnConcatSelectedValue)
                    strSourceName += " (" + _strSelectedValue + ")";

                Log.Info("_strSelectedValue = " + _strSelectedValue);
                Log.Info("strSourceName = " + strSourceName);

                Log.Info("Calling CreateImprovement");
                CreateImprovement(frmPickAttribute.SelectedAttribute, objImprovementSource, strSourceName,
                    Improvement.ImprovementType.SwapSkillAttribute, strUnique);
            }

            // Select a Spell.
            if (bonusNode.LocalName == ("selectspell"))
            {
                Log.Info("selectspell");
                // Display the Select Spell window.
                frmSelectSpell frmPickSpell = new frmSelectSpell(_objCharacter);

                if (bonusNode.Attributes["category"] != null)
                    frmPickSpell.LimitCategory = bonusNode.Attributes["category"].InnerText;

                Log.Info("selectspell = " + bonusNode.OuterXml.ToString());
                Log.Info("_strForcedValue = " + _strForcedValue);
                Log.Info("_strLimitSelection = " + _strLimitSelection);

                if (_strForcedValue != "")
                {
                    frmPickSpell.ForceSpellName = _strForcedValue;
                    frmPickSpell.Opacity = 0;
                }

                frmPickSpell.ShowDialog();

                // Make sure the dialogue window was not canceled.
                if (frmPickSpell.DialogResult == DialogResult.Cancel)
                {
                    Rollback();
                    _strForcedValue = "";
                    _strLimitSelection = "";
                    return false;
                }

                _strSelectedValue = frmPickSpell.SelectedSpell;
                if (blnConcatSelectedValue)
                    strSourceName += " (" + _strSelectedValue + ")";

                Log.Info("_strSelectedValue = " + _strSelectedValue);
                Log.Info("strSourceName = " + strSourceName);

                Log.Info("Calling CreateImprovement");
                CreateImprovement(frmPickSpell.SelectedSpell, objImprovementSource, strSourceName, Improvement.ImprovementType.Text,
                    strUnique);
            }

            // Select a Contact
            if (bonusNode.LocalName == ("selectcontact"))
            {
                Log.Info("selectcontact");
                XmlNode nodSelect = bonusNode;

                frmSelectItem frmSelect = new frmSelectItem();

                String strMode = NodeExists(nodSelect, "type")
                    ? nodSelect["type"].InnerText
                    : "all";

                List<Contact> selectedContactsList;
                if (strMode == "all")
                {
                    selectedContactsList = new List<Contact>(_objCharacter.Contacts);
                }
                else if (strMode == "group" || strMode == "nongroup")
                {
                    bool blnGroup = strMode == "group";

                    //Select any contact where IsGroup equals blnGroup
                    //and add to a list
                    selectedContactsList =
                        new List<Contact>(from contact in _objCharacter.Contacts
                            where contact.IsGroup == blnGroup
                            select contact);
                }
                else
                {
                    Rollback();
                    return false;
                }

                if (selectedContactsList.Count == 0)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_NoContactFound"),
                        LanguageManager.Instance.GetString("MessageTitle_NoContactFound"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Rollback();
                    return false;
                }

                int count = 0;
                //Black magic LINQ to cast content of list to another type
                List<ListItem> contacts = new List<ListItem>(from x in selectedContactsList
                    select new ListItem() {Name = x.Name, Value = (count++).ToString()});

                String strPrice = NodeExists(nodSelect, "cost")
                    ? nodSelect["cost"].InnerText
                    : "";

                frmSelect.GeneralItems = contacts;
                frmSelect.ShowDialog();

                int index = int.Parse(frmSelect.SelectedItem);
                if (frmSelect.DialogResult != DialogResult.Cancel)
                {
                    Contact selectedContact = selectedContactsList[index];

                    if (nodSelect["mademan"] != null)
                    {
                        selectedContact.MadeMan = true;
                        CreateImprovement(selectedContact.GUID, Improvement.ImprovementSource.Quality, strSourceName,
                            Improvement.ImprovementType.ContactMadeMan, selectedContact.GUID);
                    }

                    if (String.IsNullOrWhiteSpace(_strSelectedValue))
                    {
                        _strSelectedValue = selectedContact.Name;
                    }
                    else
                    {
                        _strSelectedValue += (", " + selectedContact.Name);
                    }
                }
                else
                {
                    Rollback();
                    return false;
                }
            }

            if (bonusNode.LocalName == "addcontact")
            {
                Log.Info("addcontact");

                int loyalty, connection;

                bonusNode.TryGetField("loyalty", out loyalty, 1);
                bonusNode.TryGetField("connection", out connection, 1);
                bool group = bonusNode["group"] != null;
                bool free = bonusNode["free"] != null;

                Contact contact = new Contact(_objCharacter);
                contact.Free = free;
                contact.IsGroup = group;
                contact.Loyalty = loyalty;
                contact.Connection = connection;
                contact.ReadOnly = true;
                _objCharacter.Contacts.Add(contact);

                CreateImprovement(contact.GUID, Improvement.ImprovementSource.Quality, strSourceName,
                            Improvement.ImprovementType.AddContact, contact.GUID);
            }

            // Affect a Specific CharacterAttribute.
            if (bonusNode.LocalName == ("specificattribute"))
            {
                Log.Info("specificattribute");

                if (bonusNode["name"].InnerText != "ESS")
                {
                    // Display the Select CharacterAttribute window and record which CharacterAttribute was selected.
                    // Record the improvement.
                    int intMin = 0;
                    int intAug = 0;
                    int intMax = 0;
                    int intAugMax = 0;

                    // Extract the modifiers.
                    if (bonusNode.InnerXml.Contains("min"))
                        intMin = ValueToInt(bonusNode["min"].InnerXml, intRating);
                    if (bonusNode.InnerXml.Contains("val"))
                        intAug = ValueToInt(bonusNode["val"].InnerXml, intRating);
                    if (bonusNode.InnerXml.Contains("max"))
                    {
                        if (bonusNode["max"].InnerText.Contains("-natural"))
                        {
                            intMax = Convert.ToInt32(bonusNode["max"].InnerText.Replace("-natural", string.Empty)) -
                                     _objCharacter.GetAttribute(bonusNode["name"].InnerText).MetatypeMaximum;
                        }
                        else
                            intMax = ValueToInt(bonusNode["max"].InnerXml, intRating);
                    }
                    if (bonusNode.InnerXml.Contains("aug"))
                        intAugMax = ValueToInt(bonusNode["aug"].InnerXml, intRating);

                    string strUseUnique = strUnique;
                    if (bonusNode["name"].Attributes["precedence"] != null)
                        strUseUnique = "precedence" + bonusNode["name"].Attributes["precedence"].InnerText;

                    string strAttribute = bonusNode["name"].InnerText;

                    if (bonusNode["affectbase"] != null)
                        strAttribute += "Base";

                    CreateImprovement(strAttribute, objImprovementSource, strSourceName, Improvement.ImprovementType.Attribute,
                        strUseUnique, 0, 1, intMin, intMax, intAug, intAugMax);
                }
                else
                {
                    CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Essence, "",
                        Convert.ToInt32(bonusNode["val"].InnerText));
                }
            }

            // Add a paid increase to an attribute
            if (bonusNode.LocalName == ("attributelevel"))
            {
                Log.Info(new object[] {"attributelevel", bonusNode.OuterXml});
                String strAttrib;
                int value;
                bonusNode.TryGetField("val", out value, 1);

                if (bonusNode.TryGetField("name", out strAttrib))
                {
                    CreateImprovement(strAttrib, objImprovementSource, strSourceName,
                        Improvement.ImprovementType.Attributelevel, "", value);
                }
                else
                {
                    Log.Error(new object[] {"attributelevel", bonusNode.OuterXml});
                }
            }

            if (bonusNode.LocalName == ("skilllevel"))
            {
                Log.Info(new object[] {"skilllevel", bonusNode.OuterXml});
                String strSkill;
                int value;
                bonusNode.TryGetField("val", out value, 1);
                if (bonusNode.TryGetField("name", out strSkill))
                {
                    CreateImprovement(strSkill, objImprovementSource, strSourceName,
                        Improvement.ImprovementType.SkillLevel, "", value);

                }
                else
                {
                    Log.Error(new object[] {"skilllevel", bonusNode.OuterXml});
                }
            }

            if (bonusNode.LocalName == "pushtext")
            {

                String push = bonusNode.InnerText;
                if (!String.IsNullOrWhiteSpace(push))
                {
                    _objCharacter.Pushtext.Push(push);
                }
            }

            if (bonusNode.LocalName == "knowsoft")
            {
                int val = bonusNode["val"] != null ? ValueToInt(bonusNode["val"].InnerText, intRating) : 1;

                string name;
                if (!string.IsNullOrWhiteSpace(_strForcedValue))
                {
                    name = _strForcedValue;
                }
                else if (bonusNode["pick"] != null)
                {
                    List<ListItem> types;
                    if (bonusNode["group"] != null)
                    {
                        var v = bonusNode.SelectNodes($"./group");
                        types =
                            KnowledgeSkill.KnowledgeTypes.Where(x => bonusNode.SelectNodes($"group[. = '{x.Value}']").Count > 0).ToList();

                    }
                    else if (bonusNode["notgroup"] != null)
                    {
                        types =
                            KnowledgeSkill.KnowledgeTypes.Where(x => bonusNode.SelectNodes($"notgroup[. = '{x.Value}']").Count == 0).ToList();
                    }
                    else
                    {
                        types = KnowledgeSkill.KnowledgeTypes;
                    }

                    frmSelectItem select = new frmSelectItem();
                    select.DropdownItems = KnowledgeSkill.KnowledgeSkillsWithCategory(types.Select(x => x.Value).ToArray());

                    select.ShowDialog();
                    if (select.DialogResult == DialogResult.Cancel)
                    {
                        return false;
                    }

                    name = select.SelectedItem;
                }
                else if (bonusNode["name"] != null)
                {
                    name = bonusNode["name"].InnerText;
                }
                else
                {
                    //TODO some kind of error handling
                    Log.Error(new[] {bonusNode.OuterXml, "Missing pick or name"});
                    return false;
                }
                _strSelectedValue = name;

                KnowledgeSkill skill = new KnowledgeSkill(_objCharacter, name);

                bool knowsoft = bonusNode.TryCheckValue("require", "skilljack");

                if (knowsoft)
                {
                    _objCharacter.SkillsSection.KnowsoftSkills.Add(skill);
                    if (_objCharacter.SkillsoftAccess)
                    {
                        _objCharacter.SkillsSection.KnowledgeSkills.Add(skill);
                    }
                }
                else
                {
                    _objCharacter.SkillsSection.KnowledgeSkills.Add(skill);
                }

                CreateImprovement(name, objImprovementSource, strSourceName, Improvement.ImprovementType.SkillBase, strUnique, val);
                CreateImprovement(skill.Id.ToString(), objImprovementSource, strSourceName,
                    Improvement.ImprovementType.SkillKnowledgeForced, strUnique);

            }

            if (bonusNode.LocalName == "knowledgeskilllevel")
            {
                //Theoretically life modules, right now we just give out free points and let people sort it out themselves.
                //Going to be fun to do the real way, from a computer science perspective, but i don't feel like using 2 weeks on that now

                int val = bonusNode["val"] != null ? ValueToInt(bonusNode["val"].InnerText, intRating) : 1;
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.FreeKnowledgeSkills, "", val);
            }

            if (bonusNode.LocalName == "knowledgeskillpoints")
            {
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.FreeKnowledgeSkills, "", ValueToInt(bonusNode.InnerText,Convert.ToInt32(bonusNode.Value)));
            }

            if (bonusNode.LocalName == ("skillgrouplevel"))
            {
                Log.Info(new object[] {"skillgrouplevel", bonusNode.OuterXml});
                String strSkillGroup;
                int value;
                if (bonusNode.TryGetField("name", out strSkillGroup) &&
                    bonusNode.TryGetField("val", out value))
                {
                    CreateImprovement(strSkillGroup, objImprovementSource, strSourceName,
                        Improvement.ImprovementType.SkillGroupLevel, "", value);
                }
                else
                {
                    Log.Error(new object[] {"skillgrouplevel", bonusNode.OuterXml});
                }
            }

            // Change the maximum number of BP that can be spent on Nuyen.
            if (bonusNode.LocalName == ("nuyenmaxbp"))
            {
                Log.Info("nuyenmaxbp");
                Log.Info("nuyenmaxbp = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.NuyenMaxBP, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Apply a bonus/penalty to physical limit.
            if (bonusNode.LocalName == ("physicallimit"))
            {
                Log.Info("physicallimit");
                Log.Info("physicallimit = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("Physical", objImprovementSource, strSourceName, Improvement.ImprovementType.PhysicalLimit, strFriendlyName,
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Apply a bonus/penalty to mental limit.
            if (bonusNode.LocalName == ("mentallimit"))
            {
                Log.Info("mentallimit");
                Log.Info("mentallimit = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("Mental", objImprovementSource, strSourceName, Improvement.ImprovementType.MentalLimit, strFriendlyName,
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Apply a bonus/penalty to social limit.
            if (bonusNode.LocalName == ("sociallimit"))
            {
                Log.Info("sociallimit");
                Log.Info("sociallimit = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("Social", objImprovementSource, strSourceName, Improvement.ImprovementType.SocialLimit, strFriendlyName,
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Change the amount of Nuyen the character has at creation time (this can put the character over the amount they're normally allowed).
            if (bonusNode.LocalName == ("nuyenamt"))
            {
                Log.Info("nuyenamt");
                Log.Info("nuyenamt = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Nuyen, strUnique,
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Improve Condition Monitors.
            if (bonusNode.LocalName == ("conditionmonitor"))
            {
                Log.Info("conditionmonitor");
                Log.Info("conditionmonitor = " + bonusNode.OuterXml.ToString());
                // Physical Condition.
                if (bonusNode.InnerXml.Contains("physical"))
                {
                    Log.Info("Calling CreateImprovement for Physical");
                    CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.PhysicalCM, strUnique,
                        ValueToInt(bonusNode["physical"].InnerText, intRating));
                }

                // Stun Condition.
                if (bonusNode.InnerXml.Contains("stun"))
                {
                    Log.Info("Calling CreateImprovement for Stun");
                    CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.StunCM, strUnique,
                        ValueToInt(bonusNode["stun"].InnerText, intRating));
                }

                // Condition Monitor Threshold.
                if (NodeExists(bonusNode, "threshold"))
                {
                    string strUseUnique = strUnique;
                    if (bonusNode["threshold"].Attributes["precedence"] != null)
                        strUseUnique = "precedence" + bonusNode["threshold"].Attributes["precedence"].InnerText;

                    Log.Info("Calling CreateImprovement for Threshold");
                    CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.CMThreshold, strUseUnique,
                        ValueToInt(bonusNode["threshold"].InnerText, intRating));
                }

                // Condition Monitor Threshold Offset. (Additioal boxes appear before the FIRST Condition Monitor penalty)
                if (NodeExists(bonusNode, "thresholdoffset"))
                {
                    string strUseUnique = strUnique;
                    if (bonusNode["thresholdoffset"].Attributes["precedence"] != null)
                        strUseUnique = "precedence" + bonusNode["thresholdoffset"].Attributes["precedence"].InnerText;

                    Log.Info("Calling CreateImprovement for Threshold Offset");
                    CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.CMThresholdOffset,
                        strUseUnique, ValueToInt(bonusNode["thresholdoffset"].InnerText, intRating));
                }

                // Condition Monitor Overflow.
                if (bonusNode.InnerXml.Contains("overflow"))
                {
                    Log.Info("Calling CreateImprovement for Overflow");
                    CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.CMOverflow, strUnique,
                        ValueToInt(bonusNode["overflow"].InnerText, intRating));
                }
            }

            // Improve Living Personal Attributes.
            if (bonusNode.LocalName == ("livingpersona"))
            {
                Log.Info("livingpersona");
                Log.Info("livingpersona = " + bonusNode.OuterXml.ToString());
                // Response.
                if (bonusNode.InnerXml.Contains("response"))
                {
                    Log.Info("Calling CreateImprovement for response");
                    CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.LivingPersonaResponse,
                        strUnique, ValueToInt(bonusNode["response"].InnerText, intRating));
                }

                // Signal.
                if (bonusNode.InnerXml.Contains("signal"))
                {
                    Log.Info("Calling CreateImprovement for signal");
                    CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.LivingPersonaSignal,
                        strUnique,
                        ValueToInt(bonusNode["signal"].InnerText, intRating));
                }

                // Firewall.
                if (bonusNode.InnerXml.Contains("firewall"))
                {
                    Log.Info("Calling CreateImprovement for firewall");
                    CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.LivingPersonaFirewall,
                        strUnique, ValueToInt(bonusNode["firewall"].InnerText, intRating));
                }

                // System.
                if (bonusNode.InnerXml.Contains("system"))
                {
                    Log.Info("Calling CreateImprovement for system");
                    CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.LivingPersonaSystem,
                        strUnique,
                        ValueToInt(bonusNode["system"].InnerText, intRating));
                }

                // Biofeedback Filter.
                if (bonusNode.InnerXml.Contains("biofeedback"))
                {
                    Log.Info("Calling CreateImprovement for biofeedback");
                    CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.LivingPersonaBiofeedback,
                        strUnique, ValueToInt(bonusNode["biofeedback"].InnerText, intRating));
                }
            }

            // The Improvement adjusts a specific Skill.
            if (bonusNode.LocalName == ("specificskill"))
            {
                Log.Info("specificskill");
                Log.Info("specificskill = " + bonusNode.OuterXml.ToString());
                bool blnAddToRating = false;
                if (bonusNode["applytorating"] != null)
                {
                    if (bonusNode["applytorating"].InnerText == "yes")
                        blnAddToRating = true;
                }

                string strUseUnique = strUnique;
                if (bonusNode.Attributes["precedence"] != null)
                    strUseUnique = "precedence" + bonusNode.Attributes["precedence"].InnerText;

                // Record the improvement.
                if (bonusNode["bonus"] != null)
                {
                    Log.Info("Calling CreateImprovement for bonus");
                    CreateImprovement(bonusNode["name"].InnerText, objImprovementSource, strSourceName,
                        Improvement.ImprovementType.Skill, strUseUnique, ValueToInt(bonusNode["bonus"].InnerXml, intRating), 1, 0, 0, 0,
                        0, "", blnAddToRating);
                }
                if (bonusNode["max"] != null)
                {
                    Log.Info("Calling CreateImprovement for max");
                    CreateImprovement(bonusNode["name"].InnerText, objImprovementSource, strSourceName,
                        Improvement.ImprovementType.Skill, strUseUnique, 0, 1, 0, ValueToInt(bonusNode["max"].InnerText, intRating), 0,
                        0,
                        "", blnAddToRating);
                }
            }

            if (bonusNode.LocalName == "reflexrecorderoptimization")
            {
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.ReflexRecorderOptimization, strUnique);
            }

            // The Improvement adds a martial art
            if (bonusNode.LocalName == ("martialart"))
            {
                Log.Info("martialart");
                Log.Info("martialart = " + bonusNode.OuterXml.ToString());
                XmlDocument _objXmlDocument = XmlManager.Instance.Load("martialarts.xml");
                XmlNode objXmlArt =
                    _objXmlDocument.SelectSingleNode("/chummer/martialarts/martialart[name = \"" + bonusNode.InnerText +
                                                     "\"]");

                TreeNode objNode = new TreeNode();
                MartialArt objMartialArt = new MartialArt(_objCharacter);
                objMartialArt.Create(objXmlArt, objNode, _objCharacter);
                objMartialArt.IsQuality = true;
                _objCharacter.MartialArts.Add(objMartialArt);
            }

            // The Improvement adds a limit modifier
            if (bonusNode.LocalName == ("limitmodifier"))
            {
                Log.Info("limitmodifier");
                Log.Info("limitmodifier = " + bonusNode.OuterXml.ToString());
                LimitModifier objLimitMod = new LimitModifier(_objCharacter);
                string strLimit = bonusNode["limit"].InnerText;
                string strBonus = bonusNode["value"].InnerText;
                if (strBonus == "Rating")
                {
                    strBonus = intRating.ToString();
                }
                string strCondition = "";
                try
                {
                    strCondition = bonusNode["condition"].InnerText;
                }
                catch
                {
                }
                int intBonus = 0;
                if (strBonus == "Rating")
                    intBonus = intRating;
                else
                    intBonus = Convert.ToInt32(strBonus);
                string strName = strFriendlyName;
                TreeNode nodTemp = new TreeNode();
                Log.Info("Calling CreateImprovement");
                CreateImprovement(strLimit, objImprovementSource, strSourceName, Improvement.ImprovementType.LimitModifier,
                    strFriendlyName, intBonus, 0, 0, 0, 0, 0, strCondition);
            }

            // The Improvement adjusts a Skill Category.
            if (bonusNode.LocalName == ("skillcategory"))
            {
                Log.Info("skillcategory");
                Log.Info("skillcategory = " + bonusNode.OuterXml.ToString());

                bool blnAddToRating = false;
                if (bonusNode["applytorating"] != null)
                {
                    if (bonusNode["applytorating"].InnerText == "yes")
                        blnAddToRating = true;
                }
                if (bonusNode.InnerXml.Contains("exclude"))
                {
                    Log.Info("Calling CreateImprovement - exclude");
                    CreateImprovement(bonusNode["name"].InnerText, objImprovementSource, strSourceName,
                        Improvement.ImprovementType.SkillCategory, strUnique, ValueToInt(bonusNode["bonus"].InnerXml, intRating), 1, 0,
                        0,
                        0, 0, bonusNode["exclude"].InnerText, blnAddToRating);
                }
                else
                {
                    Log.Info("Calling CreateImprovement");
                    CreateImprovement(bonusNode["name"].InnerText, objImprovementSource, strSourceName,
                        Improvement.ImprovementType.SkillCategory, strUnique, ValueToInt(bonusNode["bonus"].InnerXml, intRating), 1, 0,
                        0,
                        0, 0, "", blnAddToRating);
                }
            }

            // The Improvement adjusts a Skill Group.
            if (bonusNode.LocalName == ("skillgroup"))
            {
                Log.Info("skillgroup");
                Log.Info("skillgroup = " + bonusNode.OuterXml.ToString());

                bool blnAddToRating = false;
                if (bonusNode["applytorating"] != null)
                {
                    if (bonusNode["applytorating"].InnerText == "yes")
                        blnAddToRating = true;
                }
                if (bonusNode.InnerXml.Contains("exclude"))
                {
                    Log.Info("Calling CreateImprovement - exclude");
                    CreateImprovement(bonusNode["name"].InnerText, objImprovementSource, strSourceName,
                        Improvement.ImprovementType.SkillGroup, strUnique, ValueToInt(bonusNode["bonus"].InnerXml, intRating), 1, 0, 0, 0,
                        0, bonusNode["exclude"].InnerText, blnAddToRating);
                }
                else
                {
                    Log.Info("Calling CreateImprovement");
                    CreateImprovement(bonusNode["name"].InnerText, objImprovementSource, strSourceName,
                        Improvement.ImprovementType.SkillGroup, strUnique, ValueToInt(bonusNode["bonus"].InnerXml, intRating), 1, 0, 0, 0,
                        0, "", blnAddToRating);
                }
            }

            // The Improvement adjust Skills with the given CharacterAttribute.
            if (bonusNode.LocalName == ("skillattribute"))
            {
                Log.Info("skillattribute");
                Log.Info("skillattribute = " + bonusNode.OuterXml.ToString());

                string strUseUnique = strUnique;
                if (bonusNode["name"].Attributes["precedence"] != null)
                    strUseUnique = "precedence" + bonusNode["name"].Attributes["precedence"].InnerText;

                bool blnAddToRating = false;
                if (bonusNode["applytorating"] != null)
                {
                    if (bonusNode["applytorating"].InnerText == "yes")
                        blnAddToRating = true;
                }
                if (bonusNode.InnerXml.Contains("exclude"))
                {
                    Log.Info("Calling CreateImprovement - exclude");
                    CreateImprovement(bonusNode["name"].InnerText, objImprovementSource, strSourceName,
                        Improvement.ImprovementType.SkillAttribute, strUseUnique, ValueToInt(bonusNode["bonus"].InnerXml, intRating), 1,
                        0, 0, 0, 0, bonusNode["exclude"].InnerText, blnAddToRating);
                }
                else
                {
                    Log.Info("Calling CreateImprovement");
                    CreateImprovement(bonusNode["name"].InnerText, objImprovementSource, strSourceName,
                        Improvement.ImprovementType.SkillAttribute, strUseUnique, ValueToInt(bonusNode["bonus"].InnerXml, intRating), 1,
                        0, 0, 0, 0, "", blnAddToRating);
                }
            }

            // The Improvement comes from Enhanced Articulation (improves Physical Active Skills linked to a Physical CharacterAttribute).
            if (bonusNode.LocalName == ("skillarticulation"))
            {
                Log.Info("skillarticulation");
                Log.Info("skillarticulation = " + bonusNode.OuterXml.ToString());

                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.EnhancedArticulation,
                    strUnique,
                    ValueToInt(bonusNode["bonus"].InnerText, intRating));
            }

            // Check for Armor modifiers.
            if (bonusNode.LocalName == ("armor"))
            {
                Log.Info("armor");
                Log.Info("armor = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                string strUseUnique = strUnique;
                if (bonusNode.Attributes["precedence"] != null)
                {
                    strUseUnique = "precedence" + bonusNode.Attributes["precedence"].InnerText;
                }
                else if (bonusNode.Attributes["group"] != null)
                {
                    strUseUnique = "group" + bonusNode.Attributes["group"].InnerText;
                }
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Armor, strUseUnique,
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Reach modifiers.
            if (bonusNode.LocalName == ("reach"))
            {
                Log.Info("reach");
                Log.Info("reach = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Reach, strUnique,
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Unarmed Damage Value modifiers.
            if (bonusNode.LocalName == ("unarmeddv"))
            {
                Log.Info("unarmeddv");
                Log.Info("unarmeddv = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.UnarmedDV, strUnique,
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Unarmed Damage Value Physical.
            if (bonusNode.LocalName == ("unarmeddvphysical"))
            {
                Log.Info("unarmeddvphysical");
                Log.Info("unarmeddvphysical = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.UnarmedDVPhysical, "");
            }

            // Check for Unarmed Armor Penetration.
            if (bonusNode.LocalName == ("unarmedap"))
            {
                Log.Info("unarmedap");
                Log.Info("unarmedap = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.UnarmedAP, strUnique,
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Initiative modifiers.
            if (bonusNode.LocalName == ("initiative"))
            {
                Log.Info("initiative");
                Log.Info("initiative = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Initiative, strUnique,
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Initiative Pass modifiers. Only the highest one ever applies.
            if (bonusNode.LocalName == ("initiativepass"))
            {
                Log.Info("initiativepass");
                Log.Info("initiativepass = "******"Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.InitiativePass,
                    "initiativepass", ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Initiative Pass modifiers. Only the highest one ever applies.
            if (bonusNode.LocalName == ("initiativepassadd"))
            {
                Log.Info("initiativepassadd");
                Log.Info("initiativepassadd = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.InitiativePassAdd, strUnique,
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Matrix Initiative modifiers.
            if (bonusNode.LocalName == ("matrixinitiative"))
            {
                Log.Info("matrixinitiative");
                Log.Info("matrixinitiative = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.MatrixInitiative, strUnique,
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Matrix Initiative Pass modifiers.
            if (bonusNode.LocalName == ("matrixinitiativepass"))
            {
                Log.Info("matrixinitiativepass");
                Log.Info("matrixinitiativepass = "******"Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.MatrixInitiativePass,
                    "matrixinitiativepass", ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Matrix Initiative Pass modifiers.
            if (bonusNode.LocalName == ("matrixinitiativepassadd"))
            {
                Log.Info("matrixinitiativepassadd");
                Log.Info("matrixinitiativepassadd = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.MatrixInitiativePass,
                    strUnique,
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Lifestyle cost modifiers.
            if (bonusNode.LocalName == ("lifestylecost"))
            {
                Log.Info("lifestylecost");
                Log.Info("lifestylecost = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.LifestyleCost, strUnique,
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for basic Lifestyle cost modifiers.
            if (bonusNode.LocalName == ("basiclifestylecost"))
            {
                Log.Info("basiclifestylecost");
                Log.Info("basiclifestylecost = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.BasicLifestyleCost, strUnique,
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Genetech Cost modifiers.
            if (bonusNode.LocalName == ("genetechcostmultiplier"))
            {
                Log.Info("genetechcostmultiplier");
                Log.Info("genetechcostmultiplier = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.GenetechCostMultiplier,
                    strUnique, ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Genetech: Transgenics Cost modifiers.
            if (bonusNode.LocalName == ("transgenicsgenetechcost"))
            {
                Log.Info("transgenicsgenetechcost");
                Log.Info("transgenicsgenetechcost = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.TransgenicsBiowareCost,
                    strUnique, ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Basic Bioware Essence Cost modifiers.
            if (bonusNode.LocalName == ("basicbiowareessmultiplier"))
            {
                Log.Info("basicbiowareessmultiplier");
                Log.Info("basicbiowareessmultiplier = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.BasicBiowareEssCost,
                    strUnique,
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Bioware Essence Cost modifiers.
            if (bonusNode.LocalName == ("biowareessmultiplier"))
            {
                Log.Info("biowareessmultiplier");
                Log.Info("biowareessmultiplier = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.BiowareEssCost, strUnique,
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Cybeware Essence Cost modifiers.
            if (bonusNode.LocalName == ("cyberwareessmultiplier"))
            {
                Log.Info("cyberwareessmultiplier");
                Log.Info("cyberwareessmultiplier = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.CyberwareEssCost, strUnique,
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Uneducated modifiers.
            if (bonusNode.LocalName == ("uneducated"))
            {
                Log.Info("uneducated");
                Log.Info("uneducated = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Uneducated, strUnique);
                _objCharacter.SkillsSection.Uneducated = true;
            }

            // Check for College Education modifiers.
            if (bonusNode.LocalName == ("collegeeducation"))
            {
                Log.Info("collegeeducation");
                Log.Info("collegeeducation = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.CollegeEducation, strUnique);
                _objCharacter.SkillsSection.CollegeEducation = true;
            }

            // Check for Jack Of All Trades modifiers.
            if (bonusNode.LocalName == ("jackofalltrades"))
            {
                Log.Info("jackofalltrades");
                Log.Info("jackofalltrades = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.JackOfAllTrades, strUnique);
                _objCharacter.SkillsSection.JackOfAllTrades = true;
            }

            // Check for Prototype Transhuman modifiers.
            if (bonusNode.LocalName == ("prototypetranshuman"))
            {
                Log.Info("prototypetranshuman");
                Log.Info("prototypetranshuman = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");

                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.PrototypeTranshuman, strUnique);
                _objCharacter.PrototypeTranshuman = Convert.ToDecimal(bonusNode.InnerText);

            }
            // Check for Uncouth modifiers.
            if (bonusNode.LocalName == ("uncouth"))
            {
                Log.Info("uncouth");
                Log.Info("uncouth = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Uncouth, strUnique);
                _objCharacter.SkillsSection.Uncouth = true;
            }

            // Check for Friends In High Places modifiers.
            if (bonusNode.LocalName == ("friendsinhighplaces"))
            {
                Log.Info("friendsinhighplaces");
                Log.Info("friendsinhighplaces = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.FriendsInHighPlaces,
                    strUnique);
                _objCharacter.FriendsInHighPlaces = true;
            }
            // Check for School of Hard Knocks modifiers.
            if (bonusNode.LocalName == ("schoolofhardknocks"))
            {
                Log.Info("schoolofhardknocks");
                Log.Info("schoolofhardknocks = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.SchoolOfHardKnocks, strUnique);
                _objCharacter.SkillsSection.SchoolOfHardKnocks = true;
            }
            // Check for ExCon modifiers.
            if (bonusNode.LocalName == ("excon"))
            {
                Log.Info("ExCon");
                Log.Info("ExCon = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.ExCon, strUnique);
                _objCharacter.ExCon = true;
            }

            // Check for TrustFund modifiers.
            if (bonusNode.LocalName == ("trustfund"))
            {
                Log.Info("TrustFund");
                Log.Info("TrustFund = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.TrustFund,
                    strUnique,
                    ValueToInt(bonusNode.InnerText, intRating));
                _objCharacter.TrustFund = ValueToInt(bonusNode.InnerText, intRating);
            }

            // Check for Tech School modifiers.
            if (bonusNode.LocalName == ("techschool"))
            {
                Log.Info("techschool");
                Log.Info("techschool = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.TechSchool, strUnique);
                _objCharacter.SkillsSection.TechSchool = true;
            }
            // Check for MadeMan modifiers.
            if (bonusNode.LocalName == ("mademan"))
            {
                Log.Info("MadeMan");
                Log.Info("MadeMan = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.MadeMan, strUnique);
                _objCharacter.MadeMan = true;
            }

            // Check for Linguist modifiers.
            if (bonusNode.LocalName == ("linguist"))
            {
                Log.Info("Linguist");
                Log.Info("Linguist = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Linguist, strUnique);
                _objCharacter.SkillsSection.Linguist = true;
            }

            // Check for LightningReflexes modifiers.
            if (bonusNode.LocalName == ("lightningreflexes"))
            {
                Log.Info("LightningReflexes");
                Log.Info("LightningReflexes = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.LightningReflexes, strUnique);
                _objCharacter.LightningReflexes = true;
            }

            // Check for Fame modifiers.
            if (bonusNode.LocalName == ("fame"))
            {
                Log.Info("Fame");
                Log.Info("Fame = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Fame, strUnique);
                _objCharacter.Fame = true;
            }
            // Check for BornRich modifiers.
            if (bonusNode.LocalName == ("bornrich"))
            {
                Log.Info("BornRich");
                Log.Info("BornRich = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.BornRich, strUnique);
                _objCharacter.BornRich = true;
            }
            // Check for Erased modifiers.
            if (bonusNode.LocalName == ("erased"))
            {
                Log.Info("Erased");
                Log.Info("Erased = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Erased, strUnique);
                _objCharacter.Erased = true;
            }
            // Check for Erased modifiers.
            if (bonusNode.LocalName == ("overclocker"))
            {
                Log.Info("OverClocker");
                Log.Info("Overclocker = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Overclocker, strUnique);
                _objCharacter.Overclocker = true;
            }

            // Check for Restricted Gear modifiers.
            if (bonusNode.LocalName == ("restrictedgear"))
            {
                Log.Info("restrictedgear");
                Log.Info("restrictedgear = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.RestrictedGear, strUnique);
                _objCharacter.RestrictedGear = true;
            }

            // Check for Adept Linguistics.
            if (bonusNode.LocalName == ("adeptlinguistics"))
            {
                Log.Info("adeptlinguistics");
                Log.Info("adeptlinguistics = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.AdeptLinguistics, strUnique,
                    1);
            }

            // Check for Weapon Category DV modifiers.
            if (bonusNode.LocalName == ("weaponcategorydv"))
            {
                //TODO: FIX THIS
                /*
                 * I feel like talking a little bit about improvementmanager at
                 * this point. It is an intresting class. First of all, it
                 * manages to throw out everything we ever learned about OOP
                 * and create a class based on functional programming.
                 *
                 * That is true, it is a class, based on manipulating a single
                 * list on another class.
                 *
                 * But atleast there is a reference to it somewhere right?
                 *
                 * No, you create one wherever you need it, meaning there are
                 * tens of instances of this class, all operating on the same
                 * list
                 *
                 * After that, it is just plain stupid.
                 * If you have an list of xmlNodes and some might be the same
                 * it checks if a specific node exists (sometimes even by text
                 * comparison on .OuterXml) and then runs specific code for
                 * each. If it is there multiple times either of those 2 things
                 * happen.
                 *
                 * 1. Sad, nothing we can do, guess you have to survive
                 * 2. Lets create a foreach in that specific part of the code
                 *
                 * F**k ImprovementManager, kill it with fire, burn the ashes
                 * and feed what remains to a dragon that eats unholy
                 * abominations
                 */

                Log.Info("weaponcategorydv");
                Log.Info("weaponcategorydv = " + bonusNode.OuterXml.ToString());
                XmlNodeList objXmlCategoryList = bonusNode.SelectNodes("weaponcategorydv");
                XmlNode nodWeapon = bonusNode;

                if (NodeExists(nodWeapon, "selectskill"))
                {
                    // Display the Select Skill window and record which Skill was selected.
                    frmSelectItem frmPickCategory = new frmSelectItem();
                    List<ListItem> lstGeneralItems = new List<ListItem>();

                    ListItem liBlades = new ListItem();
                    liBlades.Name = "Blades";
                    liBlades.Value = "Blades";

                    ListItem liClubs = new ListItem();
                    liClubs.Name = "Clubs";
                    liClubs.Value = "Clubs";

                    ListItem liUnarmed = new ListItem();
                    liUnarmed.Name = "Unarmed";
                    liUnarmed.Value = "Unarmed";

                    ListItem liAstral = new ListItem();
                    liAstral.Name = "Astral Combat";
                    liAstral.Value = "Astral Combat";

                    ListItem liExotic = new ListItem();
                    liExotic.Name = "Exotic Melee Weapons";
                    liExotic.Value = "Exotic Melee Weapons";

                    lstGeneralItems.Add(liAstral);
                    lstGeneralItems.Add(liBlades);
                    lstGeneralItems.Add(liClubs);
                    lstGeneralItems.Add(liExotic);
                    lstGeneralItems.Add(liUnarmed);
                    frmPickCategory.GeneralItems = lstGeneralItems;

                    if (strFriendlyName != "")
                        frmPickCategory.Description =
                            LanguageManager.Instance.GetString("String_Improvement_SelectSkillNamed").Replace("{0}", strFriendlyName);
                    else
                        frmPickCategory.Description = LanguageManager.Instance.GetString("Title_SelectWeaponCategory");

                    Log.Info("_strForcedValue = " + _strForcedValue);

                    if (_strForcedValue.StartsWith("Adept:") || _strForcedValue.StartsWith("Magician:"))
                        _strForcedValue = "";

                    if (_strForcedValue != "")
                    {
                        frmPickCategory.Opacity = 0;
                    }
                    frmPickCategory.ShowDialog();

                    // Make sure the dialogue window was not canceled.
                    if (frmPickCategory.DialogResult == DialogResult.Cancel)
                    {
                        Rollback();
                        _strForcedValue = "";
                        _strLimitSelection = "";
                        return false;
                    }

                    _strSelectedValue = frmPickCategory.SelectedItem;

                    Log.Info("strSelected = " + _strSelectedValue);

                    foreach (Power objPower in _objCharacter.Powers)
                    {
                        if (objPower.InternalId == strSourceName)
                        {
                            objPower.Extra = _strSelectedValue;
                        }
                    }

                    Log.Info("Calling CreateImprovement");
                    CreateImprovement(_strSelectedValue, objImprovementSource, strSourceName,
                        Improvement.ImprovementType.WeaponCategoryDV, strUnique, ValueToInt(nodWeapon["bonus"].InnerXml, intRating));
                }
                else
                {
                    // Run through each of the Skill Groups since there may be more than one affected.
                    foreach (XmlNode objXmlCategory in objXmlCategoryList)
                    {
                        Log.Info("Calling CreateImprovement");
                        CreateImprovement(objXmlCategory["name"].InnerText, objImprovementSource, strSourceName,
                            Improvement.ImprovementType.WeaponCategoryDV, strUnique, ValueToInt(objXmlCategory["bonus"].InnerXml, intRating));
                    }
                }
            }

            // Check for Mentor Spirit bonuses.
            if (bonusNode.LocalName == ("selectmentorspirit"))
            {
                Log.Info("selectmentorspirit");
                Log.Info("selectmentorspirit = " + bonusNode.OuterXml.ToString());
                frmSelectMentorSpirit frmPickMentorSpirit = new frmSelectMentorSpirit(_objCharacter);
                frmPickMentorSpirit.ShowDialog();

                // Make sure the dialogue window was not canceled.
                if (frmPickMentorSpirit.DialogResult == DialogResult.Cancel)
                {
                    Rollback();
                    _strForcedValue = "";
                    _strLimitSelection = "";
                    return false;
                }

                _strSelectedValue = frmPickMentorSpirit.SelectedMentor;

                string strHoldValue = _strSelectedValue;
                if (blnConcatSelectedValue)
                    strSourceName += " (" + _strSelectedValue + ")";

                Log.Info("_strSelectedValue = " + _strSelectedValue);
                Log.Info("strSourceName = " + strSourceName);

                if (frmPickMentorSpirit.BonusNode != null)
                {
                    if (!CreateImprovements(objImprovementSource, strSourceName, frmPickMentorSpirit.BonusNode,
                        blnConcatSelectedValue, intRating, strFriendlyName))
                    {
                        Rollback();
                        _strForcedValue = "";
                        _strLimitSelection = "";
                        return false;
                    }
                }

                if (frmPickMentorSpirit.Choice1BonusNode != null)
                {
                    Log.Info("frmPickMentorSpirit.Choice1BonusNode = " + frmPickMentorSpirit.Choice1BonusNode.OuterXml.ToString());
                    string strForce = _strForcedValue;
                    if (!frmPickMentorSpirit.Choice1.StartsWith("Adept:") && !frmPickMentorSpirit.Choice1.StartsWith("Magician:"))
                        _strForcedValue = frmPickMentorSpirit.Choice1;
                    else
                        _strForcedValue = "";
                    Log.Info("Calling CreateImprovement");
                    bool blnSuccess = CreateImprovements(objImprovementSource, strSourceName, frmPickMentorSpirit.Choice1BonusNode,
                        blnConcatSelectedValue, intRating, strFriendlyName);
                    if (!blnSuccess)
                    {
                        Rollback();
                        _strForcedValue = "";
                        _strLimitSelection = "";
                        return false;
                    }
                    _strForcedValue = strForce;
                    _objCharacter.Improvements.Last().Notes = frmPickMentorSpirit.Choice1;
                }

                if (frmPickMentorSpirit.Choice2BonusNode != null)
                {
                    Log.Info("frmPickMentorSpirit.Choice2BonusNode = " + frmPickMentorSpirit.Choice2BonusNode.OuterXml.ToString());
                    string strForce = _strForcedValue;
                    if (!frmPickMentorSpirit.Choice2.StartsWith("Adept:") && !frmPickMentorSpirit.Choice2.StartsWith("Magician:"))
                        _strForcedValue = frmPickMentorSpirit.Choice2;
                    else
                        _strForcedValue = "";
                    Log.Info("Calling CreateImprovement");
                    bool blnSuccess = CreateImprovements(objImprovementSource, strSourceName, frmPickMentorSpirit.Choice2BonusNode,
                        blnConcatSelectedValue, intRating, strFriendlyName);
                    if (!blnSuccess)
                    {
                        Rollback();
                        _strForcedValue = "";
                        _strLimitSelection = "";
                        return false;
                    }
                    _strForcedValue = strForce;
                    _objCharacter.Improvements.Last().Notes = frmPickMentorSpirit.Choice2;
                }

                _strSelectedValue = strHoldValue;
                Log.Info("_strSelectedValue = " + _strSelectedValue);
                Log.Info("_strForcedValue = " + _strForcedValue);
            }

            // Check for Paragon bonuses.
            if (bonusNode.LocalName == ("selectparagon"))
            {
                Log.Info("selectparagon");
                Log.Info("selectparagon = " + bonusNode.OuterXml.ToString());
                frmSelectMentorSpirit frmPickMentorSpirit = new frmSelectMentorSpirit(_objCharacter);
                frmPickMentorSpirit.XmlFile = "paragons.xml";
                frmPickMentorSpirit.ShowDialog();

                // Make sure the dialogue window was not canceled.
                if (frmPickMentorSpirit.DialogResult == DialogResult.Cancel)
                {
                    Rollback();
                    _strForcedValue = "";
                    _strLimitSelection = "";
                    return false;
                }

                _strSelectedValue = frmPickMentorSpirit.SelectedMentor;
                string strHoldValue = _strSelectedValue;
                if (blnConcatSelectedValue)
                    strSourceName += " (" + _strSelectedValue + ")";

                if (frmPickMentorSpirit.BonusNode != null)
                {
                    bool blnSuccess = CreateImprovements(objImprovementSource, strSourceName, frmPickMentorSpirit.BonusNode,
                        blnConcatSelectedValue, intRating, strFriendlyName);
                    if (!blnSuccess)
                    {
                        Rollback();
                        _strForcedValue = "";
                        _strLimitSelection = "";
                        return false;
                    }
                }

                if (frmPickMentorSpirit.Choice1BonusNode != null)
                {
                    string strForce = _strForcedValue;
                    _strForcedValue = frmPickMentorSpirit.Choice1;
                    bool blnSuccess = CreateImprovements(objImprovementSource, strSourceName, frmPickMentorSpirit.Choice1BonusNode,
                        blnConcatSelectedValue, intRating, strFriendlyName);
                    if (!blnSuccess)
                    {
                        Rollback();
                        _strForcedValue = "";
                        _strLimitSelection = "";
                        return false;
                    }
                    _strForcedValue = strForce;
                    _objCharacter.Improvements.Last().Notes = frmPickMentorSpirit.Choice1;
                }

                if (frmPickMentorSpirit.Choice2BonusNode != null)
                {
                    string strForce = _strForcedValue;
                    _strForcedValue = frmPickMentorSpirit.Choice2;
                    bool blnSuccess = CreateImprovements(objImprovementSource, strSourceName, frmPickMentorSpirit.Choice2BonusNode,
                        blnConcatSelectedValue, intRating, strFriendlyName);
                    if (!blnSuccess)
                    {
                        Rollback();
                        _strForcedValue = "";
                        _strLimitSelection = "";
                        return false;
                    }
                    _strForcedValue = strForce;
                    _objCharacter.Improvements.Last().Notes = frmPickMentorSpirit.Choice2;
                }

                _strSelectedValue = strHoldValue;
            }

            // Check for Smartlink bonus.
            if (bonusNode.LocalName == ("smartlink"))
            {
                Log.Info("smartlink");
                Log.Info("smartlink = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Smartlink, "smartlink");
            }

            // Check for Adapsin bonus.
            if (bonusNode.LocalName == ("adapsin"))
            {
                Log.Info("adapsin");
                Log.Info("adapsin = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Adapsin, "adapsin");
            }

            // Check for SoftWeave bonus.
            if (bonusNode.LocalName == ("softweave"))
            {
                Log.Info("softweave");
                Log.Info("softweave = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.SoftWeave, "softweave");
            }

            // Check for Sensitive System.
            if (bonusNode.LocalName == ("sensitivesystem"))
            {
                Log.Info("sensitivesystem");
                Log.Info("sensitivesystem = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.SensitiveSystem,
                    "sensitivesystem");
            }

            // Check for Movement Percent.
            if (bonusNode.LocalName == ("movementpercent"))
            {
                Log.Info("movementpercent");
                Log.Info("movementpercent = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.MovementPercent, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Swim Percent.
            if (bonusNode.LocalName == ("swimpercent"))
            {
                Log.Info("swimpercent");
                Log.Info("swimpercent = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.SwimPercent, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Fly Percent.
            if (bonusNode.LocalName == ("flypercent"))
            {
                Log.Info("flypercent");
                Log.Info("flypercent = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.FlyPercent, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Fly Speed.
            if (bonusNode.LocalName == ("flyspeed"))
            {
                Log.Info("flyspeed");
                Log.Info("flyspeed = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.FlySpeed, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for free Positive Qualities.
            if (bonusNode.LocalName == ("freepositivequalities"))
            {
                Log.Info("freepositivequalities");
                Log.Info("freepositivequalities = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.FreePositiveQualities, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for free Negative Qualities.
            if (bonusNode.LocalName == ("freenegativequalities"))
            {
                Log.Info("freenegativequalities");
                Log.Info("freenegativequalities = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.FreeNegativeQualities, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Select Side.
            if (bonusNode.LocalName == ("selectside"))
            {
                Log.Info("selectside");
                Log.Info("selectside = " + bonusNode.OuterXml.ToString());
                frmSelectSide frmPickSide = new frmSelectSide();
                frmPickSide.Description = LanguageManager.Instance.GetString("Label_SelectSide").Replace("{0}", strFriendlyName);
                if (_strForcedValue != "")
                    frmPickSide.ForceValue(_strForcedValue);
                else
                    frmPickSide.ShowDialog();

                // Make sure the dialogue window was not canceled.
                if (frmPickSide.DialogResult == DialogResult.Cancel)
                {
                    Rollback();
                    _strForcedValue = "";
                    _strLimitSelection = "";
                    return false;
                }

                _strSelectedValue = frmPickSide.SelectedSide;
                Log.Info("_strSelectedValue = " + _strSelectedValue);
            }

            // Check for Free Spirit Power Points.
            if (bonusNode.LocalName == ("freespiritpowerpoints"))
            {
                Log.Info("freespiritpowerpoints");
                Log.Info("freespiritpowerpoints = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.FreeSpiritPowerPoints, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Adept Power Points.
            if (bonusNode.LocalName == ("adeptpowerpoints"))
            {
                Log.Info("adeptpowerpoints");
                Log.Info("adeptpowerpoints = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.AdeptPowerPoints, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Adept Powers
            if (bonusNode.LocalName == ("specificpower"))
            {
                //TODO: Probably broken
                Log.Info("specificpower");
                Log.Info("specificpower = " + bonusNode.OuterXml.ToString());
                // If the character isn't an adept or mystic adept, skip the rest of this.
                if (_objCharacter.AdeptEnabled)
                {
                    string strSelection = "";
                    _strForcedValue = "";

                    Log.Info("objXmlSpecificPower = " + bonusNode.OuterXml.ToString());

                    string strPowerName = bonusNode["name"].InnerText;
                    int intLevels = 0;
                    if (bonusNode["val"] != null)
                        intLevels = Convert.ToInt32(bonusNode["val"].InnerText);
                    bool blnFree = false;
                    if (bonusNode["free"] != null)
                        blnFree = (bonusNode["free"].InnerText == "yes");

                    string strPowerNameLimit = strPowerName;
                    if (bonusNode["selectlimit"] != null)
                    {
                        Log.Info("selectlimit = " + bonusNode["selectlimit"].OuterXml.ToString());
                        _strForcedValue = "";
                        // Display the Select Limit window and record which Limit was selected.
                        frmSelectLimit frmPickLimit = new frmSelectLimit();
                        if (strFriendlyName != "")
                            frmPickLimit.Description = LanguageManager.Instance.GetString("String_Improvement_SelectLimitNamed")
                                .Replace("{0}", strFriendlyName);
                        else
                            frmPickLimit.Description = LanguageManager.Instance.GetString("String_Improvement_SelectLimit");

                        if (bonusNode["selectlimit"].InnerXml.Contains("<limit>"))
                        {
                            List<string> strValue = new List<string>();
                            foreach (XmlNode objXmlAttribute in bonusNode["selectlimit"].SelectNodes("limit"))
                                strValue.Add(objXmlAttribute.InnerText);
                            frmPickLimit.LimitToList(strValue);
                        }

                        if (bonusNode["selectlimit"].InnerXml.Contains("<excludelimit>"))
                        {
                            List<string> strValue = new List<string>();
                            foreach (XmlNode objXmlAttribute in bonusNode["selectlimit"].SelectNodes("excludelimit"))
                                strValue.Add(objXmlAttribute.InnerText);
                            frmPickLimit.RemoveFromList(strValue);
                        }

                        // Check to see if there is only one possible selection because of _strLimitSelection.
                        if (_strForcedValue != "")
                            _strLimitSelection = _strForcedValue;

                        Log.Info("_strForcedValue = " + _strForcedValue);
                        Log.Info("_strLimitSelection = " + _strLimitSelection);

                        if (_strLimitSelection != "")
                        {
                            frmPickLimit.SingleLimit(_strLimitSelection);
                            frmPickLimit.Opacity = 0;
                        }

                        frmPickLimit.ShowDialog();

                        // Make sure the dialogue window was not canceled.
                        if (frmPickLimit.DialogResult == DialogResult.Cancel)
                        {
                            Rollback();
                            _strForcedValue = "";
                            _strLimitSelection = "";
                            return false;
                        }

                        _strSelectedValue = frmPickLimit.SelectedLimit;
                        strSelection = _strSelectedValue;
                        _strForcedValue = _strSelectedValue;

                        Log.Info("_strForcedValue = " + _strForcedValue);
                        Log.Info("_strLimitSelection = " + _strLimitSelection);
                    }

                    if (bonusNode["selectskill"] != null)
                    {
                        Log.Info("selectskill = " + bonusNode["selectskill"].OuterXml.ToString());
                        XmlNode nodSkill = bonusNode;
                        // Display the Select Skill window and record which Skill was selected.
                        frmSelectSkill frmPickSkill = new frmSelectSkill(_objCharacter);
                        if (strFriendlyName != "")
                            frmPickSkill.Description = LanguageManager.Instance.GetString("String_Improvement_SelectSkillNamed")
                                .Replace("{0}", strFriendlyName);
                        else
                            frmPickSkill.Description = LanguageManager.Instance.GetString("String_Improvement_SelectSkill");

                        if (nodSkill.SelectSingleNode("selectskill").OuterXml.Contains("skillgroup"))
                            frmPickSkill.OnlySkillGroup = nodSkill.SelectSingleNode("selectskill").Attributes["skillgroup"].InnerText;
                        else if (nodSkill.SelectSingleNode("selectskill").OuterXml.Contains("skillcategory"))
                            frmPickSkill.OnlyCategory = nodSkill.SelectSingleNode("selectskill").Attributes["skillcategory"].InnerText;
                        else if (nodSkill.SelectSingleNode("selectskill").OuterXml.Contains("excludecategory"))
                            frmPickSkill.ExcludeCategory = nodSkill.SelectSingleNode("selectskill").Attributes["excludecategory"].InnerText;
                        else if (nodSkill.SelectSingleNode("selectskill").OuterXml.Contains("limittoskill"))
                            frmPickSkill.LimitToSkill = nodSkill.SelectSingleNode("selectskill").Attributes["limittoskill"].InnerText;

                        if (_strForcedValue.StartsWith("Adept:") || _strForcedValue.StartsWith("Magician:"))
                            _strForcedValue = "";

                        Log.Info("_strForcedValue = " + _strForcedValue);
                        Log.Info("_strLimitSelection = " + _strLimitSelection);

                        if (_strForcedValue != "")
                        {
                            frmPickSkill.OnlySkill = _strForcedValue;
                            frmPickSkill.Opacity = 0;
                        }
                        frmPickSkill.ShowDialog();

                        // Make sure the dialogue window was not canceled.
                        if (frmPickSkill.DialogResult == DialogResult.Cancel)
                        {
                            Rollback();
                            _strForcedValue = "";
                            _strLimitSelection = "";
                            return false;
                        }

                        _strSelectedValue = frmPickSkill.SelectedSkill;
                        _strForcedValue = _strSelectedValue;
                        strSelection = _strSelectedValue;

                        Log.Info("_strForcedValue = " + _strForcedValue);
                        Log.Info("_strSelectedValue = " + _strSelectedValue);
                        Log.Info("strSelection = " + strSelection);
                    }

                    if (bonusNode["selecttext"] != null)
                    {
                        Log.Info("selecttext = " + bonusNode["selecttext"].OuterXml.ToString());
                        frmSelectText frmPickText = new frmSelectText();

                        if (_objCharacter.Pushtext.Count > 0)
                        {
                            strSelection = _objCharacter.Pushtext.Pop();
                        }
                        else
                        {
                            frmPickText.Description = LanguageManager.Instance.GetString("String_Improvement_SelectText")
                                .Replace("{0}", strFriendlyName);

                            Log.Info("_strForcedValue = " + _strForcedValue);
                            Log.Info("_strLimitSelection = " + _strLimitSelection);

                            if (_strLimitSelection != "")
                            {
                                frmPickText.SelectedValue = _strLimitSelection;
                                frmPickText.Opacity = 0;
                            }

                            frmPickText.ShowDialog();

                            // Make sure the dialogue window was not canceled.
                            if (frmPickText.DialogResult == DialogResult.Cancel)
                            {
                                Rollback();
                                _strForcedValue = "";
                                _strLimitSelection = "";
                                return false;
                            }

                            strSelection = frmPickText.SelectedValue;
                            _strLimitSelection = strSelection;
                        }
                        Log.Info("_strLimitSelection = " + _strLimitSelection);
                        Log.Info("strSelection = " + strSelection);
                    }

                    if (bonusNode["specificattribute"] != null)
                    {
                        Log.Info("specificattribute = " + bonusNode["specificattribute"].OuterXml.ToString());
                        strSelection = bonusNode["specificattribute"]["name"].InnerText.ToString();
                        Log.Info(
                            "strSelection = " + strSelection);
                    }

                    if (bonusNode["selectattribute"] != null)
                    {
                        Log.Info("selectattribute = " + bonusNode["selectattribute"].OuterXml.ToString());
                        XmlNode nodSkill = bonusNode;
                        if (_strForcedValue.StartsWith("Adept"))
                            _strForcedValue = "";

                        // Display the Select CharacterAttribute window and record which CharacterAttribute was selected.
                        frmSelectAttribute frmPickAttribute = new frmSelectAttribute();
                        if (strFriendlyName != "")
                            frmPickAttribute.Description =
                                LanguageManager.Instance.GetString("String_Improvement_SelectAttributeNamed").Replace("{0}", strFriendlyName);
                        else
                            frmPickAttribute.Description = LanguageManager.Instance.GetString("String_Improvement_SelectAttribute");

                        // Add MAG and/or RES to the list of Attributes if they are enabled on the form.
                        if (_objCharacter.MAGEnabled)
                            frmPickAttribute.AddMAG();
                        if (_objCharacter.RESEnabled)
                            frmPickAttribute.AddRES();

                        if (nodSkill["selectattribute"].InnerXml.Contains("<attribute>"))
                        {
                            List<string> strValue = new List<string>();
                            foreach (XmlNode objXmlAttribute in nodSkill["selectattribute"].SelectNodes("attribute"))
                                strValue.Add(objXmlAttribute.InnerText);
                            frmPickAttribute.LimitToList(strValue);
                        }

                        if (nodSkill["selectattribute"].InnerXml.Contains("<excludeattribute>"))
                        {
                            List<string> strValue = new List<string>();
                            foreach (XmlNode objXmlAttribute in nodSkill["selectattribute"].SelectNodes("excludeattribute"))
                                strValue.Add(objXmlAttribute.InnerText);
                            frmPickAttribute.RemoveFromList(strValue);
                        }

                        // Check to see if there is only one possible selection because of _strLimitSelection.
                        if (_strForcedValue != "")
                            _strLimitSelection = _strForcedValue;

                        Log.Info("_strForcedValue = " + _strForcedValue);
                        Log.Info("_strLimitSelection = " + _strLimitSelection);

                        if (_strLimitSelection != "")
                        {
                            frmPickAttribute.SingleAttribute(_strLimitSelection);
                            frmPickAttribute.Opacity = 0;
                        }

                        frmPickAttribute.ShowDialog();

                        // Make sure the dialogue window was not canceled.
                        if (frmPickAttribute.DialogResult == DialogResult.Cancel)
                        {
                            Rollback();
                            _strForcedValue = "";
                            _strLimitSelection = "";
                            return false;
                        }

                        _strSelectedValue = frmPickAttribute.SelectedAttribute;
                        if (blnConcatSelectedValue)
                            strSourceName += " (" + _strSelectedValue + ")";
                        strSelection = _strSelectedValue;
                        _strForcedValue = _strSelectedValue;

                        Log.Info("_strSelectedValue = " + _strSelectedValue);
                        Log.Info("strSourceName = " + strSourceName);
                        Log.Info("_strForcedValue = " + _strForcedValue);
                    }

                    // Check if the character already has this power
                    Log.Info("strSelection = " + strSelection);
                    bool blnHasPower = false;
                    Power objPower = new Power(_objCharacter);
                    foreach (Power power in _objCharacter.Powers)
                    {
                        if (power.Name == strPowerNameLimit)
                        {
                            if (power.Extra != "" && power.Extra == strSelection)
                            {
                                blnHasPower = true;
                                objPower = power;
                            }
                            else if (power.Extra == "")
                            {
                                blnHasPower = true;
                                objPower = power;
                            }
                        }
                    }

                    Log.Info("blnHasPower = " + blnHasPower);

                    if (blnHasPower)
                    {
                        // If yes, mark it free or give it free levels
                        if (blnFree)
                        {
                            objPower.Free = true;
                        }
                        else
                        {
                            objPower.FreeLevels += intLevels;
                            if (objPower.Rating < objPower.FreeLevels)
                                objPower.Rating = objPower.FreeLevels;
                        }
                    }
                    else
                    {
                        Log.Info("Adding Power " + strPowerName);
                        // If no, add the power and mark it free or give it free levels
                        objPower = new Power(_objCharacter);
                        _objCharacter.Powers.Add(objPower);

                        // Get the Power information
                        XmlDocument objXmlDocument = new XmlDocument();
                        objXmlDocument = XmlManager.Instance.Load("powers.xml");
                        XmlNode objXmlPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + strPowerName + "\"]");
                        Log.Info("objXmlPower = " + objXmlPower.OuterXml.ToString());

                        bool blnLevels = false;
                        if (objXmlPower["levels"] != null)
                            blnLevels = (objXmlPower["levels"].InnerText == "yes");
                        objPower.LevelsEnabled = blnLevels;
                        objPower.Name = strPowerNameLimit;
                        objPower.PointsPerLevel = Convert.ToDecimal(objXmlPower["points"].InnerText, GlobalOptions.Instance.CultureInfo);
                        objPower.Source = objXmlPower["source"].InnerText;
                        objPower.Page = objXmlPower["page"].InnerText;
                        if (strSelection != string.Empty)
                            objPower.Extra = strSelection;
                        if (objXmlPower["doublecost"] != null)
                            objPower.DoubleCost = false;

                        if (blnFree)
                        {
                            objPower.Free = true;
                        }
                        else
                        {
                            objPower.FreeLevels += intLevels;
                            if (objPower.Rating < intLevels)
                                objPower.Rating = objPower.FreeLevels;
                        }

                        if (objXmlPower.InnerXml.Contains("bonus"))
                        {
                            objPower.Bonus = objXmlPower["bonus"];
                            Log.Info("Calling CreateImprovements");
                            if (
                                !CreateImprovements(Improvement.ImprovementSource.Power, objPower.InternalId, objPower.Bonus, false,
                                    Convert.ToInt32(objPower.Rating), objPower.DisplayNameShort))
                            {
                                _objCharacter.Powers.Remove(objPower);
                            }
                        }
                    }
                    _strSelectedValue = "";
                    _strForcedValue = "";
                    strSelection = "";
                }
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.AdeptPower, "");
            }

            // Select a Power.
            if (bonusNode.LocalName == ("selectpowers"))
            {
                XmlNodeList objXmlPowerList = bonusNode.SelectNodes("selectpower");
                foreach (XmlNode objNode in objXmlPowerList)
                {
                    Log.Info("selectpower");
                    Log.Info("_strSelectedValue = " + _strSelectedValue);
                    Log.Info("_strForcedValue = " + _strForcedValue);

                    //Gerry: These unfortunately did not work in any case of multiple bonuses
                    // Switched the setting of powerpoints and levels to ADDING them
                    // Remove resetting powerpoints.
                    bool blnExistingPower = false;
                    foreach (Power objExistingPower in _objCharacter.Powers)
                    {
                        if (objExistingPower.Name.StartsWith("Improved Reflexes"))
                        {
                            if (objExistingPower.Name.EndsWith("1"))
                            {
                                if (objExistingPower.Name.EndsWith("1"))
                                {
                                    if (intRating >= 6)
                                        objExistingPower.FreePoints += 1.5M;
                                    //else
                                    //	objExistingPower.FreePoints = 0;
                                }
                                else if (objExistingPower.Name.EndsWith("2"))
                                {
                                    if (intRating >= 10)
                                        objExistingPower.FreePoints += 2.5M;
                                    else if (intRating >= 4)
                                        objExistingPower.FreePoints += 1.0M;
                                    //else
                                    //	objExistingPower.FreePoints = 0;
                                }
                                else
                                {
                                    if (intRating >= 14)
                                        objExistingPower.FreePoints += 3.5M;
                                    else if (intRating >= 8)
                                        objExistingPower.FreePoints += 2.0M;
                                    else if (intRating >= 4)
                                        objExistingPower.FreePoints += 1.0M;
                                    //else
                                    //	objExistingPower.FreePoints = 0;
                                }
                            }
                            else
                            {
                                // we have to adjust the number of free levels.
                                decimal decLevels = Convert.ToDecimal(intRating)/4;
                                decLevels = Math.Floor(decLevels/objExistingPower.PointsPerLevel);
                                objExistingPower.FreeLevels += Convert.ToInt32(decLevels);
                                if (objExistingPower.Rating < intRating)
                                    objExistingPower.Rating = objExistingPower.FreeLevels;
                                break;
                            }
                        }
                        else
                        {
                            // we have to adjust the number of free levels.
                            decimal decLevels = Convert.ToDecimal(intRating)/4;
                            decLevels = Math.Floor(decLevels/objExistingPower.PointsPerLevel);
                            objExistingPower.FreeLevels = Convert.ToInt32(decLevels);
                            if (objExistingPower.Rating < intRating)
                                objExistingPower.Rating = objExistingPower.FreeLevels;
                            break;
                        }
                        //}
                    }

                    if (!blnExistingPower)
                    {
                        // Display the Select Skill window and record which Skill was selected.
                        frmSelectPower frmPickPower = new frmSelectPower(_objCharacter);
                        Log.Info("selectpower = " + objNode.OuterXml.ToString());

                        if (objNode.OuterXml.Contains("limittopowers"))
                            frmPickPower.LimitToPowers = objNode.Attributes["limittopowers"].InnerText;
                        frmPickPower.ShowDialog();

                        // Make sure the dialogue window was not canceled.
                        if (frmPickPower.DialogResult == DialogResult.Cancel)
                        {
                            Rollback();
                            _strForcedValue = "";
                            _strLimitSelection = "";
                            return false;
                        }

                        _strSelectedValue = frmPickPower.SelectedPower;
                        if (blnConcatSelectedValue)
                            strSourceName += " (" + _strSelectedValue + ")";

                        XmlDocument objXmlDocument = XmlManager.Instance.Load("powers.xml");
                        XmlNode objXmlPower =
                            objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + _strSelectedValue + "\"]");
                        string strSelection = "";

                        Log.Info("_strSelectedValue = " + _strSelectedValue);
                        Log.Info("strSourceName = " + strSourceName);

                        XmlNode objBonus = objXmlPower["bonus"];

                        string strPowerNameLimit = _strSelectedValue;
                        if (objBonus != null)
                        {
                            if (objBonus["selectlimit"] != null)
                            {
                                Log.Info("selectlimit = " + objBonus["selectlimit"].OuterXml.ToString());
                                _strForcedValue = "";
                                // Display the Select Limit window and record which Limit was selected.
                                frmSelectLimit frmPickLimit = new frmSelectLimit();
                                if (strFriendlyName != "")
                                    frmPickLimit.Description = LanguageManager.Instance.GetString("String_Improvement_SelectLimitNamed")
                                        .Replace("{0}", strFriendlyName);
                                else
                                    frmPickLimit.Description = LanguageManager.Instance.GetString("String_Improvement_SelectLimit");

                                if (objBonus["selectlimit"].InnerXml.Contains("<limit>"))
                                {
                                    List<string> strValue = new List<string>();
                                    foreach (XmlNode objXmlAttribute in objBonus["selectlimit"].SelectNodes("limit"))
                                        strValue.Add(objXmlAttribute.InnerText);
                                    frmPickLimit.LimitToList(strValue);
                                }

                                if (objBonus["selectlimit"].InnerXml.Contains("<excludelimit>"))
                                {
                                    List<string> strValue = new List<string>();
                                    foreach (XmlNode objXmlAttribute in objBonus["selectlimit"].SelectNodes("excludelimit"))
                                        strValue.Add(objXmlAttribute.InnerText);
                                    frmPickLimit.RemoveFromList(strValue);
                                }

                                // Check to see if there is only one possible selection because of _strLimitSelection.
                                if (_strForcedValue != "")
                                    _strLimitSelection = _strForcedValue;

                                Log.Info("_strForcedValue = " + _strForcedValue);
                                Log.Info("_strLimitSelection = " + _strLimitSelection);

                                if (_strLimitSelection != "")
                                {
                                    frmPickLimit.SingleLimit(_strLimitSelection);
                                    frmPickLimit.Opacity = 0;
                                }

                                frmPickLimit.ShowDialog();

                                // Make sure the dialogue window was not canceled.
                                if (frmPickLimit.DialogResult == DialogResult.Cancel)
                                {
                                    Rollback();
                                    _strForcedValue = "";
                                    _strLimitSelection = "";
                                    return false;
                                }

                                _strSelectedValue = frmPickLimit.SelectedLimit;
                                strSelection = _strSelectedValue;
                                _strForcedValue = _strSelectedValue;

                                Log.Info("_strForcedValue = " + _strForcedValue);
                                Log.Info("_strLimitSelection = " + _strLimitSelection);
                            }

                            if (objBonus["selectskill"] != null)
                            {
                                Log.Info("selectskill = " + objBonus["selectskill"].OuterXml.ToString());
                                XmlNode nodSkill = objBonus;
                                // Display the Select Skill window and record which Skill was selected.
                                frmSelectSkill frmPickSkill = new frmSelectSkill(_objCharacter);
                                if (strFriendlyName != "")
                                    frmPickSkill.Description = LanguageManager.Instance.GetString("String_Improvement_SelectSkillNamed")
                                        .Replace("{0}", strFriendlyName);
                                else
                                    frmPickSkill.Description = LanguageManager.Instance.GetString("String_Improvement_SelectSkill");

                                if (nodSkill.SelectSingleNode("selectskill").OuterXml.Contains("skillgroup"))
                                    frmPickSkill.OnlySkillGroup = nodSkill.SelectSingleNode("selectskill").Attributes["skillgroup"].InnerText;
                                else if (nodSkill.SelectSingleNode("selectskill").OuterXml.Contains("skillcategory"))
                                    frmPickSkill.OnlyCategory = nodSkill.SelectSingleNode("selectskill").Attributes["skillcategory"].InnerText;
                                else if (nodSkill.SelectSingleNode("selectskill").OuterXml.Contains("excludecategory"))
                                    frmPickSkill.ExcludeCategory = nodSkill.SelectSingleNode("selectskill").Attributes["excludecategory"].InnerText;
                                else if (nodSkill.SelectSingleNode("selectskill").OuterXml.Contains("limittoskill"))
                                    frmPickSkill.LimitToSkill = nodSkill.SelectSingleNode("selectskill").Attributes["limittoskill"].InnerText;

                                if (_strForcedValue.StartsWith("Adept:") || _strForcedValue.StartsWith("Magician:"))
                                    _strForcedValue = "";

                                Log.Info("_strForcedValue = " + _strForcedValue);
                                Log.Info("_strLimitSelection = " + _strLimitSelection);

                                if (_strForcedValue != "")
                                {
                                    frmPickSkill.OnlySkill = _strForcedValue;
                                    frmPickSkill.Opacity = 0;
                                }
                                frmPickSkill.ShowDialog();

                                // Make sure the dialogue window was not canceled.
                                if (frmPickSkill.DialogResult == DialogResult.Cancel)
                                {
                                    Rollback();
                                    _strForcedValue = "";
                                    _strLimitSelection = "";
                                    return false;
                                }

                                _strSelectedValue = frmPickSkill.SelectedSkill;
                                _strForcedValue = _strSelectedValue;
                                strSelection = _strSelectedValue;

                                Log.Info("_strForcedValue = " + _strForcedValue);
                                Log.Info("_strSelectedValue = " + _strSelectedValue);
                                Log.Info("strSelection = " + strSelection);
                            }

                            if (objBonus["selecttext"] != null)
                            {
                                Log.Info("selecttext = " + objBonus["selecttext"].OuterXml.ToString());
                                frmSelectText frmPickText = new frmSelectText();
                                frmPickText.Description = LanguageManager.Instance.GetString("String_Improvement_SelectText")
                                    .Replace("{0}", strFriendlyName);

                                Log.Info("_strForcedValue = " + _strForcedValue);
                                Log.Info("_strLimitSelection = " + _strLimitSelection);

                                if (_strLimitSelection != "")
                                {
                                    frmPickText.SelectedValue = _strLimitSelection;
                                    frmPickText.Opacity = 0;
                                }

                                frmPickText.ShowDialog();

                                // Make sure the dialogue window was not canceled.
                                if (frmPickText.DialogResult == DialogResult.Cancel)
                                {
                                    Rollback();
                                    _strForcedValue = "";
                                    _strLimitSelection = "";
                                    return false;
                                }

                                strSelection = frmPickText.SelectedValue;
                                _strLimitSelection = strSelection;

                                Log.Info("_strLimitSelection = " + _strLimitSelection);
                                Log.Info("strSelection = " + strSelection);
                            }

                            if (objBonus["specificattribute"] != null)
                            {
                                Log.Info("specificattribute = " + objBonus["specificattribute"].OuterXml.ToString());
                                strSelection = objBonus["specificattribute"]["name"].InnerText.ToString();
                                Log.Info("strSelection = " + strSelection);
                            }

                            if (objBonus["selectattribute"] != null)
                            {
                                Log.Info("selectattribute = " + objBonus["selectattribute"].OuterXml.ToString());
                                XmlNode nodSkill = objBonus;
                                if (_strForcedValue.StartsWith("Adept"))
                                    _strForcedValue = "";

                                // Display the Select CharacterAttribute window and record which CharacterAttribute was selected.
                                frmSelectAttribute frmPickAttribute = new frmSelectAttribute();
                                if (strFriendlyName != "")
                                    frmPickAttribute.Description =
                                        LanguageManager.Instance.GetString("String_Improvement_SelectAttributeNamed").Replace("{0}", strFriendlyName);
                                else
                                    frmPickAttribute.Description = LanguageManager.Instance.GetString("String_Improvement_SelectAttribute");

                                // Add MAG and/or RES to the list of Attributes if they are enabled on the form.
                                if (_objCharacter.MAGEnabled)
                                    frmPickAttribute.AddMAG();
                                if (_objCharacter.RESEnabled)
                                    frmPickAttribute.AddRES();

                                if (nodSkill["selectattribute"].InnerXml.Contains("<attribute>"))
                                {
                                    List<string> strValue = new List<string>();
                                    foreach (XmlNode objXmlAttribute in nodSkill["selectattribute"].SelectNodes("attribute"))
                                        strValue.Add(objXmlAttribute.InnerText);
                                    frmPickAttribute.LimitToList(strValue);
                                }

                                if (nodSkill["selectattribute"].InnerXml.Contains("<excludeattribute>"))
                                {
                                    List<string> strValue = new List<string>();
                                    foreach (XmlNode objXmlAttribute in nodSkill["selectattribute"].SelectNodes("excludeattribute"))
                                        strValue.Add(objXmlAttribute.InnerText);
                                    frmPickAttribute.RemoveFromList(strValue);
                                }

                                // Check to see if there is only one possible selection because of _strLimitSelection.
                                if (_strForcedValue != "")
                                    _strLimitSelection = _strForcedValue;

                                Log.Info("_strForcedValue = " + _strForcedValue);
                                Log.Info("_strLimitSelection = " + _strLimitSelection);

                                if (_strLimitSelection != "")
                                {
                                    frmPickAttribute.SingleAttribute(_strLimitSelection);
                                    frmPickAttribute.Opacity = 0;
                                }

                                frmPickAttribute.ShowDialog();

                                // Make sure the dialogue window was not canceled.
                                if (frmPickAttribute.DialogResult == DialogResult.Cancel)
                                {
                                    Rollback();
                                    _strForcedValue = "";
                                    _strLimitSelection = "";
                                    return false;
                                }

                                _strSelectedValue = frmPickAttribute.SelectedAttribute;
                                if (blnConcatSelectedValue)
                                    strSourceName += " (" + _strSelectedValue + ")";
                                strSelection = _strSelectedValue;
                                _strForcedValue = _strSelectedValue;

                                Log.Info("_strSelectedValue = " + _strSelectedValue);
                                Log.Info("strSourceName = " + strSourceName);
                                Log.Info("_strForcedValue = " + _strForcedValue);
                            }
                        }

                        // If no, add the power and mark it free or give it free levels
                        Power objPower = new Power(_objCharacter);
                        bool blnHasPower = false;

                        foreach (Power power in _objCharacter.Powers)
                        {
                            if (power.Name == objXmlPower["name"].InnerText)
                            {
                                if (power.Extra != "" && power.Extra == strSelection)
                                {
                                    blnHasPower = true;
                                    objPower = power;
                                }
                                else if (power.Extra == "")
                                {
                                    blnHasPower = true;
                                    objPower = power;
                                }
                            }
                        }

                        Log.Info("blnHasPower = " + blnHasPower);

                        if (blnHasPower)
                        {
                            // If yes, mark it free or give it free levels
                            if (objXmlPower["levels"].InnerText == "no")
                            {
                                if (objPower.Name.StartsWith("Improved Reflexes"))
                                {
                                    if (objPower.Name.EndsWith("1"))
                                    {
                                        if (intRating >= 6)
                                            objPower.FreePoints = 1.5M;
                                        else
                                            objPower.FreePoints = 0;
                                    }
                                    else if (objPower.Name.EndsWith("2"))
                                    {
                                        if (intRating >= 10)
                                            objPower.FreePoints = 2.5M;
                                        else if (intRating >= 4)
                                            objPower.FreePoints = 1.0M;
                                        else
                                            objPower.FreePoints = 0;
                                    }
                                    else
                                    {
                                        if (intRating >= 14)
                                            objPower.FreePoints = 3.5M;
                                        else if (intRating >= 8)
                                            objPower.FreePoints = 2.0M;
                                        else if (intRating >= 4)
                                            objPower.FreePoints = 1.0M;
                                        else
                                            objPower.FreePoints = 0;
                                    }
                                }
                                else
                                {
                                    objPower.Free = true;
                                }
                            }
                            else
                            {
                                decimal decLevels = Convert.ToDecimal(intRating)/4;
                                decLevels = Math.Floor(decLevels/objPower.PointsPerLevel);
                                objPower.FreeLevels += Convert.ToInt32(decLevels);
                                objPower.Rating += Convert.ToInt32(decLevels);
                            }
                            objPower.BonusSource = strSourceName;
                        }
                        else
                        {
                            Log.Info("Adding Power " + _strSelectedValue);
                            // Get the Power information
                            _objCharacter.Powers.Add(objPower);
                            Log.Info("objXmlPower = " + objXmlPower.OuterXml.ToString());

                            bool blnLevels = false;
                            if (objXmlPower["levels"] != null)
                                blnLevels = (objXmlPower["levels"].InnerText == "yes");
                            objPower.LevelsEnabled = blnLevels;
                            objPower.Name = objXmlPower["name"].InnerText;
                            objPower.PointsPerLevel = Convert.ToDecimal(objXmlPower["points"].InnerText, GlobalOptions.Instance.CultureInfo);
                            objPower.Source = objXmlPower["source"].InnerText;
                            objPower.Page = objXmlPower["page"].InnerText;
                            objPower.BonusSource = strSourceName;
                            if (strSelection != string.Empty)
                                objPower.Extra = strSelection;
                            if (objXmlPower["doublecost"] != null)
                                objPower.DoubleCost = false;

                            if (objXmlPower["levels"].InnerText == "no")
                            {
                                if (objPower.Name.StartsWith("Improved Reflexes"))
                                {
                                    if (objPower.Name.EndsWith("1"))
                                    {
                                        if (intRating >= 6)
                                            objPower.FreePoints = 1.5M;
                                        else
                                            objPower.FreePoints = 0;
                                    }
                                    else if (objPower.Name.EndsWith("2"))
                                    {
                                        if (intRating >= 10)
                                            objPower.FreePoints = 2.5M;
                                        else if (intRating >= 4)
                                            objPower.FreePoints = 1.0M;
                                        else
                                            objPower.FreePoints = 0;
                                    }
                                    else
                                    {
                                        if (intRating >= 14)
                                            objPower.FreePoints = 3.5M;
                                        else if (intRating >= 8)
                                            objPower.FreePoints = 2.0M;
                                        else if (intRating >= 4)
                                            objPower.FreePoints = 1.0M;
                                        else
                                            objPower.FreePoints = 0;
                                    }
                                }
                                else
                                {
                                    objPower.Free = true;
                                }
                            }
                            else
                            {
                                decimal decLevels = Convert.ToDecimal(intRating)/4;
                                decLevels = Math.Floor(decLevels/objPower.PointsPerLevel);
                                objPower.FreeLevels += Convert.ToInt32(decLevels);
                                if (objPower.Rating < intRating)
                                    objPower.Rating = objPower.FreeLevels;
                            }

                            if (objXmlPower.InnerXml.Contains("bonus"))
                            {
                                objPower.Bonus = objXmlPower["bonus"];
                                Log.Info("Calling CreateImprovements");
                                if (
                                    !CreateImprovements(Improvement.ImprovementSource.Power, objPower.InternalId, objPower.Bonus, false,
                                        Convert.ToInt32(objPower.Rating), objPower.DisplayNameShort))
                                {
                                    _objCharacter.Powers.Remove(objPower);
                                }
                            }
                        }
                    }
                }
            }

            // Check for Armor Encumbrance Penalty.
            if (bonusNode.LocalName == ("armorencumbrancepenalty"))
            {
                Log.Info("armorencumbrancepenalty");
                Log.Info("armorencumbrancepenalty = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.ArmorEncumbrancePenalty, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Initiation.
            if (bonusNode.LocalName == ("initiation"))
            {
                Log.Info("initiation");
                Log.Info("initiation = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Initiation, "",
                    ValueToInt(bonusNode.InnerText, intRating));
                _objCharacter.InitiateGrade += ValueToInt(bonusNode.InnerText, intRating);
            }

            // Check for Submersion.
            if (bonusNode.LocalName == ("submersion"))
            {
                Log.Info("submersion");
                Log.Info("submersion = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Submersion, "",
                    ValueToInt(bonusNode.InnerText, intRating));
                _objCharacter.SubmersionGrade += ValueToInt(bonusNode.InnerText, intRating);
            }

            // Check for Skillwires.
            if (bonusNode.LocalName == ("skillwire"))
            {
                Log.Info("skillwire");
                Log.Info("skillwire = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Skillwire, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Hardwires.
            if (bonusNode.LocalName == ("hardwires"))
            {
                Log.Info("hardwire");
                Log.Info("hardwire = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                Cyberware objCyberware = new Cyberware(_objCharacter);
                CommonFunctions _objFunctions = new CommonFunctions();
                objCyberware = _objFunctions.FindCyberware(strSourceName, _objCharacter.Cyberware);
                if (objCyberware == null)
                {
                    Log.Info("_strSelectedValue = " + _strSelectedValue);
                    Log.Info("_strForcedValue = " + _strForcedValue);

                    // Display the Select Skill window and record which Skill was selected.
                    frmSelectSkill frmPickSkill = new frmSelectSkill(_objCharacter);
                    if (strFriendlyName != "")
                        frmPickSkill.Description = LanguageManager.Instance.GetString("String_Improvement_SelectSkillNamed")
                            .Replace("{0}", strFriendlyName);
                    else
                        frmPickSkill.Description = LanguageManager.Instance.GetString("String_Improvement_SelectSkill");

                    Log.Info("selectskill = " + bonusNode.OuterXml.ToString());
                    if (bonusNode.OuterXml.Contains("skillgroup"))
                        frmPickSkill.OnlySkillGroup = bonusNode.Attributes["skillgroup"].InnerText;
                    else if (bonusNode.OuterXml.Contains("skillcategory"))
                        frmPickSkill.OnlyCategory = bonusNode.Attributes["skillcategory"].InnerText;
                    else if (bonusNode.OuterXml.Contains("excludecategory"))
                        frmPickSkill.ExcludeCategory = bonusNode.Attributes["excludecategory"].InnerText;
                    else if (bonusNode.OuterXml.Contains("limittoskill"))
                        frmPickSkill.LimitToSkill = bonusNode.Attributes["limittoskill"].InnerText;
                    else if (bonusNode.OuterXml.Contains("limittoattribute"))
                        frmPickSkill.LinkedAttribute = bonusNode.Attributes["limittoattribute"].InnerText;

                    if (_strForcedValue != "")
                    {
                        frmPickSkill.OnlySkill = _strForcedValue;
                        frmPickSkill.Opacity = 0;
                    }
                    frmPickSkill.ShowDialog();

                    // Make sure the dialogue window was not canceled.
                    if (frmPickSkill.DialogResult == DialogResult.Cancel)
                    {
                        Rollback();
                        _strForcedValue = "";
                        _strLimitSelection = "";
                        return false;
                    }

                    _strSelectedValue = frmPickSkill.SelectedSkill;
                }
                else
                {
                    _strSelectedValue = objCyberware.Location;
                }
                if (blnConcatSelectedValue)
                    strSourceName += " (" + _strSelectedValue + ")";

                Log.Info("_strSelectedValue = " + _strSelectedValue);
                Log.Info("strSourceName = " + strSourceName);
                CreateImprovement(_strSelectedValue, objImprovementSource, strSourceName, Improvement.ImprovementType.Hardwire, _strSelectedValue,
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Damage Resistance.
            if (bonusNode.LocalName == ("damageresistance"))
            {
                Log.Info("damageresistance");
                Log.Info("damageresistance = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.DamageResistance,"",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Restricted Item Count.
            if (bonusNode.LocalName == ("restricteditemcount"))
            {
                Log.Info("restricteditemcount");
                Log.Info("restricteditemcount = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.RestrictedItemCount, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Judge Intentions.
            if (bonusNode.LocalName == ("judgeintentions"))
            {
                Log.Info("judgeintentions");
                Log.Info("judgeintentions = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.JudgeIntentions, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Composure.
            if (bonusNode.LocalName == ("composure"))
            {
                Log.Info("composure");
                Log.Info("composure = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Composure, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Lift and Carry.
            if (bonusNode.LocalName == ("liftandcarry"))
            {
                Log.Info("liftandcarry");
                Log.Info("liftandcarry = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.LiftAndCarry, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Memory.
            if (bonusNode.LocalName == ("memory"))
            {
                Log.Info("memory");
                Log.Info("memory = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Memory, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Concealability.
            if (bonusNode.LocalName == ("concealability"))
            {
                Log.Info("concealability");
                Log.Info("concealability = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Concealability, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Drain Resistance.
            if (bonusNode.LocalName == ("drainresist"))
            {
                Log.Info("drainresist");
                Log.Info("drainresist = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.DrainResistance, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Fading Resistance.
            if (bonusNode.LocalName == ("fadingresist"))
            {
                Log.Info("fadingresist");
                Log.Info("fadingresist = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.FadingResistance, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Notoriety.
            if (bonusNode.LocalName == ("notoriety"))
            {
                Log.Info("notoriety");
                Log.Info("notoriety = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Notoriety, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Complex Form Limit.
            if (bonusNode.LocalName == ("complexformlimit"))
            {
                Log.Info("complexformlimit");
                Log.Info("complexformlimit = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.ComplexFormLimit, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Spell Limit.
            if (bonusNode.LocalName == ("spelllimit"))
            {
                Log.Info("spelllimit");
                Log.Info("spelllimit = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.SpellLimit, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Spell Category bonuses.
            if (bonusNode.LocalName == ("spellcategory"))
            {
                Log.Info("spellcategory");
                Log.Info("spellcategory = " + bonusNode.OuterXml.ToString());

                string strUseUnique = strUnique;
                if (bonusNode["name"].Attributes["precedence"] != null)
                    strUseUnique = "precedence" + bonusNode["name"].Attributes["precedence"].InnerText;

                Log.Info("Calling CreateImprovement");
                CreateImprovement(bonusNode["name"].InnerText, objImprovementSource, strSourceName,
                    Improvement.ImprovementType.SpellCategory, strUseUnique, ValueToInt(bonusNode["val"].InnerText, intRating));
            }

            // Check for Throwing Range bonuses.
            if (bonusNode.LocalName == ("throwrange"))
            {
                Log.Info("throwrange");
                Log.Info("throwrange = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.ThrowRange, strUnique,
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Throwing STR bonuses.
            if (bonusNode.LocalName == ("throwstr"))
            {
                Log.Info("throwstr");
                Log.Info("throwstr = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.ThrowSTR, strUnique,
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Skillsoft access.
            if (bonusNode.LocalName == ("skillsoftaccess"))
            {
                Log.Info("skillsoftaccess");
                Log.Info("skillsoftaccess = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.SkillsoftAccess, "");
                _objCharacter.SkillsSection.KnowledgeSkills.AddRange(_objCharacter.SkillsSection.KnowsoftSkills);
            }

            // Check for Quickening Metamagic.
            if (bonusNode.LocalName == ("quickeningmetamagic"))
            {
                Log.Info("quickeningmetamagic");
                Log.Info("quickeningmetamagic = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.QuickeningMetamagic, "");
            }

            // Check for ignore Stun CM Penalty.
            if (bonusNode.LocalName == ("ignorecmpenaltystun"))
            {
                Log.Info("ignorecmpenaltystun");
                Log.Info("ignorecmpenaltystun = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.IgnoreCMPenaltyStun, "");
            }

            // Check for ignore Physical CM Penalty.
            if (bonusNode.LocalName == ("ignorecmpenaltyphysical"))
            {
                Log.Info("ignorecmpenaltyphysical");
                Log.Info("ignorecmpenaltyphysical = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.IgnoreCMPenaltyPhysical, "");
            }

            // Check for a Cyborg Essence which will permanently set the character's ESS to 0.1.
            if (bonusNode.LocalName == ("cyborgessence"))
            {
                Log.Info("cyborgessence");
                Log.Info("cyborgessence = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.CyborgEssence, "");
            }

            // Check for Maximum Essence which will permanently modify the character's Maximum Essence value.
            if (bonusNode.LocalName == ("essencemax"))
            {
                Log.Info("essencemax");
                Log.Info("essencemax = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.EssenceMax, "",
                    ValueToInt(bonusNode.InnerText, intRating));
            }

            // Check for Select Sprite.
            if (bonusNode.LocalName == ("selectsprite"))
            {
                Log.Info("selectsprite");
                Log.Info("selectsprite = " + bonusNode.OuterXml.ToString());
                XmlDocument objXmlDocument = XmlManager.Instance.Load("critters.xml");
                XmlNodeList objXmlNodeList =
                    objXmlDocument.SelectNodes("/chummer/metatypes/metatype[contains(category, \"Sprites\")]");
                List<ListItem> lstCritters = new List<ListItem>();
                foreach (XmlNode objXmlNode in objXmlNodeList)
                {
                    ListItem objItem = new ListItem();
                    if (objXmlNode["translate"] != null)
                        objItem.Name = objXmlNode["translate"].InnerText;
                    else
                        objItem.Name = objXmlNode["name"].InnerText;
                    objItem.Value = objItem.Name;
                    lstCritters.Add(objItem);
                }

                frmSelectItem frmPickItem = new frmSelectItem();
                frmPickItem.GeneralItems = lstCritters;
                frmPickItem.ShowDialog();

                if (frmPickItem.DialogResult == DialogResult.Cancel)
                {
                    Rollback();
                    _strForcedValue = "";
                    _strLimitSelection = "";
                    return false;
                }

                _strSelectedValue = frmPickItem.SelectedItem;

                Log.Info("Calling CreateImprovement");
                CreateImprovement(frmPickItem.SelectedItem, objImprovementSource, strSourceName,
                    Improvement.ImprovementType.AddSprite,
                    "");
            }

            // Check for Black Market Discount.
            if (bonusNode.LocalName == ("blackmarketdiscount"))
            {
                Log.Info("blackmarketdiscount");
                Log.Info("blackmarketdiscount = " + bonusNode.OuterXml.ToString());
                Log.Info("Calling CreateImprovement");
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.BlackMarketDiscount,
                    strUnique);
                _objCharacter.BlackMarketDiscount = true;
            }
            // Select Armor (Mostly used for Custom Fit (Stack)).
            if (bonusNode.LocalName == ("selectarmor"))
            {
                Log.Info("selectarmor");
                Log.Info("selectarmor = " + bonusNode.OuterXml.ToString());
                string strSelectedValue = "";
                if (_strForcedValue != "")
                    _strLimitSelection = _strForcedValue;

                // Display the Select Item window and record the value that was entered.

                List<ListItem> lstArmors = new List<ListItem>();
                foreach (Armor objArmor in _objCharacter.Armor)
                {
                    foreach (ArmorMod objMod in objArmor.ArmorMods)
                    {
                        if (objMod.Name.StartsWith("Custom Fit"))
                        {
                            ListItem objItem = new ListItem();
                            objItem.Value = objArmor.Name;
                            objItem.Name = objArmor.DisplayName;
                            lstArmors.Add(objItem);
                        }
                    }
                }

                if (lstArmors.Count > 0)
                {

                    frmSelectItem frmPickItem = new frmSelectItem();
                    frmPickItem.Description = LanguageManager.Instance.GetString("String_Improvement_SelectText").Replace("{0}", strFriendlyName);
                    frmPickItem.GeneralItems = lstArmors;

                    Log.Info( "_strLimitSelection = " + _strLimitSelection);
                    Log.Info( "_strForcedValue = " + _strForcedValue);

                    if (_strLimitSelection != "")
                    {
                        frmPickItem.ForceItem = _strLimitSelection;
                        frmPickItem.Opacity = 0;
                    }

                    frmPickItem.ShowDialog();

                    // Make sure the dialogue window was not canceled.
                    if (frmPickItem.DialogResult == DialogResult.Cancel)
                    {
                        Rollback();
                        _strForcedValue = "";
                        _strLimitSelection = "";
                        return false;
                    }

                    _strSelectedValue = frmPickItem.SelectedItem;
                    if (blnConcatSelectedValue)
                        strSourceName += " (" + _strSelectedValue + ")";

                    strSelectedValue = frmPickItem.SelectedItem;
                    Log.Info( "_strSelectedValue = " + _strSelectedValue);
                    Log.Info( "strSelectedValue = " + strSelectedValue);
                }

            }

            // Select Weapon (custom entry for things like Spare Clip).
            if (bonusNode.LocalName == ("selectweapon"))
            {
                Log.Info("selectweapon");
                Log.Info("selectweapon = " + bonusNode.OuterXml.ToString());
                string strSelectedValue = "";
                if (_strForcedValue != "")
                    _strLimitSelection = _strForcedValue;

                if (_objCharacter == null)
                {
                    // If the character is null (this is a Vehicle), the user must enter their own string.
                    // Display the Select Item window and record the value that was entered.
                    frmSelectText frmPickText = new frmSelectText();
                    frmPickText.Description = LanguageManager.Instance.GetString("String_Improvement_SelectText")
                        .Replace("{0}", strFriendlyName);

                    Log.Info("_strLimitSelection = " + _strLimitSelection);
                    Log.Info("_strForcedValue = " + _strForcedValue);

                    if (_strLimitSelection != "")
                    {
                        frmPickText.SelectedValue = _strLimitSelection;
                        frmPickText.Opacity = 0;
                    }

                    frmPickText.ShowDialog();

                    // Make sure the dialogue window was not canceled.
                    if (frmPickText.DialogResult == DialogResult.Cancel)
                    {
                        Rollback();
                        _strForcedValue = "";
                        _strLimitSelection = "";
                        return false;
                    }

                    _strSelectedValue = frmPickText.SelectedValue;
                    if (blnConcatSelectedValue)
                        strSourceName += " (" + _strSelectedValue + ")";

                    strSelectedValue = frmPickText.SelectedValue;
                    Log.Info("_strSelectedValue = " + _strSelectedValue);
                    Log.Info("strSelectedValue = " + strSelectedValue);
                }
                else
                {
                    List<ListItem> lstWeapons = new List<ListItem>();
                    foreach (Weapon objWeapon in _objCharacter.Weapons)
                    {
                        ListItem objItem = new ListItem();
                        objItem.Value = objWeapon.Name;
                        objItem.Name = objWeapon.DisplayName;
                        lstWeapons.Add(objItem);
                    }

                    frmSelectItem frmPickItem = new frmSelectItem();
                    frmPickItem.Description = LanguageManager.Instance.GetString("String_Improvement_SelectText")
                        .Replace("{0}", strFriendlyName);
                    frmPickItem.GeneralItems = lstWeapons;

                    Log.Info("_strLimitSelection = " + _strLimitSelection);
                    Log.Info("_strForcedValue = " + _strForcedValue);

                    if (_strLimitSelection != "")
                    {
                        frmPickItem.ForceItem = _strLimitSelection;
                        frmPickItem.Opacity = 0;
                    }

                    frmPickItem.ShowDialog();

                    // Make sure the dialogue window was not canceled.
                    if (frmPickItem.DialogResult == DialogResult.Cancel)
                    {
                        Rollback();
                        _strForcedValue = "";
                        _strLimitSelection = "";
                        return false;
                    }

                    _strSelectedValue = frmPickItem.SelectedItem;
                    if (blnConcatSelectedValue)
                        strSourceName += " (" + _strSelectedValue + ")";

                    strSelectedValue = frmPickItem.SelectedItem;
                    Log.Info("_strSelectedValue = " + _strSelectedValue);
                    Log.Info("strSelectedValue = " + strSelectedValue);
                }

                // Create the Improvement.
                Log.Info("Calling CreateImprovement");
                CreateImprovement(strSelectedValue, objImprovementSource, strSourceName, Improvement.ImprovementType.Text, strUnique);
            }

            // Select an Optional Power.
            if (bonusNode.LocalName == ("optionalpowers"))
            {
                XmlNodeList objXmlPowerList = bonusNode.SelectNodes("optionalpower");
                //Log.Info("selectoptionalpower");
                // Display the Select Attribute window and record which Skill was selected.
                frmSelectOptionalPower frmPickPower = new frmSelectOptionalPower();
                frmPickPower.Description = LanguageManager.Instance.GetString("String_Improvement_SelectOptionalPower");
                string strForcedValue = "";

                List<KeyValuePair<string, string>> lstValue = new List<KeyValuePair<string,string>>();
                foreach (XmlNode objXmlOptionalPower in objXmlPowerList)
                {
                    string strQuality = objXmlOptionalPower.InnerText;
                    if (objXmlOptionalPower.Attributes["select"] != null)
                    {
                        strForcedValue = objXmlOptionalPower.Attributes["select"].InnerText;
                    }
                    lstValue.Add(new KeyValuePair<string, string>(strQuality,strForcedValue));
                }
                frmPickPower.LimitToList(lstValue);

                // Check to see if there is only one possible selection because of _strLimitSelection.
                if (_strForcedValue != "")
                    _strLimitSelection = _strForcedValue;

                Log.Info( "_strForcedValue = " + _strForcedValue);
                Log.Info( "_strLimitSelection = " + _strLimitSelection);

                if (_strLimitSelection != "")
                {
                    frmPickPower.SinglePower(_strLimitSelection);
                    frmPickPower.Opacity = 0;
                }

                frmPickPower.ShowDialog();

                // Make sure the dialogue window was not canceled.
                if (frmPickPower.DialogResult == DialogResult.Cancel)
                {
                    Rollback();
                    _strForcedValue = "";
                    _strLimitSelection = "";
                    return false;
                }

                _strSelectedValue = frmPickPower.SelectedPower;
                // Record the improvement.
                XmlDocument objXmlDocument = XmlManager.Instance.Load("critterpowers.xml");
                XmlNode objXmlPowerNode = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + _strSelectedValue + "\"]");
                TreeNode objPowerNode = new TreeNode();
                CritterPower objPower = new CritterPower(_objCharacter);

                objPower.Create(objXmlPowerNode, _objCharacter, objPowerNode, 0, strForcedValue);
                _objCharacter.CritterPowers.Add(objPower);
            }

            if (bonusNode.LocalName == "publicawareness")
            {
                CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.PublicAwareness, strUnique, ValueToInt(bonusNode.InnerText,1));
            }

            if (bonusNode.LocalName == "dealerconnection")
            {
                Log.Info("dealerconnection");
                frmSelectItem frmPickItem = new frmSelectItem();
                List<ListItem> lstItems = new List<ListItem>();
                XmlNodeList objXmlList = bonusNode.SelectNodes("category");
                foreach (XmlNode objNode in objXmlList)
                {
                    ListItem objItem = new ListItem();
                    objItem.Value = objNode.InnerText;
                    objItem.Name = objNode.InnerText;
                    lstItems.Add(objItem);
                }
                frmPickItem.GeneralItems = lstItems;
                frmPickItem.AllowAutoSelect = false;
                frmPickItem.ShowDialog();
                // Make sure the dialogue window was not canceled.
                if (frmPickItem.DialogResult == DialogResult.Cancel)
                {
                    Rollback();
                    _strForcedValue = "";
                    _strLimitSelection = "";
                    return false;
                }

                _strSelectedValue = frmPickItem.SelectedItem;
                if (blnConcatSelectedValue)
                    strSourceName += " (" + _strSelectedValue + ")";

                Log.Info("_strSelectedValue = " + _strSelectedValue);
                Log.Info("strSourceName = " + strSourceName);

                // Create the Improvement.
                Log.Info("Calling CreateImprovement");
                CreateImprovement(frmPickItem.SelectedItem, objImprovementSource, strSourceName,
                    Improvement.ImprovementType.DealerConnection, strUnique);
            }

            if (bonusNode.LocalName == "unlockskills")
            {
                List<string> options = bonusNode.InnerText.Split(',').Select(x => x.Trim()).ToList();
                string final;
                if (options.Count == 0)
                {
                    Utils.BreakIfDebug();
                    return false;
                }
                else if (options.Count == 1)
                {
                    final = options[0];
                }
                else
                {
                    frmSelectItem frmSelect = new frmSelectItem
                    {
                        AllowAutoSelect = true,
                        GeneralItems = options.Select(x => new ListItem(x, x)).ToList()
                    };

                    if (_objCharacter.Pushtext.Count > 0)
                    {
                        frmSelect.ForceItem = _objCharacter.Pushtext.Pop();
                    }

                    if (frmSelect.ShowDialog() == DialogResult.Cancel)
                    {
                        return false;
                    }

                    final = frmSelect.SelectedItem;
                }

                SkillsSection.FilterOptions skills;
                if (Enum.TryParse(final, out skills))
                {
                    _objCharacter.SkillsSection.AddSkills(skills);
                    CreateImprovement(skills.ToString(), Improvement.ImprovementSource.Quality, strSourceName,
                        Improvement.ImprovementType.SpecialSkills, strUnique);
                }
                else
                {
                    Utils.BreakIfDebug();
                    Log.Info(new[] {"Failed to parse", "specialskills", bonusNode.OuterXml});
                }
            }

            //nothing went wrong, so return true
            return true;
        }
示例#21
0
        /// <summary>
        /// Load the Gear from the XmlNode.
        /// </summary>
        /// <param name="objNode">XmlNode to load.</param>
        public void Load(XmlNode objNode, bool blnCopy = false)
        {
            _guiID = Guid.Parse(objNode["guid"].InnerText);
            _strName = objNode["name"].InnerText;
            _strCategory = objNode["category"].InnerText;
            objNode.TryGetField("matrixcmfilled", out _intMatrixCMFilled);
            objNode.TryGetField("capacity", out _strCapacity);
            objNode.TryGetField("armorcapacity", out _strArmorCapacity);
            objNode.TryGetField("minrating", out _intMinRating);
            _intMaxRating = Convert.ToInt32(objNode["maxrating"].InnerText);
            _intRating = Convert.ToInt32(objNode["rating"].InnerText);
            _intQty = Convert.ToInt32(objNode["qty"].InnerText);
            _strAvail = objNode["avail"].InnerText;
            try
            {
                _strAvail3 = objNode["avail3"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strAvail6 = objNode["avail6"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strAvail10 = objNode["avail10"].InnerText;
            }
            catch
            {
            }
            try
            {
                _intCostFor = Convert.ToInt32(objNode["costfor"].InnerText);
            }
            catch
            {
            }
            _strCost = objNode["cost"].InnerText;
            try
            {
                _strCost3 = objNode["cost3"].InnerText;
            }
            catch { }
            try
            {
                _strCost6 = objNode["cost6"].InnerText;
            }
            catch { }
            try
            {
                _strCost10 = objNode["cost10"].InnerText;
            }
            catch
            {
            }
            if (objNode["extra"].InnerText == "Hold-Outs")
                objNode["extra"].InnerText = "Holdouts";
            _strExtra = objNode["extra"].InnerText;
            try
            {
                _blnBonded = Convert.ToBoolean(objNode["bonded"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnEquipped = Convert.ToBoolean(objNode["equipped"].InnerText);
            }
            catch
            {
            }
            try
            {
                _blnHomeNode = Convert.ToBoolean(objNode["homenode"].InnerText);
            }
            catch
            {
            }
            _nodBonus = objNode["bonus"];
            try
            {
                _nodWeaponBonus = objNode["weaponbonus"];
            }
            catch
            {
            }
            _strSource = objNode["source"].InnerText;
            try
            {
                _strPage = objNode["page"].InnerText;
            }
            catch
            {
            }
            try
            {
                _intDeviceRating = Convert.ToInt32(objNode["devicerating"].InnerText);
            }
            catch
            {
            }
            try
            {
                _guiWeaponID = Guid.Parse(objNode["weaponguid"].InnerText);
            }
            catch
            {
            }

            try
            {
                _intChildCostMultiplier = Convert.ToInt32(objNode["childcostmultiplier"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intChildAvailModifier = Convert.ToInt32(objNode["childavailmodifier"].InnerText);
            }
            catch
            {
            }

            try
            {
                _strGearName = objNode["gearname"].InnerText;
            }
            catch
            {
            }

            try
            {
                _blnIncludedInParent = Convert.ToBoolean(objNode["includedinparent"].InnerText);
            }
            catch
            {
            }

            if (objNode.InnerXml.Contains("<gear>"))
            {
                XmlNodeList nodChildren = objNode.SelectNodes("children/gear");
                foreach (XmlNode nodChild in nodChildren)
                {
                    switch (nodChild["category"].InnerText)
                    {
                        case "Commlinks":
                        case "Commlink Accessories":
                        case "Cyberdecks":
                        case "Rigger Command Consoles":
                            Commlink objCommlink = new Commlink(_objCharacter);
                            objCommlink.Load(nodChild, blnCopy);
                            objCommlink.Parent = this;
                            _objChildren.Add(objCommlink);
                            break;
                        default:
                            Gear objGear = new Gear(_objCharacter);
                            objGear.Load(nodChild, blnCopy);
                            objGear.Parent = this;
                            _objChildren.Add(objGear);
                            break;
                    }
                }
            }

            try
            {
                _strLocation = objNode["location"].InnerText;
            }
            catch
            {
            }

            try
            {
                _strNotes = objNode["notes"].InnerText;
            }
            catch
            {
            }

            try
            {
                _blnDiscountCost = Convert.ToBoolean(objNode["discountedcost"].InnerText);
            }
            catch
            {
            }

            if (GlobalOptions.Instance.Language != "en-us")
            {
                XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
                XmlNode objGearNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + _strName + "\"]");
                if (objGearNode != null)
                {
                    if (objGearNode["translate"] != null)
                        _strAltName = objGearNode["translate"].InnerText;
                    if (objGearNode["altpage"] != null)
                        _strAltPage = objGearNode["altpage"].InnerText;
                }

                if (_strAltName.StartsWith("Stacked Focus"))
                    _strAltName = _strAltName.Replace("Stacked Focus", LanguageManager.Instance.GetString("String_StackedFocus"));

                objGearNode = objXmlDocument.SelectSingleNode("/chummer/categories/category[. = \"" + _strCategory + "\"]");
                if (objGearNode != null)
                {
                    if (objGearNode.Attributes["translate"] != null)
                        _strAltCategory = objGearNode.Attributes["translate"].InnerText;
                }

                if (_strAltCategory.StartsWith("Stacked Focus"))
                    _strAltCategory = _strAltCategory.Replace("Stacked Focus", LanguageManager.Instance.GetString("String_StackedFocus"));
            }

            if (blnCopy)
            {
                _guiID = Guid.NewGuid();
                _strLocation = string.Empty;
                _blnHomeNode = false;
            }
        }