/// <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.SkillGroupPoints < 0) { blnValid = false; strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_InvalidSkillGroupExcess").Replace("{0}", ((_objCharacter.SkillGroupPoints) * -1).ToString()); } // Check if the character has gone over on Active Skills if (_objCharacter.SkillPoints < 0) { blnValid = false; strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_InvalidActiveSkillExcess").Replace("{0}", ((_objCharacter.SkillPoints) * -1).ToString()); } // Check if the character has gone over on Knowledge Skills if (_objCharacter.KnowledgeSkillPointsUsed < 0) { blnValid = false; strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_InvalidKnowledgeSkillExcess").Replace("{0}", ((_objCharacter.KnowledgeSkillPointsUsed) * -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 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 (WeaponMod objMod in objWeapon.WeaponMods) { 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(objMod.TotalAvail) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objMod.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 (WeaponMod objMod in objWeapon.WeaponMods) { if (!objMod.TotalAvail.StartsWith("+")) { if (_objCharacter.RestrictedGear && !blnRestrictedGearUsed) { if ((GetAvailInt(objMod.TotalAvail) > _objCharacter.MaximumAvailability) && (GetAvailInt(objMod.TotalAvail) <= 24) && !objMod.IncludedInWeapon) { blnRestrictedGearUsed = true; } else if (GetAvailInt(objMod.TotalAvail) > _objCharacter.MaximumAvailability && !objMod.IncludedInWeapon) { intRestrictedCount++; strAvailItems += "\n\t\t" + objMod.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++; } } // Weapon Capacity. foreach (Weapon objWeapon in _objCharacter.Weapons) { if (objWeapon.SlotsRemaining < 0) { blnOverCapacity = true; lstOverCapacity.Add(objWeapon.Name); intCapacityOver++; } // Check Underbarrel Weapons. if (objWeapon.UnderbarrelWeapons.Count > 0) { foreach (Weapon objUnderbarrelWeapon in objWeapon.UnderbarrelWeapons) { if (objUnderbarrelWeapon.SlotsRemaining < 0) { blnOverCapacity = true; lstOverCapacity.Add(objUnderbarrelWeapon.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 (objVehicle.Slots - objVehicle.SlotsUsed < 0) { blnOverCapacity = true; lstOverCapacity.Add(objVehicle.Name); intCapacityOver++; } // Check Vehicle Weapons. foreach (Weapon objWeapon in objVehicle.Weapons) { if (objWeapon.SlotsRemaining < 0) { blnOverCapacity = true; lstOverCapacity.Add(objWeapon.Name); intCapacityOver++; } // Check Underbarrel Weapons. if (objWeapon.UnderbarrelWeapons.Count > 0) { foreach (Weapon objUnderbarrelWeapon in objWeapon.UnderbarrelWeapons) { if (objUnderbarrelWeapon.SlotsRemaining < 0) { blnOverCapacity = true; lstOverCapacity.Add(objUnderbarrelWeapon.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++; } } } // Check Vehicle Mods. foreach (VehicleMod objMod in objVehicle.Mods) { // Check Weapons. foreach (Weapon objWeapon in objMod.Weapons) { if (objWeapon.SlotsRemaining < 0) { blnOverCapacity = true; lstOverCapacity.Add(objWeapon.Name); intCapacityOver++; } // Check Underbarrel Weapons. if (objWeapon.UnderbarrelWeapons.Count > 0) { foreach (Weapon objUnderbarrelWeapon in objWeapon.UnderbarrelWeapons) { if (objUnderbarrelWeapon.SlotsRemaining < 0) { blnOverCapacity = true; lstOverCapacity.Add(objUnderbarrelWeapon.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; } } } if (!_objCharacter.IgnoreRules) { if (!blnValid) 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.SkillGroups) { foreach (Skill objSkill in _objCharacter.Skills) { if (objSkill.Rating != objGroup.Rating && objSkill.SkillGroup == objGroup.Name) { objGroup.Broken = true; break; } } } } return blnValid; }
/// <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 = ""; // Check if the character has gone over the Build Point total. int intBuildPoints = CalculateBP(); if (intBuildPoints < 0 && !_blnFreestyle) { blnValid = false; if (_objCharacter.BuildMethod == CharacterBuildMethod.BP) strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_InvalidPointExcess").Replace("{0}", (intBuildPoints * -1).ToString() + " " + LanguageManager.Instance.GetString("String_BP")); else strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_InvalidPointExcess").Replace("{0}", (intBuildPoints * -1).ToString() + " " + LanguageManager.Instance.GetString("String_Karma")); } // 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 == Guid.Empty) { 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 == Guid.Empty) { blnValid = false; strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_InvalidNoStream"); } // Check the character's equipment and make sure nothing goes over their set Maximum Availability. // Gear Availability. foreach (Gear objGear in _objCharacter.Gear) { if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objGear.DisplayNameShort; } foreach (Gear objChild in objGear.Gears) { if (!objChild.TotalAvail().StartsWith("+")) { if (GetAvailInt(objChild.TotalAvail(true)) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objChild.DisplayNameShort; } foreach (Gear objSubChild in objChild.Gears) { if (!objSubChild.TotalAvail().StartsWith("+")) { if (GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objSubChild.DisplayNameShort; } } } } } } // Cyberware Availability. foreach (Cyberware objCyberware in _objCharacter.Cyberware) { if (GetAvailInt(objCyberware.TotalAvail) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objCyberware.DisplayNameShort; } foreach (Cyberware objPlugin in objCyberware.Cyberwares) { if (!objPlugin.TotalAvail.StartsWith("+")) { if (GetAvailInt(objPlugin.TotalAvail) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objPlugin.DisplayNameShort; } } foreach (Gear objGear in objPlugin.Gears) { if (!objGear.TotalAvail().StartsWith("+")) { if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objGear.DisplayNameShort; } } foreach (Gear objChild in objGear.Gears) { if (!objChild.TotalAvail().StartsWith("+")) { if (GetAvailInt(objChild.TotalAvail(true)) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objChild.DisplayNameShort; } } foreach (Gear objSubChild in objChild.Gears) { if (!objSubChild.TotalAvail().StartsWith("+")) { if (GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objSubChild.DisplayNameShort; } } } } } } foreach (Gear objGear in objCyberware.Gears) { if (!objGear.TotalAvail().StartsWith("+")) { if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objGear.DisplayNameShort; } } foreach (Gear objChild in objGear.Gears) { if (!objChild.TotalAvail().StartsWith("+")) { if (GetAvailInt(objChild.TotalAvail(true)) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objChild.DisplayNameShort; } } foreach (Gear objSubChild in objChild.Gears) { if (!objSubChild.TotalAvail().StartsWith("+")) { if (GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objSubChild.DisplayNameShort; } } } } } } // Armor Availability. foreach (Armor objArmor in _objCharacter.Armor) { if (GetAvailInt(objArmor.TotalAvail) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objArmor.DisplayNameShort; } foreach (ArmorMod objMod in objArmor.ArmorMods) { if (!objMod.TotalAvail.StartsWith("+")) { if (GetAvailInt(objMod.TotalAvail) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objMod.DisplayNameShort; } } } foreach (Gear objGear in objArmor.Gears) { if (!objGear.TotalAvail().StartsWith("+")) { if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objGear.DisplayNameShort; } } foreach (Gear objChild in objGear.Gears) { if (!objChild.TotalAvail().StartsWith("+")) { if (GetAvailInt(objChild.TotalAvail(true)) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objChild.DisplayNameShort; } } foreach (Gear objSubChild in objChild.Gears) { if (!objSubChild.TotalAvail().StartsWith("+")) { if (GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objSubChild.DisplayNameShort; } } } } } } // Weapon Availability. foreach (Weapon objWeapon in _objCharacter.Weapons) { if (GetAvailInt(objWeapon.TotalAvail) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objWeapon.DisplayNameShort; } foreach (WeaponMod objMod in objWeapon.WeaponMods) { if (!objMod.TotalAvail.StartsWith("+")) { if (GetAvailInt(objMod.TotalAvail) > _objCharacter.MaximumAvailability && !objMod.IncludedInParent) { intRestrictedCount++; strAvailItems += "\n\t\t" + objMod.DisplayNameShort; } } } foreach (WeaponAccessory objAccessory in objWeapon.WeaponAccessories) { if (!objAccessory.TotalAvail.StartsWith("+")) { if (GetAvailInt(objAccessory.TotalAvail) > _objCharacter.MaximumAvailability && !objAccessory.IncludedInParent) { intRestrictedCount++; strAvailItems += "\n\t\t" + objAccessory.DisplayNameShort; } } foreach (Gear objGear in objAccessory.Gears) { if (!objGear.TotalAvail().StartsWith("+")) { if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objGear.DisplayNameShort; } } foreach (Gear objChild in objGear.Gears) { if (!objChild.TotalAvail().StartsWith("+")) { if (GetAvailInt(objChild.TotalAvail(true)) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objChild.DisplayNameShort; } } foreach (Gear objSubChild in objChild.Gears) { if (!objSubChild.TotalAvail().StartsWith("+")) { if (GetAvailInt(objSubChild.TotalAvail(true)) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objSubChild.DisplayNameShort; } } } } } } } // Vehicle Availability. foreach (Vehicle objVehicle in _objCharacter.Vehicles) { if (GetAvailInt(objVehicle.TotalAvail) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objVehicle.DisplayNameShort; } foreach (VehicleMod objVehicleMod in objVehicle.VehicleMods) { if (!objVehicleMod.TotalAvail.StartsWith("+")) { if (GetAvailInt(objVehicleMod.TotalAvail) > _objCharacter.MaximumAvailability && !objVehicleMod.IncludedInParent) { intRestrictedCount++; strAvailItems += "\n\t\t" + objVehicleMod.DisplayNameShort; } } foreach (Weapon objWeapon in objVehicleMod.Weapons) { if (GetAvailInt(objWeapon.TotalAvail) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objWeapon.DisplayNameShort; } foreach (WeaponMod objMod in objWeapon.WeaponMods) { if (!objMod.TotalAvail.StartsWith("+")) { if (GetAvailInt(objMod.TotalAvail) > _objCharacter.MaximumAvailability && !objMod.IncludedInParent) { intRestrictedCount++; strAvailItems += "\n\t\t" + objMod.DisplayNameShort; } } } foreach (WeaponAccessory objAccessory in objWeapon.WeaponAccessories) { if (!objAccessory.TotalAvail.StartsWith("+")) { if (GetAvailInt(objAccessory.TotalAvail) > _objCharacter.MaximumAvailability && !objAccessory.IncludedInParent) { intRestrictedCount++; strAvailItems += "\n\t\t" + objAccessory.DisplayNameShort; } } } } } foreach (Gear objGear in objVehicle.Gears) { if (!objGear.TotalAvail().StartsWith("+")) { if (GetAvailInt(objGear.TotalAvail(true)) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objGear.DisplayNameShort; } } foreach (Gear objChild in objGear.Gears) { if (!objChild.TotalAvail().StartsWith("+")) { if (GetAvailInt(objChild.TotalAvail(true)) > _objCharacter.MaximumAvailability) { intRestrictedCount++; strAvailItems += "\n\t\t" + objChild.DisplayNameShort; } } foreach (Gear objSubChild in objChild.Gears) { if (!objSubChild.TotalAvail().StartsWith("+")) { 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; } // Check item Capacities if the option is enabled. if (_objOptions.EnforceCapacity) { bool blnOverCapacity = false; int intCapacityOver = 0; // Armor Capacity. foreach (Armor objArmor in _objCharacter.Armor) { if (objArmor.CapacityRemaining < 0) { blnOverCapacity = true; intCapacityOver++; } } // Weapon Capacity. foreach (Weapon objWeapon in _objCharacter.Weapons) { if (objWeapon.SlotsRemaining < 0) { blnOverCapacity = true; intCapacityOver++; } // Check Underbarrel Weapons. if (objWeapon.Weapons.Count > 0) { foreach (Weapon objUnderbarrelWeapon in objWeapon.Weapons) { if (objUnderbarrelWeapon.SlotsRemaining < 0) { blnOverCapacity = true; intCapacityOver++; } } } } // Gear Capacity. foreach (Gear objGear in _objCharacter.Gear) { if (objGear.CapacityRemaining < 0) { blnOverCapacity = true; intCapacityOver++; } // Child Gear. foreach (Gear objChild in objGear.Gears) { if (objChild.CapacityRemaining < 0) { blnOverCapacity = true; intCapacityOver++; } } } // Cyberware Capacity. foreach (Cyberware objCyberware in _objCharacter.Cyberware) { if (objCyberware.CapacityRemaining < 0) { blnOverCapacity = true; intCapacityOver++; } // Check plugins. foreach (Cyberware objChild in objCyberware.Cyberwares) { if (objChild.CapacityRemaining < 0) { blnOverCapacity = true; intCapacityOver++; } } } // Vehicle Capacity. foreach (Vehicle objVehicle in _objCharacter.Vehicles) { if (objVehicle.Slots - objVehicle.SlotsUsed < 0) { blnOverCapacity = true; intCapacityOver++; } // Check Vehicle Weapons. foreach (Weapon objWeapon in objVehicle.Weapons) { if (objWeapon.SlotsRemaining < 0) { blnOverCapacity = true; intCapacityOver++; } // Check Underbarrel Weapons. if (objWeapon.Weapons.Count > 0) { foreach (Weapon objUnderbarrelWeapon in objWeapon.Weapons) { if (objUnderbarrelWeapon.SlotsRemaining < 0) { blnOverCapacity = true; intCapacityOver++; } } } } // Check Vehicle Gear. foreach (Gear objGear in objVehicle.Gears) { if (objGear.CapacityRemaining < 0) { blnOverCapacity = true; intCapacityOver++; } // Check Child Gear. foreach (Gear objChild in objGear.Gears) { if (objChild.CapacityRemaining < 0) { blnOverCapacity = true; intCapacityOver++; } } } // Check Vehicle Mods. foreach (VehicleMod objMod in objVehicle.VehicleMods) { // Check Weapons. foreach (Weapon objWeapon in objMod.Weapons) { if (objWeapon.SlotsRemaining < 0) { blnOverCapacity = true; intCapacityOver++; } // Check Underbarrel Weapons. if (objWeapon.Weapons.Count > 0) { foreach (Weapon objUnderbarrelWeapon in objWeapon.Weapons) { if (objUnderbarrelWeapon.SlotsRemaining < 0) { blnOverCapacity = true; intCapacityOver++; } } } } } } if (blnOverCapacity) { blnValid = false; strMessage += "\n\t" + LanguageManager.Instance.GetString("Message_CapacityReachedValidate").Replace("{0}", intCapacityOver.ToString()); } } if (!_objCharacter.IgnoreRules) { if (!blnValid) 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(GlobalOptions.ApplicationPath(), "saves", "backup"))) Directory.CreateDirectory(Path.Combine(GlobalOptions.ApplicationPath(), "saves", "backup")); string strFileName = _objCharacter.FileName; string[] strParts = strFileName.Split(Path.DirectorySeparatorChar); string strNewName = strParts[strParts.Length - 1].Replace(".chum", " (" + LanguageManager.Instance.GetString("Title_CreateMode") + ").chum"); 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") + ").chum"; } strNewName = Path.Combine(GlobalOptions.ApplicationPath(), "saves", "backup", strNewName); _objCharacter.FileName = strNewName; _objCharacter.Save(); _objCharacter.FileName = strFileName; } // See if the character has any Karma remaining. if (_objCharacter.BuildMethod == CharacterBuildMethod.Karma) { if (intBuildPoints > _objOptions.KarmaCarryover) { 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; } } // 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. int intNuyenBonus = Convert.ToInt32(Math.Floor((Convert.ToDouble(intNuyen, GlobalOptions.Instance.CultureInfo)) / 100.0)); if (intNuyenBonus > intNuyenDice * 3) intNuyenBonus = intNuyenDice * 3; frmLifestyleNuyen frmStartingNuyen = new frmLifestyleNuyen(); frmStartingNuyen.Dice = intNuyenDice; frmStartingNuyen.Multiplier = objLifestyle.Multiplier; frmStartingNuyen.Extra = intNuyenBonus; frmStartingNuyen.ShowDialog(this); // Assign the starting Nuyen amount. int intStartingNuyen = frmStartingNuyen.StartingNuyen; if (intStartingNuyen < 0) intStartingNuyen = 0; _objCharacter.Nuyen = intStartingNuyen; // 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.SkillGroups) { foreach (Skill objSkill in _objCharacter.Skills) { if (objSkill.Rating != objGroup.Rating && objSkill.SkillGroup == objGroup.Name) { objGroup.Broken = true; break; } } } } return blnValid; }