public frmSelectLifestyleAdvanced(Lifestyle objLifestyle, Character objCharacter)
 {
     InitializeComponent();
     LanguageManager.Instance.Load(GlobalOptions.Instance.Language, this);
     _objCharacter = objCharacter;
     _objLifestyle = objLifestyle;
     MoveControls();
 }
Пример #2
0
        /// <summary>
        /// Check the character and determine if it has broken any of the rules.
        /// </summary>
        public bool ValidateCharacter()
        {
            bool blnValid = true;
            string strMessage = LanguageManager.Instance.GetString("Message_InvalidBeginning");

            // Number of items over the specified Availability the character is allowed to have (typically from the Restricted Gear Quality).
            int intRestrictedAllowed = _objImprovementManager.ValueOf(Improvement.ImprovementType.RestrictedItemCount);
            int intRestrictedCount = 0;
            string strAvailItems = "";
            string strExConItems = "";
            string strCyberwareGrade = "";

            // Check limits specific to the Priority build method.
            if (_objCharacter.BuildMethod == CharacterBuildMethod.Priority ||
                _objCharacter.BuildMethod == CharacterBuildMethod.SumtoTen)
            {
                // Check if the character has more than 1 Martial Art
                int intMartialArts = _objCharacter.MartialArts.Count;
                if (intMartialArts > 1)
                    strMessage += "\n\t" +
                                  LanguageManager.Instance.GetString("Message_InvalidPointExcess")
                                      .Replace("{0}",
                                          ((1 - intMartialArts)*-1).ToString() + " " +
                                          LanguageManager.Instance.GetString("String_MartialArtsCount"));

                // Check if the character has more than 5 Techniques in a Martial Art
                if (_objCharacter.MartialArts.Count > 0)
                {
                    int intTechniques = _objCharacter.MartialArts[0].Advantages.Count;
                    if (intTechniques > 5)
                        strMessage += "\n\t" +
                                      LanguageManager.Instance.GetString("Message_InvalidPointExcess")
                                          .Replace("{0}",
                                              ((5 - intTechniques)*-1).ToString() + " " +
                                              LanguageManager.Instance.GetString("String_TechniquesCount"));
                }

                // Check if the character has gone over limits from optional rules
                int intContactPointsUsed = 0;
                int intGroupContacts = 0;
                int intHighPlaces = 0;
                foreach (ContactControl objContactControl in panContacts.Controls)
                {
                    if (!objContactControl.Free)
                    {
                        if (objContactControl.IsGroup)
                        {
                            intGroupContacts += objContactControl.ContactObject.ContactPoints;
                        }
                        else if (objContactControl.ConnectionRating >= 8 && _objCharacter.FriendsInHighPlaces)
                        {
                            intHighPlaces += (objContactControl.ConnectionRating +
                                              objContactControl.LoyaltyRating);
                        }
                        else
                        {
                            // The Contact's BP cost = their Connection + Loyalty Rating.
                            intContactPointsUsed += (objContactControl.ConnectionRating +
                                                     objContactControl.LoyaltyRating)*_objOptions.BPContact;
                        }

                    }
                }

                // If the option for CHA * X free points of Contacts is enabled, deduct that amount of points (or as many points have been spent if not the full amount).
                int intFreePoints = (_objCharacter.CHA.TotalValue*_objOptions.FreeContactsMultiplier);

                if (intContactPointsUsed >= intFreePoints)
                {
                    intContactPointsUsed -= intFreePoints;
                }
                else
                {
                    intContactPointsUsed = 0;
                }

                intContactPointsUsed += Math.Max(0, intHighPlaces - (_objCharacter.CHA.TotalValue*4));

                //if (intContactPointsUsed > _objCharacter.ContactPoints)
                //    strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_InvalidPointExcess").Replace("{0}", ((_objCharacter.ContactPoints - intContactPointsUsed) * -1).ToString() + " " + LanguageManager.Instance.GetString("String_Contacts"));

                // Calculate the BP used by Enemies. These are added to the BP since they are technically
                // a Negative Quality.
                int intPointsUsed = 0;
                int intNegativePoints = 0;
                foreach (ContactControl objContactControl in panEnemies.Controls)
                {
                    if (!objContactControl.Free)
                    {
                        // The Enemy's BP cost = their Connection + Loyalty Rating.
                        //intPointsUsed -= (objContactControl.ConnectionRating + objContactControl.LoyaltyRating)*
                        //                 _objOptions.KarmaContact;
                        intNegativePoints -= (objContactControl.ConnectionRating + objContactControl.LoyaltyRating) * _objOptions.KarmaEnemy;
                    }
                }

                // Calculate the BP used by Positive Qualities.
                intPointsUsed = 0;
                foreach (Quality objQuality in _objCharacter.Qualities)
                {
                    if (objQuality.Type == QualityType.Positive && objQuality.ContributeToBP && objQuality.ContributeToLimit)
                    {
                        intPointsUsed += objQuality.BP;
                    }
                }
                // Group contacts are counted as positive qualities
                intPointsUsed += intGroupContacts;

                // Deduct the amount for free Qualities.
                intPointsUsed -= _objImprovementManager.ValueOf(Improvement.ImprovementType.FreePositiveQualities);
                int intPositivePointsUsed = intPointsUsed;

                // Calculate the BP used for Negative Qualities.
                intPointsUsed = 0;
                foreach (Quality objQuality in _objCharacter.Qualities)
                {
                    if (objQuality.Type == QualityType.Negative && objQuality.ContributeToBP && objQuality.ContributeToLimit)
                    {
                        intPointsUsed += objQuality.BP;
                        intNegativePoints += objQuality.BP;
                    }
                }

                // Deduct the amount for free Qualities.
                intPointsUsed -= _objImprovementManager.ValueOf(Improvement.ImprovementType.FreeNegativeQualities);
                intNegativePoints -= _objImprovementManager.ValueOf(Improvement.ImprovementType.FreeNegativeQualities);

                // If the character is only allowed to gain 25 Karma from Negative Qualities but allowed to take as many as they'd like, limit their refunded points.
                if (_objOptions.ExceedNegativeQualitiesLimit)
                {
                    if (intNegativePoints < (_objCharacter.MaxKarma*-1))
                    {
                        intNegativePoints = -1 * _objCharacter.MaxKarma;
                    }
                }

                // if positive points > 25
                if (intPositivePointsUsed > _objCharacter.MaxKarma && !_objOptions.ExceedPositiveQualities)
                {
                    strMessage += "\n\t" +
                                  LanguageManager.Instance.GetString("Message_PositiveQualityLimit")
                                      .Replace("{0}", (_objCharacter.MaxKarma).ToString());
                    blnValid = false;
                }

                // if negative points > 25
                if (intNegativePoints < (_objCharacter.MaxKarma * -1) && !_objOptions.ExceedNegativeQualities)
                {
                    strMessage += "\n\t" +
                                  LanguageManager.Instance.GetString("Message_NegativeQualityLimit")
                                      .Replace("{0}", (_objCharacter.MaxKarma).ToString());
                    blnValid = false;
                }

            }

            if (_objCharacter.Contacts.Any(x => x.Connection <= 7 && (x.Connection + x.Loyalty) > 7 && !x.Free))
            {
                blnValid = false;
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_HighContact");
            }

            // Check if the character has gone over the Build Point total.
            int intBuildPoints = CalculateBP();
            if (intBuildPoints < 0 && !_blnFreestyle)
            {
                blnValid = false;
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_InvalidPointExcess").Replace("{0}", (intBuildPoints * -1).ToString() + " " + LanguageManager.Instance.GetString("String_Karma"));
            }

            // if character has more than permitted Metagenetic qualities
            if (_objCharacter.MetageneticLimit > 0)
            {
                int metageneticPositiveQualities = 0;
                int metageneticNegativeQualities = 0;
                foreach (Quality objQuality in _objCharacter.Qualities)
                {
                    if (objQuality._strMetagenetic == "yes" && objQuality.OriginSource.ToString() != QualitySource.Metatype.ToString())
                    {
                        if (objQuality.Type == QualityType.Positive)
                        {
                            metageneticPositiveQualities = metageneticPositiveQualities + objQuality.BP;
                        }
                        else if (objQuality.Type == QualityType.Negative)
                        {
                            metageneticNegativeQualities = metageneticNegativeQualities - objQuality.BP;
                        }
                    }
                }
                if (metageneticNegativeQualities > _objCharacter.MetageneticLimit)
                {
                    strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_OverNegativeMetagenicQualities").Replace("{0}", metageneticNegativeQualities.ToString()).Replace("{1}", _objCharacter.MetageneticLimit.ToString());
                    blnValid = false;
                }
                if (metageneticPositiveQualities > _objCharacter.MetageneticLimit)
                {
                    strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_OverPositiveMetagenicQualities").Replace("{0}", metageneticPositiveQualities.ToString()).Replace("{1}", _objCharacter.MetageneticLimit.ToString());
                    blnValid = false;
                }

                if (metageneticNegativeQualities != metageneticPositiveQualities && metageneticNegativeQualities != (metageneticPositiveQualities - 1))
                {
                    strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_MetagenicQualitiesUnbalanced").Replace("{0}", metageneticNegativeQualities.ToString()).Replace("{1}", (metageneticPositiveQualities - 1).ToString()).Replace("{2}", metageneticPositiveQualities.ToString());
                    blnValid = false;
                }
                //Subtract 1 karma to balance Metagenic Qualities
                if (metageneticNegativeQualities == (metageneticPositiveQualities - 1))
                {
                    if (intBuildPoints > 0)
                    {
                        if (MessageBox.Show(LanguageManager.Instance.GetString("Message_MetagenicQualitiesSubtractingKarma").Replace("{0}", intBuildPoints.ToString()), LanguageManager.Instance.GetString("MessageTitle_ExtraKarma"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                        {
                            blnValid = false;
                        }
                        else
                        {
                            intBuildPoints = intBuildPoints - 1;
                        }
                    }
                    else
                    {
                        strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_MetagenicQualitiesInsufficientKarma").Replace("{0}", intBuildPoints.ToString());
                        blnValid = false;
                    }
                }

            }
            // Check if the character has gone over on Primary Attributes
            if (_objCharacter.Attributes < 0)
            {
                blnValid = false;
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_InvalidAttributeExcess").Replace("{0}", ((_objCharacter.Attributes) * -1).ToString());
            }

            // Check if the character has gone over on Special Attributes
            if (_objCharacter.Special < 0)
            {
                blnValid = false;
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_InvalidSpecialExcess").Replace("{0}", ((_objCharacter.Special) * -1).ToString());
            }

            // Check if the character has gone over on Skill Groups
            if (_objCharacter.SkillsSection.SkillGroupPoints < 0)
            {
                blnValid = false;
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_InvalidSkillGroupExcess").Replace("{0}", ((_objCharacter.SkillsSection.SkillGroupPoints) * -1).ToString());
            }

            // Check if the character has gone over on Active Skills
            if (_objCharacter.SkillsSection.SkillPoints < 0)
            {
                blnValid = false;
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_InvalidActiveSkillExcess").Replace("{0}", ((_objCharacter.SkillsSection.SkillPoints) * -1).ToString());
            }

            // Check if the character has gone over on Knowledge Skills
            if (_objCharacter.SkillsSection.KnowledgeSkillPointsRemain < 0)
            {
                blnValid = false;
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_InvalidKnowledgeSkillExcess").Replace("{0}", ((_objCharacter.SkillsSection.KnowledgeSkillPointsRemain) * -1).ToString());
            }

            // Check if the character has gone over the Nuyen limit.
            int intNuyen = CalculateNuyen();
            if (intNuyen < 0)
            {
                blnValid = false;
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_InvalidNuyenExcess").Replace("{0}", String.Format("{0:###,###,##0¥}", (intNuyen * -1)));
            }

            // Check if the character's Essence is above 0.
            decimal decEss = _objCharacter.Essence;
            if (decEss < 0.01m && _objCharacter.ESS.MetatypeMaximum > 0)
            {
                blnValid = false;
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_InvalidEssenceExcess").Replace("{0}", ((decEss - 0.01m) * -1).ToString());
            }

            // If the character has Magician enabled, make sure a Tradition has been selected.
            if (_objCharacter.MagicianEnabled && _objCharacter.MagicTradition == "")
            {
                blnValid = false;
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_InvalidNoTradition");
            }

            // If the character has RES enabled, make sure a Stream has been selected.
            if (_objCharacter.RESEnabled && _objCharacter.TechnomancerStream == "")
            {
                blnValid = false;
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_InvalidNoStream");
            }

            // Check if the character has more than the permitted amount of native languages.
            int intLanguages = _objCharacter.SkillsSection.KnowledgeSkills.Count(objSkill => (objSkill.SkillCategory == "Language" && objSkill.Rating == 0));

            //TODO: This should probably be an improvement type. Also slightly excessive, as Bilingual normally has a limit of 1.
            int intLanguageLimit = 1 + _objCharacter.Qualities.Count(objQuality => objQuality.Name == "Bilingual");

            if (intLanguages > intLanguageLimit)
            {
                blnValid = false;
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_OverLanguageLimit").Replace("{0}",intLanguages.ToString()).Replace("{1}", intLanguageLimit.ToString());
            }

            // Check the character's equipment and make sure nothing goes over their set Maximum Availability.
            bool blnRestrictedGearUsed = false;
            // Gear Availability.
            foreach (Gear objGear in _objCharacter.Gear)
            {
                if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                {
                    if ((GetAvailInt(objGear.TotalAvail(true)) <= 24) && ((GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)))
                    {
                        blnRestrictedGearUsed = true;
                    }
                    else if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                    {
                        intRestrictedCount++;
                        strAvailItems += "\n\t\t" + objGear.DisplayNameShort;
                    }
                }

                else if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                {
                    intRestrictedCount++;
                    strAvailItems += "\n\t\t" + objGear.DisplayNameShort;
                }
                foreach (Gear objChild in objGear.Children)
                {
                    if (!objChild.TotalAvail().StartsWith("+"))
                    {

                        if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                        {
                            if ((GetAvailInt(objGear.TotalAvail(true)) <= 24) && ((GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)))
                            {
                                blnRestrictedGearUsed = true;
                            }
                            else if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                            {
                                intRestrictedCount++;
                                strAvailItems += "\n\t\t" + objGear.DisplayNameShort;
                            }
                        }

                        else if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                        {
                            intRestrictedCount++;
                            strAvailItems += "\n\t\t" + objGear.DisplayNameShort;
                        }
                        foreach (Gear objSubChild in objChild.Children)
                        {
                            if (!objSubChild.TotalAvail().StartsWith("+"))
                            {
                                if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                                {
                                    if ((GetAvailInt(objGear.TotalAvail(true)) <= 24) && ((GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)))
                                    {
                                        blnRestrictedGearUsed = true;
                                    }
                                    else if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                    {
                                        intRestrictedCount++;
                                        strAvailItems += "\n\t\t" + objGear.DisplayNameShort;
                                    }
                                }

                                else if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                {
                                    intRestrictedCount++;
                                    strAvailItems += "\n\t\t" + objGear.DisplayNameShort;
                                }
                            }
                        }
                    }
                }
            }

            // Cyberware Availability.
            foreach (Cyberware objCyberware in _objCharacter.Cyberware)
            {
                if (objCyberware.Grade.Name == "Deltaware" || objCyberware.Grade.Name == "Betaware")
                {
                    strCyberwareGrade += "\n\t\t" + objCyberware.DisplayNameShort;
                }

                if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                {
                    if ((GetAvailInt(objCyberware.TotalAvail) <= 24) && ((GetAvailInt(objCyberware.TotalAvail) > _objCharacter.MaximumAvailability)))
                    {
                        blnRestrictedGearUsed = true;
                    }
                    else if (GetAvailInt(objCyberware.TotalAvail) > _objCharacter.MaximumAvailability)
                    {
                        intRestrictedCount++;
                        strAvailItems += "\n\t\t" + objCyberware.DisplayNameShort;
                    }
                }

                else if (GetAvailInt(objCyberware.TotalAvail) > _objCharacter.MaximumAvailability)
                {
                    intRestrictedCount++;
                    strAvailItems += "\n\t\t" + objCyberware.DisplayNameShort;
                }

                foreach (Cyberware objPlugin in objCyberware.Children)
                {
                    if (!objPlugin.TotalAvail.StartsWith("+"))
                    {
                        if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                        {
                            if ((GetAvailInt(objPlugin.TotalAvail) <= 24) && ((GetAvailInt(objPlugin.TotalAvail) > _objCharacter.MaximumAvailability)))
                            {
                                blnRestrictedGearUsed = true;
                            }
                            else if (GetAvailInt(objPlugin.TotalAvail) > _objCharacter.MaximumAvailability)
                            {
                                intRestrictedCount++;
                                strAvailItems += "\n\t\t" + objPlugin.DisplayNameShort;
                            }
                        }

                        else if (GetAvailInt(objCyberware.TotalAvail) > _objCharacter.MaximumAvailability)
                        {
                            intRestrictedCount++;
                            strAvailItems += "\n\t\t" + objCyberware.DisplayNameShort;
                        }
                    }

                    foreach (Gear objGear in objPlugin.Gear)
                    {
                        if (!objGear.TotalAvail().StartsWith("+"))
                        {
                            if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                            {
                                if ((GetAvailInt(objGear.TotalAvail(true)) <= 24) && ((GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)))
                                {
                                    blnRestrictedGearUsed = true;
                                }
                                else if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                {
                                    intRestrictedCount++;
                                    strAvailItems += "\n\t\t" + objGear.DisplayNameShort;
                                }
                            }

                            else if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                            {
                                intRestrictedCount++;
                                strAvailItems += "\n\t\t" + objGear.DisplayNameShort;
                            }
                        }
                        foreach (Gear objChild in objGear.Children)
                        {
                            if (!objChild.TotalAvail().StartsWith("+"))
                            {
                                if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                                {
                                    if ((GetAvailInt(objChild.TotalAvail(true)) <= 24) && ((GetAvailInt(objChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)))
                                    {
                                        blnRestrictedGearUsed = true;
                                    }
                                    else if (GetAvailInt(objChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                    {
                                        intRestrictedCount++;
                                        strAvailItems += "\n\t\t" + objChild.DisplayNameShort;
                                    }
                                }

                                else if (GetAvailInt(objChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                {
                                    intRestrictedCount++;
                                    strAvailItems += "\n\t\t" + objChild.DisplayNameShort;
                                }
                            }
                            foreach (Gear objSubChild in objChild.Children)
                            {
                                if (!objSubChild.TotalAvail().StartsWith("+"))
                                {
                                    if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                                    {
                                        if ((GetAvailInt(objSubChild.TotalAvail(true)) <= 24) && ((GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)))
                                        {
                                            blnRestrictedGearUsed = true;
                                        }
                                        else if (GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                        {
                                            intRestrictedCount++;
                                            strAvailItems += "\n\t\t" + objSubChild.DisplayNameShort;
                                        }
                                    }

                                    else if (GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                    {
                                        intRestrictedCount++;
                                        strAvailItems += "\n\t\t" + objSubChild.DisplayNameShort;
                                    }
                                }
                            }
                        }
                    }
                }

                foreach (Gear objGear in objCyberware.Gear)
                {
                    if (!objGear.TotalAvail().StartsWith("+"))
                    {

                        if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                        {
                            if ((GetAvailInt(objGear.TotalAvail(true)) <= 24) && ((GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)))
                            {
                                blnRestrictedGearUsed = true;
                            }
                            else if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                            {
                                intRestrictedCount++;
                                strAvailItems += "\n\t\t" + objGear.DisplayNameShort;
                            }
                        }

                        else if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                        {
                            intRestrictedCount++;
                            strAvailItems += "\n\t\t" + objGear.DisplayNameShort;
                        }
                    }
                    foreach (Gear objChild in objGear.Children)
                    {
                        if (!objChild.TotalAvail().StartsWith("+"))
                        {
                            if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                            {
                                if ((GetAvailInt(objChild.TotalAvail(true)) <= 24) && ((GetAvailInt(objChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)))
                                {
                                    blnRestrictedGearUsed = true;
                                }
                                else if (GetAvailInt(objChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                {
                                    intRestrictedCount++;
                                    strAvailItems += "\n\t\t" + objChild.DisplayNameShort;
                                }
                            }

                            else if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                            {
                                intRestrictedCount++;
                                strAvailItems += "\n\t\t" + objGear.DisplayNameShort;
                            }
                        }
                        foreach (Gear objSubChild in objChild.Children)
                        {
                            if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                            {
                                if ((GetAvailInt(objSubChild.TotalAvail(true)) <= 24) && ((GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)))
                                {
                                    blnRestrictedGearUsed = true;
                                }
                                else if (!objSubChild.TotalAvail().StartsWith("+"))
                                {
                                    if (GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                    {
                                        intRestrictedCount++;
                                        strAvailItems += "\n\t\t" + objSubChild.DisplayNameShort;
                                    }
                                }
                            }

                            else if (GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                            {
                                intRestrictedCount++;
                                strAvailItems += "\n\t\t" + objGear.DisplayNameShort;
                            }
                        }
                    }
                }
            }

            // Armor Availability.
            foreach (Armor objArmor in _objCharacter.Armor)
            {

                if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                {
                    if ((GetAvailInt(objArmor.TotalAvail) <= 24) && ((GetAvailInt(objArmor.TotalAvail) > _objCharacter.MaximumAvailability)))
                    {
                        blnRestrictedGearUsed = true;
                    }
                    else if (GetAvailInt(objArmor.TotalAvail) > _objCharacter.MaximumAvailability)
                    {
                        intRestrictedCount++;
                        strAvailItems += "\n\t\t" + objArmor.DisplayNameShort;
                    }
                }

                else if (GetAvailInt(objArmor.TotalAvail) > _objCharacter.MaximumAvailability)
                {
                    intRestrictedCount++;
                    strAvailItems += "\n\t\t" + objArmor.DisplayNameShort;
                }

                foreach (ArmorMod objMod in objArmor.ArmorMods)
                {
                    if (!objMod.TotalAvail.StartsWith("+"))
                    {
                        if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                        {
                            if ((GetAvailInt(objMod.TotalAvail) <= 24) && ((GetAvailInt(objMod.TotalAvail) > _objCharacter.MaximumAvailability)))
                            {
                                blnRestrictedGearUsed = true;
                            }
                            else if (GetAvailInt(objMod.TotalAvail) > _objCharacter.MaximumAvailability)
                            {
                                intRestrictedCount++;
                                strAvailItems += "\n\t\t" + objMod.DisplayNameShort;
                            }
                        }

                        else if (GetAvailInt(objArmor.TotalAvail) > _objCharacter.MaximumAvailability)
                        {
                            intRestrictedCount++;
                            strAvailItems += "\n\t\t" + objArmor.DisplayNameShort;
                        }
                    }

                    foreach (Gear objGear in objArmor.Gear)
                    {
                        if (!objGear.TotalAvail().StartsWith("+"))
                        {
                            if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                            {
                                if ((GetAvailInt(objGear.TotalAvail(true)) <= 24) && ((GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)))
                                {
                                    blnRestrictedGearUsed = true;
                                }
                                else if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                {
                                    intRestrictedCount++;
                                    strAvailItems += "\n\t\t" + objGear.DisplayNameShort;
                                }
                            }

                            else if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                            {
                                intRestrictedCount++;
                                strAvailItems += "\n\t\t" + objGear.DisplayNameShort;
                            }
                        }
                        foreach (Gear objChild in objGear.Children)
                        {
                            if (!objChild.TotalAvail().StartsWith("+"))
                            {
                                if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                                {
                                    if ((GetAvailInt(objChild.TotalAvail(true)) <= 24) && ((GetAvailInt(objChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)))
                                    {
                                        blnRestrictedGearUsed = true;
                                    }
                                    else if (GetAvailInt(objChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                    {
                                        intRestrictedCount++;
                                        strAvailItems += "\n\t\t" + objChild.DisplayNameShort;
                                    }
                                }

                                else if (GetAvailInt(objChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                {
                                    intRestrictedCount++;
                                    strAvailItems += "\n\t\t" + objChild.DisplayNameShort;
                                }
                            }
                            foreach (Gear objSubChild in objChild.Children)
                            {
                                if (!objSubChild.TotalAvail().StartsWith("+"))
                                {
                                    if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                                    {
                                        if ((GetAvailInt(objSubChild.TotalAvail(true)) <= 24) && ((GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)))
                                        {
                                            blnRestrictedGearUsed = true;
                                        }
                                        else if (GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                        {
                                            intRestrictedCount++;
                                            strAvailItems += "\n\t\t" + objSubChild.DisplayNameShort;
                                        }
                                    }

                                    else if (GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                    {
                                        intRestrictedCount++;
                                        strAvailItems += "\n\t\t" + objSubChild.DisplayNameShort;
                                    }
                                }
                            }
                        }
                    }
                }

                foreach (Gear objGear in objArmor.Gear)
                {
                    if (!objGear.TotalAvail().StartsWith("+"))
                    {

                        if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                        {
                            if ((GetAvailInt(objGear.TotalAvail(true)) <= 24) && ((GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)))
                            {
                                blnRestrictedGearUsed = true;
                            }
                            else if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                            {
                                intRestrictedCount++;
                                strAvailItems += "\n\t\t" + objGear.DisplayNameShort;
                            }
                        }

                        else if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                        {
                            intRestrictedCount++;
                            strAvailItems += "\n\t\t" + objGear.DisplayNameShort;
                        }
                    }
                    foreach (Gear objChild in objGear.Children)
                    {
                        if (!objChild.TotalAvail().StartsWith("+"))
                        {
                            if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                            {
                                if ((GetAvailInt(objChild.TotalAvail(true)) <= 24) && ((GetAvailInt(objChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)))
                                {
                                    blnRestrictedGearUsed = true;
                                }
                                else if (GetAvailInt(objChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                {
                                    intRestrictedCount++;
                                    strAvailItems += "\n\t\t" + objChild.DisplayNameShort;
                                }
                            }

                            else if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                            {
                                intRestrictedCount++;
                                strAvailItems += "\n\t\t" + objGear.DisplayNameShort;
                            }
                        }
                        foreach (Gear objSubChild in objChild.Children)
                        {
                            if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                            {
                                if ((GetAvailInt(objSubChild.TotalAvail(true)) <= 24) && ((GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)))
                                {
                                    blnRestrictedGearUsed = true;
                                }
                                else if (!objSubChild.TotalAvail().StartsWith("+"))
                                {
                                    if (GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                    {
                                        intRestrictedCount++;
                                        strAvailItems += "\n\t\t" + objSubChild.DisplayNameShort;
                                    }
                                }
                            }

                            else if (GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                            {
                                intRestrictedCount++;
                                strAvailItems += "\n\t\t" + objGear.DisplayNameShort;
                            }
                        }
                    }
                }
            }

            // Weapon Availability.
            foreach (Weapon objWeapon in _objCharacter.Weapons)
            {
                if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                {
                    if ((GetAvailInt(objWeapon.TotalAvail) <= 24) && ((GetAvailInt(objWeapon.TotalAvail) > _objCharacter.MaximumAvailability)))
                    {
                        blnRestrictedGearUsed = true;
                    }
                    else if (GetAvailInt(objWeapon.TotalAvail) > _objCharacter.MaximumAvailability)
                    {
                        intRestrictedCount++;
                        strAvailItems += "\n\t\t" + objWeapon.DisplayNameShort;
                    }
                }

                else if (GetAvailInt(objWeapon.TotalAvail) > _objCharacter.MaximumAvailability)
                {
                    intRestrictedCount++;
                    strAvailItems += "\n\t\t" + objWeapon.DisplayNameShort;
                }
                foreach (WeaponAccessory objAccessory in objWeapon.WeaponAccessories)
                {
                    if (!objAccessory.TotalAvail.StartsWith("+"))
                    {
                        if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                        {
                            if ((GetAvailInt(objAccessory.TotalAvail) <= 24) && ((GetAvailInt(objAccessory.TotalAvail) > _objCharacter.MaximumAvailability)) && !objAccessory.IncludedInWeapon)
                            {
                                blnRestrictedGearUsed = true;
                            }
                            else if (GetAvailInt(objAccessory.TotalAvail) > _objCharacter.MaximumAvailability && !objAccessory.IncludedInWeapon)
                            {
                                intRestrictedCount++;
                                strAvailItems += "\n\t\t" + objAccessory.DisplayNameShort;
                            }
                        }

                        else if (GetAvailInt(objWeapon.TotalAvail) > _objCharacter.MaximumAvailability && !objAccessory.IncludedInWeapon)
                        {
                            intRestrictedCount++;
                            strAvailItems += "\n\t\t" + objWeapon.DisplayNameShort;
                        }
                    }

                    foreach (Gear objGear in objAccessory.Gear)
                    {
                        if (!objGear.TotalAvail().StartsWith("+"))
                        {
                            if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                            {
                                if ((GetAvailInt(objGear.TotalAvail(true)) <= 24) && ((GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)))
                                {
                                    blnRestrictedGearUsed = true;
                                }
                                else if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                {
                                    intRestrictedCount++;
                                    strAvailItems += "\n\t\t" + objGear.DisplayNameShort;
                                }
                            }

                            else if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                            {
                                intRestrictedCount++;
                                strAvailItems += "\n\t\t" + objGear.DisplayNameShort;
                            }
                        }
                        foreach (Gear objChild in objGear.Children)
                        {
                            if (!objChild.TotalAvail().StartsWith("+"))
                            {
                                if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                                {
                                    if ((GetAvailInt(objChild.TotalAvail(true)) <= 24) && ((GetAvailInt(objChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)))
                                    {
                                        blnRestrictedGearUsed = true;
                                    }
                                    else if (GetAvailInt(objChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                    {
                                        intRestrictedCount++;
                                        strAvailItems += "\n\t\t" + objChild.DisplayNameShort;
                                    }
                                }

                                else if (GetAvailInt(objChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                {
                                    intRestrictedCount++;
                                    strAvailItems += "\n\t\t" + objChild.DisplayNameShort;
                                }
                            }
                            foreach (Gear objSubChild in objChild.Children)
                            {
                                if (!objSubChild.TotalAvail().StartsWith("+"))
                                {
                                    if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                                    {
                                        if ((GetAvailInt(objSubChild.TotalAvail(true)) <= 24) && ((GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)))
                                        {
                                            blnRestrictedGearUsed = true;
                                        }
                                        else if (GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                        {
                                            intRestrictedCount++;
                                            strAvailItems += "\n\t\t" + objSubChild.DisplayNameShort;
                                        }
                                    }

                                    else if (GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                    {
                                        intRestrictedCount++;
                                        strAvailItems += "\n\t\t" + objSubChild.DisplayNameShort;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // Vehicle Availability.
            foreach (Vehicle objVehicle in _objCharacter.Vehicles)
            {
                if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                {
                    if ((GetAvailInt(objVehicle.CalculatedAvail) > _objCharacter.MaximumAvailability) && (GetAvailInt(objVehicle.CalculatedAvail) <= 24))
                    {
                        blnRestrictedGearUsed = true;
                    }
                    else if (GetAvailInt(objVehicle.CalculatedAvail) > _objCharacter.MaximumAvailability)
                    {
                        intRestrictedCount++;
                        strAvailItems += "\n\t\t" + objVehicle.DisplayNameShort;
                    }
                }
                else if (GetAvailInt(objVehicle.CalculatedAvail) > _objCharacter.MaximumAvailability)
                {
                    intRestrictedCount++;
                    strAvailItems += "\n\t\t" + objVehicle.DisplayNameShort;
                }
                foreach (VehicleMod objVehicleMod in objVehicle.Mods)
                {
                    if (!objVehicleMod.TotalAvail.StartsWith("+"))
                    {
                        if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                        {
                            if ((GetAvailInt(objVehicleMod.TotalAvail) > _objCharacter.MaximumAvailability) && (GetAvailInt(objVehicleMod.TotalAvail) <= 24) && !objVehicleMod.IncludedInVehicle)
                            {
                                blnRestrictedGearUsed = true;
                            }
                            else if (GetAvailInt(objVehicleMod.TotalAvail) > _objCharacter.MaximumAvailability && !objVehicleMod.IncludedInVehicle)
                            {
                                intRestrictedCount++;
                                strAvailItems += "\n\t\t" + objVehicleMod.DisplayNameShort;
                            }
                        }
                        foreach (Weapon objWeapon in objVehicleMod.Weapons)
                        {
                            if ((GetAvailInt(objWeapon.TotalAvail) > _objCharacter.MaximumAvailability) && (GetAvailInt(objWeapon.TotalAvail) <= 24))
                            {
                                blnRestrictedGearUsed = true;
                            }
                            else if (GetAvailInt(objWeapon.TotalAvail) > _objCharacter.MaximumAvailability)
                            {
                                intRestrictedCount++;
                                strAvailItems += "\n\t\t" + objWeapon.DisplayNameShort;
                            }
                            foreach (WeaponAccessory objAccessory in objWeapon.WeaponAccessories)
                            {
                                if (!objAccessory.TotalAvail.StartsWith("+"))
                                {
                                    if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                                    {
                                        if ((GetAvailInt(objAccessory.TotalAvail) > _objCharacter.MaximumAvailability) && (GetAvailInt(objAccessory.TotalAvail) <= 24) && !objAccessory.IncludedInWeapon)
                                        {
                                            blnRestrictedGearUsed = true;
                                        }
                                        else if (GetAvailInt(objAccessory.TotalAvail) > _objCharacter.MaximumAvailability)
                                        {
                                            intRestrictedCount++;
                                            strAvailItems += "\n\t\t" + objAccessory.DisplayNameShort;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    foreach (Gear objGear in objVehicle.Gear)
                    {
                        if (!objGear.TotalAvail().StartsWith("+"))
                        {
                            if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                            {
                                if ((GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability) && (GetAvailInt(objGear.TotalAvail(true)) <= 24))
                                {
                                    blnRestrictedGearUsed = true;
                                }
                                else if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                {
                                    intRestrictedCount++;
                                    strAvailItems += "\n\t\t" + objGear.DisplayNameShort;
                                }
                            }
                        }
                        foreach (Gear objChild in objGear.Children)
                        {
                            if (!objChild.TotalAvail().StartsWith("+"))
                            {
                                if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                                {
                                    if ((GetAvailInt(objChild.TotalAvail(true)) > _objCharacter.MaximumAvailability) && (GetAvailInt(objChild.TotalAvail(true)) <= 24))
                                    {
                                        blnRestrictedGearUsed = true;
                                    }
                                    else if (GetAvailInt(objChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                    {
                                        intRestrictedCount++;
                                        strAvailItems += "\n\t\t" + objChild.DisplayNameShort;
                                    }
                                }
                            }
                            foreach (Gear objSubChild in objChild.Children)
                            {
                                if (!objSubChild.TotalAvail().StartsWith("+"))
                                {
                                    if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed)
                                    {
                                        if ((GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability) && (GetAvailInt(objSubChild.TotalAvail(true)) <= 24))
                                        {
                                            blnRestrictedGearUsed = true;
                                        }
                                        else if (GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability)
                                        {
                                            intRestrictedCount++;
                                            strAvailItems += "\n\t\t" + objSubChild.DisplayNameShort;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // Make sure the character is not carrying more items over the allowed Avail than they are allowed.
            if (intRestrictedCount > intRestrictedAllowed)
            {
                blnValid = false;
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_InvalidAvail").Replace("{0}", (intRestrictedCount - intRestrictedAllowed).ToString()).Replace("{1}", _objCharacter.MaximumAvailability.ToString());
                strMessage += strAvailItems;
            }

            if (!String.IsNullOrWhiteSpace(strExConItems))
            {
                blnValid = false;
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_InvalidExConWare");
                strMessage += strExConItems;
            }

            if (!String.IsNullOrWhiteSpace(strCyberwareGrade))
            {
                blnValid = false;
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_InvalidCyberwareGrades");
                strMessage += strCyberwareGrade;
            }

            // Check item Capacities if the option is enabled.
            List<string> lstOverCapacity = new List<string>();

            if (_objOptions.EnforceCapacity)
            {
                bool blnOverCapacity = false;
                int intCapacityOver = 0;
                // Armor Capacity.
                foreach (Armor objArmor in _objCharacter.Armor)
                {
                    if (objArmor.CapacityRemaining < 0)
                    {
                        blnOverCapacity = true;
                        lstOverCapacity.Add(objArmor.Name);
                        intCapacityOver++;
                    }
                }

                // Gear Capacity.
                foreach (Gear objGear in _objCharacter.Gear)
                {
                    if (objGear.CapacityRemaining < 0)
                    {
                        blnOverCapacity = true;
                        lstOverCapacity.Add(objGear.Name);
                        intCapacityOver++;
                    }
                    // Child Gear.
                    foreach (Gear objChild in objGear.Children)
                    {
                        if (objChild.CapacityRemaining < 0)
                        {
                            blnOverCapacity = true;
                            lstOverCapacity.Add(objChild.Name);
                            intCapacityOver++;
                        }
                    }
                }

                // Cyberware Capacity.
                foreach (Cyberware objCyberware in _objCharacter.Cyberware)
                {
                    if (objCyberware.CapacityRemaining < 0)
                    {
                        blnOverCapacity = true;
                        lstOverCapacity.Add(objCyberware.Name);
                        intCapacityOver++;
                    }
                    // Check plugins.
                    foreach (Cyberware objChild in objCyberware.Children)
                    {
                        if (objChild.CapacityRemaining < 0)
                        {
                            blnOverCapacity = true;
                            lstOverCapacity.Add(objChild.Name);
                            intCapacityOver++;
                        }
                    }
                }

                // Vehicle Capacity.
                foreach (Vehicle objVehicle in _objCharacter.Vehicles)
                {
                    if (_objOptions.BookEnabled("R5"))
                    {
                        if (objVehicle.IsDrone && GlobalOptions.Instance.Dronemods)
                        {
                            if (objVehicle.DroneModSlotsUsed > objVehicle.DroneModSlots)
                            {
                                blnOverCapacity = true;
                                lstOverCapacity.Add(objVehicle.Name);
                                intCapacityOver++;
                            }
                        }
                        else
                        {
                            if (objVehicle.OverR5Capacity)
                            {
                                blnOverCapacity = true;
                                lstOverCapacity.Add(objVehicle.Name);
                                intCapacityOver++;
                            }
                        }
                    }
                    else if (objVehicle.Slots < objVehicle.SlotsUsed)
                    {
                        blnOverCapacity = true;
                        lstOverCapacity.Add(objVehicle.Name);
                        intCapacityOver++;
                    }
                    // Check Vehicle Gear.
                    foreach (Gear objGear in objVehicle.Gear)
                    {
                        if (objGear.CapacityRemaining < 0)
                        {
                            blnOverCapacity = true;
                            lstOverCapacity.Add(objGear.Name);
                            intCapacityOver++;
                        }
                        // Check Child Gear.
                        foreach (Gear objChild in objGear.Children)
                        {
                            if (objChild.CapacityRemaining < 0)
                            {
                                blnOverCapacity = true;
                                lstOverCapacity.Add(objChild.Name);
                                intCapacityOver++;
                            }
                        }
                    }
                }

                if (blnOverCapacity)
                {
                    blnValid = false;
                    strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_CapacityReachedValidate").Replace("{0}", intCapacityOver.ToString());
                    foreach (string strItem in lstOverCapacity)
                    {
                        strMessage += "\n\t- " + strItem;
                    }
                }
            }

            // Check if the character has gone over on Primary Attributes
            if (blnValid && _objCharacter.Attributes > 0)
            {
                if (MessageBox.Show(
                    LanguageManager.Instance.GetString("Message_ExtraPoints")
                        .Replace("{0}", _objCharacter.Attributes.ToString())
                        .Replace("{1}", LanguageManager.Instance.GetString("Label_SummaryPrimaryAttributes")),
                    LanguageManager.Instance.GetString("MessageTitle_ExtraPoints"), MessageBoxButtons.YesNo,
                    MessageBoxIcon.Warning) == DialogResult.No)
                {
                    blnValid = false;
                }
            }

            // Check if the character has gone over on Special Attributes
            if (blnValid && _objCharacter.Special > 0)
            {
                if (
                    MessageBox.Show(
                        LanguageManager.Instance.GetString("Message_ExtraPoints")
                            .Replace("{0}", _objCharacter.Special.ToString())
                            .Replace("{1}", LanguageManager.Instance.GetString("Label_SummarySpecialAttributes")),
                        LanguageManager.Instance.GetString("MessageTitle_ExtraPoints"), MessageBoxButtons.YesNo,
                        MessageBoxIcon.Warning) == DialogResult.No)
                    blnValid = false;
            }

            // Check if the character has gone over on Skill Groups
            if (blnValid && _objCharacter.SkillsSection.SkillGroupPoints > 0)
            {
                if (
                    MessageBox.Show(
                        LanguageManager.Instance.GetString("Message_ExtraPoints")
                            .Replace("{0}", _objCharacter.SkillsSection.SkillGroupPoints.ToString())
                            .Replace("{1}", LanguageManager.Instance.GetString("Label_SummarySpecialAttributes")),
                        LanguageManager.Instance.GetString("MessageTitle_ExtraPoints"), MessageBoxButtons.YesNo,
                        MessageBoxIcon.Warning) == DialogResult.No)
                    blnValid = false;
            }

            // Check if the character has gone over on Active Skills
            if (blnValid && _objCharacter.SkillsSection.SkillPoints > 0)
            {
                if (
                    MessageBox.Show(
                        LanguageManager.Instance.GetString("Message_ExtraPoints")
                            .Replace("{0}", _objCharacter.SkillsSection.SkillPoints.ToString())
                            .Replace("{1}", LanguageManager.Instance.GetString("Label_SummaryActiveSkills")),
                        LanguageManager.Instance.GetString("MessageTitle_ExtraPoints"), MessageBoxButtons.YesNo,
                        MessageBoxIcon.Warning) == DialogResult.No)
                    blnValid = false;
            }

            // Check if the character has gone over on Knowledge Skills
            if (blnValid && _objCharacter.SkillsSection.KnowledgeSkillPointsUsed > 0)
            {
                if (
                    MessageBox.Show(
                        LanguageManager.Instance.GetString("Message_ExtraPoints")
                            .Replace("{0}", _objCharacter.SkillsSection.KnowledgeSkillPointsUsed.ToString())
                            .Replace("{1}", LanguageManager.Instance.GetString("Label_SummaryKnowledgeSkills")),
                        LanguageManager.Instance.GetString("MessageTitle_ExtraPoints"), MessageBoxButtons.YesNo,
                        MessageBoxIcon.Warning) == DialogResult.No)
                    blnValid = false;
            }

            if (!_objCharacter.IgnoreRules)
            {
                if (!blnValid && strMessage.Length > LanguageManager.Instance.GetString("Message_InvalidBeginning").Length)
                    MessageBox.Show(strMessage, LanguageManager.Instance.GetString("MessageTitle_Invalid"), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
                blnValid = true;

            if (blnValid)
            {
                if (_objOptions.CreateBackupOnCareer && chkCharacterCreated.Checked)
                {
                    // Create a pre-Career Mode backup of the character.
                    // Make sure the backup directory exists.
                    if (!Directory.Exists(Path.Combine(Environment.CurrentDirectory, "saves", "backup")))
                        Directory.CreateDirectory(Path.Combine(Environment.CurrentDirectory, "saves", "backup"));

                    string strFileName = _objCharacter.FileName;
                    string[] strParts = strFileName.Split(Path.DirectorySeparatorChar);
                    string strNewName = strParts[strParts.Length - 1].Replace(".chum5", " (" + LanguageManager.Instance.GetString("Title_CreateMode") + ").chum5");
                    if (strNewName == string.Empty)
                    {
                        strNewName = _objCharacter.Alias;
                        if (strNewName == string.Empty)
                            strNewName = _objCharacter.Name;
                        if (strNewName == string.Empty)
                            strNewName = Guid.NewGuid().ToString().Substring(0, 13).Replace("-", string.Empty);
                        strNewName += " (" + LanguageManager.Instance.GetString("Title_CreateMode") + ").chum5";
                    }

                    strNewName = Path.Combine(Environment.CurrentDirectory, "saves", "backup", strNewName);

                    _objCharacter.FileName = strNewName;
                    _objCharacter.Save();
                    _objCharacter.FileName = strFileName;
                }

                // See if the character has any Karma remaining.
                if (intBuildPoints > _objOptions.KarmaCarryover)
                {
                    if (_objCharacter.BuildMethod == CharacterBuildMethod.Karma)
                    {
                        if (MessageBox.Show(LanguageManager.Instance.GetString("Message_NoExtraKarma").Replace("{0}", intBuildPoints.ToString()), LanguageManager.Instance.GetString("MessageTitle_ExtraKarma"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                            blnValid = false;
                        else
                            _objCharacter.Karma = 0;
                    }
                    else
                    {
                        if (MessageBox.Show(LanguageManager.Instance.GetString("Message_ExtraKarma").Replace("{0}", intBuildPoints.ToString()).Replace("{1}", _objOptions.KarmaCarryover.ToString()), LanguageManager.Instance.GetString("MessageTitle_ExtraKarma"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                            blnValid = false;
                        else
                            _objCharacter.Karma = _objOptions.KarmaCarryover;
                    }
                }
                else
                {
                    _objCharacter.Karma = intBuildPoints;
                }
                // Determine the highest Lifestyle the character has.
                Lifestyle objLifestyle = new Lifestyle(_objCharacter);
                foreach (Lifestyle objCharacterLifestyle in _objCharacter.Lifestyles)
                {
                    if (objCharacterLifestyle.Multiplier > objLifestyle.Multiplier)
                        objLifestyle = objCharacterLifestyle;
                }

                // If the character does not have any Lifestyles, give them the Street Lifestyle.
                if (_objCharacter.Lifestyles.Count == 0)
                {
                    Lifestyle objStreet = new Lifestyle(_objCharacter);
                    XmlDocument objXmlDocument = XmlManager.Instance.Load("lifestyles.xml");
                    XmlNode objXmlLifestyle = objXmlDocument.SelectSingleNode("/chummer/lifestyles/lifestyle[name = \"Street\"]");
                    TreeNode objNode = new TreeNode();

                    objStreet.Create(objXmlLifestyle, objNode);
                    treLifestyles.Nodes[0].Nodes.Add(objNode);
                    treLifestyles.Nodes[0].Expand();

                    _objCharacter.Lifestyles.Add(objStreet);

                    objLifestyle = objStreet;
                }

                int intNuyenDice = objLifestyle.Dice;

                // Characters get a +1 bonus to the roll for every 100 Nueyn they have left over, up to a maximum of 3X the number of dice rolled for the Lifestyle.
                frmLifestyleNuyen frmStartingNuyen = new frmLifestyleNuyen();
                frmStartingNuyen.Dice = intNuyenDice;
                frmStartingNuyen.Multiplier = objLifestyle.Multiplier;

                if (blnValid)
                {
                    if (_objCharacter.Nuyen > 5000)
                    {
                        if (MessageBox.Show(LanguageManager.Instance.GetString("Message_ExtraNuyen").Replace("{0}", _objCharacter.Nuyen.ToString()).Replace("{1}", (5000).ToString()), LanguageManager.Instance.GetString("MessageTitle_ExtraNuyen"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                            blnValid = false;
                        else
                            _objCharacter.Nuyen = 5000;
                    }
                }

                if (blnValid)
                {
                    frmStartingNuyen.ShowDialog(this);

                    // Assign the starting Nuyen amount.
                    int intStartingNuyen = frmStartingNuyen.StartingNuyen;
                    if (intStartingNuyen < 0)
                        intStartingNuyen = 0;

                    _objCharacter.Nuyen += intStartingNuyen;
                }

                // Cannot carry over more than 7 karma from the build process
                if (_objCharacter.Karma > 7)
                    _objCharacter.Karma = 7;

                // Break any Skill Groups if any of their associated Skills have a Rating while that does not match the Group's.
                foreach (SkillGroup objGroup in _objCharacter.SkillsSection.SkillGroups)
                {
                    foreach (Skill objSkill in _objCharacter.SkillsSection.Skills)
                    {
                        if (objSkill.Rating != objGroup.Rating && objSkill.SkillGroup == objGroup.Name)
                        {
                            //objGroup.Broken = true;
                            break;
                        }
                    }
                }
            }

            return blnValid;
        }
Пример #3
0
        private void tsLifestyleName_Click(object sender, EventArgs e)
        {
            try
            {
                if (treLifestyles.SelectedNode.Level == 0)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectLifestyleName"), LanguageManager.Instance.GetString("MessageTitle_SelectLifestyle"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            catch
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectLifestyleName"), LanguageManager.Instance.GetString("MessageTitle_SelectLifestyle"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // Get the information for the currently selected Lifestyle.
            Lifestyle objLifestyle = new Lifestyle(_objCharacter);
            foreach (Lifestyle objSelectedLifestyle in _objCharacter.Lifestyles)
            {
                if (objSelectedLifestyle.InternalId == treLifestyles.SelectedNode.Tag.ToString())
                {
                    objLifestyle = objSelectedLifestyle;
                    break;
                }
            }

            frmSelectText frmPickText = new frmSelectText();
            frmPickText.Description = LanguageManager.Instance.GetString("String_LifestyleName");
            frmPickText.ShowDialog(this);

            if (frmPickText.DialogResult == DialogResult.Cancel)
                return;

            objLifestyle.LifestyleName = frmPickText.SelectedValue;
            treLifestyles.SelectedNode.Text = objLifestyle.DisplayName;
        }
Пример #4
0
        private void tsAdvancedLifestyle_Click(object sender, EventArgs e)
        {
            Lifestyle objNewLifestyle = new Lifestyle(_objCharacter);
            frmSelectLifestyleAdvanced frmPickLifestyle = new frmSelectLifestyleAdvanced(objNewLifestyle, _objCharacter);
            frmPickLifestyle.ShowDialog(this);

            // Make sure the dialogue window was not canceled.
            if (frmPickLifestyle.DialogResult == DialogResult.Cancel)
                return;

            objNewLifestyle.StyleType = LifestyleType.Advanced;

            _objCharacter.Lifestyles.Add(objNewLifestyle);

            TreeNode objNode = new TreeNode();
            objNode.Text = objNewLifestyle.Name;
            objNode.Tag = objNewLifestyle.InternalId;
            objNode.ContextMenuStrip = cmsAdvancedLifestyle;
            treLifestyles.Nodes[0].Nodes.Add(objNode);
            treLifestyles.Nodes[0].Expand();

            if (frmPickLifestyle.AddAgain)
                tsAdvancedLifestyle_Click(sender, e);

            UpdateCharacterInfo();
        }
Пример #5
0
        private void treLifestyles_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                if (treLifestyles.SelectedNode.Level == 0)
                    return;
            }
            catch
            {
                return;
            }

            // Locate the selected Lifestyle.
            Lifestyle objLifestyle = new Lifestyle(_objCharacter);
            string strGuid = "";
            int intMonths = 0;
            int intPosition = -1;
            foreach (Lifestyle objCharacterLifestyle in _objCharacter.Lifestyles)
            {
                intPosition++;
                if (objCharacterLifestyle.InternalId == treLifestyles.SelectedNode.Tag.ToString())
                {
                    objLifestyle = objCharacterLifestyle;
                    strGuid = objLifestyle.InternalId;
                    intMonths = objLifestyle.Months;
                    break;
                }
            }

            Lifestyle objNewLifestyle = new Lifestyle(_objCharacter);
            if (objLifestyle.StyleType.ToString() != "Standard")
            {
                // Edit Advanced Lifestyle.
                frmSelectLifestyleAdvanced frmPickLifestyle = new frmSelectLifestyleAdvanced(objNewLifestyle, _objCharacter);
                frmPickLifestyle.SetLifestyle(objLifestyle);
                frmPickLifestyle.ShowDialog(this);

                if (frmPickLifestyle.DialogResult == DialogResult.Cancel)
                    return;

                // Update the selected Lifestyle and refresh the list.
                objLifestyle = frmPickLifestyle.SelectedLifestyle;
                objLifestyle.SetInternalId(strGuid);
                objLifestyle.Months = intMonths;
                _objCharacter.Lifestyles[intPosition] = objLifestyle;
                treLifestyles.SelectedNode.Text = objLifestyle.DisplayNameShort;
                RefreshSelectedLifestyle();
                UpdateCharacterInfo();
            }
            else
            {
                // Edit Basic Lifestyle.
                frmSelectLifestyle frmPickLifestyle = new frmSelectLifestyle(objNewLifestyle, _objCharacter);
                frmPickLifestyle.SetLifestyle(objLifestyle);
                frmPickLifestyle.ShowDialog(this);

                if (frmPickLifestyle.DialogResult == DialogResult.Cancel)
                    return;

                // Update the selected Lifestyle and refresh the list.
                objLifestyle = frmPickLifestyle.SelectedLifestyle;
                objLifestyle.SetInternalId(strGuid);
                objLifestyle.Months = intMonths;
                _objCharacter.Lifestyles[intPosition] = objLifestyle;
                treLifestyles.SelectedNode.Text = objLifestyle.DisplayName;
                RefreshSelectedLifestyle();
                UpdateCharacterInfo();
            }
        }
Пример #6
0
        /// <summary>
        /// Add a PACKS Kit to the character.
        /// </summary>
        public void AddPACKSKit()
        {
            frmSelectPACKSKit frmPickPACKSKit = new frmSelectPACKSKit(_objCharacter);
            frmPickPACKSKit.ShowDialog(this);

            bool blnCreateChildren = true;

            // If the form was canceled, don't do anything.
            if (frmPickPACKSKit.DialogResult == DialogResult.Cancel)
                return;

            XmlDocument objXmlDocument = XmlManager.Instance.Load("packs.xml");

            // Do not create child items for Gear if the chosen Kit is in the Custom category since these items will contain the exact plugins desired.
            //if (frmPickPACKSKit.SelectedCategory == "Custom")
            //blnCreateChildren = false;

            XmlNode objXmlKit = objXmlDocument.SelectSingleNode("/chummer/packs/pack[name = \"" + frmPickPACKSKit.SelectedKit + "\" and category = \"" + frmPickPACKSKit.SelectedCategory + "\"]");
            // Update Qualities.
            if (objXmlKit["qualities"] != null)
            {
                XmlDocument objXmlQualityDocument = XmlManager.Instance.Load("qualities.xml");

                // Positive Qualities.
                foreach (XmlNode objXmlQuality in objXmlKit.SelectNodes("qualities/positive/quality"))
                {
                    XmlNode objXmlQualityNode = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQuality.InnerText + "\"]");

                    TreeNode objNode = new TreeNode();
                    List<Weapon> objWeapons = new List<Weapon>();
                    List<TreeNode> objWeaponNodes = new List<TreeNode>();
                    Quality objQuality = new Quality(_objCharacter);
                    string strForceValue = "";

                    if (objXmlQuality.Attributes["select"] != null)
                        strForceValue = objXmlQuality.Attributes["select"].InnerText;

                    objQuality.Create(objXmlQualityNode, _objCharacter, QualitySource.Selected, objNode, objWeapons, objWeaponNodes, strForceValue);
                    _objCharacter.Qualities.Add(objQuality);

                    treQualities.Nodes[0].Nodes.Add(objNode);
                    treQualities.Nodes[0].Expand();

                    // Add any created Weapons to the character.
                    foreach (Weapon objWeapon in objWeapons)
                        _objCharacter.Weapons.Add(objWeapon);

                    // Create the Weapon Node if one exists.
                    foreach (TreeNode objWeaponNode in objWeaponNodes)
                    {
                        objWeaponNode.ContextMenuStrip = cmsWeapon;
                        treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
                        treWeapons.Nodes[0].Expand();
                    }
                }

                // Negative Qualities.
                foreach (XmlNode objXmlQuality in objXmlKit.SelectNodes("qualities/negative/quality"))
                {
                    XmlNode objXmlQualityNode = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQuality.InnerText + "\"]");

                    TreeNode objNode = new TreeNode();
                    List<Weapon> objWeapons = new List<Weapon>();
                    List<TreeNode> objWeaponNodes = new List<TreeNode>();
                    Quality objQuality = new Quality(_objCharacter);
                    string strForceValue = "";

                    if (objXmlQuality.Attributes["select"] != null)
                        strForceValue = objXmlQuality.Attributes["select"].InnerText;

                    objQuality.Create(objXmlQualityNode, _objCharacter, QualitySource.Selected, objNode, objWeapons, objWeaponNodes, strForceValue);
                    _objCharacter.Qualities.Add(objQuality);

                    treQualities.Nodes[1].Nodes.Add(objNode);
                    treQualities.Nodes[1].Expand();

                    // Add any created Weapons to the character.
                    foreach (Weapon objWeapon in objWeapons)
                        _objCharacter.Weapons.Add(objWeapon);

                    // Create the Weapon Node if one exists.
                    foreach (TreeNode objWeaponNode in objWeaponNodes)
                    {
                        objWeaponNode.ContextMenuStrip = cmsWeapon;
                        treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
                        treWeapons.Nodes[0].Expand();
                    }
                }
            }

            // Update Attributes.
            if (objXmlKit["attributes"] != null)
            {
                // Reset all Attributes back to 1 so we don't go over any BP limits.
                nudBOD.Value = nudBOD.Minimum;
                nudAGI.Value = nudAGI.Minimum;
                nudREA.Value = nudREA.Minimum;
                nudSTR.Value = nudSTR.Minimum;
                nudCHA.Value = nudCHA.Minimum;
                nudINT.Value = nudINT.Minimum;
                nudLOG.Value = nudLOG.Minimum;
                nudWIL.Value = nudWIL.Minimum;
                nudEDG.Value = nudEDG.Minimum;
                nudMAG.Value = nudMAG.Minimum;
                nudRES.Value = nudRES.Minimum;
                foreach (XmlNode objXmlAttribute in objXmlKit["attributes"])
                {
                    // The CharacterAttribute is calculated as given value - (6 - Metatype Maximum) so that each Metatype has the values from the file adjusted correctly.
                    switch (objXmlAttribute.Name)
                    {
                        case "bod":
                            nudBOD.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.BOD.MetatypeMaximum);
                            break;
                        case "agi":
                            nudAGI.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.AGI.MetatypeMaximum);
                            break;
                        case "rea":
                            nudREA.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.REA.MetatypeMaximum);
                            break;
                        case "str":
                            nudSTR.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.STR.MetatypeMaximum);
                            break;
                        case "cha":
                            nudCHA.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.CHA.MetatypeMaximum);
                            break;
                        case "int":
                            nudINT.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.INT.MetatypeMaximum);
                            break;
                        case "log":
                            nudLOG.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.LOG.MetatypeMaximum);
                            break;
                        case "wil":
                            nudWIL.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.WIL.MetatypeMaximum);
                            break;
                        case "mag":
                            nudMAG.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.MAG.MetatypeMaximum);
                            break;
                        case "res":
                            nudRES.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.RES.MetatypeMaximum);
                            break;
                        default:
                            nudEDG.Value = Convert.ToInt32(objXmlAttribute.InnerText) - (6 - _objCharacter.EDG.MetatypeMaximum);
                            break;
                    }
                }
            }

               //TODO: PACKS SKILLS?

            // Select a Martial Art.
            if (objXmlKit["selectmartialart"] != null)
            {
                string strForcedValue = "";
                int intRating = 1;
                if (objXmlKit["selectmartialart"].Attributes["select"] != null)
                    strForcedValue = objXmlKit["selectmartialart"].Attributes["select"].InnerText;
                if (objXmlKit["selectmartialart"].Attributes["rating"] != null)
                    intRating = Convert.ToInt32(objXmlKit["selectmartialart"].Attributes["rating"].InnerText);

                frmSelectMartialArt frmPickMartialArt = new frmSelectMartialArt(_objCharacter);
                frmPickMartialArt.ForcedValue = strForcedValue;
                frmPickMartialArt.ShowDialog(this);

                if (frmPickMartialArt.DialogResult != DialogResult.Cancel)
                {
                    // Open the Martial Arts XML file and locate the selected piece.
                    XmlDocument objXmlMartialArtDocument = XmlManager.Instance.Load("martialarts.xml");

                    XmlNode objXmlArt = objXmlMartialArtDocument.SelectSingleNode("/chummer/martialarts/martialart[name = \"" + frmPickMartialArt.SelectedMartialArt + "\"]");

                    TreeNode objNode = new TreeNode();
                    MartialArt objMartialArt = new MartialArt(_objCharacter);
                    objMartialArt.Create(objXmlArt, objNode, _objCharacter);
                    objMartialArt.Rating = intRating;
                    _objCharacter.MartialArts.Add(objMartialArt);

                    objNode.ContextMenuStrip = cmsMartialArts;

                    treMartialArts.Nodes[0].Nodes.Add(objNode);
                    treMartialArts.Nodes[0].Expand();

                    treMartialArts.SelectedNode = objNode;
                }
            }

            // Update Martial Arts.
            if (objXmlKit["martialarts"] != null)
            {
                // Open the Martial Arts XML file and locate the selected art.
                XmlDocument objXmlMartialArtDocument = XmlManager.Instance.Load("martialarts.xml");

                foreach (XmlNode objXmlArt in objXmlKit.SelectNodes("martialarts/martialart"))
                {
                    TreeNode objNode = new TreeNode();
                    MartialArt objArt = new MartialArt(_objCharacter);
                    XmlNode objXmlArtNode = objXmlMartialArtDocument.SelectSingleNode("/chummer/martialarts/martialart[name = \"" + objXmlArt["name"].InnerText + "\"]");
                    objArt.Create(objXmlArtNode, objNode, _objCharacter);
                    objArt.Rating = Convert.ToInt32(objXmlArt["rating"].InnerText);
                    _objCharacter.MartialArts.Add(objArt);

                    // Check for Advantages.
                    foreach (XmlNode objXmlAdvantage in objXmlArt.SelectNodes("techniques/technique"))
                    {
                        TreeNode objChildNode = new TreeNode();
                        MartialArtAdvantage objAdvantage = new MartialArtAdvantage(_objCharacter);
                        XmlNode objXmlAdvantageNode = objXmlMartialArtDocument.SelectSingleNode("/chummer/techniques/technique[name = \"" + objXmlAdvantage["name"].InnerText + "\"]");
                        objAdvantage.Create(objXmlAdvantageNode, _objCharacter, objChildNode);
                        objArt.Advantages.Add(objAdvantage);

                        objNode.Nodes.Add(objChildNode);
                        objNode.Expand();
                    }

                    treMartialArts.Nodes[0].Nodes.Add(objNode);
                    treMartialArts.Nodes[0].Expand();
                }
            }

            // Update Adept Powers.
            if (objXmlKit["powers"] != null)
            {
                // Open the Powers XML file and locate the selected power.
                XmlDocument objXmlPowerDocument = XmlManager.Instance.Load("powers.xml");

                foreach (XmlNode objXmlPower in objXmlKit.SelectNodes("powers/power"))
                {
                    XmlNode objXmlPowerNode = objXmlPowerDocument.SelectSingleNode("/chummer/powers/power[name = \"" + objXmlPower["name"].InnerText + "\"]");

                    int i = panPowers.Controls.Count;

                    Power objPower = new Power(_objCharacter);
                    _objCharacter.Powers.Add(objPower);

                    PowerControl objPowerControl = new PowerControl();
                    objPowerControl.PowerObject = objPower;

                    // Attach an EventHandler for the PowerRatingChanged Event.
                    objPowerControl.PowerRatingChanged += objPower_PowerRatingChanged;
                    objPowerControl.DeletePower += objPower_DeletePower;

                    objPowerControl.PowerName = objXmlPowerNode["name"].InnerText;
                    objPowerControl.PointsPerLevel = Convert.ToDecimal(objXmlPowerNode["points"].InnerText, GlobalOptions.Instance.CultureInfo);
                    objPowerControl.AdeptWayDiscount = Convert.ToDecimal(objXmlPowerNode["adeptway"].InnerText, GlobalOptions.Instance.CultureInfo);
                    if (objXmlPowerNode["levels"].InnerText == "no")
                    {
                        objPowerControl.LevelEnabled = false;
                    }
                    else
                    {
                        objPowerControl.LevelEnabled = true;
                        if (objXmlPowerNode["levels"].InnerText != "yes")
                            objPower.MaxLevels = Convert.ToInt32(objXmlPowerNode["levels"].InnerText);
                    }

                    objPower.Source = objXmlPowerNode["source"].InnerText;
                    objPower.Page = objXmlPowerNode["page"].InnerText;
                    if (objXmlPowerNode["doublecost"] != null)
                        objPower.DoubleCost = false;

                    if (objXmlPowerNode.InnerXml.Contains("bonus"))
                    {
                        objPower.Bonus = objXmlPowerNode["bonus"];

                        if (objXmlPower["name"].Attributes["select"] != null)
                            _objImprovementManager.ForcedValue = objXmlPower["name"].Attributes["select"].InnerText;

                        _objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Power, objPower.InternalId, objPower.Bonus, false, Convert.ToInt32(objPower.Rating), objPower.DisplayNameShort);
                        objPowerControl.Extra = _objImprovementManager.SelectedValue;
                    }

                    objPowerControl.Top = i * objPowerControl.Height;
                    panPowers.Controls.Add(objPowerControl);

                    // Set the Rating of the Power if applicable.
                    if (objXmlPower["rating"] != null)
                        objPowerControl.PowerLevel = Convert.ToInt32(objXmlPower["rating"].InnerText);
                }
            }

            // Update Complex Forms.
            if (objXmlKit["programs"] != null)
            {
                // Open the Programs XML file and locate the selected program.
                XmlDocument objXmlProgramDocument = XmlManager.Instance.Load("complexforms.xml");

                foreach (XmlNode objXmlProgram in objXmlKit.SelectNodes("complexforms/complexform"))
                {
                    XmlNode objXmlProgramNode = objXmlProgramDocument.SelectSingleNode("/chummer/complexforms/complexform[name = \"" + objXmlProgram["name"].InnerText + "\"]");

                    string strForceValue = "";
                    if (objXmlProgram.Attributes["select"] != null)
                        strForceValue = objXmlProgram.Attributes["select"].InnerText;

                    TreeNode objNode = new TreeNode();
                    ComplexForm objProgram = new ComplexForm(_objCharacter);
                    objProgram.Create(objXmlProgramNode, _objCharacter, objNode, strForceValue);

                    treComplexForms.Nodes[0].Nodes.Add(objNode);
                    treComplexForms.Nodes[0].Expand();

                    _objCharacter.ComplexForms.Add(objProgram);

                    treComplexForms.SortCustom();
                }
            }

            // Update Spells.
            if (objXmlKit["spells"] != null)
            {
                XmlDocument objXmlSpellDocument = XmlManager.Instance.Load("spells.xml");

                foreach (XmlNode objXmlSpell in objXmlKit.SelectNodes("spells/spell"))
                {
                    // Make sure the Spell has not already been added to the character.
                    bool blnFound = false;
                    foreach (TreeNode nodSpell in treSpells.Nodes[0].Nodes)
                    {
                        if (nodSpell.Text == objXmlSpell.InnerText)
                        {
                            blnFound = true;
                            break;
                        }
                    }

                    // The Spell is not in the list, so add it.
                    if (!blnFound)
                    {
                        string strForceValue = "";
                        if (objXmlSpell.Attributes["select"] != null)
                            strForceValue = objXmlSpell.Attributes["select"].InnerText;

                        XmlNode objXmlSpellNode = objXmlSpellDocument.SelectSingleNode("/chummer/spells/spell[name = \"" + objXmlSpell.InnerText + "\"]");

                        Spell objSpell = new Spell(_objCharacter);
                        TreeNode objNode = new TreeNode();
                        objSpell.Create(objXmlSpellNode, _objCharacter, objNode, strForceValue);
                        objNode.ContextMenuStrip = cmsSpell;
                        _objCharacter.Spells.Add(objSpell);

                        switch (objSpell.Category)
                        {
                            case "Combat":
                                treSpells.Nodes[0].Nodes.Add(objNode);
                                treSpells.Nodes[0].Expand();
                                break;
                            case "Detection":
                                treSpells.Nodes[1].Nodes.Add(objNode);
                                treSpells.Nodes[1].Expand();
                                break;
                            case "Health":
                                treSpells.Nodes[2].Nodes.Add(objNode);
                                treSpells.Nodes[2].Expand();
                                break;
                            case "Illusion":
                                treSpells.Nodes[3].Nodes.Add(objNode);
                                treSpells.Nodes[3].Expand();
                                break;
                            case "Manipulation":
                                treSpells.Nodes[4].Nodes.Add(objNode);
                                treSpells.Nodes[4].Expand();
                                break;
                            case "Rituals":
                                int intNode = 5;
                                if (_objCharacter.AdeptEnabled && !_objCharacter.MagicianEnabled)
                                    intNode = 0;
                                treSpells.Nodes[intNode].Nodes.Add(objNode);
                                treSpells.Nodes[intNode].Expand();
                                break;
                        }

                        treSpells.SortCustom();
                    }
                }
            }

            // Update Spirits.
            if (objXmlKit["spirits"] != null)
            {
                foreach (XmlNode objXmlSpirit in objXmlKit.SelectNodes("spirits/spirit"))
                {
                    int i = panSpirits.Controls.Count;

                    Spirit objSpirit = new Spirit(_objCharacter);
                    _objCharacter.Spirits.Add(objSpirit);

                    SpiritControl objSpiritControl = new SpiritControl();
                    objSpiritControl.SpiritObject = objSpirit;
                    objSpiritControl.EntityType = SpiritType.Spirit;

                    // Attach an EventHandler for the ServicesOwedChanged Event.
                    objSpiritControl.ServicesOwedChanged += objSpirit_ServicesOwedChanged;
                    objSpiritControl.ForceChanged += objSpirit_ForceChanged;
                    objSpiritControl.BoundChanged += objSpirit_BoundChanged;
                    objSpiritControl.DeleteSpirit += objSpirit_DeleteSpirit;

                    objSpiritControl.Name = objXmlSpirit["name"].InnerText;
                    objSpiritControl.Force = Convert.ToInt32(objXmlSpirit["force"].InnerText);
                    objSpiritControl.ServicesOwed = Convert.ToInt32(objXmlSpirit["services"].InnerText);

                    objSpiritControl.Top = i * objSpiritControl.Height;
                    panSpirits.Controls.Add(objSpiritControl);
                }
            }

            // Update Lifestyles.
            if (objXmlKit["lifestyles"] != null)
            {
                XmlDocument objXmlLifestyleDocument = XmlManager.Instance.Load("lifestyles.xml");

                foreach (XmlNode objXmlLifestyle in objXmlKit.SelectNodes("lifestyles/lifestyle"))
                {
                    string strName = objXmlLifestyle["name"].InnerText;
                    int intMonths = Convert.ToInt32(objXmlLifestyle["months"].InnerText);

                    // Create the Lifestyle.
                    TreeNode objNode = new TreeNode();
                    Lifestyle objLifestyle = new Lifestyle(_objCharacter);

                    XmlNode objXmlLifestyleNode = objXmlLifestyleDocument.SelectSingleNode("/chummer/lifestyles/lifestyle[name = \"" + strName + "\"]");
                    if (objXmlLifestyleNode != null)
                    {
                        // This is a standard Lifestyle, so just use the Create method.
                        objLifestyle.Create(objXmlLifestyleNode, objNode);
                        objLifestyle.Months = intMonths;
                    }
                    else
                    {
                        // This is an Advanced Lifestyle, so build it manually.
                        objLifestyle.Name = strName;
                        objLifestyle.Months = intMonths;
                        objLifestyle.Cost = Convert.ToInt32(objXmlLifestyle["cost"].InnerText);
                        objLifestyle.Dice = Convert.ToInt32(objXmlLifestyle["dice"].InnerText);
                        objLifestyle.Multiplier = Convert.ToInt32(objXmlLifestyle["multiplier"].InnerText);
                        objLifestyle.BaseLifestyle = objXmlLifestyle["baselifestyle"].InnerText;
                        objLifestyle.Source = "SR5";
                        objLifestyle.Page = "373";
                        objLifestyle.Comforts = Convert.ToInt32(objXmlLifestyle["comforts"].InnerText);
                        objLifestyle.ComfortsEntertainment = Convert.ToInt32(objXmlLifestyle["comfortsentertainment"].InnerText);
                        objLifestyle.Security = Convert.ToInt32(objXmlLifestyle["security"].InnerText);
                        objLifestyle.SecurityEntertainment = Convert.ToInt32(objXmlLifestyle["securityentertainment"].InnerText);
                        objLifestyle.Area = Convert.ToInt32(objXmlLifestyle["area"].InnerText);
                        objLifestyle.AreaEntertainment = Convert.ToInt32(objXmlLifestyle["areaentertainment"].InnerText);

                        foreach (LifestyleQuality objXmlQuality in objXmlLifestyle.SelectNodes("lifestylequalities/lifestylequality"))
                            objLifestyle.LifestyleQualities.Add(objXmlQuality);

                        objNode.Text = strName;
                    }

                    // Add the Lifestyle to the character and Lifestyle Tree.
                    if (objLifestyle.BaseLifestyle != "")
                        objNode.ContextMenuStrip = cmsAdvancedLifestyle;
                    else
                        objNode.ContextMenuStrip = cmsLifestyleNotes;
                    _objCharacter.Lifestyles.Add(objLifestyle);
                    treLifestyles.Nodes[0].Nodes.Add(objNode);
                    treLifestyles.Nodes[0].Expand();
                }
            }

            // Update NuyenBP.
            if (objXmlKit["nuyenbp"] != null)
            {
                int intAmount = Convert.ToInt32(objXmlKit["nuyenbp"].InnerText);
                //if (_objCharacter.BuildMethod == CharacterBuildMethod.Karma)
                //intAmount *= 2;

                // Make sure we don't go over the field's maximum which would throw an Exception.
                if (nudNuyen.Value + intAmount > nudNuyen.Maximum)
                    nudNuyen.Value = nudNuyen.Maximum;
                else
                    nudNuyen.Value += intAmount;
            }

            // Update Armor.
            if (objXmlKit["armors"] != null)
            {
                XmlDocument objXmlArmorDocument = XmlManager.Instance.Load("armor.xml");

                foreach (XmlNode objXmlArmor in objXmlKit.SelectNodes("armors/armor"))
                {
                    XmlNode objXmlArmorNode = objXmlArmorDocument.SelectSingleNode("/chummer/armors/armor[name = \"" + objXmlArmor["name"].InnerText + "\"]");

                    Armor objArmor = new Armor(_objCharacter);
                    TreeNode objNode = new TreeNode();
                    int intArmorRating = 0;
                    if (objXmlArmor["rating"] != null)
                    {
                        intArmorRating = Convert.ToInt32(objXmlArmor["rating"].InnerText);
                    }
                    objArmor.Create(objXmlArmorNode, objNode, cmsArmorMod, intArmorRating, false, blnCreateChildren);
                    _objCharacter.Armor.Add(objArmor);

                    // Look for Armor Mods.
                    if (objXmlArmor["mods"] != null)
                    {
                        foreach (XmlNode objXmlMod in objXmlArmor.SelectNodes("mods/mod"))
                        {
                            List<Weapon> lstWeapons = new List<Weapon>();
                            List<TreeNode> lstWeaponNodes = new List<TreeNode>();
                            XmlNode objXmlModNode = objXmlArmorDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + objXmlMod["name"].InnerText + "\"]");
                            ArmorMod objMod = new ArmorMod(_objCharacter);
                            TreeNode objModNode = new TreeNode();
                            int intRating = 0;
                            if (objXmlMod["rating"] != null)
                                intRating = Convert.ToInt32(objXmlMod["rating"].InnerText);
                            objMod.Create(objXmlModNode, objModNode, intRating, lstWeapons, lstWeaponNodes);
                            objModNode.ContextMenuStrip = cmsArmorMod;
                            objMod.Parent = objArmor;

                            objArmor.ArmorMods.Add(objMod);

                            objNode.Nodes.Add(objModNode);
                            objNode.Expand();

                            // Add any Weapons created by the Mod.
                            foreach (Weapon objWeapon in lstWeapons)
                                _objCharacter.Weapons.Add(objWeapon);

                            foreach (TreeNode objWeaponNode in lstWeaponNodes)
                            {
                                objWeaponNode.ContextMenuStrip = cmsWeapon;
                                treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
                                treWeapons.Nodes[0].Expand();
                            }
                        }
                    }

                    XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml");
                    foreach (XmlNode objXmlGear in objXmlArmor.SelectNodes("gears/gear"))
                        AddPACKSGear(objXmlGearDocument, objXmlGear, objNode, objArmor, cmsArmorGear, blnCreateChildren);

                    objNode.ContextMenuStrip = cmsArmor;
                    treArmor.Nodes[0].Nodes.Add(objNode);
                    treArmor.Nodes[0].Expand();
                }
            }

            // Update Weapons.
            if (objXmlKit["weapons"] != null)
            {
                XmlDocument objXmlWeaponDocument = XmlManager.Instance.Load("weapons.xml");

                pgbProgress.Visible = true;
                pgbProgress.Value = 0;
                pgbProgress.Maximum = objXmlKit.SelectNodes("weapons/weapon").Count;
                int i = 0;
                foreach (XmlNode objXmlWeapon in objXmlKit.SelectNodes("weapons/weapon"))
                {
                    i++;
                    pgbProgress.Value = i;
                    Application.DoEvents();

                    XmlNode objXmlWeaponNode = objXmlWeaponDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + objXmlWeapon["name"].InnerText + "\"]");

                    Weapon objWeapon = new Weapon(_objCharacter);
                    TreeNode objNode = new TreeNode();
                    objWeapon.Create(objXmlWeaponNode, _objCharacter, objNode, cmsWeapon, cmsWeaponAccessory, blnCreateChildren);
                    _objCharacter.Weapons.Add(objWeapon);

                    // Look for Weapon Accessories.
                    if (objXmlWeapon["accessories"] != null)
                    {
                        foreach (XmlNode objXmlAccessory in objXmlWeapon.SelectNodes("accessories/accessory"))
                        {
                            XmlNode objXmlAccessoryNode = objXmlWeaponDocument.SelectSingleNode("/chummer/accessories/accessory[name = \"" + objXmlAccessory["name"].InnerText + "\"]");
                            WeaponAccessory objMod = new WeaponAccessory(_objCharacter);
                            TreeNode objModNode = new TreeNode();
                            string strMount = "";
                            int intRating = 0;
                            if (objXmlAccessory["mount"] != null)
                                strMount = objXmlAccessory["mount"].InnerText;
                            objMod.Create(objXmlAccessoryNode, objModNode, strMount, intRating);
                            objModNode.ContextMenuStrip = cmsWeaponAccessory;
                            objMod.Parent = objWeapon;

                            objWeapon.WeaponAccessories.Add(objMod);

                            XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml");
                            foreach (XmlNode objXmlGear in objXmlAccessory.SelectNodes("gears/gear"))
                                AddPACKSGear(objXmlGearDocument, objXmlGear, objModNode, objMod, cmsWeaponAccessoryGear, blnCreateChildren);

                            objNode.Nodes.Add(objModNode);
                            objNode.Expand();
                        }
                    }

                    // Look for an Underbarrel Weapon.
                    if (objXmlWeapon["underbarrel"] != null)
                    {
                        XmlNode objXmlUnderbarrelNode = objXmlWeaponDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + objXmlWeapon["underbarrel"].InnerText + "\"]");

                        Weapon objUnderbarrelWeapon = new Weapon(_objCharacter);
                        TreeNode objUnderbarrelNode = new TreeNode();
                        objUnderbarrelWeapon.Create(objXmlUnderbarrelNode, _objCharacter, objUnderbarrelNode, cmsWeapon, cmsWeaponAccessory, blnCreateChildren);
                        objWeapon.UnderbarrelWeapons.Add(objUnderbarrelWeapon);
                        objNode.Nodes.Add(objUnderbarrelNode);
                        objNode.Expand();
                    }

                    objNode.ContextMenuStrip = cmsWeapon;
                    treWeapons.Nodes[0].Nodes.Add(objNode);
                    treWeapons.Nodes[0].Expand();

                    Application.DoEvents();
                }
            }

            // Update Cyberware.
            if (objXmlKit["cyberwares"] != null)
            {
                XmlDocument objXmlCyberwareDocument = XmlManager.Instance.Load("cyberware.xml");
                XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml");

                pgbProgress.Visible = true;
                pgbProgress.Value = 0;
                pgbProgress.Maximum = objXmlKit.SelectNodes("cyberwares/cyberware").Count;
                int i = 0;
                foreach (XmlNode objXmlCyberware in objXmlKit.SelectNodes("cyberwares/cyberware"))
                {
                    i++;
                    pgbProgress.Value = i;
                    Application.DoEvents();

                    List<Weapon> objWeapons = new List<Weapon>();
                    List<TreeNode> objWeaponNodes = new List<TreeNode>();
                    TreeNode objNode = new TreeNode();
                    Cyberware objCyberware = new Cyberware(_objCharacter);
                    Grade objGrade = objCyberware.ConvertToCyberwareGrade(objXmlCyberware["grade"].InnerText, Improvement.ImprovementSource.Cyberware);

                    int intRating = 0;
                    if (objXmlCyberware["rating"] != null)
                        intRating = Convert.ToInt32(objXmlCyberware["rating"].InnerText);

                    XmlNode objXmlCyberwareNode = objXmlCyberwareDocument.SelectSingleNode("/chummer/cyberwares/cyberware[name = \"" + objXmlCyberware["name"].InnerText + "\"]");
                    objCyberware.Create(objXmlCyberwareNode, _objCharacter, objGrade, Improvement.ImprovementSource.Cyberware, intRating, objNode, objWeapons, objWeaponNodes, true, blnCreateChildren);
                    _objCharacter.Cyberware.Add(objCyberware);

                    // Add any children.
                    if (objXmlCyberware["cyberwares"] != null)
                    {
                        foreach (XmlNode objXmlChild in objXmlCyberware.SelectNodes("cyberwares/cyberware"))
                        {
                            TreeNode objChildNode = new TreeNode();
                            Cyberware objChildCyberware = new Cyberware(_objCharacter);

                            int intChildRating = 0;
                            if (objXmlChild["rating"] != null)
                                intChildRating = Convert.ToInt32(objXmlChild["rating"].InnerText);

                            XmlNode objXmlChildNode = objXmlCyberwareDocument.SelectSingleNode("/chummer/cyberwares/cyberware[name = \"" + objXmlChild["name"].InnerText + "\"]");
                            objChildCyberware.Create(objXmlChildNode, _objCharacter, objGrade, Improvement.ImprovementSource.Cyberware, intChildRating, objChildNode, objWeapons, objWeaponNodes, true, blnCreateChildren);
                            objCyberware.Children.Add(objChildCyberware);
                            objChildNode.ContextMenuStrip = cmsCyberware;

                            foreach (XmlNode objXmlGear in objXmlChild.SelectNodes("gears/gear"))
                                AddPACKSGear(objXmlGearDocument, objXmlGear, objChildNode, objChildCyberware, cmsCyberwareGear, blnCreateChildren);

                            objNode.Nodes.Add(objChildNode);
                            objNode.Expand();
                        }
                    }

                    foreach (XmlNode objXmlGear in objXmlCyberware.SelectNodes("gears/gear"))
                        AddPACKSGear(objXmlGearDocument, objXmlGear, objNode, objCyberware, cmsCyberwareGear, blnCreateChildren);

                    objNode.ContextMenuStrip = cmsCyberware;
                    treCyberware.Nodes[0].Nodes.Add(objNode);
                    treCyberware.Nodes[0].Expand();

                    // Add any Weapons created by the Gear.
                    foreach (Weapon objWeapon in objWeapons)
                        _objCharacter.Weapons.Add(objWeapon);

                    foreach (TreeNode objWeaponNode in objWeaponNodes)
                    {
                        objWeaponNode.ContextMenuStrip = cmsWeapon;
                        treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
                        treWeapons.Nodes[0].Expand();
                    }

                    Application.DoEvents();
                }

                treCyberware.SortCustom();
            }

            // Update Bioware.
            if (objXmlKit["biowares"] != null)
            {
                XmlDocument objXmlBiowareDocument = XmlManager.Instance.Load("bioware.xml");

                pgbProgress.Visible = true;
                pgbProgress.Value = 0;
                pgbProgress.Maximum = objXmlKit.SelectNodes("biowares/bioware").Count;
                int i = 0;

                foreach (XmlNode objXmlBioware in objXmlKit.SelectNodes("biowares/bioware"))
                {
                    i++;
                    pgbProgress.Value = i;
                    Application.DoEvents();

                    List<Weapon> objWeapons = new List<Weapon>();
                    List<TreeNode> objWeaponNodes = new List<TreeNode>();
                    TreeNode objNode = new TreeNode();
                    Cyberware objCyberware = new Cyberware(_objCharacter);
                    Grade objGrade = objCyberware.ConvertToCyberwareGrade(objXmlBioware["grade"].InnerText, Improvement.ImprovementSource.Bioware);

                    int intRating = 0;
                    if (objXmlBioware["rating"] != null)
                        intRating = Convert.ToInt32(objXmlBioware["rating"].InnerText);

                    XmlNode objXmlBiowareNode = objXmlBiowareDocument.SelectSingleNode("/chummer/biowares/bioware[name = \"" + objXmlBioware["name"].InnerText + "\"]");
                    objCyberware.Create(objXmlBiowareNode, _objCharacter, objGrade, Improvement.ImprovementSource.Bioware, intRating, objNode, objWeapons, objWeaponNodes, true, blnCreateChildren);
                    _objCharacter.Cyberware.Add(objCyberware);

                    objNode.ContextMenuStrip = cmsBioware;
                    treCyberware.Nodes[1].Nodes.Add(objNode);
                    treCyberware.Nodes[1].Expand();

                    // Add any Weapons created by the Gear.
                    foreach (Weapon objWeapon in objWeapons)
                        _objCharacter.Weapons.Add(objWeapon);

                    foreach (TreeNode objWeaponNode in objWeaponNodes)
                    {
                        objWeaponNode.ContextMenuStrip = cmsWeapon;
                        treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
                        treWeapons.Nodes[0].Expand();
                    }

                    Application.DoEvents();
                }

                treCyberware.SortCustom();
            }

            // Update Gear.
            if (objXmlKit["gears"] != null)
            {
                XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml");

                pgbProgress.Visible = true;
                pgbProgress.Value = 0;
                pgbProgress.Maximum = objXmlKit.SelectNodes("gears/gear").Count;
                int i = 0;

                foreach (XmlNode objXmlGear in objXmlKit.SelectNodes("gears/gear"))
                {
                    i++;
                    pgbProgress.Value = i;
                    Application.DoEvents();

                    AddPACKSGear(objXmlGearDocument, objXmlGear, treGear.Nodes[0], _objCharacter, cmsGear, blnCreateChildren);

                    Application.DoEvents();
                }
            }

            // Update Vehicles.
            if (objXmlKit["vehicles"] != null)
            {
                XmlDocument objXmlVehicleDocument = XmlManager.Instance.Load("vehicles.xml");

                pgbProgress.Visible = true;
                pgbProgress.Value = 0;
                pgbProgress.Maximum = objXmlKit.SelectNodes("vehicles/vehicle").Count;
                int i = 0;

                foreach (XmlNode objXmlVehicle in objXmlKit.SelectNodes("vehicles/vehicle"))
                {
                    i++;
                    pgbProgress.Value = i;
                    Application.DoEvents();

                    Gear objDefaultSensor = new Gear(_objCharacter);

                    TreeNode objNode = new TreeNode();
                    Vehicle objVehicle = new Vehicle(_objCharacter);

                    XmlNode objXmlVehicleNode = objXmlVehicleDocument.SelectSingleNode("/chummer/vehicles/vehicle[name = \"" + objXmlVehicle["name"].InnerText + "\"]");
                    objVehicle.Create(objXmlVehicleNode, objNode, cmsVehicle, cmsVehicleGear, cmsVehicleWeapon, cmsVehicleWeaponAccessory, blnCreateChildren);
                    _objCharacter.Vehicles.Add(objVehicle);

                    // Grab the default Sensor that comes with the Vehicle.
                    foreach (Gear objSensorGear in objVehicle.Gear)
                    {
                        if (objSensorGear.Category == "Sensors" && objSensorGear.Cost == "0" && objSensorGear.Rating == 0)
                        {
                            objDefaultSensor = objSensorGear;
                            break;
                        }
                    }

                    // Add any Vehicle Mods.
                    if (objXmlVehicle["mods"] != null)
                    {
                        foreach (XmlNode objXmlMod in objXmlVehicle.SelectNodes("mods/mod"))
                        {
                            TreeNode objModNode = new TreeNode();
                            VehicleMod objMod = new VehicleMod(_objCharacter);

                            int intRating = 0;
                            if (objXmlMod["rating"] != null)
                                intRating = Convert.ToInt32(objXmlMod["rating"].InnerText);

                            XmlNode objXmlModNode = objXmlVehicleDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + objXmlMod["name"].InnerText + "\"]");
                            objMod.Create(objXmlModNode, objModNode, intRating);
                            objVehicle.Mods.Add(objMod);

                            objNode.Nodes.Add(objModNode);
                            objNode.Expand();
                        }
                    }

                    // Add any Vehicle Gear.
                    if (objXmlVehicle["gears"] != null)
                    {
                        XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml");

                        foreach (XmlNode objXmlGear in objXmlVehicle.SelectNodes("gears/gear"))
                        {
                            List<Weapon> objWeapons = new List<Weapon>();
                            List<TreeNode> objWeaponNodes = new List<TreeNode>();
                            TreeNode objGearNode = new TreeNode();
                            Gear objGear = new Gear(_objCharacter);
                            int intQty = 1;

                            int intRating = 0;
                            if (objXmlGear["rating"] != null)
                                intRating = Convert.ToInt32(objXmlGear["rating"].InnerText);
                            string strForceValue = "";
                            if (objXmlGear["name"].Attributes["select"] != null)
                                strForceValue = objXmlGear["name"].Attributes["select"].InnerText;
                            if (objXmlGear["qty"] != null)
                                intQty = Convert.ToInt32(objXmlGear["qty"].InnerText);

                            XmlNode objXmlGearNode = objXmlGearDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objXmlGear["name"].InnerText + "\"]");
                            objGear.Create(objXmlGearNode, _objCharacter, objGearNode, intRating, objWeapons, objWeaponNodes, strForceValue, false, false, false, blnCreateChildren, false);
                            objGear.Quantity = intQty;
                            objGearNode.Text = objGear.DisplayName;
                            objVehicle.Gear.Add(objGear);

                            // Look for child components.
                            if (objXmlGear["gears"] != null)
                            {
                                foreach (XmlNode objXmlChild in objXmlGear.SelectNodes("gears/gear"))
                                {
                                    AddPACKSGear(objXmlGearDocument, objXmlChild, objGearNode, objGear, cmsVehicleGear, blnCreateChildren);
                                }
                            }

                            objGearNode.Expand();
                            objGearNode.ContextMenuStrip = cmsVehicleGear;
                            objNode.Nodes.Add(objGearNode);
                            objNode.Expand();

                            // If this is a Sensor, it will replace the Vehicle's base sensor, so remove it.
                            if (objGear.Category == "Sensors" && objGear.Cost == "0" && objGear.Rating == 0)
                            {
                                objVehicle.Gear.Remove(objDefaultSensor);
                                foreach (TreeNode objSensorNode in objNode.Nodes)
                                {
                                    if (objSensorNode.Tag.ToString() == objDefaultSensor.InternalId)
                                    {
                                        objSensorNode.Remove();
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    // Add any Vehicle Weapons.
                    if (objXmlVehicle["weapons"] != null)
                    {
                        XmlDocument objXmlWeaponDocument = XmlManager.Instance.Load("weapons.xml");

                        foreach (XmlNode objXmlWeapon in objXmlVehicle.SelectNodes("weapons/weapon"))
                        {
                            TreeNode objWeaponNode = new TreeNode();
                            Weapon objWeapon = new Weapon(_objCharacter);

                            XmlNode objXmlWeaponNode = objXmlWeaponDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + objXmlWeapon["name"].InnerText + "\"]");
                            objWeapon.Create(objXmlWeaponNode, _objCharacter, objWeaponNode, cmsVehicleWeapon, cmsVehicleWeaponAccessory, blnCreateChildren);
                            objWeapon.VehicleMounted = true;

                            // Find the first Weapon Mount in the Vehicle.
                            foreach (VehicleMod objMod in objVehicle.Mods)
                            {
                                if (objMod.Name.Contains("Weapon Mount") || (objMod.WeaponMountCategories != "" && objMod.WeaponMountCategories.Contains(objWeapon.Category)))
                                {
                                    objMod.Weapons.Add(objWeapon);
                                    foreach (TreeNode objModNode in objNode.Nodes)
                                    {
                                        if (objModNode.Tag.ToString() == objMod.InternalId)
                                        {
                                            objWeaponNode.ContextMenuStrip = cmsVehicleWeapon;
                                            objModNode.Nodes.Add(objWeaponNode);
                                            objModNode.Expand();
                                            break;
                                        }
                                    }
                                    break;
                                }
                            }

                            // Look for Weapon Accessories.
                            if (objXmlWeapon["accessories"] != null)
                            {
                                foreach (XmlNode objXmlAccessory in objXmlWeapon.SelectNodes("accessories/accessory"))
                                {
                                    XmlNode objXmlAccessoryNode = objXmlWeaponDocument.SelectSingleNode("/chummer/accessories/accessory[name = \"" + objXmlAccessory["name"].InnerText + "\"]");
                                    WeaponAccessory objMod = new WeaponAccessory(_objCharacter);
                                    TreeNode objModNode = new TreeNode();
                                    string strMount = "";
                                    int intRating = 0;
                                    if (objXmlAccessory["mount"] != null)
                                        strMount = objXmlAccessory["mount"].InnerText;
                                    objMod.Create(objXmlAccessoryNode, objModNode, strMount,intRating);
                                    objModNode.ContextMenuStrip = cmsWeaponAccessory;
                                    objMod.Parent = objWeapon;

                                    objWeapon.WeaponAccessories.Add(objMod);

                                    objWeaponNode.Nodes.Add(objModNode);
                                    objWeaponNode.Expand();
                                }
                            }
                        }
                    }

                    objNode.ContextMenuStrip = cmsVehicle;
                    treVehicles.Nodes[0].Nodes.Add(objNode);
                    treVehicles.Nodes[0].Expand();

                    Application.DoEvents();
                }
            }

            pgbProgress.Visible = false;

            if (frmPickPACKSKit.AddAgain)
                AddPACKSKit();

            PopulateGearList();
            UpdateCharacterInfo();
        }
Пример #7
0
        private void mnuSpecialCyberzombie_Click(object sender, EventArgs e)
        {
            bool blnEssence = true;
            bool blnCyberware = false;
            string strMessage = LanguageManager.Instance.GetString("Message_CyberzombieRequirements");

            // Make sure the character has an Essence lower than 0.
            if (_objCharacter.Essence >= 0)
            {
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_CyberzombieRequirementsEssence");
                blnEssence = false;
            }

            // Make sure the character has an Invoked Memory Stimulator.
            foreach (Cyberware objCyberware in _objCharacter.Cyberware)
            {
                if (objCyberware.Name == "Invoked Memory Stimulator")
                    blnCyberware = true;
            }

            if (!blnCyberware)
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_CyberzombieRequirementsStimulator");

            if (!blnEssence || !blnCyberware)
            {
                MessageBox.Show(strMessage, LanguageManager.Instance.GetString("MessageTitle_CyberzombieRequirements"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (MessageBox.Show(LanguageManager.Instance.GetString("Message_CyberzombieConfirm"), LanguageManager.Instance.GetString("MessageTitle_CyberzombieConfirm"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                return;

            // Get the player to roll Dice to make a WIL Test and record the result.
            frmDiceHits frmWILHits = new frmDiceHits();
            frmWILHits.Text = LanguageManager.Instance.GetString("String_CyberzombieWILText");
            frmWILHits.Description = LanguageManager.Instance.GetString("String_CyberzombieWILDescription");
            int intDice = _objCharacter.WIL.TotalValue;
            int intThreshold = 3 + (Convert.ToInt32(_objCharacter.EssencePenalty - Convert.ToInt32(_objCharacter.EssenceMaximum)));
            frmWILHits.Dice = intDice;
            frmWILHits.ShowDialog(this);

            if (frmWILHits.DialogResult != DialogResult.OK)
                return;

            int intWILResult = frmWILHits.Result;

            // The character gains 10 + ((Threshold - Hits) * 10)BP worth of Negative Qualities.
            int intResult = 10;
            if (intWILResult < intThreshold)
            {
                intResult = (intThreshold - intWILResult) * 10;
            }
            _objImprovementManager.CreateImprovement("", Improvement.ImprovementSource.Cyberzombie, "Cyberzombie Qualities", Improvement.ImprovementType.FreeNegativeQualities, "", intResult * -1);

            // Convert the character.
            // Characters lose access to Resonance.
            _objCharacter.RESEnabled = false;

            // Gain MAG that is permanently set to 1.
            _objCharacter.MAGEnabled = true;
            _objCharacter.MAG.MetatypeMinimum = 1;
            _objCharacter.MAG.MetatypeMaximum = 1;
            _objCharacter.MAG.Value = 1;

            // Add the Cyberzombie Lifestyle if it is not already taken.
            bool blnHasLifestyle = false;
            foreach (Lifestyle objLifestyle in _objCharacter.Lifestyles)
            {
                if (objLifestyle.Name == "Cyberzombie Lifestyle Addition")
                    blnHasLifestyle = true;
            }
            if (!blnHasLifestyle)
            {
                XmlDocument objXmlLifestyleDocument = XmlManager.Instance.Load("lifestyles.xml");
                XmlNode objXmlLifestyle = objXmlLifestyleDocument.SelectSingleNode("/chummer/lifestyles/lifestyle[name = \"Cyberzombie Lifestyle Addition\"]");

                TreeNode objLifestyleNode = new TreeNode();
                Lifestyle objLifestyle = new Lifestyle(_objCharacter);
                objLifestyle.Create(objXmlLifestyle, objLifestyleNode);
                _objCharacter.Lifestyles.Add(objLifestyle);

                treLifestyles.Nodes[0].Nodes.Add(objLifestyleNode);
                treLifestyles.Nodes[0].Expand();
            }

            // Change the MetatypeCategory to Cyberzombie.
            _objCharacter.MetatypeCategory = "Cyberzombie";

            // Gain access to Critter Powers.
            _objCharacter.CritterEnabled = true;

            // Gain the Dual Natured Critter Power if it does not yet exist.
            bool blnHasPower = false;
            foreach (CritterPower objPower in _objCharacter.CritterPowers)
            {
                if (objPower.Name == "Dual Natured")
                    blnHasPower = true;
            }
            if (!blnHasPower)
            {
                XmlDocument objXmlPowerDocument = XmlManager.Instance.Load("critterpowers.xml");
                XmlNode objXmlPowerNode = objXmlPowerDocument.SelectSingleNode("/chummer/powers/power[name = \"Dual Natured\"]");

                TreeNode objNode = new TreeNode();
                CritterPower objCritterPower = new CritterPower(_objCharacter);
                objCritterPower.Create(objXmlPowerNode, _objCharacter, objNode);
                _objCharacter.CritterPowers.Add(objCritterPower);

                treCritterPowers.Nodes[0].Nodes.Add(objNode);
                treCritterPowers.Nodes[0].Expand();
            }

            // Gain the Immunity (Normal Weapons) Critter Power if it does not yet exist.
            blnHasPower = false;
            foreach (CritterPower objPower in _objCharacter.CritterPowers)
            {
                if (objPower.Name == "Immunity" && objPower.Extra == "Normal Weapons")
                    blnHasPower = true;
            }
            if (!blnHasPower)
            {
                XmlDocument objXmlPowerDocument = XmlManager.Instance.Load("critterpowers.xml");
                XmlNode objXmlPowerNode = objXmlPowerDocument.SelectSingleNode("/chummer/powers/power[name = \"Immunity\"]");

                TreeNode objNode = new TreeNode();
                CritterPower objCritterPower = new CritterPower(_objCharacter);
                objCritterPower.Create(objXmlPowerNode, _objCharacter, objNode, 0, "Normal Weapons");
                _objCharacter.CritterPowers.Add(objCritterPower);

                treCritterPowers.Nodes[0].Nodes.Add(objNode);
                treCritterPowers.Nodes[0].Expand();
            }

            mnuSpecialCyberzombie.Visible = false;

            _blnIsDirty = true;
            UpdateWindowTitle();

            UpdateCharacterInfo();
        }
Пример #8
0
        /// <summary>
        /// Create a LifestyleQuality from an XmlNode and return the TreeNodes for it.
        /// </summary>
        /// <param name="objXmlLifestyleQuality">XmlNode to create the object from.</param>
        /// <param name="objCharacter">Character object the LifestyleQuality will be added to.</param>
        /// <param name="objLifestyleQualitySource">Source of the LifestyleQuality.</param>
        /// <param name="objNode">TreeNode to populate a TreeView.</param>
        public void Create(XmlNode objXmlLifestyleQuality, Lifestyle objParentLifestyle, Character objCharacter, QualitySource objLifestyleQualitySource, TreeNode objNode)
        {
            _objParentLifestyle = objParentLifestyle;
            _SourceGuid         = Guid.Parse(objXmlLifestyleQuality["id"].InnerText);
            if (objXmlLifestyleQuality.TryGetStringFieldQuickly("name", ref _strName))
            {
                _objCachedMyXmlNode = null;
            }
            objXmlLifestyleQuality.TryGetInt32FieldQuickly("lp", ref _intLP);
            objXmlLifestyleQuality.TryGetStringFieldQuickly("cost", ref _strCost);
            objXmlLifestyleQuality.TryGetInt32FieldQuickly("multiplier", ref _intMultiplier);
            objXmlLifestyleQuality.TryGetInt32FieldQuickly("multiplierbaseonly", ref _intBaseMultiplier);
            if (objXmlLifestyleQuality["category"] != null)
            {
                _objLifestyleQualityType = ConvertToLifestyleQualityType(objXmlLifestyleQuality["category"].InnerText);
            }
            _objLifestyleQualitySource = objLifestyleQualitySource;
            if (objXmlLifestyleQuality["print"]?.InnerText == "no")
            {
                _blnPrint = false;
            }
            if (objXmlLifestyleQuality["contributetolimit"]?.InnerText == "no")
            {
                _blnContributeToLimit = false;
            }
            objXmlLifestyleQuality.TryGetStringFieldQuickly("notes", ref _strNotes);
            objXmlLifestyleQuality.TryGetStringFieldQuickly("source", ref _strSource);
            objXmlLifestyleQuality.TryGetStringFieldQuickly("page", ref _strPage);
            string strAllowedFreeLifestyles = string.Empty;

            if (objXmlLifestyleQuality.TryGetStringFieldQuickly("allowed", ref strAllowedFreeLifestyles))
            {
                _lstAllowedFreeLifestyles = strAllowedFreeLifestyles.Split(',').ToList();
            }
            if (objNode.Text.Contains('('))
            {
                _strExtra = objNode.Text.Split('(')[1].TrimEnd(')');
            }

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

            // Built-In Qualities appear as grey text to show that they cannot be removed.
            if (objLifestyleQualitySource == QualitySource.BuiltIn)
            {
                objNode.ForeColor = SystemColors.GrayText;
                Free = true;
            }
            objNode.Name = Name;
            objNode.Text = FormattedDisplayName(GlobalOptions.CultureInfo, GlobalOptions.Language);
            objNode.Tag  = InternalId;
        }
Пример #9
0
        /// <summary>
        ///     Load the CharacterAttribute from the XmlNode.
        /// </summary>
        /// <param name="objNode">XmlNode to load.</param>
        /// <param name="objParentLifestyle">Lifestyle object to which this LifestyleQuality belongs.</param>
        public void Load(XmlNode objNode, Lifestyle objParentLifestyle)
        {
            ParentLifestyle = objParentLifestyle;
            if (!objNode.TryGetField("guid", Guid.TryParse, out _guiID))
            {
                _guiID = Guid.NewGuid();
            }
            if (objNode.TryGetStringFieldQuickly("name", ref _strName))
            {
                _objCachedMyXmlNode = null;
            }
            if (!objNode.TryGetGuidFieldQuickly("sourceid", ref _guiSourceID))
            {
                var node = GetNode(GlobalOptions.Language);
                node?.TryGetGuidFieldQuickly("id", ref _guiSourceID);
            }
            objNode.TryGetStringFieldQuickly("extra", ref _strExtra);
            objNode.TryGetInt32FieldQuickly("lp", ref _intLP);
            objNode.TryGetStringFieldQuickly("cost", ref _strCost);
            objNode.TryGetInt32FieldQuickly("multiplier", ref _intMultiplier);
            objNode.TryGetInt32FieldQuickly("basemultiplier", ref _intBaseMultiplier);
            objNode.TryGetBoolFieldQuickly("contributetolimit", ref _blnContributeToLP);
            if (!objNode.TryGetInt32FieldQuickly("areamaximum", ref _intAreaMaximum))
            {
                _objCachedMyXmlNode.TryGetInt32FieldQuickly("areamaximum", ref _intAreaMaximum);
            }
            if (!objNode.TryGetInt32FieldQuickly("area", ref _intArea))
            {
                _objCachedMyXmlNode.TryGetInt32FieldQuickly("area", ref _intArea);
            }
            if (!objNode.TryGetInt32FieldQuickly("securitymaximum", ref _intSecurityMaximum))
            {
                _objCachedMyXmlNode.TryGetInt32FieldQuickly("securitymaximum", ref _intSecurityMaximum);
            }
            if (!objNode.TryGetInt32FieldQuickly("security", ref _intSecurity))
            {
                _objCachedMyXmlNode.TryGetInt32FieldQuickly("security", ref _intSecurity);
            }
            if (!objNode.TryGetInt32FieldQuickly("comforts", ref _intComfort))
            {
                _objCachedMyXmlNode.TryGetInt32FieldQuickly("comforts", ref _intComfort);
            }
            if (!objNode.TryGetInt32FieldQuickly("comfortsmaximum", ref _intComfortMaximum))
            {
                _objCachedMyXmlNode.TryGetInt32FieldQuickly("comfortsmaximum", ref _intComfortMaximum);
            }
            objNode.TryGetBoolFieldQuickly("print", ref _blnPrint);
            if (objNode["lifestylequalitytype"] != null)
            {
                Type = ConvertToLifestyleQualityType(objNode["lifestylequalitytype"].InnerText);
            }
#if DEBUG
            if (objNode["lifestylequalitysource"] != null)
            {
                OriginSource = ConvertToLifestyleQualitySource(objNode["lifestylequalitysource"].InnerText);
            }
#else
            OriginSource = QualitySource.Selected;
#endif
            if (!objNode.TryGetStringFieldQuickly("category", ref _strCategory))
            {
                _strCategory = GetNode()?["category"]?.InnerText ?? string.Empty;
            }
            objNode.TryGetStringFieldQuickly("source", ref _strSource);
            objNode.TryGetStringFieldQuickly("page", ref _strPage);
            var strAllowedFreeLifestyles = string.Empty;
            if (!objNode.TryGetStringFieldQuickly("allowed", ref strAllowedFreeLifestyles))
            {
                strAllowedFreeLifestyles = GetNode()?["allowed"]?.InnerText ?? string.Empty;
            }
            _lstAllowedFreeLifestyles = strAllowedFreeLifestyles.Split(',', StringSplitOptions.RemoveEmptyEntries);
            Bonus = objNode["bonus"];
            objNode.TryGetStringFieldQuickly("notes", ref _strNotes);

            LegacyShim();
        }
Пример #10
0
        /// <summary>
        ///     Create a LifestyleQuality from an XmlNode.
        /// </summary>
        /// <param name="objXmlLifestyleQuality">XmlNode to create the object from.</param>
        /// <param name="objCharacter">Character object the LifestyleQuality will be added to.</param>
        /// <param name="objParentLifestyle">Lifestyle object to which the LifestyleQuality will be added.</param>
        /// <param name="objLifestyleQualitySource">Source of the LifestyleQuality.</param>
        /// <param name="strExtra">Forced value for the LifestyleQuality's Extra string (also used by its bonus node).</param>
        public void Create(XmlNode objXmlLifestyleQuality, Lifestyle objParentLifestyle, Character objCharacter,
                           QualitySource objLifestyleQualitySource, string strExtra = "")
        {
            ParentLifestyle = objParentLifestyle;
            if (!objXmlLifestyleQuality.TryGetField("id", Guid.TryParse, out _guiSourceID))
            {
                Log.Warn(new object[] { "Missing id field for xmlnode", objXmlLifestyleQuality });
                Utils.BreakIfDebug();
            }
            else
            {
                _objCachedMyXmlNode = null;
            }

            if (objXmlLifestyleQuality.TryGetStringFieldQuickly("name", ref _strName))
            {
                _objCachedMyXmlNode = null;
            }
            objXmlLifestyleQuality.TryGetInt32FieldQuickly("lp", ref _intLP);
            objXmlLifestyleQuality.TryGetStringFieldQuickly("cost", ref _strCost);
            objXmlLifestyleQuality.TryGetInt32FieldQuickly("multiplier", ref _intMultiplier);
            objXmlLifestyleQuality.TryGetInt32FieldQuickly("multiplierbaseonly", ref _intBaseMultiplier);
            if (objXmlLifestyleQuality.TryGetStringFieldQuickly("category", ref _strCategory))
            {
                Type = ConvertToLifestyleQualityType(_strCategory);
            }
            OriginSource = objLifestyleQualitySource;
            objXmlLifestyleQuality.TryGetInt32FieldQuickly("areamaximum", ref _intAreaMaximum);
            objXmlLifestyleQuality.TryGetInt32FieldQuickly("comfortsmaximum", ref _intComfortMaximum);
            objXmlLifestyleQuality.TryGetInt32FieldQuickly("securitymaximum", ref _intSecurityMaximum);
            objXmlLifestyleQuality.TryGetInt32FieldQuickly("area", ref _intArea);
            objXmlLifestyleQuality.TryGetInt32FieldQuickly("comforts", ref _intComfort);
            objXmlLifestyleQuality.TryGetInt32FieldQuickly("security", ref _intSecurity);
            objXmlLifestyleQuality.TryGetBoolFieldQuickly("print", ref _blnPrint);
            objXmlLifestyleQuality.TryGetBoolFieldQuickly("contributetolimit", ref _blnContributeToLP);
            if (!objXmlLifestyleQuality.TryGetStringFieldQuickly("altnotes", ref _strNotes))
            {
                objXmlLifestyleQuality.TryGetStringFieldQuickly("notes", ref _strNotes);
            }
            objXmlLifestyleQuality.TryGetStringFieldQuickly("source", ref _strSource);
            objXmlLifestyleQuality.TryGetStringFieldQuickly("page", ref _strPage);
            var strAllowedFreeLifestyles = string.Empty;

            if (objXmlLifestyleQuality.TryGetStringFieldQuickly("allowed", ref strAllowedFreeLifestyles))
            {
                _lstAllowedFreeLifestyles = strAllowedFreeLifestyles.Split(',', StringSplitOptions.RemoveEmptyEntries);
            }
            _strExtra = strExtra;
            if (!string.IsNullOrEmpty(_strExtra))
            {
                var intParenthesesIndex = _strExtra.IndexOf('(');
                if (intParenthesesIndex != -1)
                {
                    _strExtra = intParenthesesIndex + 1 < strExtra.Length
                        ? strExtra.Substring(intParenthesesIndex + 1).TrimEndOnce(')')
                        : string.Empty;
                }
            }


            if (string.IsNullOrEmpty(Notes))
            {
                string strEnglishNameOnPage = Name;
                string strNameOnPage        = string.Empty;
                // make sure we have something and not just an empty tag
                if (objXmlLifestyleQuality.TryGetStringFieldQuickly("nameonpage", ref strNameOnPage) &&
                    !string.IsNullOrEmpty(strNameOnPage))
                {
                    strEnglishNameOnPage = strNameOnPage;
                }

                string strGearNotes = CommonFunctions.GetTextFromPDF(Source + ' ' + Page, strEnglishNameOnPage);

                if (string.IsNullOrEmpty(strGearNotes) && GlobalOptions.Language != GlobalOptions.DefaultLanguage)
                {
                    string strTranslatedNameOnPage = CurrentDisplayName;

                    // don't check again it is not translated
                    if (strTranslatedNameOnPage != _strName)
                    {
                        // if we found <altnameonpage>, and is not empty and not the same as english we must use that instead
                        if (objXmlLifestyleQuality.TryGetStringFieldQuickly("altnameonpage", ref strNameOnPage) &&
                            !string.IsNullOrEmpty(strNameOnPage) && strNameOnPage != strEnglishNameOnPage)
                        {
                            strTranslatedNameOnPage = strNameOnPage;
                        }

                        Notes = CommonFunctions.GetTextFromPDF(Source + ' ' + DisplayPage(GlobalOptions.Language),
                                                               strTranslatedNameOnPage);
                    }
                }
                else
                {
                    Notes = strGearNotes;
                }
            }
            // If the item grants a bonus, pass the information to the Improvement Manager.
            XmlNode xmlBonus = objXmlLifestyleQuality["bonus"];

            if (xmlBonus != null)
            {
                var strOldForced = ImprovementManager.ForcedValue;
                if (!string.IsNullOrEmpty(_strExtra))
                {
                    ImprovementManager.ForcedValue = _strExtra;
                }
                if (!ImprovementManager.CreateImprovements(objCharacter, Improvement.ImprovementSource.Quality,
                                                           InternalId, xmlBonus, 1, DisplayNameShort(GlobalOptions.Language)))
                {
                    _guiID = Guid.Empty;
                    ImprovementManager.ForcedValue = strOldForced;
                    return;
                }

                if (!string.IsNullOrEmpty(ImprovementManager.SelectedValue))
                {
                    _strExtra = ImprovementManager.SelectedValue;
                }
                ImprovementManager.ForcedValue = strOldForced;
            }

            // Built-In Qualities appear as grey text to show that they cannot be removed.
            if (objLifestyleQualitySource == QualitySource.BuiltIn)
            {
                Free = true;
            }
        }
Пример #11
0
        /// <summary>
        /// Create a LifestyleQuality from an XmlNode and return the TreeNodes for it.
        /// </summary>
        /// <param name="objXmlLifestyleQuality">XmlNode to create the object from.</param>
        /// <param name="objCharacter">Character object the LifestyleQuality will be added to.</param>
        /// <param name="objLifestyleQualitySource">Source of the LifestyleQuality.</param>
        /// <param name="objNode">TreeNode to populate a TreeView.</param>
        public void Create(XmlNode objXmlLifestyleQuality, Lifestyle objParentLifestyle, Character objCharacter, QualitySource objLifestyleQualitySource, TreeNode objNode)
        {
            _objParentLifestyle = objParentLifestyle;
            objXmlLifestyleQuality.TryGetStringFieldQuickly("name", ref _strName);
            objXmlLifestyleQuality.TryGetInt32FieldQuickly("lp", ref _intLP);
            objXmlLifestyleQuality.TryGetInt32FieldQuickly("cost", ref _intCost);
            objXmlLifestyleQuality.TryGetInt32FieldQuickly("multiplier", ref _intMultiplier);
            objXmlLifestyleQuality.TryGetInt32FieldQuickly("multiplierbaseonly", ref _intBaseMultiplier);
            if (objXmlLifestyleQuality["category"] != null)
            {
                _objLifestyleQualityType = ConvertToLifestyleQualityType(objXmlLifestyleQuality["category"].InnerText);
            }
            _objLifestyleQualitySource = objLifestyleQualitySource;
            if (objXmlLifestyleQuality["print"]?.InnerText == "no")
            {
                _blnPrint = false;
            }
            if (objXmlLifestyleQuality["contributetolimit"]?.InnerText == "no")
            {
                _blnContributeToLimit = false;
            }
            objXmlLifestyleQuality.TryGetStringFieldQuickly("source", ref _strSource);
            objXmlLifestyleQuality.TryGetStringFieldQuickly("page", ref _strPage);
            string strAllowedFreeLifestyles = string.Empty;

            if (objXmlLifestyleQuality.TryGetStringFieldQuickly("allowed", ref strAllowedFreeLifestyles))
            {
                _lstAllowedFreeLifestyles = strAllowedFreeLifestyles.Split(',').ToList();
            }
            if (objNode.Text.Contains('('))
            {
                _strExtra = objNode.Text.Split('(')[1].TrimEnd(')');
            }
            if (GlobalOptions.Instance.Language != "en-us")
            {
                XmlDocument objXmlDocument          = XmlManager.Instance.Load("lifestyles.xml");
                XmlNode     objLifestyleQualityNode = objXmlDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + _strName + "\"]");
                if (objLifestyleQualityNode != null)
                {
                    objXmlLifestyleQuality.TryGetStringFieldQuickly("translate", ref _strAltName);
                    objXmlLifestyleQuality.TryGetStringFieldQuickly("altpage", ref _strAltPage);
                }
            }

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

            // Built-In Qualities appear as grey text to show that they cannot be removed.
            if (objLifestyleQualitySource == QualitySource.BuiltIn)
            {
                objNode.ForeColor = SystemColors.GrayText;
                Free = true;
            }
            objNode.Name = Name;
            objNode.Text = DisplayName;
            objNode.Tag  = InternalId;
        }
        /// <summary>
        /// Create a LifestyleQuality from an XmlNode.
        /// </summary>
        /// <param name="objXmlLifestyleQuality">XmlNode to create the object from.</param>
        /// <param name="objCharacter">Character object the LifestyleQuality will be added to.</param>
        /// <param name="objParentLifestyle">Lifestyle object to which the LifestyleQuality will be added.</param>
        /// <param name="objLifestyleQualitySource">Source of the LifestyleQuality.</param>
        /// <param name="strExtra">Forced value for the LifestyleQuality's Extra string (also used by its bonus node).</param>
        public void Create(XmlNode objXmlLifestyleQuality, Lifestyle objParentLifestyle, Character objCharacter, QualitySource objLifestyleQualitySource, string strExtra = "")
        {
            _objParentLifestyle = objParentLifestyle;
            objXmlLifestyleQuality.TryGetField("id", Guid.TryParse, out _SourceGuid);
            if (objXmlLifestyleQuality.TryGetStringFieldQuickly("name", ref _strName))
            {
                _objCachedMyXmlNode = null;
            }
            objXmlLifestyleQuality.TryGetInt32FieldQuickly("lp", ref _intLP);
            objXmlLifestyleQuality.TryGetStringFieldQuickly("cost", ref _strCost);
            objXmlLifestyleQuality.TryGetInt32FieldQuickly("multiplier", ref _intMultiplier);
            objXmlLifestyleQuality.TryGetInt32FieldQuickly("multiplierbaseonly", ref _intBaseMultiplier);
            if (objXmlLifestyleQuality.TryGetStringFieldQuickly("category", ref _strCategory))
            {
                _objLifestyleQualityType = ConvertToLifestyleQualityType(_strCategory);
            }
            _objLifestyleQualitySource = objLifestyleQualitySource;
            objXmlLifestyleQuality.TryGetBoolFieldQuickly("print", ref _blnPrint);
            objXmlLifestyleQuality.TryGetBoolFieldQuickly("contributetolimit", ref _blnContributeToLimit);
            if (!objXmlLifestyleQuality.TryGetStringFieldQuickly("altnotes", ref _strNotes))
            {
                objXmlLifestyleQuality.TryGetStringFieldQuickly("notes", ref _strNotes);
            }
            objXmlLifestyleQuality.TryGetStringFieldQuickly("source", ref _strSource);
            objXmlLifestyleQuality.TryGetStringFieldQuickly("page", ref _strPage);
            string strAllowedFreeLifestyles = string.Empty;

            if (objXmlLifestyleQuality.TryGetStringFieldQuickly("allowed", ref strAllowedFreeLifestyles))
            {
                _lstAllowedFreeLifestyles = strAllowedFreeLifestyles.Split(',').ToList();
            }
            _strExtra = strExtra;
            int intParenthesesIndex = _strExtra.IndexOf('(');

            if (intParenthesesIndex != -1)
            {
                _strExtra = intParenthesesIndex + 1 < strExtra.Length ? strExtra.Substring(intParenthesesIndex + 1).TrimEndOnce(')') : string.Empty;
            }

            // If the item grants a bonus, pass the information to the Improvement Manager.
            XmlNode xmlBonus = objXmlLifestyleQuality["bonus"];

            if (xmlBonus != null)
            {
                string strOldFoced = ImprovementManager.ForcedValue;
                if (!string.IsNullOrEmpty(_strExtra))
                {
                    ImprovementManager.ForcedValue = _strExtra;
                }
                if (!ImprovementManager.CreateImprovements(objCharacter, Improvement.ImprovementSource.Quality, InternalId, xmlBonus, false, 1, DisplayNameShort(GlobalOptions.Language)))
                {
                    _guiID = Guid.Empty;
                    ImprovementManager.ForcedValue = strOldFoced;
                    return;
                }
                if (!string.IsNullOrEmpty(ImprovementManager.SelectedValue))
                {
                    _strExtra = ImprovementManager.SelectedValue;
                }
                ImprovementManager.ForcedValue = strOldFoced;
            }

            // Built-In Qualities appear as grey text to show that they cannot be removed.
            if (objLifestyleQualitySource == QualitySource.BuiltIn)
            {
                Free = true;
            }
        }
Пример #13
0
        private void mnuSpecialCyberzombie_Click(object sender, EventArgs e)
        {
            bool blnEssence = true;
            bool blnCyberware = false;
            string strMessage = LanguageManager.Instance.GetString("Message_CyberzombieRequirements");

            // Make sure the character has an Essence lower than 0.
            if (_objCharacter.Essence >= 0)
            {
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_CyberzombieRequirementsEssence");
                blnEssence = false;
            }

            // Make sure the character has an Invoked Memory Stimulator.
            foreach (Cyberware objCyberware in _objCharacter.Cyberware)
            {
                if (objCyberware.Name == "Invoked Memory Stimulator")
                    blnCyberware = true;
            }

            if (!blnCyberware)
                strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_CyberzombieRequirementsStimulator");

            if (!blnEssence || !blnCyberware)
            {
                MessageBox.Show(strMessage, LanguageManager.Instance.GetString("MessageTitle_CyberzombieRequirements"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (MessageBox.Show(LanguageManager.Instance.GetString("Message_CyberzombieConfirm"), LanguageManager.Instance.GetString("MessageTitle_CyberzombieConfirm"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                return;

            // Convert the character.
            // Characters lose access to Resonance.
            _objCharacter.RESEnabled = false;

            // Gain MAG that is permanently set to 1.
            _objCharacter.MAGEnabled = true;
            _objCharacter.MAG.MetatypeMinimum = 1;
            _objCharacter.MAG.MetatypeMaximum = 1;
            _objCharacter.MAG.Value = 1;

            // Add the Cyberzombie Lifestyle if it is not already taken.
            bool blnHasLifestyle = false;
            foreach (Lifestyle objLifestyle in _objCharacter.Lifestyles)
            {
                if (objLifestyle.Name == "Cyberzombie Lifestyle Addition")
                    blnHasLifestyle = true;
            }
            if (!blnHasLifestyle)
            {
                XmlDocument objXmlLifestyleDocument = XmlManager.Instance.Load("lifestyles.xml");
                XmlNode objXmlLifestyle = objXmlLifestyleDocument.SelectSingleNode("/chummer/lifestyles/lifestyle[name = \"Cyberzombie Lifestyle Addition\"]");

                TreeNode objLifestyleNode = new TreeNode();
                Lifestyle objLifestyle = new Lifestyle(_objCharacter);
                objLifestyle.Create(objXmlLifestyle, objLifestyleNode);
                _objCharacter.Lifestyles.Add(objLifestyle);

                treLifestyles.Nodes[0].Nodes.Add(objLifestyleNode);
                treLifestyles.Nodes[0].Expand();
            }

            // Change the MetatypeCategory to Cyberzombie.
            _objCharacter.MetatypeCategory = "Cyberzombie";

            // Gain access to Critter Powers.
            _objCharacter.CritterEnabled = true;

            // Gain the Dual Natured Critter Power if it does not yet exist.
            bool blnHasPower = false;
            foreach (CritterPower objPower in _objCharacter.CritterPowers)
            {
                if (objPower.Name == "Dual Natured")
                    blnHasPower = true;
            }
            if (!blnHasPower)
            {
                XmlDocument objXmlPowerDocument = XmlManager.Instance.Load("critterpowers.xml");
                XmlNode objXmlPowerNode = objXmlPowerDocument.SelectSingleNode("/chummer/powers/power[name = \"Dual Natured\"]");

                TreeNode objNode = new TreeNode();
                CritterPower objCritterPower = new CritterPower(_objCharacter);
                objCritterPower.Create(objXmlPowerNode, _objCharacter, objNode);
                _objCharacter.CritterPowers.Add(objCritterPower);

                treCritterPowers.Nodes[0].Nodes.Add(objNode);
                treCritterPowers.Nodes[0].Expand();
            }

            // Gain the Immunity (Normal Weapons) Critter Power if it does not yet exist.
            blnHasPower = false;
            foreach (CritterPower objPower in _objCharacter.CritterPowers)
            {
                if (objPower.Name == "Immunity" && objPower.Extra == "Normal Weapons")
                    blnHasPower = true;
            }
            if (!blnHasPower)
            {
                XmlDocument objXmlPowerDocument = XmlManager.Instance.Load("critterpowers.xml");
                XmlNode objXmlPowerNode = objXmlPowerDocument.SelectSingleNode("/chummer/powers/power[name = \"Immunity\"]");

                TreeNode objNode = new TreeNode();
                CritterPower objCritterPower = new CritterPower(_objCharacter);
                objCritterPower.Create(objXmlPowerNode, _objCharacter, objNode, 0, "Normal Weapons");
                _objCharacter.CritterPowers.Add(objCritterPower);

                treCritterPowers.Nodes[0].Nodes.Add(objNode);
                treCritterPowers.Nodes[0].Expand();
            }

            mnuSpecialCyberzombie.Visible = false;

            _blnIsDirty = true;
            UpdateWindowTitle();

            UpdateCharacterInfo();
        }
 /// <summary>
 /// Lifestyle to update when editing.
 /// </summary>
 /// <param name="objLifestyle">Lifestyle to edit.</param>
 public void SetLifestyle(Lifestyle objLifestyle)
 {
     _objSourceLifestyle = objLifestyle;
     _objType = objLifestyle.StyleType;
 }
Пример #15
0
        private void cmdAddLifestyle_Click(object sender, EventArgs e)
        {
            Lifestyle objLifestyle = new Lifestyle(_objCharacter);
            frmSelectLifestyle frmPickLifestyle = new frmSelectLifestyle(objLifestyle, _objCharacter);
            frmPickLifestyle.ShowDialog(this);

            // Make sure the dialogue window was not canceled.
            if (frmPickLifestyle.DialogResult == DialogResult.Cancel)
                return;

            _objCharacter.Lifestyles.Add(objLifestyle);

            TreeNode objNode = new TreeNode();
            objNode.Text = objLifestyle.DisplayName;
            objNode.Tag = objLifestyle.InternalId;
            objNode.ContextMenuStrip = cmsLifestyleNotes;
            treLifestyles.Nodes[0].Nodes.Add(objNode);
            treLifestyles.Nodes[0].Expand();
            treLifestyles.SelectedNode = objNode;

            UpdateCharacterInfo();

            _blnIsDirty = true;
            UpdateWindowTitle();

            if (frmPickLifestyle.AddAgain)
                cmdAddLifestyle_Click(sender, e);
        }
Пример #16
0
        private void mnuEditPaste_Click(object sender, EventArgs e)
        {
            if (tabCharacterTabs.SelectedTab == tabStreetGear)
            {
                // Lifestyle Tab.
                if (tabStreetGearTabs.SelectedTab == tabLifestyle)
                {
                    // Paste Lifestyle.
                    Lifestyle objLifestyle = new Lifestyle(_objCharacter);
                    XmlNode objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/lifestyle");
                    if (objXmlNode != null)
                    {
                        objLifestyle.Load(objXmlNode, true);
                        // Reset the number of months back to 1 since 0 isn't valid in Create Mode.
                        objLifestyle.Months = 1;

                        _objCharacter.Lifestyles.Add(objLifestyle);

                        TreeNode objLifestyleNode = new TreeNode();
                        objLifestyleNode.Text = objLifestyle.DisplayName;
                        objLifestyleNode.Tag = objLifestyle.InternalId;
                        if (objLifestyle.StyleType.ToString() != "Standard")
                            objLifestyleNode.ContextMenuStrip = cmsAdvancedLifestyle;
                        else
                            objLifestyleNode.ContextMenuStrip = cmsLifestyleNotes;
                        if (objLifestyle.Notes != string.Empty)
                            objLifestyleNode.ForeColor = Color.SaddleBrown;
                        objLifestyleNode.ToolTipText = CommonFunctions.WordWrap(objLifestyle.Notes, 100);
                        treLifestyles.Nodes[0].Nodes.Add(objLifestyleNode);

                        UpdateCharacterInfo();
                        _blnIsDirty = true;
                        UpdateWindowTitle();
                        return;
                    }
                }

                // Armor Tab.
                if (tabStreetGearTabs.SelectedTab == tabArmor)
                {
                    // Paste Armor.
                    Armor objArmor = new Armor(_objCharacter);
                    XmlNode objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/armor");
                    if (objXmlNode != null)
                    {
                        objArmor.Load(objXmlNode, true);

                        _objCharacter.Armor.Add(objArmor);

                        _objFunctions.CreateArmorTreeNode(objArmor, treArmor, cmsArmor, cmsArmorMod, cmsArmorGear);

                        UpdateCharacterInfo();
                        _blnIsDirty = true;
                        UpdateWindowTitle();
                        return;
                    }

                    // Paste Gear.
                    Gear objGear = new Gear(_objCharacter);
                    objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/gear");

                    if (objXmlNode != null)
                    {
                        switch (objXmlNode["category"].InnerText)
                        {
                            case "Commlinks":
                            case "Cyberdecks":
                            case "Rigger Command Consoles":
                                Commlink objCommlink = new Commlink(_objCharacter);
                                objCommlink.Load(objXmlNode, true);
                                objGear = objCommlink;
                                break;
                            default:
                                Gear objNewGear = new Gear(_objCharacter);
                                objNewGear.Load(objXmlNode, true);
                                objGear = objNewGear;
                                break;
                        }

                        foreach (Armor objCharacterArmor in _objCharacter.Armor)
                        {
                            if (objCharacterArmor.InternalId == treArmor.SelectedNode.Tag.ToString())
                            {
                                objCharacterArmor.Gear.Add(objGear);
                                TreeNode objNode = new TreeNode();
                                objNode.Text = objGear.DisplayName;
                                objNode.Tag = objGear.InternalId;
                                objNode.ContextMenuStrip = cmsArmorGear;

                                _objFunctions.BuildGearTree(objGear, objNode, cmsArmorGear);

                                treArmor.SelectedNode.Nodes.Add(objNode);
                                treArmor.SelectedNode.Expand();
                            }
                        }

                        // Add any Weapons that come with the Gear.
                        objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/weapon");
                        if (objXmlNode != null)
                        {
                            Weapon objWeapon = new Weapon(_objCharacter);
                            objWeapon.Load(objXmlNode, true);
                            _objCharacter.Weapons.Add(objWeapon);
                            objGear.WeaponID = objWeapon.InternalId;
                            _objFunctions.CreateWeaponTreeNode(objWeapon, treWeapons.Nodes[0], cmsWeapon, cmsWeaponAccessory, cmsWeaponAccessoryGear);
                        }

                        UpdateCharacterInfo();
                        _blnIsDirty = true;
                        UpdateWindowTitle();
                        return;
                    }
                }

                // Weapons Tab.
                if (tabStreetGearTabs.SelectedTab == tabWeapons)
                {
                    // Paste Gear into a Weapon Accessory.
                    Gear objGear = new Gear(_objCharacter);
                    XmlNode objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/gear");
                    if (objXmlNode != null)
                    {
                        switch (objXmlNode["category"].InnerText)
                        {
                            case "Commlinks":
                            case "Cyberdecks":
                            case "Rigger Command Consoles":
                                Commlink objCommlink = new Commlink(_objCharacter);
                                objCommlink.Load(objXmlNode, true);
                                objGear = objCommlink;
                                break;
                            default:
                                Gear objNewGear = new Gear(_objCharacter);
                                objNewGear.Load(objXmlNode, true);
                                objGear = objNewGear;
                                break;
                        }

                        objGear.Parent = null;

                        // Make sure that a Weapon Accessory is selected and that it allows Gear of the item's Category.
                        WeaponAccessory objAccessory = _objFunctions.FindWeaponAccessory(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons);
                        bool blnAllowPaste = false;
                        if (objAccessory.AllowGear != null)
                        {
                            foreach (XmlNode objAllowed in objAccessory.AllowGear.SelectNodes("gearcategory"))
                            {
                                if (objAllowed.InnerText == objGear.Category)
                                {
                                    blnAllowPaste = true;
                                    break;
                                }
                            }
                        }
                        if (blnAllowPaste)
                        {
                            objAccessory.Gear.Add(objGear);
                            TreeNode objNode = new TreeNode();
                            objNode.Text = objGear.DisplayName;
                            objNode.Tag = objGear.InternalId;
                            objNode.ContextMenuStrip = cmsWeaponAccessoryGear;

                            _objFunctions.BuildGearTree(objGear, objNode, cmsWeaponAccessoryGear);

                            treWeapons.SelectedNode.Nodes.Add(objNode);
                            treWeapons.SelectedNode.Expand();

                            // Add any Weapons that come with the Gear.
                            objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/weapon");
                            if (objXmlNode != null)
                            {
                                Weapon objGearWeapon = new Weapon(_objCharacter);
                                objGearWeapon.Load(objXmlNode, true);
                                _objCharacter.Weapons.Add(objGearWeapon);
                                objGear.WeaponID = objGearWeapon.InternalId;
                                _objFunctions.CreateWeaponTreeNode(objGearWeapon, treWeapons.Nodes[0], cmsWeapon, cmsWeaponAccessory, cmsWeaponAccessoryGear);
                            }

                            UpdateCharacterInfo();
                            _blnIsDirty = true;
                            UpdateWindowTitle();
                            return;
                        }
                    }

                    // Paste Weapon.
                    Weapon objWeapon = new Weapon(_objCharacter);
                    objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/weapon");
                    if (objXmlNode != null)
                    {
                        objWeapon.Load(objXmlNode, true);
                        objWeapon.VehicleMounted = false;

                        _objCharacter.Weapons.Add(objWeapon);

                        _objFunctions.CreateWeaponTreeNode(objWeapon, treWeapons.Nodes[0], cmsWeapon, cmsWeaponAccessory, cmsWeaponAccessoryGear);

                        UpdateCharacterInfo();
                        _blnIsDirty = true;
                        UpdateWindowTitle();
                        return;
                    }
                }

                // Gear Tab.
                if (tabStreetGearTabs.SelectedTab == tabGear)
                {
                    // Paste Gear.
                    Gear objGear = new Gear(_objCharacter);
                    XmlNode objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/gear");
                    if (objXmlNode != null)
                    {
                        switch (objXmlNode["category"].InnerText)
                        {
                            case "Commlinks":
                            case "Cyberdecks":
                            case "Rigger Command Consoles":
                                Commlink objCommlink = new Commlink(_objCharacter);
                                objCommlink.Load(objXmlNode, true);
                                _objCharacter.Gear.Add(objCommlink);
                                objGear = objCommlink;
                                break;
                            default:
                                Gear objNewGear = new Gear(_objCharacter);
                                objNewGear.Load(objXmlNode, true);
                                _objCharacter.Gear.Add(objNewGear);
                                objGear = objNewGear;
                                break;
                        }

                        objGear.Parent = null;

                        TreeNode objNode = new TreeNode();
                        objNode.Text = objGear.DisplayName;
                        objNode.Tag = objGear.InternalId;
                        if (objGear.Notes != string.Empty)
                            objNode.ForeColor = Color.SaddleBrown;
                        objNode.ToolTipText = CommonFunctions.WordWrap(objGear.Notes, 100);

                        _objFunctions.BuildGearTree(objGear, objNode, cmsGear);

                        objNode.ContextMenuStrip = cmsGear;

                        TreeNode objParent = new TreeNode();
                        if (objGear.Location == "")
                            objParent = treGear.Nodes[0];
                        else
                        {
                            foreach (TreeNode objFind in treGear.Nodes)
                            {
                                if (objFind.Text == objGear.Location)
                                {
                                    objParent = objFind;
                                    break;
                                }
                            }
                        }
                        objParent.Nodes.Add(objNode);
                        objParent.Expand();

                        // Add any Weapons that come with the Gear.
                        objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/weapon");
                        if (objXmlNode != null)
                        {
                            Weapon objWeapon = new Weapon(_objCharacter);
                            objWeapon.Load(objXmlNode, true);
                            _objCharacter.Weapons.Add(objWeapon);
                            objGear.WeaponID = objWeapon.InternalId;
                            _objFunctions.CreateWeaponTreeNode(objWeapon, treWeapons.Nodes[0], cmsWeapon, cmsWeaponAccessory, cmsWeaponAccessoryGear);
                        }

                        UpdateCharacterInfo();
                        _blnIsDirty = true;
                        UpdateWindowTitle();
                        return;
                    }
                }
            }

            // Vehicles Tab.
            if (tabCharacterTabs.SelectedTab == tabVehicles)
            {
                // Paste Vehicle.
                Vehicle objVehicle = new Vehicle(_objCharacter);
                XmlNode objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/vehicle");
                if (objXmlNode != null)
                {
                    objVehicle.Load(objXmlNode, true);

                    _objCharacter.Vehicles.Add(objVehicle);

                    _objFunctions.CreateVehicleTreeNode(objVehicle, treVehicles, cmsVehicle, cmsVehicleLocation, cmsVehicleWeapon, cmsVehicleWeaponAccessory, cmsVehicleWeaponAccessoryGear, cmsVehicleGear);

                    UpdateCharacterInfo();
                    _blnIsDirty = true;
                    UpdateWindowTitle();
                    return;
                }

                // Paste Gear.
                Gear objGear = new Gear(_objCharacter);
                objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/gear");

                if (objXmlNode != null)
                {
                    switch (objXmlNode["category"].InnerText)
                    {
                        case "Commlinks":
                        case "Cyberdecks":
                        case "Rigger Command Consoles":
                            Commlink objCommlink = new Commlink(_objCharacter);
                            objCommlink.Load(objXmlNode, true);
                            objGear = objCommlink;
                            break;
                        default:
                            Gear objNewGear = new Gear(_objCharacter);
                            objNewGear.Load(objXmlNode, true);
                            objGear = objNewGear;
                            break;
                    }

                    // Paste the Gear into a Vehicle.
                    foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
                    {
                        if (objCharacterVehicle.InternalId == treVehicles.SelectedNode.Tag.ToString())
                        {
                            objCharacterVehicle.Gear.Add(objGear);
                            TreeNode objNode = new TreeNode();
                            objNode.Text = objGear.DisplayName;
                            objNode.Tag = objGear.InternalId;
                            objNode.ContextMenuStrip = cmsVehicleGear;
                            objVehicle = objCharacterVehicle;

                            _objFunctions.BuildGearTree(objGear, objNode, cmsVehicleGear);

                            treVehicles.SelectedNode.Nodes.Add(objNode);
                            treVehicles.SelectedNode.Expand();
                        }
                    }

                    // Paste the Gear into a Vehicle's Gear.
                    Vehicle objTempVehicle = objVehicle;
                    Gear objVehicleGear = _objFunctions.FindVehicleGear(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objVehicle);
                    if (objVehicle == null)
                        objVehicle = objTempVehicle;
                    if (objVehicleGear != null)
                    {
                        objVehicleGear.Children.Add(objGear);
                        objGear.Parent = objVehicleGear;
                        TreeNode objNode = new TreeNode();
                        objNode.Text = objGear.DisplayName;
                        objNode.Tag = objGear.InternalId;
                        objNode.ContextMenuStrip = cmsVehicleGear;

                        _objFunctions.BuildGearTree(objGear, objNode, cmsVehicleGear);

                        treVehicles.SelectedNode.Nodes.Add(objNode);
                        treVehicles.SelectedNode.Expand();
                    }

                    UpdateCharacterInfo();
                    _blnIsDirty = true;
                    UpdateWindowTitle();
                    return;
                }

                // Paste Weapon.
                Weapon objWeapon = new Weapon(_objCharacter);
                objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/weapon");
                if (objXmlNode != null)
                {
                    objWeapon.Load(objXmlNode, true);
                    objWeapon.VehicleMounted = true;

                    try
                    {
                        // Weapons can only be added to Vehicle Mods that support them (Weapon Mounts and Mechanical Arms).
                        VehicleMod objMod = new VehicleMod(_objCharacter);
                        foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
                        {
                            foreach (VehicleMod objVehicleMod in objCharacterVehicle.Mods)
                            {
                                if (objVehicleMod.InternalId == treVehicles.SelectedNode.Tag.ToString())
                                {
                                    if (objVehicleMod.Name.StartsWith("Weapon Mount") || objVehicleMod.Name.StartsWith("Heavy Weapon Mount") || objVehicleMod.Name.StartsWith("Mechanical Arm") || objVehicleMod.WeaponMountCategories != "")
                                    {
                                        objVehicleMod.Weapons.Add(objWeapon);

                                        _objFunctions.CreateWeaponTreeNode(objWeapon, treVehicles.SelectedNode, cmsVehicleWeapon, cmsVehicleWeaponAccessory, null);

                                        UpdateCharacterInfo();
                                        _blnIsDirty = true;
                                        UpdateWindowTitle();
                                        return;
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }
Пример #17
0
        /// <summary>
        /// Move a Lifestyle TreeNode after Drag and Drop.
        /// </summary>
        /// <param name="intNewIndex">Node's new index.</param>
        /// <param name="objDestination">Destination Node.</param>
        public void MoveLifestyleNode(int intNewIndex, TreeNode objDestination, TreeView treLifestyles)
        {
            Lifestyle objLifestyle = new Lifestyle(_objCharacter);
            // Locate the currently selected Lifestyle.
            foreach (Lifestyle objCharacterLifestyle in _objCharacter.Lifestyles)
            {
                if (objCharacterLifestyle.Name == treLifestyles.SelectedNode.Tag.ToString())
                {
                    objLifestyle = objCharacterLifestyle;
                    break;
                }
            }
            _objCharacter.Lifestyles.Remove(objLifestyle);
            if (intNewIndex > _objCharacter.Lifestyles.Count)
                _objCharacter.Lifestyles.Add(objLifestyle);
            else
                _objCharacter.Lifestyles.Insert(intNewIndex, objLifestyle);

            TreeNode objNewParent = objDestination;
            while (objNewParent.Level > 0)
                objNewParent = objNewParent.Parent;

            TreeNode objOldParent = treLifestyles.SelectedNode;
            while (objOldParent.Level > 0)
                objOldParent = objOldParent.Parent;

            TreeNode objClone = treLifestyles.SelectedNode;

            objOldParent.Nodes.Remove(treLifestyles.SelectedNode);
            objNewParent.Nodes.Insert(intNewIndex, objClone);
            objNewParent.Expand();
        }
Пример #18
0
        /// <summary>
        ///     Load the CharacterAttribute from the XmlNode.
        /// </summary>
        /// <param name="objNode">XmlNode to load.</param>
        /// <param name="objParentLifestyle">Lifestyle object to which this LifestyleQuality belongs.</param>
        public void Load(XmlNode objNode, Lifestyle objParentLifestyle)
        {
            ParentLifestyle = objParentLifestyle;
            if (!objNode.TryGetField("guid", Guid.TryParse, out _guiID))
            {
                _guiID = Guid.NewGuid();
            }
            objNode.TryGetStringFieldQuickly("name", ref _strName);
            _objCachedMyXmlNode   = null;
            _objCachedMyXPathNode = null;
            Lazy <XPathNavigator> objMyNode = new Lazy <XPathNavigator>(this.GetNodeXPath);

            if (!objNode.TryGetGuidFieldQuickly("sourceid", ref _guiSourceID))
            {
                objMyNode.Value?.TryGetGuidFieldQuickly("id", ref _guiSourceID);
            }
            objNode.TryGetStringFieldQuickly("extra", ref _strExtra);
            objNode.TryGetInt32FieldQuickly("lp", ref _intLP);
            objNode.TryGetStringFieldQuickly("cost", ref _strCost);
            objNode.TryGetInt32FieldQuickly("multiplier", ref _intMultiplier);
            objNode.TryGetInt32FieldQuickly("basemultiplier", ref _intBaseMultiplier);
            objNode.TryGetBoolFieldQuickly("contributetolimit", ref _blnContributeToLP);
            if (!objNode.TryGetInt32FieldQuickly("areamaximum", ref _intAreaMaximum))
            {
                objMyNode.Value?.TryGetInt32FieldQuickly("areamaximum", ref _intAreaMaximum);
            }
            if (!objNode.TryGetInt32FieldQuickly("area", ref _intArea))
            {
                objMyNode.Value?.TryGetInt32FieldQuickly("area", ref _intArea);
            }
            if (!objNode.TryGetInt32FieldQuickly("securitymaximum", ref _intSecurityMaximum))
            {
                objMyNode.Value?.TryGetInt32FieldQuickly("securitymaximum", ref _intSecurityMaximum);
            }
            if (!objNode.TryGetInt32FieldQuickly("security", ref _intSecurity))
            {
                objMyNode.Value?.TryGetInt32FieldQuickly("security", ref _intSecurity);
            }
            if (!objNode.TryGetInt32FieldQuickly("comforts", ref _intComfort))
            {
                objMyNode.Value?.TryGetInt32FieldQuickly("comforts", ref _intComfort);
            }
            if (!objNode.TryGetInt32FieldQuickly("comfortsmaximum", ref _intComfortMaximum))
            {
                objMyNode.Value?.TryGetInt32FieldQuickly("comfortsmaximum", ref _intComfortMaximum);
            }
            objNode.TryGetBoolFieldQuickly("print", ref _blnPrint);
            if (objNode["lifestylequalitytype"] != null)
            {
                Type = ConvertToLifestyleQualityType(objNode["lifestylequalitytype"].InnerText);
            }
#if DEBUG
            if (objNode["lifestylequalitysource"] != null)
            {
                OriginSource = ConvertToLifestyleQualitySource(objNode["lifestylequalitysource"].InnerText);
            }
#else
            OriginSource = QualitySource.Selected;
#endif
            if (!objNode.TryGetStringFieldQuickly("category", ref _strCategory) && objMyNode.Value?.TryGetStringFieldQuickly("category", ref _strCategory) != true)
            {
                _strCategory = string.Empty;
            }
            objNode.TryGetStringFieldQuickly("source", ref _strSource);
            objNode.TryGetStringFieldQuickly("page", ref _strPage);
            string strAllowedFreeLifestyles = string.Empty;
            if (!objNode.TryGetStringFieldQuickly("allowed", ref strAllowedFreeLifestyles) && objMyNode.Value?.TryGetStringFieldQuickly("allowed", ref strAllowedFreeLifestyles) != true)
            {
                strAllowedFreeLifestyles = string.Empty;
            }
            _setAllowedFreeLifestyles.Clear();
            foreach (string strLoopLifestyle in strAllowedFreeLifestyles.SplitNoAlloc(',', StringSplitOptions.RemoveEmptyEntries))
            {
                _setAllowedFreeLifestyles.Add(strLoopLifestyle);
            }
            Bonus = objNode["bonus"];
            objNode.TryGetMultiLineStringFieldQuickly("notes", ref _strNotes);

            string sNotesColor = ColorTranslator.ToHtml(ColorManager.HasNotesColor);
            objNode.TryGetStringFieldQuickly("notesColor", ref sNotesColor);
            _colNotes = ColorTranslator.FromHtml(sNotesColor);

            LegacyShim();
        }