Exemplo n.º 1
0
        /// <summary>
        /// Update the Modified Rating shown.
        /// </summary>
        public void RefreshControl()
        {
            bool blnSkillsoft = false;
            ImprovementManager objImprovementManager = new ImprovementManager(_objSkill.CharacterObject);

            int intRating = _objSkill.TotalRating;
            lblModifiedRating.Text = intRating.ToString();

            int intSkillRating = _objSkill.Rating;
            foreach (Gear objGear in _objSkill.CharacterObject.Gear)
            {
                // Look for any Skillsoft that would conflict with the Skill's Rating.
                if (objGear.Equipped && objGear.Category == "Skillsofts" && (objGear.Extra == _objSkill.Name || objGear.Extra == _objSkill.Name + ", " + LanguageManager.Instance.GetString("Label_SelectGear_Hacked")))
                {
                    if (objGear.Rating > _objSkill.Rating)
                    {
                        // Use the Skillsoft's Rating or Skillwire Rating, whichever is lower.
                        // If this is a Knowsoft or Linguasoft, it is not limited to the Skillwire Rating.
                        if (objGear.Name == "Activesoft")
                            intSkillRating = Math.Min(objGear.Rating, objImprovementManager.ValueOf(Improvement.ImprovementType.Skillwire));
                        else
                            intSkillRating = objGear.Rating;
                        blnSkillsoft = true;
                        break;
                    }
                }

                foreach (Gear objChild in objGear.Children)
                {
                    if (objChild.Equipped && objChild.Category == "Skillsofts" && (objChild.Extra == _objSkill.Name || objChild.Extra == _objSkill.Name + ", " + LanguageManager.Instance.GetString("Label_SelectGear_Hacked")))
                    {
                        if (objChild.Rating > _objSkill.Rating)
                        {
                            // Use the Skillsoft's Rating or Skillwire Rating, whichever is lower.
                            // If this is a Knowsoft or Linguasoft, it is not limited to the Skillwire Rating.
                            if (objChild.Name == "Activesoft")
                                intSkillRating = Math.Min(objChild.Rating, objImprovementManager.ValueOf(Improvement.ImprovementType.Skillwire));
                            else
                                intSkillRating = objChild.Rating;
                            blnSkillsoft = true;
                            break;
                        }
                    }
                }
            }
            if (_objSkill.FreeLevels > 0)
            {
                nudSkill.Minimum = _objSkill.FreeLevels;
            }
            else
            {
                nudSkill.Minimum = 0;
            }

            if (cboSpec.Text != "" && !_objSkill.ExoticSkill)
            {
                bool blnFound = false;
                if (this.SkillName == "Artisan")
                {
                    // Look for the Inspired quality to see if we get a free specialization
                    foreach (Quality objQuality in _objSkill.CharacterObject.Qualities)
                    {
                        if (objQuality.Name == "Inspired")
                            blnFound = true;
                    }
                }
                if (!blnFound)
                {
                    lblModifiedRating.Text += " (" + (intRating + 2).ToString() + ")";
                }
                else
                {
                    lblModifiedRating.Text += " (" + (intRating + 3).ToString() + ")";
                }
            }
            lblAttribute.Text = _objSkill.DisplayAttribute;

            // Build the Tooltip.
            string strTooltip = "";
            if (blnSkillsoft)
                strTooltip += LanguageManager.Instance.GetString("Tip_Skill_SkillsoftRating") + " (" + intSkillRating.ToString() + ")";
            else
                strTooltip += LanguageManager.Instance.GetString("Tip_Skill_SkillRating") + " (" + _objSkill.Rating.ToString() + ")";

            if (_objSkill.Default && intSkillRating == 0)
                strTooltip += " - " + LanguageManager.Instance.GetString("Tip_Skill_Defaulting") + " (1)";
            if ((!_objSkill.Default && intSkillRating > 0) || _objSkill.Default)
            {
                strTooltip += " + " + LanguageManager.Instance.GetString("String_Attribute" + _objSkill.Attribute + "Short") + " (" + _objSkill.AttributeModifiers.ToString() + ")";
            }

            // Modifiers only apply when not Defaulting.
            if (intSkillRating > 0 || _objSkill.CharacterObject.Options.SkillDefaultingIncludesModifiers)
            {
                if (_objSkill.RatingModifiers != 0)
                {
                    if (_objSkill.CharacterObject.Options.EnforceMaximumSkillRatingModifier)
                    {
                        int intModifier = _objSkill.RatingModifiers;
                        if (intModifier > Convert.ToInt32(Math.Floor(Convert.ToDouble(intSkillRating, GlobalOptions.Instance.CultureInfo) * 0.5)))
                        {
                            int intMax = intModifier;
                            intModifier = Convert.ToInt32(Math.Floor(Convert.ToDouble(intSkillRating, GlobalOptions.Instance.CultureInfo) * 0.5));
                            if (intModifier != 0)
                                strTooltip += " + " + LanguageManager.Instance.GetString("Tip_Skill_RatingModifiers") + " (" + intModifier.ToString() + " " + LanguageManager.Instance.GetString("String_Of") + " " + intMax.ToString() + ")";
                            else
                                strTooltip += " + " + LanguageManager.Instance.GetString("Tip_Skill_RatingModifiers") + " (0 " + LanguageManager.Instance.GetString("String_Of") + " " + intMax.ToString() + ")";
                        }
                        else
                            strTooltip += " + " + LanguageManager.Instance.GetString("Tip_Skill_RatingModifiers") + " (" + _objSkill.RatingModifiers.ToString() + ")";
                    }
                    else
                        strTooltip += " + " + LanguageManager.Instance.GetString("Tip_Skill_RatingModifiers") + " (" + _objSkill.RatingModifiers.ToString() + ")";
                }
                // Dice Pool Modifiers.
                strTooltip += _objSkill.DicePoolModifiersTooltip;
            }

            if (_objSkill.SkillCategory == "Language" && _objSkill.KnowledgeSkill && intSkillRating == 0)
            {
                lblModifiedRating.Text = "N";
                strTooltip = LanguageManager.Instance.GetString("Tip_Skill_NativeLanguage");
            }

            // Condition Monitor Modifiers.
            if (objImprovementManager.ValueOf(Improvement.ImprovementType.ConditionMonitor) < 0)
                strTooltip += " + " + LanguageManager.Instance.GetString("Tip_Skill_Wounds") + " (" + objImprovementManager.ValueOf(Improvement.ImprovementType.ConditionMonitor).ToString() + ")";

            tipTooltip.SetToolTip(lblModifiedRating, strTooltip);

            if (_objSkill.Rating > 0 && !_objSkill.KnowledgeSkill)
            {
                this.BackColor = SystemColors.ButtonHighlight;
                //lblSkillName.Font = new Font(lblSkillName.Font, FontStyle.Bold);
                lblModifiedRating.Font = new Font(lblModifiedRating.Font, FontStyle.Bold);
            }
            else
            {
                this.BackColor = SystemColors.Control;
                //lblSkillName.Font = new Font(lblSkillName.Font, FontStyle.Regular);
                lblModifiedRating.Font = new Font(lblModifiedRating.Font, FontStyle.Regular);
            }

            // Specializations should not be enabled for Active Skills in Create Mode if their Rating is 0.
            if (!_objSkill.KnowledgeSkill && !_objSkill.ExoticSkill && !_objSkill.CharacterObject.Created)
            {
                if (_objSkill.Rating > 0 && !_objSkill.IsGrouped)
                    cboSpec.Enabled = true;
                else
                {
                    cboSpec.Enabled = false;
                    cboSpec.Text = "";
                }
            }
            if (!_objSkill.KnowledgeSkill && !_objSkill.ExoticSkill && _objSkill.CharacterObject.Created)
            {
                if (_objSkill.Rating > 0)
                    cmdChangeSpec.Enabled = true;
                else
                    cmdChangeSpec.Enabled = false;
            }

            if (_objSkill.CharacterObject.Created)
            {
                lblSkillRating.Text = _objSkill.Rating.ToString();
                // Enable or disable the Improve Skill button as necessary.
                if (_objSkill.Rating < _objSkill.RatingMaximum)
                    cmdImproveSkill.Enabled = true;
                else
                    cmdImproveSkill.Enabled = false;
            }

            if (KnowledgeSkill && _objCharacter != null && SkillRating < SkillRatingMaximum && !_objCharacter.Created)
            {
                List<Skill> joinList =
                    objCharacter.Skills.FindAll(s => s.KnowledgeSkill && s.Name == _objSkill.Name && s != _objSkill);

                type = _objSkill.Fold.Count == 0;

                if (type)
                {

                    if (joinList.Count > 0)
                    {
                        cmdExpand.Visible = true;
                    }
                    else
                    {
                        cmdExpand.Visible = false;
                    }
                }
                else
                {

                    cmdExpand.Visible = true;
                }

                //If 2 knowledgeskills have same name, offer to join them
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Check if the Cyberware's requirements/restrictions are being met.
        /// </summary>
        /// <param name="objXmlCyberware">XmlNode of the Cyberware.</param>
        /// <param name="blnShowMessage">Whether or not a message should be shown if the requirements are not met.</param>
        private bool RequirementMet(XmlNode objXmlCyberware, bool blnShowMessage)
        {
            // Ignore the rules.
            if (_objCharacter.IgnoreRules)
                return true;

            if (objXmlCyberware.InnerXml.Contains("forbidden"))
            {
                bool blnRequirementForbidden = false;
                string strForbidden = "";

                // Loop through the oneof requirements.
                XmlNodeList objXmlForbiddenList = objXmlCyberware.SelectNodes("forbidden/oneof");
                foreach (XmlNode objXmlOneOf in objXmlForbiddenList)
                {
                    XmlNodeList objXmlOneOfList = objXmlOneOf.ChildNodes;

                    foreach (XmlNode objXmlForbidden in objXmlOneOfList)
                    {
                        if (objXmlForbidden.Name == "Cyberware")
                        {
                            // Run through all of the Cyberwares the character has and see if the current forbidden item exists.
                            // If so, turn on the RequirementForbidden flag so it cannot be selected.
                            foreach (Cyberware objCharacterCyberware in _objCharacter.Cyberware)
                            {
                                if (objCharacterCyberware.Name == objXmlForbidden.InnerText)
                                {
                                    blnRequirementForbidden = true;
                                    strForbidden += "\n\t" + objCharacterCyberware.DisplayNameShort;
                                }
                            }
                        }
                    }
                }

                // The character is not allowed to take the Cyberware, so display a message and uncheck the item.
                if (blnRequirementForbidden)
                {
                    if (blnShowMessage)
                        MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectQuality_QualityRestriction") + strForbidden, LanguageManager.Instance.GetString("MessageTitle_SelectQuality_QualityRestriction"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return false;
                }
            }

            if (objXmlCyberware.InnerXml.Contains("required"))
            {
                string strRequirement = "";
                bool blnRequirementMet = true;

                // Loop through the oneof requirements.
                XmlNodeList objXmlRequiredList = objXmlCyberware.SelectNodes("required/oneof");
                foreach (XmlNode objXmlOneOf in objXmlRequiredList)
                {
                    bool blnOneOfMet = false;
                    string strThisRequirement = "\n" + LanguageManager.Instance.GetString("Message_SelectQuality_OneOf");
                    XmlNodeList objXmlOneOfList = objXmlOneOf.ChildNodes;
                    foreach (XmlNode objXmlRequired in objXmlOneOfList)
                    {
                        if (objXmlRequired.Name == "quality")
                        {
                            XmlDocument _objQualityDocument = XmlManager.Instance.Load("qualities.xml");
                            // Run through all of the Qualities the character has and see if the current required item exists.
                            // If so, turn on the RequirementMet flag so it can be selected.
                            foreach (Quality objCharacterQuality in _objCharacter.Qualities)
                            {
                                if (objCharacterQuality.Name == objXmlRequired.InnerText)
                                    blnOneOfMet = true;
                            }

                            if (!blnOneOfMet)
                            {
                                XmlNode objNode = _objQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlRequired.InnerText + "\"]");
                                if (objNode["translate"] != null)
                                    strThisRequirement += "\n\t" + objNode["translate"].InnerText;
                                else
                                    strThisRequirement += "\n\t" + objXmlRequired.InnerText;
                            }
                        }
                        else if (objXmlRequired.Name == "metatype")
                        {
                            XmlDocument _objMetatypeDocument = XmlManager.Instance.Load("metatypes.xml");
                            // Check the Metatype requirement.
                            if (objXmlRequired.InnerText == _objCharacter.Metatype)
                                blnOneOfMet = true;
                            else
                            {
                                XmlNode objNode = _objMetatypeDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + objXmlRequired.InnerText + "\"]");
                                if (objNode["translate"] != null)
                                    strThisRequirement += "\n\t" + objNode["translate"].InnerText;
                                else
                                    strThisRequirement += "\n\t" + objXmlRequired.InnerText;
                            }
                        }
                        else if (objXmlRequired.Name == "metatypecategory")
                        {
                            // Check the Metatype Category requirement.
                            if (objXmlRequired.InnerText == _objCharacter.MetatypeCategory)
                                blnOneOfMet = true;
                            else
                            {
                                XmlNode objNode = _objMetatypeDocument.SelectSingleNode("/chummer/categories/category[. = \"" + objXmlRequired.InnerText + "\"]");
                                if (objNode.Attributes["translate"] != null)
                                    strThisRequirement += "\n\t" + objNode.Attributes["translate"].InnerText;
                                else
                                    strThisRequirement = "\n\t" + objXmlRequired.InnerText;
                            }
                        }
                        else if (objXmlRequired.Name == "metavariant")
                        {
                            // Check the Metavariant requirement.
                            if (objXmlRequired.InnerText == _objCharacter.Metavariant)
                                blnOneOfMet = true;
                            else
                            {
                                XmlNode objNode = _objMetatypeDocument.SelectSingleNode("/chummer/metatypes/metatype/metavariants/metavariant[name = \"" + objXmlRequired.InnerText + "\"]");
                                if (objNode["translate"] != null)
                                    strThisRequirement += "\n\t" + objNode["translate"].InnerText;
                                else
                                    strThisRequirement += "\n\t" + objXmlRequired.InnerText;
                            }
                        }
                        else if (objXmlRequired.Name == "power")
                        {
                            // Run through all of the Powers the character has and see if the current required item exists.
                            // If so, turn on the RequirementMet flag so it can be selected.
                            if (_objCharacter.AdeptEnabled && _objCharacter.Powers != null)
                            {
                                foreach (Power objCharacterPower in _objCharacter.Powers)
                                {
                                    //Check that the power matches the name and doesn't come from a bonus source like a focus. There's probably an edge case that this will break.
                                    if (objXmlRequired.InnerText == objCharacterPower.Name && objCharacterPower.BonusSource.Length == 0)
                                    {
                                        blnOneOfMet = true;
                                    }
                                }

                                if (!blnOneOfMet)
                                {
                                    strThisRequirement += "\n\t" + objXmlRequired.InnerText;
                                }
                            }
                        }
                        else if (objXmlRequired.Name == "inherited")
                        {
                            strThisRequirement += "\n\t" + LanguageManager.Instance.GetString("Message_SelectQuality_Inherit");
                        }
                        else if (objXmlRequired.Name == "careerkarma")
                        {
                            // Check Career Karma requirement.
                            if (_objCharacter.CareerKarma >= Convert.ToInt32(objXmlRequired.InnerText))
                                blnOneOfMet = true;
                            else
                                strThisRequirement = "\n\t" + LanguageManager.Instance.GetString("Message_SelectQuality_RequireKarma").Replace("{0}", objXmlRequired.InnerText);
                        }
                        else if (objXmlRequired.Name == "ess")
                        {
                            // Check Essence requirement.
                            if (objXmlRequired.InnerText.StartsWith("-"))
                            {
                                // Essence must be less than the value.
                                if (_objCharacter.Essence < Convert.ToDecimal(objXmlRequired.InnerText.Replace("-", string.Empty), GlobalOptions.Instance.CultureInfo))
                                    blnOneOfMet = true;
                            }
                            else
                            {
                                // Essence must be equal to or greater than the value.
                                if (_objCharacter.Essence >= Convert.ToDecimal(objXmlRequired.InnerText, GlobalOptions.Instance.CultureInfo))
                                    blnOneOfMet = true;
                            }

                        }
                        else if (objXmlRequired.Name == "skill")
                        {
                            // Check if the character has the required Skill.
                            foreach (Skill objSkill in _objCharacter.SkillsSection.Skills)
                            {
                                if (objSkill.Name == objXmlRequired["name"].InnerText)
                                {
                                    if (objSkill.Rating >= Convert.ToInt32(objXmlRequired["val"].InnerText))
                                    {
                                        blnOneOfMet = true;
                                        break;
                                    }
                                }
                            }
                        }
                        else if (objXmlRequired.Name == "attribute")
                        {
                            // Check to see if an Attribute meets a requirement.
                            CharacterAttrib objAttribute = _objCharacter.GetAttribute(objXmlRequired["name"].InnerText);

                            if (objXmlRequired["total"] != null)
                            {
                                // Make sure the Attribute's total value meets the requirement.
                                if (objAttribute.TotalValue >= Convert.ToInt32(objXmlRequired["total"].InnerText))
                                    blnOneOfMet = true;
                            }
                        }
                        else if (objXmlRequired.Name == "attributetotal")
                        {
                            // Check if the character's Attributes add up to a particular total.
                            string strAttributes = objXmlRequired["attributes"].InnerText;
                            strAttributes = strAttributes.Replace("BOD", _objCharacter.GetAttribute("BOD").Value.ToString());
                            strAttributes = strAttributes.Replace("AGI", _objCharacter.GetAttribute("AGI").Value.ToString());
                            strAttributes = strAttributes.Replace("REA", _objCharacter.GetAttribute("REA").Value.ToString());
                            strAttributes = strAttributes.Replace("STR", _objCharacter.GetAttribute("STR").Value.ToString());
                            strAttributes = strAttributes.Replace("CHA", _objCharacter.GetAttribute("CHA").Value.ToString());
                            strAttributes = strAttributes.Replace("INT", _objCharacter.GetAttribute("INT").Value.ToString());
                            strAttributes = strAttributes.Replace("INT", _objCharacter.GetAttribute("LOG").Value.ToString());
                            strAttributes = strAttributes.Replace("WIL", _objCharacter.GetAttribute("WIL").Value.ToString());
                            strAttributes = strAttributes.Replace("MAG", _objCharacter.GetAttribute("MAG").Value.ToString());
                            strAttributes = strAttributes.Replace("RES", _objCharacter.GetAttribute("RES").Value.ToString());
                            strAttributes = strAttributes.Replace("EDG", _objCharacter.GetAttribute("EDG").Value.ToString());

                            XmlDocument objXmlDocument = new XmlDocument();
                            XPathNavigator nav = objXmlDocument.CreateNavigator();
                            XPathExpression xprAttributes = nav.Compile(strAttributes);
                            if (Convert.ToInt32(nav.Evaluate(xprAttributes)) >= Convert.ToInt32(objXmlRequired["val"].InnerText))
                                blnOneOfMet = true;
                        }
                        else if (objXmlRequired.Name == "skillgrouptotal")
                        {
                            // Check if the total combined Ratings of Skill Groups adds up to a particular total.
                            int intTotal = 0;
                            string[] strGroups = objXmlRequired["skillgroups"].InnerText.Split('+');
                            for (int i = 0; i <= strGroups.Length - 1; i++)
                            {
                                foreach (SkillGroup objGroup in _objCharacter.SkillsSection.SkillGroups)
                                {
                                    if (objGroup.Name == strGroups[i])
                                    {
                                        intTotal += objGroup.Rating;
                                        break;
                                    }
                                }
                            }

                            if (intTotal >= Convert.ToInt32(objXmlRequired["val"].InnerText))
                                blnOneOfMet = true;
                        }
                        else if (objXmlRequired.Name == "cyberwares")
                        {
                            // Check to see if the character has a number of the required Cyberware/Bioware items.
                            int intTotal = 0;

                            // Check Cyberware.
                            foreach (XmlNode objXmlDocument in objXmlRequired.SelectNodes("cyberware"))
                            {
                                foreach (Cyberware objCyberware in _objCharacter.Cyberware)
                                {
                                    bool blnFound = false;
                                    if (objCyberware.Name == objXmlCyberware.InnerText)
                                    {
                                        if (objXmlCyberware.Attributes["select"] == null)
                                        {
                                            intTotal++;
                                            blnFound = true;
                                            break;
                                        }
                                        else if (objXmlCyberware.Attributes["select"].InnerText == objCyberware.Location)
                                        {
                                            intTotal++;
                                            blnFound = true;
                                            break;
                                        }
                                    }
                                    if (!blnFound)
                                    {
                                        strThisRequirement += "\n\t" + objXmlCyberware.InnerText;
                                    }
                                }
                            }

                            // Check Bioware.
                            foreach (XmlNode objXmlBioware in objXmlRequired.SelectNodes("bioware"))
                            {
                                bool blnFound = false;
                                foreach (Cyberware objCyberware in _objCharacter.Cyberware)
                                {
                                    if (objCyberware.Name == objXmlBioware.InnerText)
                                    {
                                        intTotal++;
                                        blnFound = true;
                                        break;
                                    }
                                }
                                if (!blnFound)
                                {
                                    strThisRequirement += "\n\t" + objXmlBioware.InnerText;
                                }
                            }

                            // Check Cyberware name that contain a straing.
                            foreach (XmlNode objXmlDocument in objXmlRequired.SelectNodes("cyberwarecontains"))
                            {
                                foreach (Cyberware objCyberware in _objCharacter.Cyberware)
                                {
                                    if (objCyberware.Name.Contains(objXmlCyberware.InnerText))
                                    {
                                        if (objXmlCyberware.Attributes["select"] == null)
                                        {
                                            intTotal++;
                                            break;
                                        }
                                        else if (objXmlCyberware.Attributes["select"].InnerText == objCyberware.Location)
                                        {
                                            intTotal++;
                                            break;
                                        }
                                    }
                                }
                            }

                            // Check Bioware name that contain a straing.
                            foreach (XmlNode objXmlDocument in objXmlRequired.SelectNodes("biowarecontains"))
                            {
                                foreach (Cyberware objCyberware in _objCharacter.Cyberware)
                                {
                                    if (objCyberware.Name.Contains(objXmlCyberware.InnerText))
                                    {
                                        if (objXmlCyberware.Attributes["select"] == null)
                                        {
                                            intTotal++;
                                            break;
                                        }
                                        else if (objXmlCyberware.Attributes["select"].InnerText == objCyberware.Location)
                                        {
                                            intTotal++;
                                            break;
                                        }
                                    }
                                }
                            }

                            // Check for Cyberware Plugins.
                            foreach (XmlNode objXmlDocument in objXmlRequired.SelectNodes("cyberwareplugin"))
                            {
                                foreach (Cyberware objCyberware in _objCharacter.Cyberware)
                                {
                                    foreach (Cyberware objPlugin in objCyberware.Children)
                                    {
                                        if (objPlugin.Name == objXmlCyberware.InnerText)
                                        {
                                            intTotal++;
                                            break;
                                        }
                                    }
                                }
                            }

                            // Check for Cyberware Categories.
                            foreach (XmlNode objXmlDocument in objXmlRequired.SelectNodes("cyberwarecategory"))
                            {
                                foreach (Cyberware objCyberware in _objCharacter.Cyberware)
                                {
                                    if (objCyberware.Category == objXmlCyberware.InnerText)
                                        intTotal++;
                                }
                            }

                            if (intTotal >= Convert.ToInt32(objXmlRequired["count"].InnerText))
                                blnOneOfMet = true;
                        }
                        else if (objXmlRequired.Name == "streetcredvsnotoriety")
                        {
                            // Street Cred must be higher than Notoriety.
                            if (_objCharacter.StreetCred >= _objCharacter.Notoriety)
                                blnOneOfMet = true;
                        }
                        else if (objXmlRequired.Name == "damageresistance")
                        {
                            // Damage Resistance must be a particular value.
                            ImprovementManager _objImprovementManager = new ImprovementManager(_objCharacter);
                            if (_objCharacter.BOD.TotalValue + _objImprovementManager.ValueOf(Improvement.ImprovementType.DamageResistance) >= Convert.ToInt32(objXmlRequired.InnerText))
                                blnOneOfMet = true;
                        }
                    }

                    // Update the flag for requirements met.
                    blnRequirementMet = blnRequirementMet && blnOneOfMet;
                    strRequirement += strThisRequirement;
                }

                // The character has not met the requirements, so display a message and uncheck the item.
                if (!blnRequirementMet)
                {
                    string strMessage = LanguageManager.Instance.GetString("Message_SelectQuality_QualityRequirement");
                    strMessage += strRequirement;

                    if (blnShowMessage)
                        MessageBox.Show(strMessage, LanguageManager.Instance.GetString("MessageTitle_SelectQuality_QualityRequirement"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return false;
                }
            }

            return true;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Calculate the LP value for the selected items.
        /// </summary>
        private int CalculateValues(bool blnIncludePercentage = true)
        {
            if (_blnSkipRefresh)
                return 0;

            int intNuyen = 0;
            decimal decBaseCost = 0;
            decimal decCost = 0;
            // Get the base cost of the lifestyle
            XmlNode objXmlAspect = _objXmlDocument.SelectSingleNode("/chummer/lifestyles/lifestyle[name = \"" + cboLifestyle.SelectedValue + "\"]");
            decBaseCost += Convert.ToDecimal(objXmlAspect["cost"].InnerText);
            _objLifestyle.Dice = Convert.ToInt32(objXmlAspect["dice"].InnerText);
            _objLifestyle.Multiplier = Convert.ToInt32(objXmlAspect["multiplier"].InnerText);

            // Add the flat costs from qualities
            foreach (TreeNode objNode in treQualities.Nodes)
            {
                if (objNode.Checked)
                {
                    XmlNode objXmlQuality = _objXmlDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + GetQualityName(objNode.Tag.ToString()) + "\"]");
                    if (objXmlQuality["cost"] != null && objXmlQuality["cost"].InnerText != "")
                        decCost += Convert.ToDecimal(objXmlQuality["cost"].InnerText);
                }
            }

            decimal decMod = 0;
            if (blnIncludePercentage)
            {
                // Add the modifiers from qualities
                foreach (TreeNode objNode in treQualities.Nodes)
                {
                    if (objNode.Checked)
                    {
                        objXmlAspect = _objXmlDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + GetQualityName(objNode.Tag.ToString()) + "\"]");
                        if (objXmlAspect["multiplier"] != null)
                            decMod += (Convert.ToDecimal(objXmlAspect["multiplier"].InnerText) / 100);
                    }
                }

                // Check for modifiers in the improvements
                ImprovementManager objImprovementManager = new ImprovementManager(_objCharacter);
                decimal decModifier = Convert.ToDecimal(objImprovementManager.ValueOf(Improvement.ImprovementType.LifestyleCost), GlobalOptions.Instance.CultureInfo);
                decMod += Convert.ToDecimal(decModifier / 100, GlobalOptions.Instance.CultureInfo);
            }

            intNuyen = Convert.ToInt32(decBaseCost + (decBaseCost * decMod));
            intNuyen += Convert.ToInt32(decCost);
            lblCost.Text = String.Format("{0:###,###,##0¥}", intNuyen);

            if (nudPercentage.Value != 100)
            {
                decimal decDiscount = 0;
                decDiscount = decBaseCost + (decBaseCost * decMod);
                decDiscount += decCost;
                decDiscount = decDiscount * (nudPercentage.Value /100);
                lblCost.Text += String.Format(" (" + "{0:###,###,##0¥}" +")", Convert.ToInt32(decDiscount));
            }
            return intNuyen;
        }
Exemplo n.º 4
0
        private void SkillControl_Load(object sender, EventArgs e)
        {
            //Find character ourselves instead...
            if (_objCharacter == null && _objSkill != null)
                _objCharacter = _objSkill.CharacterObject;

            if (_objSkill.CharacterObject.BuildMethod == CharacterBuildMethod.Karma || _objSkill.CharacterObject.BuildMethod == CharacterBuildMethod.LifeModule)
            {
                if (_objSkill.CharacterObject.BuildMethod == CharacterBuildMethod.Karma)
                {
                    nudSkill.Visible = false;
                }
                else
                {
                    nudSkill.Enabled = false;
                }

                chkKarma.Checked = true;
                chkKarma.Enabled = false;

                if (_objSkill.KnowledgeSkill)
                {
                    if ((!_objSkill.CharacterObject.Options.FreeKarmaKnowledge) && _objSkill.CharacterObject.BuildMethod != CharacterBuildMethod.LifeModule)
                    {
                        nudKarma.Minimum = 1;
                    }
                    chkKarma.Checked = false;
                    chkKarma.Enabled = true;
                }
            }
            _blnSkipRefresh = true;
            if (_objSkill.KnowledgeSkill)
            {
                cboSkillName.Text = _objSkill.Name;
                if (!_objSkill.CharacterObject.Created && _objSkill.CharacterObject.Options.FreeKarmaKnowledge == true)
                {
                    nudSkill.Visible = true;
                    nudSkill.Enabled = true;
                }

                type = true;
                if (_objSkill.Fold.Count != 0)
                {
                    cmdExpand.Visible = true;
                    type = false;
                }

            }

            if (_objSkill.CharacterObject.Created)
            {
                string strTooltip = "";
                int intNewRating = _objSkill.Rating + 1;
                int intKarmaCost = 0;

                chkKarma.Visible = false;

                if (_objSkill.Rating < _objSkill.RatingMaximum)
                {
                    if (KnowledgeSkill == false)
                    {
                        if (_objSkill.Rating == 0)
                            intKarmaCost = _objSkill.CharacterObject.Options.KarmaNewActiveSkill;
                        else
                        {
                            intKarmaCost = (_objSkill.Rating + 1) * _objSkill.CharacterObject.Options.KarmaImproveActiveSkill;
                        }
                    }
                    else
                    {
                        if (_objSkill.Rating == 0)
                            intKarmaCost = _objSkill.CharacterObject.Options.KarmaNewKnowledgeSkill;
                        else if (_objSkill.Rating >= 3)
                        {
                            //Street Knowledge Skills > Rank 2 gain a 1 karma discount with the School of Hard Knocks quality.
                            if (_objSkill.CharacterObject.SchoolOfHardKnocks && _objSkill.SkillCategory == "Street")
                            {
                                intKarmaCost = ((_objSkill.Rating + 1) * _objSkill.CharacterObject.Options.KarmaImproveKnowledgeSkill) - 1;
                            }
                            //Academic Knowledge Skills > Rank 2 gain a 1 karma discount with the College Education quality.
                            else if (_objSkill.CharacterObject.CollegeEducation && _objSkill.SkillCategory == "Academic")
                            {
                                intKarmaCost = ((_objSkill.Rating + 1) * _objSkill.CharacterObject.Options.KarmaImproveKnowledgeSkill) - 1;
                            }
                            //Professional Knowledge Skills > Rank 2 gain a 1 karma discount with the Tech School quality.
                            else if (_objSkill.CharacterObject.TechSchool && _objSkill.SkillCategory == "Professional")
                            {
                                intKarmaCost = ((_objSkill.Rating + 1) * _objSkill.CharacterObject.Options.KarmaImproveKnowledgeSkill) - 1;
                            }
                            //Linguist Skills > Rank 2 gain a 1 karma discount with the Linguist quality.
                            else if (_objSkill.CharacterObject.Linguist && _objSkill.SkillCategory == "Language")
                            {
                                intKarmaCost = ((_objSkill.Rating + 1) * _objSkill.CharacterObject.Options.KarmaImproveKnowledgeSkill) - 1;
                            }
                        }
                        else
                            intKarmaCost = (_objSkill.Rating + 1) * _objSkill.CharacterObject.Options.KarmaImproveKnowledgeSkill;
                    }
                    // Double the Karma cost if the character is Uneducated and is a Technical Active, Academic, or Professional Skill.
                    if (_objSkill.CharacterObject.Uneducated && (SkillCategory == "Technical Active" || SkillCategory == "Academic" || SkillCategory == "Professional"))
                        intKarmaCost *= 2;
                    //Double the Karma cost if the character is Uncouth and is a Social Active Skill.
                    if (_objSkill.CharacterObject.Uncouth && (SkillCategory == "Social Active"))
                    {
                        intKarmaCost *= 2;
                    }
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", intNewRating.ToString()).Replace("{1}", intKarmaCost.ToString());
                    tipTooltip.SetToolTip(cmdImproveSkill, strTooltip);
                }

                ImprovementManager objImprovementManager = new ImprovementManager(_objSkill.CharacterObject);
                if (objImprovementManager.ValueOf(Improvement.ImprovementType.AdeptLinguistics) > 0 && SkillCategory == "Language" && SkillRating == 0)
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", "1").Replace("{1}", "0");
                tipTooltip.SetToolTip(cmdImproveSkill, strTooltip);

                nudSkill.Visible = false;
                nudKarma.Visible = false;
                lblSkillRating.Visible = true;
                cmdImproveSkill.Visible = true;

                if (_objSkill.FreeLevels > 0)
                    nudSkill.Minimum = _objSkill.FreeLevels;
                else
                    nudSkill.Minimum = 0;

                // Show the Dice Rolling button if the option is enabled.
                if (_objSkill.CharacterObject.Options.AllowSkillDiceRolling)
                {
                    cmdRoll.Visible = true;
                    this.Width += 30;
                    cboSpec.Left += 30;
                    lblSpec.Left += 30;
                    cmdChangeSpec.Left += 30;
                    cboKnowledgeSkillCategory.Left += 30;
                    cmdDelete.Left += 30;
                    tipTooltip.SetToolTip(cmdRoll, LanguageManager.Instance.GetString("Tip_DiceRoller"));
                }

                if (!_objSkill.ExoticSkill)
                {
                    cboSpec.Visible = false;
                    lblSpec.Visible = true;
                    lblSpec.Text = _objSkill.Specialization;
                    cmdChangeSpec.Visible = true;
                    cboSpec.Enabled = false;
                }
                else
                {
                    cboSpec.Text = _objSkill.Specialization;
                }

                string strTip = LanguageManager.Instance.GetString("Tip_Skill_AddSpecialization").Replace("{0}", _objSkill.CharacterObject.Options.KarmaSpecialization.ToString());
                tipTooltip.SetToolTip(cmdChangeSpec, strTip);
            }
            if (KnowledgeSkill)
            {
                this.Width = cmdExpand.Left + cmdExpand.Width;
            }
            else
                this.Width = cmdChangeSpec.Left + cmdChangeSpec.Width;

            if (!_objSkill.CharacterObject.Created && _objSkill.SkillGroupObject != null && _objSkill.SkillGroupObject.Broken)
            {
                if (!_objSkill.CharacterObject.Options.UsePointsOnBrokenGroups)
                    nudSkill.Enabled = false;
                cmdBreakGroup.Visible = false;
            }

            this.Height = lblSpec.Height + 10;

            chkKarma.Checked = _objSkill.BuyWithKarma;
            lblAttribute.Text = _objSkill.DisplayAttribute;

            RefreshControl();
            _blnSkipRefresh = false;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Update the label and tooltip for the character's Condition Monitors.
        /// </summary>
        /// <param name="lblPhysical"></param>
        /// <param name="lblStun"></param>
        /// <param name="tipTooltip"></param>
        protected void UpdateConditionMonitor(Label lblPhysical, Label lblStun, ToolTip tipTooltip, ImprovementManager _objImprovementManager)
        {
            // Condition Monitor.
            double dblBOD = _objCharacter.BOD.TotalValue;
            double dblWIL = _objCharacter.WIL.TotalValue;
            int intCMPhysical = _objCharacter.PhysicalCM;
            int intCMStun = _objCharacter.StunCM;

            // Update the Condition Monitor labels.
            lblPhysical.Text = intCMPhysical.ToString();
            lblStun.Text = intCMStun.ToString();
            string strCM = "8 + (BOD/2)(" + ((int)Math.Ceiling(dblBOD / 2)).ToString() + ")";
            if (_objImprovementManager.ValueOf(Improvement.ImprovementType.PhysicalCM) != 0)
                strCM += " + " + LanguageManager.Instance.GetString("Tip_Modifiers") + " (" +
                         _objImprovementManager.ValueOf(Improvement.ImprovementType.PhysicalCM).ToString() + ")";
            tipTooltip.SetToolTip(lblPhysical, strCM);
            strCM = "8 + (WIL/2)(" + ((int)Math.Ceiling(dblWIL / 2)).ToString() + ")";
            if (_objImprovementManager.ValueOf(Improvement.ImprovementType.StunCM) != 0)
                strCM += " + " + LanguageManager.Instance.GetString("Tip_Modifiers") + " (" +
                         _objImprovementManager.ValueOf(Improvement.ImprovementType.StunCM).ToString() + ")";
            tipTooltip.SetToolTip(lblStun, strCM);
        }
Exemplo n.º 6
0
        private void SkillControl_Load(object sender, EventArgs e)
        {
            _blnSkipRefresh = true;
            if (_objSkill.KnowledgeSkill)
            {
                cboSkillName.Text = _objSkill.Name;
            }

            if (_objSkill.CharacterObject.Created)
            {
                string strTooltip = "";
                int intNewRating = _objSkill.Rating + 1;
                int intKarmaCost = 0;

                if (_objSkill.Rating < _objSkill.RatingMaximum)
                {
                    if (KnowledgeSkill == false)
                    {
                        if (_objSkill.Rating == 0)
                            intKarmaCost = _objSkill.CharacterObject.Options.KarmaNewActiveSkill;
                        else
                        {
                            if (_objSkill.Rating == 6)
                                // The cost for raising an Active Skill from 6 to 7 (thanks to Aptitude) is doubled.
                                intKarmaCost = ((_objSkill.Rating + 1) * _objSkill.CharacterObject.Options.KarmaImproveActiveSkill) * 2;
                            else
                                intKarmaCost = (_objSkill.Rating + 1) * _objSkill.CharacterObject.Options.KarmaImproveActiveSkill;
                        }
                    }
                    else
                    {
                        if (_objSkill.Rating == 0)
                            intKarmaCost = _objSkill.CharacterObject.Options.KarmaNewKnowledgeSkill;
                        else
                            intKarmaCost = (_objSkill.Rating + 1) * _objSkill.CharacterObject.Options.KarmaImproveKnowledgeSkill;
                    }

                    // Double the Karma cost if the character is Uneducated and is a Technical Active, Academic, or Professional Skill.
                    if (_objSkill.CharacterObject.Uneducated && (SkillCategory == "Technical Active" || SkillCategory == "Academic" || SkillCategory == "Professional"))
                        intKarmaCost *= 2;
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", intNewRating.ToString()).Replace("{1}", intKarmaCost.ToString());
                    tipTooltip.SetToolTip(cmdImproveSkill, strTooltip);
                }

                ImprovementManager objImprovementManager = new ImprovementManager(_objSkill.CharacterObject);
                if (objImprovementManager.ValueOf(Improvement.ImprovementType.AdeptLinguistics) > 0 && SkillCategory == "Language" && SkillRating == 0)
                    strTooltip = LanguageManager.Instance.GetString("Tip_ImproveItem").Replace("{0}", "1").Replace("{1}", "0");
                tipTooltip.SetToolTip(cmdImproveSkill, strTooltip);

                nudSkill.Visible = false;
                lblSkillRating.Visible = true;
                cmdImproveSkill.Visible = true;

                // Show the Dice Rolling button if the option is enabled.
                if (_objSkill.CharacterObject.Options.AllowSkillDiceRolling)
                {
                    cmdRoll.Visible = true;
                    this.Width += 30;
                    cboSpec.Left += 30;
                    cmdChangeSpec.Left += 30;
                    cboKnowledgeSkillCategory.Left += 30;
                    cmdDelete.Left += 30;
                    tipTooltip.SetToolTip(cmdRoll, LanguageManager.Instance.GetString("Tip_DiceRoller"));
                }

                if (!_objSkill.ExoticSkill)
                {
                    cmdChangeSpec.Visible = true;
                    cboSpec.Enabled = false;
                }

                string strTip = LanguageManager.Instance.GetString("Tip_Skill_ChangeSpecialization").Replace("{0}", _objSkill.CharacterObject.Options.KarmaSpecialization.ToString());
                tipTooltip.SetToolTip(cmdChangeSpec, strTip);
            }
            if (KnowledgeSkill)
                this.Width = cmdDelete.Left + cmdDelete.Width;
            else
                this.Width = cmdChangeSpec.Left + cmdChangeSpec.Width;

            lblAttribute.Text = _objSkill.DisplayAttribute;

            RefreshControl();
            _blnSkipRefresh = false;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Update the Modified Rating shown.
        /// </summary>
        public void RefreshControl()
        {
            bool blnSkillsoft = false;
            ImprovementManager objImprovementManager = new ImprovementManager(_objSkill.CharacterObject);

            int intRating = _objSkill.TotalRating;
            lblModifiedRating.Text = intRating.ToString();

            int intSkillRating = _objSkill.Rating;
            foreach (Gear objGear in _objSkill.CharacterObject.Gear)
            {
                // Look for any Skillsoft that would conflict with the Skill's Rating.
                if (objGear.Equipped && objGear.Category == "Skillsofts" && (objGear.Extra == _objSkill.Name || objGear.Extra == _objSkill.Name + ", " + LanguageManager.Instance.GetString("Label_SelectGear_Hacked")))
                {
                    if (objGear.Rating > _objSkill.Rating)
                    {
                        // Use the Skillsoft's Rating or Skillwire Rating, whichever is lower.
                        // If this is a Knowsoft or Linguasoft, it is not limited to the Skillwire Rating.
                        if (objGear.Name == "Activesoft")
                            intSkillRating = Math.Min(objGear.Rating, objImprovementManager.ValueOf(Improvement.ImprovementType.Skillwire));
                        else
                            intSkillRating = objGear.Rating;
                        blnSkillsoft = true;
                        break;
                    }
                }

                foreach (Gear objChild in objGear.Children)
                {
                    if (objChild.Equipped && objChild.Category == "Skillsofts" && (objChild.Extra == _objSkill.Name || objChild.Extra == _objSkill.Name + ", " + LanguageManager.Instance.GetString("Label_SelectGear_Hacked")))
                    {
                        if (objChild.Rating > _objSkill.Rating)
                        {
                            // Use the Skillsoft's Rating or Skillwire Rating, whichever is lower.
                            // If this is a Knowsoft or Linguasoft, it is not limited to the Skillwire Rating.
                            if (objChild.Name == "Activesoft")
                                intSkillRating = Math.Min(objChild.Rating, objImprovementManager.ValueOf(Improvement.ImprovementType.Skillwire));
                            else
                                intSkillRating = objChild.Rating;
                            blnSkillsoft = true;
                            break;
                        }
                    }
                }
            }

            foreach (TechProgram objProgram in _objSkill.CharacterObject.TechPrograms)
            {
                // Look for any Skillsoft Complex Forms that would conflict with the Skill's Rating.
                if (objProgram.Category == "Skillsofts" && (objProgram.Extra == _objSkill.Name || objProgram.Extra == _objSkill.Name + ", " + LanguageManager.Instance.GetString("Label_SelectGear_Hacked")))
                {
                    if (objProgram.Rating > _objSkill.Rating)
                    {
                        // Use the Complex Form's Rating or Skillwire Rating, whichever is lower.
                        // If this is a Knowsoft or Linguasoft, it is not limited to the Skillwire Rating.
                        if (objProgram.Name == "Activesoft")
                            intSkillRating = Math.Min(objProgram.Rating, objImprovementManager.ValueOf(Improvement.ImprovementType.Skillwire));
                        else
                            intSkillRating = objProgram.Rating;
                        blnSkillsoft = true;
                        break;
                    }
                }
            }

            if (cboSpec.Text != "" && !_objSkill.ExoticSkill)
                lblModifiedRating.Text += " (" + (intRating + 2).ToString() + ")";

            lblAttribute.Text = _objSkill.DisplayAttribute;

            // Build the Tooltip.
            string strTooltip = "";
            if (blnSkillsoft)
                strTooltip += LanguageManager.Instance.GetString("Tip_Skill_SkillsoftRating") + " (" + intSkillRating.ToString() + ")";
            else
                strTooltip += LanguageManager.Instance.GetString("Tip_Skill_SkillRating") + " (" + _objSkill.Rating.ToString() + ")";

            if (_objSkill.Default && intSkillRating == 0)
                strTooltip += " - " + LanguageManager.Instance.GetString("Tip_Skill_Defaulting") + " (1)";
            if ((!_objSkill.Default && intSkillRating > 0) || _objSkill.Default)
            {
                if (_objSkill.Attribute == "MAG" && _objSkill.CharacterObject.AdeptEnabled && _objSkill.CharacterObject.MagicianEnabled)
                {
                    // The character is a Mystic Adept, so only the MAG invested in Magician counts towards the Skill.
                    strTooltip += " + " + LanguageManager.Instance.GetString("String_Attribute" + _objSkill.Attribute + "Short") + " (" + _objSkill.CharacterObject.MAGMagician.ToString() + ")";
                }
                else
                {
                    strTooltip += " + " + LanguageManager.Instance.GetString("String_Attribute" + _objSkill.Attribute + "Short") + " (" + _objSkill.AttributeModifiers.ToString() + ")";
                }
            }

            // Modifiers only apply when not Defaulting.
            if (intSkillRating > 0 || _objSkill.CharacterObject.Options.SkillDefaultingIncludesModifiers)
            {
                if (_objSkill.RatingModifiers != 0)
                {
                    if (_objSkill.CharacterObject.Options.EnforceMaximumSkillRatingModifier)
                    {
                        int intModifier = _objSkill.RatingModifiers;
                        if (intModifier > Convert.ToInt32(Math.Floor(Convert.ToDouble(intSkillRating, GlobalOptions.Instance.CultureInfo) * 0.5)))
                        {
                            int intMax = intModifier;
                            intModifier = Convert.ToInt32(Math.Floor(Convert.ToDouble(intSkillRating, GlobalOptions.Instance.CultureInfo) * 0.5));
                            if (intModifier != 0)
                                strTooltip += " + " + LanguageManager.Instance.GetString("Tip_Skill_RatingModifiers") + " (" + intModifier.ToString() + " " + LanguageManager.Instance.GetString("String_Of") + " " + intMax.ToString() + ")";
                            else
                                strTooltip += " + " + LanguageManager.Instance.GetString("Tip_Skill_RatingModifiers") + " (0 " + LanguageManager.Instance.GetString("String_Of") + " " + intMax.ToString() + ")";
                        }
                        else
                            strTooltip += " + " + LanguageManager.Instance.GetString("Tip_Skill_RatingModifiers") + " (" + _objSkill.RatingModifiers.ToString() + ")";
                    }
                    else
                        strTooltip += " + " + LanguageManager.Instance.GetString("Tip_Skill_RatingModifiers") + " (" + _objSkill.RatingModifiers.ToString() + ")";
                }
                // Dice Pool Modifiers.
                //if (_objSkill.DicePoolModifiers != 0)
                //	strTooltip += " + " + LanguageManager.Instance.GetString("Tip_Skill_DicePoolModifiers") + " (" + _objSkill.DicePoolModifiers.ToString() + ")";
                strTooltip += _objSkill.DicePoolModifiersTooltip;
            }

            if (_objSkill.SkillCategory == "Language" && _objSkill.KnowledgeSkill && intSkillRating == 0)
            {
                lblModifiedRating.Text = "N";
                strTooltip = LanguageManager.Instance.GetString("Tip_Skill_NativeLanguage");
            }

            // Condition Monitor Modifiers.
            if (objImprovementManager.ValueOf(Improvement.ImprovementType.ConditionMonitor) < 0)
                strTooltip += " + " + LanguageManager.Instance.GetString("Tip_Skill_Wounds") + " (" + objImprovementManager.ValueOf(Improvement.ImprovementType.ConditionMonitor).ToString() + ")";

            tipTooltip.SetToolTip(lblModifiedRating, strTooltip);

            if (_objSkill.Rating > 0 && !_objSkill.KnowledgeSkill)
            {
                this.BackColor = SystemColors.ButtonHighlight;
                //lblSkillName.Font = new Font(lblSkillName.Font, FontStyle.Bold);
                lblModifiedRating.Font = new Font(lblModifiedRating.Font, FontStyle.Bold);
            }
            else
            {
                this.BackColor = SystemColors.Control;
                //lblSkillName.Font = new Font(lblSkillName.Font, FontStyle.Regular);
                lblModifiedRating.Font = new Font(lblModifiedRating.Font, FontStyle.Regular);
            }

            // Specializations should not be enabled for Active Skills in Create Mode if their Rating is 0.
            if (!_objSkill.KnowledgeSkill && !_objSkill.ExoticSkill && !_objSkill.CharacterObject.Created)
            {
                if (_objSkill.Rating > 0 && !_objSkill.IsGrouped)
                    cboSpec.Enabled = true;
                else
                {
                    cboSpec.Enabled = false;
                    cboSpec.Text = "";
                }
            }
            if (!_objSkill.KnowledgeSkill && !_objSkill.ExoticSkill && _objSkill.CharacterObject.Created)
            {
                if (_objSkill.Rating > 0)
                    cmdChangeSpec.Enabled = true;
                else
                    cmdChangeSpec.Enabled = false;
            }

            if (_objSkill.CharacterObject.Created)
            {
                lblSkillRating.Text = _objSkill.Rating.ToString();
                // Enable or disable the Improve Skill button as necessary.
                if (_objSkill.Rating < _objSkill.RatingMaximum)
                    cmdImproveSkill.Enabled = true;
                else
                    cmdImproveSkill.Enabled = false;
            }
        }
        private int CalculateDamageModifier()
        {
            var physDamage = CurrentNPC.PhysicalCMFilled;
            var stunDamage = CurrentNPC.StunCMFilled;

            ImprovementManager man = new ImprovementManager(CurrentNPC);
            var ignoredPhys=  man.ValueOf(Improvement.ImprovementType.IgnoreCMPenaltyPhysical);
            var ignoredStun = man.ValueOf(Improvement.ImprovementType.IgnoreCMPenaltyStun);
            //todo Add other types of improvements (get a list of damage modifier changing improvements) 
            var returnValue = 0;
            returnValue += physDamage > ignoredPhys ? physDamage/3 : 0;
            returnValue += stunDamage > ignoredStun ? stunDamage/3 : 0;

            return -returnValue;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Check if the Quality's requirements/restrictions are being met.
        /// </summary>
        /// <param name="objXmlQuality">XmlNode of the Quality.</param>
        /// <param name="blnShowMessage">Whether or not a message should be shown if the requirements are not met.</param>
        private bool RequirementMet(XmlNode objXmlQuality, bool blnShowMessage)
        {
            // Ignore the rules.
            if (_objCharacter.IgnoreRules)
                return true;

            int intMaxOccurrences = 1;

            // See if the character already has this Quality and whether or not multiple copies are allowed.
            if (objXmlQuality["limit"] != null)
            {
                if (objXmlQuality["limit"].InnerText == "no")
                    intMaxOccurrences = 9999;
                else
                {
                    try
                    {
                        intMaxOccurrences = Convert.ToInt32(objXmlQuality["limit"].InnerText);
                    }
                    catch
                    {
                    }
                }
            }

            // Make sure the character has not hit the limit on how many times the Quality can be taken.
            int intOccurrences = 0;
            foreach (Quality objQuality in _objCharacter.Qualities)
            {
                if (objQuality.Name == objXmlQuality["name"].InnerText)
                    intOccurrences++;
            }

            if (intOccurrences >= intMaxOccurrences)
            {
                if (blnShowMessage)
                {
                    if (intMaxOccurrences == 1)
                        MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectQuality_QualityLimit"), LanguageManager.Instance.GetString("MessageTitle_SelectQuality_QualityLimit"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    else
                        MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectQuality_QualityLimitMultiple").Replace("{0}", intMaxOccurrences.ToString()), LanguageManager.Instance.GetString("MessageTitle_SelectQuality_QualityLimit"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                return false;
            }

            if (objXmlQuality["selectable"] != null)
            {
                if (objXmlQuality["selectable"].InnerText == "no")
                    return false;
            }

            if (objXmlQuality["forbidden"] != null)
            {
                bool blnRequirementForbidden = false;
                string strForbidden = "";

                // Loop through the oneof requirements.
                XmlNodeList objXmlForbiddenList = objXmlQuality.SelectNodes("forbidden/oneof");
                foreach (XmlNode objXmlOneOf in objXmlForbiddenList)
                {
                    XmlNodeList objXmlOneOfList = objXmlOneOf.ChildNodes;

                    foreach (XmlNode objXmlForbidden in objXmlOneOfList)
                    {
                        if (objXmlForbidden.Name == "careermode")
                        {
                            // Check to make sure the character is not in Career Mode.
                            if (_objCharacter.Created)
                            {
                                blnRequirementForbidden = true;
                                strForbidden += "\n\t" + LanguageManager.Instance.GetString("Title_CareerMode");
                            }
                        }
                        else if (objXmlForbidden.Name == "quality")
                        {
                            // Run through all of the Qualities the character has and see if the current forbidden item exists.
                            // If so, turn on the RequirementForbidden flag so it cannot be selected.
                            foreach (Quality objCharacterQuality in _objCharacter.Qualities)
                            {
                                if (objCharacterQuality.ExternalId == objXmlForbidden.InnerText && objCharacterQuality.ExternalId != _strIgnoreQuality)
                                {
                                    blnRequirementForbidden = true;
                                    strForbidden += "\n\t" + objCharacterQuality.DisplayNameShort;
                                }
                            }
                        }
                        else if (objXmlForbidden.Name == "metatype")
                        {
                            // Check the Metatype restriction.
                            if (objXmlForbidden.InnerText == _objCharacter.MetatypeExternalId)
                            {
                                blnRequirementForbidden = true;
                                XmlNode objNode = _objMetatypeDocument.SelectSingleNode("/chummer/metatypes/metatype[id = \"" + objXmlForbidden.InnerText + "\"]");
                                if (objNode == null)
                                    objNode = _objCritterDocument.SelectSingleNode("/chummer/metatypes/metatype[id = \"" + objXmlForbidden.InnerText + "\"]");
                                if (objNode["translate"] != null)
                                    strForbidden += "\n\t" + objNode["translate"].InnerText;
                                else
                                    strForbidden += "\n\t" + objNode["name"].InnerText;
                            }
                        }
                        else if (objXmlForbidden.Name == "metatypecategory")
                        {
                            // Check the Metatype Category restriction.
                            if (objXmlForbidden.InnerText == _objCharacter.MetatypeCategory)
                            {
                                blnRequirementForbidden = true;
                                XmlNode objNode = _objMetatypeDocument.SelectSingleNode("/chummer/categories/category[. = \"" + objXmlForbidden.InnerText + "\"]");
                                if (objNode == null)
                                    objNode = _objCritterDocument.SelectSingleNode("/chummer/categories/category[. = \"" + objXmlForbidden.InnerText + "\"]");
                                if (objNode.Attributes["translate"] != null)
                                    strForbidden += "\n\t" + objNode.Attributes["translate"].InnerText;
                                else
                                    strForbidden += "\n\t" + objXmlForbidden.InnerText;
                            }
                        }
                        else if (objXmlForbidden.Name == "metavariant")
                        {
                            // Check the Metavariant restriction.
                            if (objXmlForbidden.InnerText == _objCharacter.Metavariant)
                            {
                                blnRequirementForbidden = true;
                                XmlNode objNode = _objMetatypeDocument.SelectSingleNode("/chummer/metatypes/metatype/metavariants/metavariant[name = \"" + objXmlForbidden.InnerText + "\"]");
                                if (objNode == null)
                                    objNode = _objCritterDocument.SelectSingleNode("/chummer/metatypes/metatype/metavariants/metavariant[name = \"" + objXmlForbidden.InnerText + "\"]");
                                if (objNode["translate"] != null)
                                    strForbidden += "\n\t" + objNode["translate"].InnerText;
                                else
                                    strForbidden += "\n\t" + objXmlForbidden.InnerText;
                            }
                        }
                        else if (objXmlForbidden.Name == "metagenetic")
                        {
                            // Check to see if the character has a Metagenetic Quality.
                            foreach (Quality objQuality in _objCharacter.Qualities)
                            {
                                XmlNode objXmlCheck = _objXmlDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objQuality.Name + "\"]");
                                if (objXmlCheck["metagenetic"] != null)
                                {
                                    if (objXmlCheck["metagenetic"].InnerText.ToLower() == "yes")
                                    {
                                        blnRequirementForbidden = true;
                                        strForbidden += "\n\t" + objQuality.DisplayName;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }

                // The character is not allowed to take the Quality, so display a message and uncheck the item.
                if (blnRequirementForbidden)
                {
                    if (blnShowMessage)
                        MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectQuality_QualityRestriction") + strForbidden, LanguageManager.Instance.GetString("MessageTitle_SelectQuality_QualityRestriction"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return false;
                }
            }

            if (objXmlQuality["required"] != null)
            {
                string strRequirement = "";
                bool blnRequirementMet = true;

                // Loop through the oneof requirements.
                XmlNodeList objXmlRequiredList = objXmlQuality.SelectNodes("required/oneof");
                foreach (XmlNode objXmlOneOf in objXmlRequiredList)
                {
                    bool blnOneOfMet = false;
                    string strThisRequirement = "\n" + LanguageManager.Instance.GetString("Message_SelectQuality_OneOf");
                    XmlNodeList objXmlOneOfList = objXmlOneOf.ChildNodes;
                    foreach (XmlNode objXmlRequired in objXmlOneOfList)
                    {
                        if (objXmlRequired.Name == "quality")
                        {
                            // Run through all of the Qualities the character has and see if the current required item exists.
                            // If so, turn on the RequirementMet flag so it can be selected.
                            foreach (Quality objCharacterQuality in _objCharacter.Qualities)
                            {
                                if (objCharacterQuality.ExternalId == objXmlRequired.InnerText)
                                    blnOneOfMet = true;
                            }

                            if (!blnOneOfMet)
                            {
                                XmlNode objNode = _objXmlDocument.SelectSingleNode("/chummer/qualities/quality[id = \"" + objXmlRequired.InnerText + "\"]");
                                if (objNode["translate"] != null)
                                    strThisRequirement += "\n\t" + objNode["translate"].InnerText;
                                else
                                    strThisRequirement += "\n\t" + objNode["name"].InnerText;
                            }
                        }
                        else if (objXmlRequired.Name == "attributeexist")
                        {
                            // Make sure the character has access to an Attribute.
                            if (objXmlRequired.InnerText == "MAG")
                            {
                                if (_objCharacter.MAGEnabled)
                                    blnOneOfMet = true;
                                else
                                    strThisRequirement += "\n\t" + LanguageManager.Instance.GetString("String_AttributeMAGLong");
                            }
                            if (objXmlRequired.InnerText == "RES")
                            {
                                if (_objCharacter.RESEnabled)
                                    blnOneOfMet = true;
                                else
                                    strThisRequirement += "\n\t" + LanguageManager.Instance.GetString("String_AttributeRESLong");
                            }
                        }
                        else if (objXmlRequired.Name == "metatype")
                        {
                            // Check the Metatype requirement.
                            if (objXmlRequired.InnerText == _objCharacter.MetatypeExternalId)
                                blnOneOfMet = true;
                            else
                            {
                                XmlNode objNode = _objMetatypeDocument.SelectSingleNode("/chummer/metatypes/metatype[id = \"" + objXmlRequired.InnerText + "\"]");
                                if (objNode == null)
                                    objNode = _objCritterDocument.SelectSingleNode("/chummer/metatypes/metatype[id = \"" + objXmlRequired.InnerText + "\"]");
                                if (objNode["translate"] != null)
                                    strThisRequirement += "\n\t" + objNode["translate"].InnerText;
                                else
                                    strThisRequirement += "\n\t" + objNode["name"].InnerText;
                            }
                        }
                        else if (objXmlRequired.Name == "metatypecategory")
                        {
                            // Check the Metatype Category requirement.
                            if (objXmlRequired.InnerText == _objCharacter.MetatypeCategory)
                                blnOneOfMet = true;
                            else
                            {
                                XmlNode objNode = _objMetatypeDocument.SelectSingleNode("/chummer/categories/category[. = \"" + objXmlRequired.InnerText + "\"]");
                                if (objNode == null)
                                    objNode = _objCritterDocument.SelectSingleNode("/chummer/categories/category[. = \"" + objXmlRequired.InnerText + "\"]");
                                if (objNode.Attributes["translate"] != null)
                                    strThisRequirement += "\n\t" + objNode.Attributes["translate"].InnerText;
                                else
                                    strThisRequirement = "\n\t" + objNode["name"].InnerText;
                            }
                        }
                        else if (objXmlRequired.Name == "metavariant")
                        {
                            // Check the Metavariant requirement.
                            if (objXmlRequired.InnerText == _objCharacter.Metavariant)
                                blnOneOfMet = true;
                            else
                            {
                                XmlNode objNode = _objMetatypeDocument.SelectSingleNode("/chummer/metatypes/metatype/metavariants/metavariant[id = \"" + objXmlRequired.InnerText + "\"]");
                                if (objNode == null)
                                    objNode = _objCritterDocument.SelectSingleNode("/chummer/metatypes/metatype/metavariants/metavariant[id = \"" + objXmlRequired.InnerText + "\"]");
                                if (objNode["translate"] != null)
                                    strThisRequirement += "\n\t" + objNode["translate"].InnerText;
                                else
                                    strThisRequirement += "\n\t" + objNode["name"].InnerText;
                            }
                        }
                        else if (objXmlRequired.Name == "inherited")
                        {
                            strThisRequirement += "\n\t" + LanguageManager.Instance.GetString("Message_SelectQuality_Inherit");
                        }
                        else if (objXmlRequired.Name == "careerkarma")
                        {
                            // Check Career Karma requirement.
                            if (_objCharacter.CareerKarma >= Convert.ToInt32(objXmlRequired.InnerText))
                                blnOneOfMet = true;
                            else
                                strThisRequirement = "\n\t" + LanguageManager.Instance.GetString("Message_SelectQuality_RequireKarma").Replace("{0}", objXmlRequired.InnerText);
                        }
                        else if (objXmlRequired.Name == "ess")
                        {
                            // Check Essence requirement.
                            if (objXmlRequired.InnerText.StartsWith("-"))
                            {
                                // Essence must be less than the value.
                                if (_objCharacter.Essence < Convert.ToDecimal(objXmlRequired.InnerText.Replace("-", string.Empty), GlobalOptions.Instance.CultureInfo))
                                    blnOneOfMet = true;
                            }
                            else
                            {
                                // Essence must be equal to or greater than the value.
                                if (_objCharacter.Essence >= Convert.ToDecimal(objXmlRequired.InnerText, GlobalOptions.Instance.CultureInfo))
                                    blnOneOfMet = true;
                            }

                        }
                        else if (objXmlRequired.Name == "skill")
                        {
                            // Check if the character has the required Skill.
                            foreach (Skill objSkill in _objCharacter.Skills)
                            {
                                if (objSkill.Name == objXmlRequired["name"].InnerText)
                                {
                                    if (objSkill.Rating >= Convert.ToInt32(objXmlRequired["val"].InnerText))
                                    {
                                        blnOneOfMet = true;
                                        break;
                                    }
                                }
                            }
                        }
                        else if (objXmlRequired.Name == "attribute")
                        {
                            // Check to see if an Attribute meets a requirement.
                            Attribute objAttribute = _objCharacter.GetAttribute(objXmlRequired["name"].InnerText);

                            if (objXmlRequired["total"] != null)
                            {
                                // Make sure the Attribute's total value meets the requirement.
                                if (objAttribute.TotalValue >= Convert.ToInt32(objXmlRequired["total"].InnerText))
                                    blnOneOfMet = true;
                            }
                        }
                        else if (objXmlRequired.Name == "attributetotal")
                        {
                            // Check if the character's Attributes add up to a particular total.
                            string strAttributes = objXmlRequired["attributes"].InnerText;
                            strAttributes = strAttributes.Replace("BOD", _objCharacter.GetAttribute("BOD").Value.ToString());
                            strAttributes = strAttributes.Replace("AGI", _objCharacter.GetAttribute("AGI").Value.ToString());
                            strAttributes = strAttributes.Replace("REA", _objCharacter.GetAttribute("REA").Value.ToString());
                            strAttributes = strAttributes.Replace("STR", _objCharacter.GetAttribute("STR").Value.ToString());
                            strAttributes = strAttributes.Replace("CHA", _objCharacter.GetAttribute("CHA").Value.ToString());
                            strAttributes = strAttributes.Replace("INT", _objCharacter.GetAttribute("INT").Value.ToString());
                            strAttributes = strAttributes.Replace("INT", _objCharacter.GetAttribute("LOG").Value.ToString());
                            strAttributes = strAttributes.Replace("WIL", _objCharacter.GetAttribute("WIL").Value.ToString());
                            strAttributes = strAttributes.Replace("MAG", _objCharacter.GetAttribute("MAG").Value.ToString());
                            strAttributes = strAttributes.Replace("RES", _objCharacter.GetAttribute("RES").Value.ToString());
                            strAttributes = strAttributes.Replace("EDG", _objCharacter.GetAttribute("EDG").Value.ToString());

                            XmlDocument objXmlDocument = new XmlDocument();
                            XPathNavigator nav = objXmlDocument.CreateNavigator();
                            XPathExpression xprAttributes = nav.Compile(strAttributes);
                            if (Convert.ToInt32(nav.Evaluate(xprAttributes)) >= Convert.ToInt32(objXmlRequired["val"].InnerText))
                                blnOneOfMet = true;
                        }
                        else if (objXmlRequired.Name == "skillgrouptotal")
                        {
                            // Check if the total combined Ratings of Skill Groups adds up to a particular total.
                            int intTotal = 0;
                            string[] strGroups = objXmlRequired["skillgroups"].InnerText.Split('+');
                            for (int i = 0; i <= strGroups.Length - 1; i++)
                            {
                                foreach (SkillGroup objGroup in _objCharacter.SkillGroups)
                                {
                                    if (objGroup.Name == strGroups[i])
                                    {
                                        intTotal += objGroup.Rating;
                                        break;
                                    }
                                }
                            }

                            if (intTotal >= Convert.ToInt32(objXmlRequired["val"].InnerText))
                                blnOneOfMet = true;
                        }
                        else if (objXmlRequired.Name == "cyberwares")
                        {
                            // Check to see if the character has a number of the required Cyberware/Bioware items.
                            int intTotal = 0;

                            // Check Cyberware.
                            foreach (XmlNode objXmlCyberware in objXmlRequired.SelectNodes("cyberware"))
                            {
                                foreach (Cyberware objCyberware in _objCharacter.Cyberware)
                                {
                                    if (objCyberware.Name == objXmlCyberware.InnerText)
                                    {
                                        if (objXmlCyberware.Attributes["select"] == null)
                                        {
                                            intTotal++;
                                            break;
                                        }
                                        else if (objXmlCyberware.Attributes["select"].InnerText == objCyberware.Location)
                                        {
                                            intTotal++;
                                            break;
                                        }
                                    }
                                }
                            }

                            // Check Bioware.
                            foreach (XmlNode objXmlBioware in objXmlRequired.SelectNodes("bioware"))
                            {
                                foreach (Cyberware objCyberware in _objCharacter.Cyberware)
                                {
                                    if (objCyberware.Name == objXmlBioware.InnerText)
                                    {
                                        intTotal++;
                                        break;
                                    }
                                }
                            }

                            // Check Cyberware name that contain a straing.
                            foreach (XmlNode objXmlCyberware in objXmlRequired.SelectNodes("cyberwarecontains"))
                            {
                                foreach (Cyberware objCyberware in _objCharacter.Cyberware)
                                {
                                    if (objCyberware.Name.Contains(objXmlCyberware.InnerText))
                                    {
                                        if (objXmlCyberware.Attributes["select"] == null)
                                        {
                                            intTotal++;
                                            break;
                                        }
                                        else if (objXmlCyberware.Attributes["select"].InnerText == objCyberware.Location)
                                        {
                                            intTotal++;
                                            break;
                                        }
                                    }
                                }
                            }

                            // Check Bioware name that contain a straing.
                            foreach (XmlNode objXmlCyberware in objXmlRequired.SelectNodes("biowarecontains"))
                            {
                                foreach (Cyberware objCyberware in _objCharacter.Cyberware)
                                {
                                    if (objCyberware.Name.Contains(objXmlCyberware.InnerText))
                                    {
                                        if (objXmlCyberware.Attributes["select"] == null)
                                        {
                                            intTotal++;
                                            break;
                                        }
                                        else if (objXmlCyberware.Attributes["select"].InnerText == objCyberware.Location)
                                        {
                                            intTotal++;
                                            break;
                                        }
                                    }
                                }
                            }

                            // Check for Cyberware Plugins.
                            foreach (XmlNode objXmlCyberware in objXmlRequired.SelectNodes("cyberwareplugin"))
                            {
                                foreach (Cyberware objCyberware in _objCharacter.Cyberware)
                                {
                                    foreach (Cyberware objPlugin in objCyberware.Cyberwares)
                                    {
                                        if (objPlugin.Name == objXmlCyberware.InnerText)
                                        {
                                            intTotal++;
                                            break;
                                        }
                                    }
                                }
                            }

                            // Check for Cyberware Categories.
                            foreach (XmlNode objXmlCyberware in objXmlRequired.SelectNodes("cyberwarecategory"))
                            {
                                foreach (Cyberware objCyberware in _objCharacter.Cyberware)
                                {
                                    if (objCyberware.Category == objXmlCyberware.InnerText)
                                        intTotal++;
                                }
                            }

                            if (intTotal >= Convert.ToInt32(objXmlRequired["count"].InnerText))
                                blnOneOfMet = true;
                        }
                        else if (objXmlRequired.Name == "streetcredvsnotoriety")
                        {
                            // Street Cred must be higher than Notoriety.
                            if (_objCharacter.StreetCred >= _objCharacter.Notoriety)
                                blnOneOfMet = true;
                        }
                        else if (objXmlRequired.Name == "damageresistance")
                        {
                            // Damage Resistance must be a particular value.
                            ImprovementManager _objImprovementManager = new ImprovementManager(_objCharacter);
                            if (_objCharacter.BOD.TotalValue + _objImprovementManager.ValueOf(Improvement.ImprovementType.DamageResistance) >= Convert.ToInt32(objXmlRequired.InnerText))
                                blnOneOfMet = true;
                        }
                    }

                    // Update the flag for requirements met.
                    blnRequirementMet = blnRequirementMet && blnOneOfMet;
                    strRequirement += strThisRequirement;
                }

                // Loop through the allof requirements.
                objXmlRequiredList = objXmlQuality.SelectNodes("required/allof");
                foreach (XmlNode objXmlAllOf in objXmlRequiredList)
                {
                    bool blnAllOfMet = true;
                    string strThisRequirement = "\n" + LanguageManager.Instance.GetString("Message_SelectQuality_AllOf");
                    XmlNodeList objXmlAllOfList = objXmlAllOf.ChildNodes;
                    foreach (XmlNode objXmlRequired in objXmlAllOfList)
                    {
                        bool blnFound = false;
                        if (objXmlRequired.Name == "quality")
                        {
                            // Run through all of the Qualities the character has and see if the current required item exists.
                            // If so, turn on the RequirementMet flag so it can be selected.
                            foreach (Quality objCharacterQuality in _objCharacter.Qualities)
                            {
                                if (objCharacterQuality.ExternalId == objXmlRequired.InnerText)
                                    blnFound = true;
                            }

                            if (!blnFound)
                            {
                                XmlNode objNode = _objXmlDocument.SelectSingleNode("/chummer/qualities/quality[id = \"" + objXmlRequired.InnerText + "\"]");
                                if (objNode["translate"] != null)
                                    strThisRequirement += "\n\t" + objNode["translate"].InnerText;
                                else
                                    strThisRequirement += "\n\t" + objNode["name"].InnerText;
                            }
                        }
                        else if (objXmlRequired.Name == "attributeexist")
                        {
                            // Check to see if the character has access to an Attribute.
                            if (objXmlRequired.InnerText == "MAG")
                            {
                                if (_objCharacter.MAGEnabled)
                                    blnFound = true;
                                else
                                    strThisRequirement += "\n\t" + LanguageManager.Instance.GetString("String_AttributeMAGLong");
                            }
                            if (objXmlRequired.InnerText == "RES")
                            {
                                if (_objCharacter.RESEnabled)
                                    blnFound = true;
                                else
                                    strThisRequirement += "\n\t" + LanguageManager.Instance.GetString("String_AttributeRESLong");
                            }
                        }
                        else if (objXmlRequired.Name == "metatype")
                        {
                            // Check the Metatype requirement.
                            if (objXmlRequired.InnerText == _objCharacter.MetatypeExternalId)
                                blnFound = true;
                            else
                            {
                                XmlNode objNode = _objMetatypeDocument.SelectSingleNode("/chummer/metatypes/metatype[id = \"" + objXmlRequired.InnerText + "\"]");
                                if (objNode == null)
                                    objNode = _objCritterDocument.SelectSingleNode("/chummer/metatypes/metatype[id = \"" + objXmlRequired.InnerText + "\"]");
                                if (objNode["translate"] != null)
                                    strThisRequirement += "\n\t" + objNode["translate"].InnerText;
                                else
                                    strThisRequirement += "\n\t" + objNode["name"].InnerText;
                            }
                        }
                        else if (objXmlRequired.Name == "metatypecategory")
                        {
                            // Check the Metatype Category requirement.
                            if (objXmlRequired.InnerText == _objCharacter.MetatypeCategory)
                                blnFound = true;
                            else
                            {
                                XmlNode objNode = _objMetatypeDocument.SelectSingleNode("/chummer/categories/category[. = \"" + objXmlRequired.InnerText + "\"]");
                                if (objNode == null)
                                    objNode = _objCritterDocument.SelectSingleNode("/chummer/categories/category[. = \"" + objXmlRequired.InnerText + "\"]");
                                if (objNode.Attributes["translate"] != null)
                                    strThisRequirement += "\n\t" + objNode.Attributes["translate"].InnerText;
                                else
                                    strThisRequirement = "\n\t" + objNode["name"].InnerText;
                            }
                        }
                        else if (objXmlRequired.Name == "metavariant")
                        {
                            // Check the Metavariant requirement.
                            if (objXmlRequired.InnerText == _objCharacter.Metavariant)
                                blnFound = true;
                            else
                            {
                                XmlNode objNode = _objMetatypeDocument.SelectSingleNode("/chummer/metatypes/metatype/metavariants/metavariant[id = \"" + objXmlRequired.InnerText + "\"]");
                                if (objNode == null)
                                    objNode = _objCritterDocument.SelectSingleNode("/chummer/metatypes/metatype/metavariants/metavariant[id = \"" + objXmlRequired.InnerText + "\"]");
                                if (objNode["translate"] != null)
                                    strThisRequirement += "\n\t" + objNode["translate"].InnerText;
                                else
                                    strThisRequirement += "\n\t" + objNode["name"].InnerText;
                            }
                        }
                        else if (objXmlRequired.Name == "inherited")
                        {
                            strThisRequirement += "\n\t" + LanguageManager.Instance.GetString("Message_SelectQuality_Inherit");
                        }
                        else if (objXmlRequired.Name == "careerkarma")
                        {
                            // Check Career Karma requirement.
                            if (_objCharacter.CareerKarma >= Convert.ToInt32(objXmlRequired.InnerText))
                                blnFound = true;
                            else
                                strThisRequirement = "\n\t" + LanguageManager.Instance.GetString("Message_SelectQuality_RequireKarma").Replace("{0}", objXmlRequired.InnerText);
                        }
                        else if (objXmlRequired.Name == "ess")
                        {
                            // Check Essence requirement.
                            if (objXmlRequired.InnerText.StartsWith("-"))
                            {
                                // Essence must be less than the value.
                                if (_objCharacter.Essence < Convert.ToDecimal(objXmlRequired.InnerText.Replace("-", string.Empty), GlobalOptions.Instance.CultureInfo))
                                    blnFound = true;
                            }
                            else
                            {
                                // Essence must be equal to or greater than the value.
                                if (_objCharacter.Essence >= Convert.ToDecimal(objXmlRequired.InnerText, GlobalOptions.Instance.CultureInfo))
                                    blnFound = true;
                            }

                        }
                        else if (objXmlRequired.Name == "skill")
                        {
                            // Check if the character has the required Skill.
                            foreach (Skill objSkill in _objCharacter.Skills)
                            {
                                if (objSkill.Name == objXmlRequired["name"].InnerText)
                                {
                                    if (objSkill.Rating >= Convert.ToInt32(objXmlRequired["val"].InnerText))
                                    {
                                        blnFound = true;
                                        break;
                                    }
                                }
                            }
                        }
                        else if (objXmlRequired.Name == "attribute")
                        {
                            // Check to see if an Attribute meets a requirement.
                            Attribute objAttribute = _objCharacter.GetAttribute(objXmlRequired["name"].InnerText);

                            if (objXmlRequired["total"] != null)
                            {
                                // Make sure the Attribute's total value meets the requirement.
                                if (objAttribute.TotalValue >= Convert.ToInt32(objXmlRequired["total"].InnerText))
                                    blnFound = true;
                            }
                        }
                        else if (objXmlRequired.Name == "attributetotal")
                        {
                            // Check if the character's Attributes add up to a particular total.
                            string strAttributes = objXmlRequired["attributes"].InnerText;
                            strAttributes = strAttributes.Replace("BOD", _objCharacter.GetAttribute("BOD").Value.ToString());
                            strAttributes = strAttributes.Replace("AGI", _objCharacter.GetAttribute("AGI").Value.ToString());
                            strAttributes = strAttributes.Replace("REA", _objCharacter.GetAttribute("REA").Value.ToString());
                            strAttributes = strAttributes.Replace("STR", _objCharacter.GetAttribute("STR").Value.ToString());
                            strAttributes = strAttributes.Replace("CHA", _objCharacter.GetAttribute("CHA").Value.ToString());
                            strAttributes = strAttributes.Replace("INT", _objCharacter.GetAttribute("INT").Value.ToString());
                            strAttributes = strAttributes.Replace("INT", _objCharacter.GetAttribute("LOG").Value.ToString());
                            strAttributes = strAttributes.Replace("WIL", _objCharacter.GetAttribute("WIL").Value.ToString());
                            strAttributes = strAttributes.Replace("MAG", _objCharacter.GetAttribute("MAG").Value.ToString());
                            strAttributes = strAttributes.Replace("RES", _objCharacter.GetAttribute("RES").Value.ToString());
                            strAttributes = strAttributes.Replace("EDG", _objCharacter.GetAttribute("EDG").Value.ToString());

                            XmlDocument objXmlDocument = new XmlDocument();
                            XPathNavigator nav = objXmlDocument.CreateNavigator();
                            XPathExpression xprAttributes = nav.Compile(strAttributes);
                            if (Convert.ToInt32(nav.Evaluate(xprAttributes)) >= Convert.ToInt32(objXmlRequired["val"].InnerText))
                                blnFound = true;
                        }
                        else if (objXmlRequired.Name == "skillgrouptotal")
                        {
                            // Check if the total combined Ratings of Skill Groups adds up to a particular total.
                            int intTotal = 0;
                            string[] strGroups = objXmlRequired["skillgroups"].InnerText.Split('+');
                            for (int i = 0; i <= strGroups.Length - 1; i++)
                            {
                                foreach (SkillGroup objGroup in _objCharacter.SkillGroups)
                                {
                                    if (objGroup.Name == strGroups[i])
                                    {
                                        intTotal += objGroup.Rating;
                                        break;
                                    }
                                }
                            }

                            if (intTotal >= Convert.ToInt32(objXmlRequired["val"].InnerText))
                                blnFound = true;
                        }
                        else if (objXmlRequired.Name == "cyberwares")
                        {
                            // Check to see if the character has a number of the required Cyberware/Bioware items.
                            int intTotal = 0;

                            // Check Cyberware.
                            foreach (XmlNode objXmlCyberware in objXmlRequired.SelectNodes("cyberware"))
                            {
                                foreach (Cyberware objCyberware in _objCharacter.Cyberware)
                                {
                                    if (objCyberware.Name == objXmlCyberware.InnerText)
                                    {
                                        if (objXmlCyberware.Attributes["select"] == null)
                                        {
                                            intTotal++;
                                            break;
                                        }
                                        else if (objXmlCyberware.Attributes["select"].InnerText == objCyberware.Location)
                                        {
                                            intTotal++;
                                            break;
                                        }
                                    }
                                }
                            }

                            // Check Bioware.
                            foreach (XmlNode objXmlBioware in objXmlRequired.SelectNodes("bioware"))
                            {
                                foreach (Cyberware objCyberware in _objCharacter.Cyberware)
                                {
                                    if (objCyberware.Name == objXmlBioware.InnerText)
                                    {
                                        intTotal++;
                                        break;
                                    }
                                }
                            }

                            // Check Cyberware name that contain a straing.
                            foreach (XmlNode objXmlCyberware in objXmlRequired.SelectNodes("cyberwarecontains"))
                            {
                                foreach (Cyberware objCyberware in _objCharacter.Cyberware)
                                {
                                    if (objCyberware.Name.Contains(objXmlCyberware.InnerText))
                                    {
                                        if (objXmlCyberware.Attributes["select"] == null)
                                        {
                                            intTotal++;
                                            break;
                                        }
                                        else if (objXmlCyberware.Attributes["select"].InnerText == objCyberware.Location)
                                        {
                                            intTotal++;
                                            break;
                                        }
                                    }
                                }
                            }

                            // Check Bioware name that contain a straing.
                            foreach (XmlNode objXmlCyberware in objXmlRequired.SelectNodes("biowarecontains"))
                            {
                                foreach (Cyberware objCyberware in _objCharacter.Cyberware)
                                {
                                    if (objCyberware.Name.Contains(objXmlCyberware.InnerText))
                                    {
                                        if (objXmlCyberware.Attributes["select"] == null)
                                        {
                                            intTotal++;
                                            break;
                                        }
                                        else if (objXmlCyberware.Attributes["select"].InnerText == objCyberware.Location)
                                        {
                                            intTotal++;
                                            break;
                                        }
                                    }
                                }
                            }

                            // Check for Cyberware Plugins.
                            foreach (XmlNode objXmlCyberware in objXmlRequired.SelectNodes("cyberwareplugin"))
                            {
                                foreach (Cyberware objCyberware in _objCharacter.Cyberware)
                                {
                                    foreach (Cyberware objPlugin in objCyberware.Cyberwares)
                                    {
                                        if (objPlugin.Name == objXmlCyberware.InnerText)
                                        {
                                            intTotal++;
                                            break;
                                        }
                                    }
                                }
                            }

                            // Check for Cyberware Categories.
                            foreach (XmlNode objXmlCyberware in objXmlRequired.SelectNodes("cyberwarecategory"))
                            {
                                foreach (Cyberware objCyberware in _objCharacter.Cyberware)
                                {
                                    if (objCyberware.Category == objXmlCyberware.InnerText)
                                        intTotal++;
                                }
                            }

                            if (intTotal >= Convert.ToInt32(objXmlRequired["count"].InnerText))
                                blnFound = true;
                        }
                        else if (objXmlRequired.Name == "streetcredvsnotoriety")
                        {
                            // Street Cred must be higher than Notoriety.
                            if (_objCharacter.StreetCred >= _objCharacter.Notoriety)
                                blnFound = true;
                        }
                        else if (objXmlRequired.Name == "damageresistance")
                        {
                            // Damage Resistance must be a particular value.
                            ImprovementManager _objImprovementManager = new ImprovementManager(_objCharacter);
                            if (_objCharacter.BOD.TotalValue + _objImprovementManager.ValueOf(Improvement.ImprovementType.DamageResistance) >= Convert.ToInt32(objXmlRequired.InnerText))
                                blnFound = true;
                        }

                        // If this item was not found, fail the AllOfMet condition.
                        if (!blnFound)
                            blnAllOfMet = false;
                    }

                    // Update the flag for requirements met.
                    blnRequirementMet = blnRequirementMet && blnAllOfMet;
                    strRequirement += strThisRequirement;
                }

                // The character has not met the requirements, so display a message and uncheck the item.
                if (!blnRequirementMet)
                {
                    string strMessage = LanguageManager.Instance.GetString("Message_SelectQuality_QualityRequirement");
                    strMessage += strRequirement;

                    if (blnShowMessage)
                        MessageBox.Show(strMessage, LanguageManager.Instance.GetString("MessageTitle_SelectQuality_QualityRequirement"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return false;
                }
            }

            return true;
        }