/// Create a Spell from an XmlNode. /// <param name="objXmlSpellNode">XmlNode to create the object from.</param> /// <param name="strForcedValue">Value to forcefully select for any ImprovementManager prompts.</param> /// <param name="blnLimited">Whether or not the Spell should be marked as Limited.</param> /// <param name="blnExtended">Whether or not the Spell should be marked as Extended.</param> /// <param name="blnAlchemical">Whether or not the Spell is one for an alchemical preparation.</param> /// <param name="objSource">Enum representing the actual type of spell this object represents. Used for initiation benefits that would grant spells.</param> public void Create(XmlNode objXmlSpellNode, string strForcedValue = "", bool blnLimited = false, bool blnExtended = false, bool blnAlchemical = false, Improvement.ImprovementSource objSource = Improvement.ImprovementSource.Spell) { if (!objXmlSpellNode.TryGetField("id", Guid.TryParse, out _guiSourceID)) { Log.Warn(new object[] { "Missing id field for xmlnode", objXmlSpellNode }); Utils.BreakIfDebug(); } objXmlSpellNode.TryGetStringFieldQuickly("name", ref _strName); _blnExtended = blnExtended; ImprovementManager.ForcedValue = strForcedValue; if (objXmlSpellNode["bonus"] != null) { if (!ImprovementManager.CreateImprovements(_objCharacter, Improvement.ImprovementSource.Spell, _guiID.ToString("D", GlobalOptions.InvariantCultureInfo), objXmlSpellNode["bonus"], 1, DisplayNameShort(GlobalOptions.Language))) { _guiID = Guid.Empty; return; } if (!string.IsNullOrEmpty(ImprovementManager.SelectedValue)) { _strExtra = ImprovementManager.SelectedValue; } } if (!objXmlSpellNode.TryGetStringFieldQuickly("altnotes", ref _strNotes)) { objXmlSpellNode.TryGetStringFieldQuickly("notes", ref _strNotes); } objXmlSpellNode.TryGetStringFieldQuickly("descriptor", ref _strDescriptors); objXmlSpellNode.TryGetStringFieldQuickly("category", ref _strCategory); objXmlSpellNode.TryGetStringFieldQuickly("type", ref _strType); objXmlSpellNode.TryGetStringFieldQuickly("range", ref _strRange); objXmlSpellNode.TryGetStringFieldQuickly("damage", ref _strDamage); objXmlSpellNode.TryGetStringFieldQuickly("duration", ref _strDuration); objXmlSpellNode.TryGetStringFieldQuickly("dv", ref _strDV); _blnLimited = blnLimited; _blnAlchemical = blnAlchemical; objXmlSpellNode.TryGetStringFieldQuickly("source", ref _strSource); objXmlSpellNode.TryGetStringFieldQuickly("page", ref _strPage); _objImprovementSource = objSource; /* * if (string.IsNullOrEmpty(_strNotes)) * { * _strNotes = CommonFunctions.GetText(_strSource + ' ' + _strPage, Name); * } */ }
/// Create a Metamagic from an XmlNode. /// <param name="objXmlMetamagicNode">XmlNode to create the object from.</param> /// <param name="objSource">Source of the Improvement.</param> /// <param name="strForcedValue">Value to forcefully select for any ImprovementManager prompts.</param> public void Create(XmlNode objXmlMetamagicNode, Improvement.ImprovementSource objSource, string strForcedValue = "") { if (objXmlMetamagicNode.TryGetStringFieldQuickly("name", ref _strName)) { _objCachedMyXmlNode = null; } objXmlMetamagicNode.TryGetStringFieldQuickly("source", ref _strSource); objXmlMetamagicNode.TryGetStringFieldQuickly("page", ref _strPage); _objImprovementSource = objSource; objXmlMetamagicNode.TryGetInt32FieldQuickly("grade", ref _intGrade); if (!objXmlMetamagicNode.TryGetStringFieldQuickly("altnotes", ref _strNotes)) { objXmlMetamagicNode.TryGetStringFieldQuickly("notes", ref _strNotes); } _nodBonus = objXmlMetamagicNode["bonus"]; if (_nodBonus != null) { int intRating = _objCharacter.SubmersionGrade > 0 ? _objCharacter.SubmersionGrade : _objCharacter.InitiateGrade; string strOldFocedValue = ImprovementManager.ForcedValue; string strOldSelectedValue = ImprovementManager.SelectedValue; ImprovementManager.ForcedValue = strOldFocedValue; if (!ImprovementManager.CreateImprovements(_objCharacter, objSource, _guiID.ToString("D"), _nodBonus, true, intRating, DisplayNameShort(GlobalOptions.Language))) { _guiID = Guid.Empty; ImprovementManager.ForcedValue = strOldFocedValue; return; } if (!string.IsNullOrEmpty(ImprovementManager.SelectedValue)) { _strName += LanguageManager.GetString("String_Space", GlobalOptions.Language) + '(' + ImprovementManager.SelectedValue + ')'; _objCachedMyXmlNode = null; } ImprovementManager.ForcedValue = strOldFocedValue; ImprovementManager.SelectedValue = strOldSelectedValue; } /* * if (string.IsNullOrEmpty(_strNotes)) * { * _strNotes = CommonFunctions.GetTextFromPDF($"{_strSource} {_strPage}", _strName); * if (string.IsNullOrEmpty(_strNotes)) * { * _strNotes = CommonFunctions.GetTextFromPDF($"{Source} {Page(GlobalOptions.Language)}", DisplayName(GlobalOptions.Language)); * } * }*/ }
public frmCreateCyberwareSuite(Character objCharacter, Improvement.ImprovementSource objSource = Improvement.ImprovementSource.Cyberware) { InitializeComponent(); _objSource = objSource; LanguageManager.TranslateWinForm(GlobalOptions.Language, this); _objCharacter = objCharacter; if (_objSource == Improvement.ImprovementSource.Cyberware) _strType = "cyberware"; else { _strType = "bioware"; Text = LanguageManager.GetString("Title_CreateBiowareSuite", GlobalOptions.Language); } txtFileName.Text = "custom_" + _strType + ".xml"; }
public frmSelectCyberwareSuite(Improvement.ImprovementSource objSource, Character objCharacter) { InitializeComponent(); _objSource = objSource; LanguageManager.Instance.Load(GlobalOptions.Instance.Language, this); if (_objSource == Improvement.ImprovementSource.Cyberware) _strType = "cyberware"; else { _strType = "bioware"; this.Text = LanguageManager.Instance.GetString("Title_SelectBiowareSuite"); lblCyberwareLabel.Text = LanguageManager.Instance.GetString("Label_SelectBiowareSuite_PartsInSuite"); } _objCharacter = objCharacter; }
/// <summary> /// Fill the list of CyberwareGrades from the XML files. /// </summary> /// <param name="objSource">Source to load the Grades from, either Bioware or Cyberware.</param> public void LoadList(Improvement.ImprovementSource objSource) { string strXmlFile = "cyberware.xml"; if (objSource == Improvement.ImprovementSource.Bioware) { strXmlFile = "bioware.xml"; } XmlDocument objXMlDocument = XmlManager.Instance.Load(strXmlFile); foreach (XmlNode objNode in objXMlDocument.SelectNodes("/chummer/grades/grade")) { Grade objGrade = new Grade(); objGrade.Load(objNode); _lstGrades.Add(objGrade); } }
public frmCreateCyberwareSuite(Character objCharacter, Improvement.ImprovementSource objSource) { InitializeComponent(); _objSource = objSource; LanguageManager.Instance.Load(GlobalOptions.Instance.Language, this); _objCharacter = objCharacter; if (_objSource == Improvement.ImprovementSource.Cyberware) _strType = "cyberware"; else { _strType = "bioware"; this.Text = LanguageManager.Instance.GetString("Title_CreateBiowareSuite"); } txtFileName.Text = "custom_" + _strType + ".xml"; }
/// Create a Spell from an XmlNode. /// <param name="objXmlSpellNode">XmlNode to create the object from.</param> /// <param name="strForcedValue">Value to forcefully select for any ImprovementManager prompts.</param> /// <param name="blnLimited">Whether or not the Spell should be marked as Limited.</param> /// <param name="blnExtended">Whether or not the Spell should be marked as Extended.</param> /// <param name="blnAlchemical">Whether or not the Spell is one for an alchemical preparation.</param> /// <param name="objSource">Enum representing the actual type of spell this object represents. Used for initiation benefits that would grant spells.</param> public void Create(XmlNode objXmlSpellNode, string strForcedValue = "", bool blnLimited = false, bool blnExtended = false, bool blnAlchemical = false, Improvement.ImprovementSource objSource = Improvement.ImprovementSource.Spell) { if (objXmlSpellNode.TryGetStringFieldQuickly("name", ref _strName)) { _objCachedMyXmlNode = null; } _blnExtended = blnExtended; ImprovementManager.ForcedValue = strForcedValue; if (objXmlSpellNode["bonus"] != null) { if (!ImprovementManager.CreateImprovements(_objCharacter, Improvement.ImprovementSource.Spell, _guiID.ToString("D"), objXmlSpellNode["bonus"], false, 1, DisplayNameShort(GlobalOptions.Language))) { _guiID = Guid.Empty; return; } if (!string.IsNullOrEmpty(ImprovementManager.SelectedValue)) { _strExtra = ImprovementManager.SelectedValue; } } if (!objXmlSpellNode.TryGetStringFieldQuickly("altnotes", ref _strNotes)) { objXmlSpellNode.TryGetStringFieldQuickly("notes", ref _strNotes); } objXmlSpellNode.TryGetStringFieldQuickly("descriptor", ref _strDescriptors); objXmlSpellNode.TryGetStringFieldQuickly("category", ref _strCategory); objXmlSpellNode.TryGetStringFieldQuickly("type", ref _strType); objXmlSpellNode.TryGetStringFieldQuickly("range", ref _strRange); objXmlSpellNode.TryGetStringFieldQuickly("damage", ref _strDamage); objXmlSpellNode.TryGetStringFieldQuickly("duration", ref _strDuration); objXmlSpellNode.TryGetStringFieldQuickly("dv", ref _strDV); _blnLimited = blnLimited; _blnAlchemical = blnAlchemical; objXmlSpellNode.TryGetStringFieldQuickly("source", ref _strSource); objXmlSpellNode.TryGetStringFieldQuickly("page", ref _strPage); _objImprovementSource = objSource; SourceDetail = new SourceString(_strSource, _strPage); /* * if (_strNotes == string.Empty) * { * _strNotes = CommonFunctions.GetText($"{_strSource} {_strPage}", Name); * }*/ }
/// Create an Enhancement from an XmlNode. /// <param name="objXmlArtNode">XmlNode to create the object from.</param> /// <param name="objSource">Source of the Improvement.</param> public void Create(XmlNode objXmlArtNode, Improvement.ImprovementSource objSource) { if (!objXmlArtNode.TryGetField("id", Guid.TryParse, out _guiSourceID)) { Log.Warn(new object[] { "Missing id field for xmlnode", objXmlArtNode }); Utils.BreakIfDebug(); } if (objXmlArtNode.TryGetStringFieldQuickly("name", ref _strName)) { _objCachedMyXmlNode = null; } objXmlArtNode.TryGetStringFieldQuickly("source", ref _strSource); objXmlArtNode.TryGetStringFieldQuickly("page", ref _strPage); _objImprovementSource = objSource; if (!objXmlArtNode.TryGetStringFieldQuickly("altnotes", ref _strNotes)) { objXmlArtNode.TryGetStringFieldQuickly("notes", ref _strNotes); } objXmlArtNode.TryGetInt32FieldQuickly("grade", ref _intGrade); _nodBonus = objXmlArtNode["bonus"]; if (_nodBonus != null) { if (!ImprovementManager.CreateImprovements(_objCharacter, objSource, _guiID.ToString("D", GlobalOptions.InvariantCultureInfo), _nodBonus, 1, DisplayNameShort(GlobalOptions.Language))) { _guiID = Guid.Empty; return; } if (!string.IsNullOrEmpty(ImprovementManager.SelectedValue)) { _strName += LanguageManager.GetString("String_Space") + '(' + ImprovementManager.SelectedValue + ')'; _objCachedMyXmlNode = null; } } /* * if (string.IsNullOrEmpty(_strNotes)) * { * _strNotes = CommonFunctions.GetTextFromPDF(_strSource + ' ' + _strPage, _strName); * if (string.IsNullOrEmpty(_strNotes)) * { * _strNotes = CommonFunctions.GetTextFromPDF(Source + ' ' + DisplayPage(GlobalOptions.Language), CurrentDisplayName); * } * } */ }
/// <summary> /// Load the Enhancement from the XmlNode. /// </summary> /// <param name="objNode">XmlNode to load.</param> public void Load(XmlNode objNode) { objNode.TryGetField("guid", Guid.TryParse, out _guiID); if (objNode.TryGetStringFieldQuickly("name", ref _strName)) { _objCachedMyXmlNode = null; } objNode.TryGetStringFieldQuickly("source", ref _strSource); objNode.TryGetStringFieldQuickly("page", ref _strPage); _nodBonus = objNode["bonus"]; if (objNode["improvementsource"] != null) { _objImprovementSource = Improvement.ConvertToImprovementSource(objNode["improvementsource"].InnerText); } objNode.TryGetInt32FieldQuickly("grade", ref _intGrade); objNode.TryGetStringFieldQuickly("notes", ref _strNotes); }
/// <summary> /// Gets the name of the data file to use that corresponds to a particular Improvement Source denoting the type of object being used. /// </summary> /// <param name="eSource">Type of object being looked at that has grades. Should be either drug, bioware, or cyberware.</param> /// <returns>A full file name that can be used with LoadData() or LoadXData() methods.</returns> public static string GetDataFileNameFromImprovementSource(Improvement.ImprovementSource eSource) { switch (eSource) { case Improvement.ImprovementSource.Drug: return("drugcomponents.xml"); case Improvement.ImprovementSource.Bioware: return("bioware.xml"); case Improvement.ImprovementSource.Cyberware: return("cyberware.xml"); default: Utils.BreakIfDebug(); return("cyberware.xml"); } }
/// <summary> /// Convert a string to a Grade. /// </summary> /// <param name="strValue">String value to convert.</param> /// <param name="objSource">Source representing whether this is a cyberware, drug or bioware grade.</param> /// <param name="objCharacter">Character from which to fetch a grade list</param> public static Grade ConvertToCyberwareGrade(string strValue, Improvement.ImprovementSource objSource, Character objCharacter) { if (objCharacter == null) { throw new ArgumentNullException(nameof(objCharacter)); } IList <Grade> lstGrades = objCharacter.GetGradeList(objSource, true); foreach (Grade objGrade in lstGrades) { if (objGrade.Name == strValue) { return(objGrade); } } return(lstGrades.FirstOrDefault(x => x.Name == "Standard")); }
public frmSelectCyberwareSuite(Character objCharacter, Improvement.ImprovementSource eSource = Improvement.ImprovementSource.Cyberware) { InitializeComponent(); _eSource = eSource; if (_eSource == Improvement.ImprovementSource.Cyberware) { _strType = "cyberware"; } else { _strType = "bioware"; Tag = "Title_SelectBiowareSuite"; gpbCyberware.Tag = "Label_SelectBiowareSuite_PartsInSuite"; } this.UpdateLightDarkMode(); this.TranslateWinForm(); _objCharacter = objCharacter; _objXmlDocument = objCharacter.LoadData(_strType + ".xml", string.Empty, true); }
/// <summary> /// Load the Spell from the XmlNode. /// </summary> /// <param name="objNode">XmlNode to load.</param> public void Load(XmlNode objNode) { if (objNode == null) { return; } if (!objNode.TryGetField("guid", Guid.TryParse, out _guiID)) { _guiID = Guid.NewGuid(); } objNode.TryGetStringFieldQuickly("name", ref _strName); if (!objNode.TryGetGuidFieldQuickly("sourceid", ref _guiSourceID)) { XmlNode node = GetNode(GlobalOptions.Language); node?.TryGetGuidFieldQuickly("id", ref _guiSourceID); } objNode.TryGetStringFieldQuickly("descriptors", ref _strDescriptors); objNode.TryGetStringFieldQuickly("category", ref _strCategory); objNode.TryGetStringFieldQuickly("type", ref _strType); objNode.TryGetStringFieldQuickly("range", ref _strRange); objNode.TryGetStringFieldQuickly("damage", ref _strDamage); objNode.TryGetStringFieldQuickly("duration", ref _strDuration); if (objNode["improvementsource"] != null) { _objImprovementSource = Improvement.ConvertToImprovementSource(objNode["improvementsource"].InnerText); } objNode.TryGetInt32FieldQuickly("grade", ref _intGrade); objNode.TryGetStringFieldQuickly("dv", ref _strDV); if (objNode.TryGetBoolFieldQuickly("limited", ref _blnLimited) && _blnLimited && _objCharacter.LastSavedVersion <= new Version(5, 197, 30)) { GetNode()?.TryGetStringFieldQuickly("dv", ref _strDV); } objNode.TryGetBoolFieldQuickly("extended", ref _blnExtended); objNode.TryGetBoolFieldQuickly("freebonus", ref _blnFreeBonus); objNode.TryGetBoolFieldQuickly("usesunarmed", ref _blnUsesUnarmed); objNode.TryGetBoolFieldQuickly("alchemical", ref _blnAlchemical); objNode.TryGetStringFieldQuickly("source", ref _strSource); objNode.TryGetStringFieldQuickly("page", ref _strPage); objNode.TryGetStringFieldQuickly("extra", ref _strExtra); objNode.TryGetStringFieldQuickly("notes", ref _strNotes); }
public frmSelectCyberwareSuite(Improvement.ImprovementSource objSource, Character objCharacter) { InitializeComponent(); _objSource = objSource; LanguageManager.Instance.Load(GlobalOptions.Instance.Language, this); if (_objSource == Improvement.ImprovementSource.Cyberware) { _strType = "cyberware"; } else { _strType = "bioware"; Text = LanguageManager.Instance.GetString("Title_SelectBiowareSuite"); lblCyberwareLabel.Text = LanguageManager.Instance.GetString("Label_SelectBiowareSuite_PartsInSuite"); } _objCharacter = objCharacter; }
public frmCreateCyberwareSuite(Character objCharacter, Improvement.ImprovementSource objSource) { InitializeComponent(); _objSource = objSource; LanguageManager.Instance.Load(this); _objCharacter = objCharacter; if (_objSource == Improvement.ImprovementSource.Cyberware) { _strType = "cyberware"; } else { _strType = "bioware"; this.Text = LanguageManager.Instance.GetString("Title_CreateBiowareSuite"); } txtFileName.Text = "custom_" + _strType + ".xml"; }
public frmSelectCyberwareSuite(Character objCharacter, Improvement.ImprovementSource eSource = Improvement.ImprovementSource.Cyberware) { InitializeComponent(); _eSource = eSource; this.TranslateWinForm(); if (_eSource == Improvement.ImprovementSource.Cyberware) { _strType = "cyberware"; } else { _strType = "bioware"; Text = LanguageManager.GetString("Title_SelectBiowareSuite"); lblCyberwareLabel.Text = LanguageManager.GetString("Label_SelectBiowareSuite_PartsInSuite"); } _objCharacter = objCharacter; _objXmlDocument = XmlManager.Load(_strType + ".xml", string.Empty, true); }
public CreateCyberwareSuite(Character objCharacter, Improvement.ImprovementSource objSource = Improvement.ImprovementSource.Cyberware) { InitializeComponent(); _objSource = objSource; this.UpdateLightDarkMode(); this.TranslateWinForm(); _objCharacter = objCharacter; if (_objSource == Improvement.ImprovementSource.Cyberware) { _strType = "cyberware"; } else { _strType = "bioware"; Text = LanguageManager.GetString("Title_CreateBiowareSuite"); } txtFileName.Text = "custom_" + _strType + ".xml"; }
/// <summary> /// Creates a sustained object from a thing that can be sustained (usually a Spell, Complex Form, or Critter Power) /// </summary> /// <param name="objLinkedObject">The liked object that is meant to be sustained.</param> /// <returns></returns> public void Create(IHasInternalId objLinkedObject) { _objLinkedObject = objLinkedObject; switch (objLinkedObject) { case Spell _: _eLinkedObjectType = Improvement.ImprovementSource.Spell; break; case ComplexForm _: _eLinkedObjectType = Improvement.ImprovementSource.ComplexForm; break; case CritterPower _: _eLinkedObjectType = Improvement.ImprovementSource.CritterPower; break; default: throw new ArgumentOutOfRangeException(nameof(objLinkedObject)); } }
/// Create an Enhancement from an XmlNode. /// <param name="objXmlArtNode">XmlNode to create the object from.</param> /// <param name="objSource">Source of the Improvement.</param> public void Create(XmlNode objXmlArtNode, Improvement.ImprovementSource objSource) { if (objXmlArtNode.TryGetStringFieldQuickly("name", ref _strName)) { _objCachedMyXmlNode = null; } objXmlArtNode.TryGetStringFieldQuickly("source", ref _strSource); objXmlArtNode.TryGetStringFieldQuickly("page", ref _strPage); _objImprovementSource = objSource; if (!objXmlArtNode.TryGetStringFieldQuickly("altnotes", ref _strNotes)) { objXmlArtNode.TryGetStringFieldQuickly("notes", ref _strNotes); } objXmlArtNode.TryGetInt32FieldQuickly("grade", ref _intGrade); SourceDetail = new SourceString(_strSource, _strPage); _nodBonus = objXmlArtNode["bonus"]; if (_nodBonus != null) { if (!ImprovementManager.CreateImprovements(_objCharacter, objSource, _guiID.ToString("D"), _nodBonus, true, 1, DisplayNameShort(GlobalOptions.Language))) { _guiID = Guid.Empty; return; } if (!string.IsNullOrEmpty(ImprovementManager.SelectedValue)) { _strName += LanguageManager.GetString("String_Space", GlobalOptions.Language) + '(' + ImprovementManager.SelectedValue + ')'; _objCachedMyXmlNode = null; } } /* * if (string.IsNullOrEmpty(_strNotes)) * { * _strNotes = CommonFunctions.GetTextFromPDF($"{_strSource} {_strPage}", _strName); * if (string.IsNullOrEmpty(_strNotes)) * { * _strNotes = CommonFunctions.GetTextFromPDF($"{Source} {Page(GlobalOptions.Language)}", DisplayName(GlobalOptions.Language)); * } * }*/ }
/// <summary> /// Convert a string to a Grade. /// </summary> /// <param name="strValue">String value to convert.</param> /// <param name="objSource">Source representing whether this is a cyberware, drug or bioware grade.</param> /// <param name="objCharacter">Character from which to fetch a grade list</param> public static Grade ConvertToCyberwareGrade(string strValue, Improvement.ImprovementSource objSource, Character objCharacter) { if (objCharacter == null) { throw new ArgumentNullException(nameof(objCharacter)); } Grade objStandardGrade = null; foreach (Grade objGrade in objCharacter.GetGradeList(objSource, true)) { if (objGrade.Name == strValue) { return(objGrade); } if (objGrade.Name == "Standard") { objStandardGrade = objGrade; } } return(objStandardGrade); }
/// <summary> /// Fill the list of CyberwareGrades from the XML files. /// </summary> /// <param name="objSource">Source to load the Grades from, either Bioware or Cyberware.</param> public void LoadList(Improvement.ImprovementSource objSource, CharacterOptions objCharacterOptions = null) { _lstGrades.Clear(); string strXmlFile = "cyberware.xml"; if (objSource == Improvement.ImprovementSource.Bioware) { strXmlFile = "bioware.xml"; } XmlDocument objXMlDocument = XmlManager.Load(strXmlFile); string strBookFilter = string.Empty; if (objCharacterOptions != null) { strBookFilter = "[(" + objCharacterOptions.BookXPath() + ")]"; } foreach (XmlNode objNode in objXMlDocument.SelectNodes("/chummer/grades/grade" + strBookFilter)) { Grade objGrade = new Grade(); objGrade.Load(objNode); _lstGrades.Add(objGrade); } }
/// Create a Metamagic from an XmlNode and return the TreeNodes for it. /// <param name="objXmlMetamagicNode">XmlNode to create the object from.</param> /// <param name="objCharacter">Character the Gear is being added to.</param> /// <param name="objNode">TreeNode to populate a TreeView.</param> /// <param name="objSource">Source of the Improvement.</param> public void Create(XmlNode objXmlMetamagicNode, Character objCharacter, TreeNode objNode, Improvement.ImprovementSource objSource) { _strName = objXmlMetamagicNode["name"].InnerText; _strSource = objXmlMetamagicNode["source"].InnerText; _strPage = objXmlMetamagicNode["page"].InnerText; _objImprovementSource = objSource; try { _intGrade = Convert.ToInt32(objXmlMetamagicNode["grade"].InnerText); } catch { } if (objXmlMetamagicNode.InnerXml.Contains("<bonus>")) { _nodBonus = objXmlMetamagicNode["bonus"]; int intRating = 1; if (_objCharacter.SubmersionGrade > 0) intRating = _objCharacter.SubmersionGrade; else intRating = _objCharacter.InitiateGrade; ImprovementManager objImprovementManager = new ImprovementManager(objCharacter); if (!objImprovementManager.CreateImprovements(objSource, _guiID.ToString(), _nodBonus, true, intRating, DisplayNameShort)) { _guiID = Guid.Empty; return; } if (objImprovementManager.SelectedValue != "") _strName += " (" + objImprovementManager.SelectedValue + ")"; } LanguageManager.Instance.Load(GlobalOptions.Instance.Language, null); if (_objCharacter.SubmersionGrade > 0) objNode.Text = LanguageManager.Instance.GetString("Label_Echo") + " " + DisplayName; else objNode.Text = LanguageManager.Instance.GetString("Label_Metamagic") + " " + DisplayName; objNode.Tag = _guiID.ToString(); }
/// <summary> /// Load the Spell from the XmlNode. /// </summary> /// <param name="objNode">XmlNode to load.</param> public void Load(XmlNode objNode) { Improvement objImprovement = new Improvement(); _guiID = Guid.Parse(objNode["guid"].InnerText); _strName = objNode["name"].InnerText; _strDescriptors = objNode["descriptors"].InnerText; _strCategory = objNode["category"].InnerText; _strType = objNode["type"].InnerText; _strRange = objNode["range"].InnerText; _strDamage = objNode["damage"].InnerText; _strDuration = objNode["duration"].InnerText; try { _objImprovementSource = objImprovement.ConvertToImprovementSource(objNode["improvementsource"].InnerText); } catch { } try { _intGrade = Convert.ToInt32(objNode["grade"].InnerText); } catch { } _strDV = objNode["dv"].InnerText; try { _blnLimited = Convert.ToBoolean(objNode["limited"].InnerText); } catch { } try { _blnExtended = Convert.ToBoolean(objNode["extended"].InnerText); } catch { } try { _blnAlchemical = Convert.ToBoolean(objNode["alchemical"].InnerText); } catch { } _strSource = objNode["source"].InnerText; try { _strPage = objNode["page"].InnerText; } catch { } try { _strExtra = objNode["extra"].InnerText; } catch { } try { _strNotes = objNode["notes"].InnerText; } catch { } if (GlobalOptions.Instance.Language != "en-us") { XmlDocument objXmlDocument = XmlManager.Instance.Load("spells.xml"); XmlNode objSpellNode = objXmlDocument.SelectSingleNode("/chummer/spells/spell[name = \"" + _strName + "\"]"); if (objSpellNode != null) { if (objSpellNode["translate"] != null) _strAltName = objSpellNode["translate"].InnerText; if (objSpellNode["altpage"] != null) _strAltPage = objSpellNode["altpage"].InnerText; } objSpellNode = objXmlDocument.SelectSingleNode("/chummer/categories/category[. = \"" + _strCategory + "\"]"); if (objSpellNode != null) { if (objSpellNode.Attributes["translate"] != null) _strAltCategory = objSpellNode.Attributes["translate"].InnerText; } } }
/// Create a Spell from an XmlNode and return the TreeNodes for it. /// <param name="objXmlSpellNode">XmlNode to create the object from.</param> /// <param name="objCharacter">Character the Gear is being added to.</param> /// <param name="objNode">TreeNode to populate a TreeView.</param> /// <param name="strForcedValue">Value to forcefully select for any ImprovementManager prompts.</param> /// <param name="blnLimited">Whether or not the Spell should be marked as Limited.</param> /// <param name="blnExtended">Whether or not the Spell should be marked as Extended.</param> public void Create(XmlNode objXmlSpellNode, Character objCharacter, TreeNode objNode, string strForcedValue = "", bool blnLimited = false, bool blnExtended = false, bool blnAlchemical = false, Improvement.ImprovementSource objSource = Improvement.ImprovementSource.Spell) { _strName = objXmlSpellNode["name"].InnerText; _strDescriptors = objXmlSpellNode["descriptor"].InnerText; _strCategory = objXmlSpellNode["category"].InnerText; _strType = objXmlSpellNode["type"].InnerText; _strRange = objXmlSpellNode["range"].InnerText; _strDamage = objXmlSpellNode["damage"].InnerText; _strDuration = objXmlSpellNode["duration"].InnerText; _strDV = objXmlSpellNode["dv"].InnerText; _blnLimited = blnLimited; _blnExtended = blnExtended; _blnAlchemical = blnAlchemical; _strSource = objXmlSpellNode["source"].InnerText; _strPage = objXmlSpellNode["page"].InnerText; _objImprovementSource = objSource; string strDV = _strDV; if (_blnLimited && _strDV.StartsWith("F")) { int intPos = 0; if (strDV.Contains("-")) { intPos = strDV.IndexOf("-") + 1; string strAfter = strDV.Substring(intPos, strDV.Length - intPos); strDV = strDV.Substring(0, intPos); int intAfter = Convert.ToInt32(strAfter); intAfter += 2; strDV += intAfter.ToString(); } else if (strDV.Contains("+")) { intPos = strDV.IndexOf("+"); string strAfter = strDV.Substring(intPos, strDV.Length - intPos); strDV = strDV.Substring(0, intPos); int intAfter = Convert.ToInt32(strAfter); intAfter -= 2; if (intAfter > 0) strDV += "+" + intAfter.ToString(); else if (intAfter < 0) strDV += intAfter.ToString(); } else { strDV += "-2"; } } _strDV = strDV; ImprovementManager objImprovementManager = new ImprovementManager(objCharacter); objImprovementManager.ForcedValue = strForcedValue; if (GlobalOptions.Instance.Language != "en-us") { XmlDocument objXmlDocument = XmlManager.Instance.Load("spells.xml"); XmlNode objSpellNode = objXmlDocument.SelectSingleNode("/chummer/spells/spell[name = \"" + _strName + "\"]"); if (objSpellNode != null) { if (objSpellNode["translate"] != null) _strAltName = objSpellNode["translate"].InnerText; if (objSpellNode["altpage"] != null) _strAltPage = objSpellNode["altpage"].InnerText; } objSpellNode = objXmlDocument.SelectSingleNode("/chummer/categories/category[. = \"" + _strCategory + "\"]"); if (objSpellNode != null) { if (objSpellNode.Attributes["translate"] != null) _strAltCategory = objSpellNode.Attributes["translate"].InnerText; } } if (objXmlSpellNode["bonus"] != null) { if (!objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Spell, _guiID.ToString(), objXmlSpellNode["bonus"], false, 1, DisplayNameShort)) { _guiID = Guid.Empty; return; } if (objImprovementManager.SelectedValue != "") { _strExtra = objImprovementManager.SelectedValue; } } //TreeNode objNode = new TreeNode(); objNode.Text = DisplayName; objNode.Tag = _guiID.ToString(); //return objNode; }
/// Create a Metamagic from an XmlNode. /// <param name="objXmlMetamagicNode">XmlNode to create the object from.</param> /// <param name="objSource">Source of the Improvement.</param> /// <param name="strForcedValue">Value to forcefully select for any ImprovementManager prompts.</param> public void Create(XmlNode objXmlMetamagicNode, Improvement.ImprovementSource objSource, string strForcedValue = "") { if (!objXmlMetamagicNode.TryGetField("id", Guid.TryParse, out _guiSourceID)) { Log.Warn(new object[] { "Missing id field for xmlnode", objXmlMetamagicNode }); Utils.BreakIfDebug(); } if (objXmlMetamagicNode.TryGetStringFieldQuickly("name", ref _strName)) { _objCachedMyXmlNode = null; _objCachedMyXPathNode = null; } objXmlMetamagicNode.TryGetStringFieldQuickly("source", ref _strSource); objXmlMetamagicNode.TryGetStringFieldQuickly("page", ref _strPage); _eImprovementSource = objSource; objXmlMetamagicNode.TryGetInt32FieldQuickly("grade", ref _intGrade); if (!objXmlMetamagicNode.TryGetMultiLineStringFieldQuickly("altnotes", ref _strNotes)) { objXmlMetamagicNode.TryGetMultiLineStringFieldQuickly("notes", ref _strNotes); } string sNotesColor = ColorTranslator.ToHtml(ColorManager.HasNotesColor); objXmlMetamagicNode.TryGetStringFieldQuickly("notesColor", ref sNotesColor); _colNotes = ColorTranslator.FromHtml(sNotesColor); if (string.IsNullOrEmpty(Notes)) { Notes = CommonFunctions.GetBookNotes(objXmlMetamagicNode, Name, CurrentDisplayName, Source, Page, DisplayPage(GlobalSettings.Language), _objCharacter); } _nodBonus = objXmlMetamagicNode["bonus"]; if (_nodBonus != null) { int intRating = _objCharacter.SubmersionGrade > 0 ? _objCharacter.SubmersionGrade : _objCharacter.InitiateGrade; string strOldFocedValue = ImprovementManager.ForcedValue; string strOldSelectedValue = ImprovementManager.SelectedValue; ImprovementManager.ForcedValue = strForcedValue; if (!ImprovementManager.CreateImprovements(_objCharacter, objSource, _guiID.ToString("D", GlobalSettings.InvariantCultureInfo), _nodBonus, intRating, DisplayNameShort(GlobalSettings.Language))) { _guiID = Guid.Empty; ImprovementManager.ForcedValue = strOldFocedValue; return; } if (!string.IsNullOrEmpty(ImprovementManager.SelectedValue)) { _strName += LanguageManager.GetString("String_Space") + '(' + ImprovementManager.SelectedValue + ')'; _objCachedMyXmlNode = null; _objCachedMyXPathNode = null; } ImprovementManager.ForcedValue = strOldFocedValue; ImprovementManager.SelectedValue = strOldSelectedValue; } /* * if (string.IsNullOrEmpty(_strNotes)) * { * _strNotes = CommonFunctions.GetTextFromPdf(_strSource + ' ' + _strPage, _strName); * if (string.IsNullOrEmpty(_strNotes)) * { * _strNotes = CommonFunctions.GetTextFromPdf(Source + ' ' + DisplayPage(GlobalSettings.Language), CurrentDisplayName); * } * } */ }
private void TestCyberware(string strFile) { string strPrefix = ""; Improvement.ImprovementSource objSource = new Improvement.ImprovementSource(); if (strFile == "bioware.xml") { strPrefix = "bioware"; objSource = Improvement.ImprovementSource.Bioware; } else { strPrefix = "cyberware"; objSource = Improvement.ImprovementSource.Cyberware; } Character objCharacter = new Character(); XmlDocument objXmlDocument = XmlManager.Instance.Load(strFile); pgbProgress.Minimum = 0; pgbProgress.Value = 0; pgbProgress.Maximum = objXmlDocument.SelectNodes("/chummer/" + strPrefix + "s/" + strPrefix).Count; // Gear. foreach (XmlNode objXmlGear in objXmlDocument.SelectNodes("/chummer/" + strPrefix + "s/" + strPrefix)) { pgbProgress.Value++; Application.DoEvents(); try { TreeNode objTempNode = new TreeNode(); Cyberware objTemp = new Cyberware(objCharacter); List<Weapon> lstWeapons = new List<Weapon>(); List<TreeNode> lstNodes = new List<TreeNode>(); objTemp.Create(objXmlGear, objCharacter, GlobalOptions.CyberwareGrades.GetGrade("Standard"), objSource, 1, objTempNode, lstWeapons, lstNodes); try { int objValue = objTemp.TotalCost; } catch { txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalCost\n"; } try { string objValue = objTemp.TotalAvail; } catch { txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalAvail\n"; } try { int objValue = objTemp.TotalAgility; } catch { txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalAgility\n"; } try { int objValue = objTemp.TotalBody; } catch { txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalBody\n"; } try { int objValue = objTemp.TotalStrength; } catch { txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalStrength\n"; } try { string objValue = objTemp.CalculatedCapacity; } catch { txtOutput.Text += objXmlGear["name"].InnerText + " failed CalculatedCapacity\n"; } try { decimal objValue = objTemp.CalculatedESS; } catch { txtOutput.Text += objXmlGear["name"].InnerText + " failed CalculatedESS\n"; } } catch { txtOutput.Text += objXmlGear["name"].InnerText + " general failure\n"; } } }
/// <summary> /// Load the Metamagic from the XmlNode. /// </summary> /// <param name="objNode">XmlNode to load.</param> public void Load(XmlNode objNode) { Improvement objImprovement = new Improvement(); _guiID = Guid.Parse(objNode["guid"].InnerText); _strName = objNode["name"].InnerText; _strSource = objNode["source"].InnerText; _strPage = objNode["page"].InnerText; try { _blnPaidWithKarma = Convert.ToBoolean(objNode["paidwithkarma"].InnerText); } catch { } _nodBonus = objNode["bonus"]; _objImprovementSource = objImprovement.ConvertToImprovementSource(objNode["improvementsource"].InnerText); try { _strNotes = objNode["notes"].InnerText; } catch { } }
public Grade(Improvement.ImprovementSource eSource) { _eSource = eSource; }
public Grade(Character objCharacter, Improvement.ImprovementSource eSource) { _objCharacter = objCharacter ?? throw new ArgumentNullException(nameof(objCharacter)); _guiID = Guid.NewGuid(); _eSource = eSource; }
/// Create a Metamagic from an XmlNode and return the TreeNodes for it. /// <param name="objXmlMetamagicNode">XmlNode to create the object from.</param> /// <param name="objCharacter">Character the Gear is being added to.</param> /// <param name="objNode">TreeNode to populate a TreeView.</param> /// <param name="objSource">Source of the Improvement.</param> /// <param name="blnCreateImprovements">Whether or not Improvements should be created.</param> public void Create(XmlNode objXmlMetamagicNode, Character objCharacter, TreeNode objNode, Improvement.ImprovementSource objSource, bool blnCreateImprovements = true) { _guidExternalID = Guid.Parse(objXmlMetamagicNode["id"].InnerText); _strName = objXmlMetamagicNode["name"].InnerText; _strSource = objXmlMetamagicNode["source"].InnerText; _strPage = objXmlMetamagicNode["page"].InnerText; _objImprovementSource = objSource; if (blnCreateImprovements) { _nodBonus = objXmlMetamagicNode["bonus"]; _nodConditional = objXmlMetamagicNode["conditional"]; int intRating = 1; if (_objCharacter.SubmersionGrade > 0) intRating = _objCharacter.SubmersionGrade; else intRating = _objCharacter.InitiateGrade; ImprovementManager objImprovementManager = new ImprovementManager(objCharacter); if (!objImprovementManager.CreateImprovements(objSource, _guiID.ToString(), _nodBonus, true, intRating, DisplayNameShort)) { _guiID = Guid.Empty; return; } if (objImprovementManager.SelectedValue != "") _strName += " (" + objImprovementManager.SelectedValue + ")"; // Conditional Improvements. if (!objImprovementManager.CreateImprovements(objSource, _guiID.ToString(), _nodConditional, false, 1, DisplayNameShort, true)) { _guiID = Guid.Empty; return; } } if (GlobalOptions.Instance.Language != "en-us") { string strXmlFile = ""; string strXPath = ""; if (_objImprovementSource == Improvement.ImprovementSource.Metamagic) { strXmlFile = "metamagic.xml"; strXPath = "/chummer/metamagics/metamagic"; } else { strXmlFile = "echoes.xml"; strXPath = "/chummer/echoes/echo"; } XmlDocument objXmlDocument = XmlManager.Instance.Load(strXmlFile); XmlNode objMetamagicNode = objXmlDocument.SelectSingleNode(strXPath + "[id = \"" + ExternalId + "\"]"); if (objMetamagicNode != null) { if (objMetamagicNode["translate"] != null) _strAltName = objMetamagicNode["translate"].InnerText; if (objMetamagicNode["altpage"] != null) _strAltPage = objMetamagicNode["altpage"].InnerText; } } objNode.Text = DisplayName; objNode.Tag = _guiID.ToString(); }
/// Create an Enhancement from an XmlNode and return the TreeNodes for it. /// <param name="objXmlEnhancementNode">XmlNode to create the object from.</param> /// <param name="objCharacter">Character the Enhancement is being added to.</param> /// <param name="objNode">TreeNode to populate a TreeView.</param> /// <param name="objSource">Source of the Improvement.</param> public void Create(XmlNode objXmlArtNode, Character objCharacter, TreeNode objNode, Improvement.ImprovementSource objSource) { _strName = objXmlArtNode["name"].InnerText; _strSource = objXmlArtNode["source"].InnerText; _strPage = objXmlArtNode["page"].InnerText; _objImprovementSource = objSource; try { _intGrade = Convert.ToInt32(objXmlArtNode["grade"].InnerText); } catch { } if (objXmlArtNode.InnerXml.Contains("<bonus>")) { _nodBonus = objXmlArtNode["bonus"]; ImprovementManager objImprovementManager = new ImprovementManager(objCharacter); if (!objImprovementManager.CreateImprovements(objSource, _guiID.ToString(), _nodBonus, true, 1, DisplayNameShort)) { _guiID = Guid.Empty; return; } if (objImprovementManager.SelectedValue != "") _strName += " (" + objImprovementManager.SelectedValue + ")"; } objNode.Text = LanguageManager.Instance.GetString("Label_Enhancement") + " " + DisplayName; objNode.Tag = _guiID.ToString(); }
/// <summary> /// Load the Enhancement from the XmlNode. /// </summary> /// <param name="objNode">XmlNode to load.</param> public void Load(XmlNode objNode) { Improvement objImprovement = new Improvement(); _guiID = Guid.Parse(objNode["guid"].InnerText); _strName = objNode["name"].InnerText; _strSource = objNode["source"].InnerText; _strPage = objNode["page"].InnerText; _nodBonus = objNode["bonus"]; _objImprovementSource = objImprovement.ConvertToImprovementSource(objNode["improvementsource"].InnerText); try { _intGrade = Convert.ToInt32(objNode["grade"].InnerText); } catch { } try { _strNotes = objNode["notes"].InnerText; } catch { } }
public Grade(Improvement.ImprovementSource eSource) { _guidId = Guid.NewGuid(); _eSource = eSource; }
private void TestCyberware(string strFile) { string strPrefix = "cyberware"; Improvement.ImprovementSource objSource = Improvement.ImprovementSource.Cyberware; if (strFile == "bioware.xml") { strPrefix = "bioware"; objSource = Improvement.ImprovementSource.Bioware; } Character objCharacter = new Character(); XmlDocument objXmlDocument = XmlManager.Load(strFile); pgbProgress.Minimum = 0; pgbProgress.Value = 0; pgbProgress.Maximum = objXmlDocument.SelectNodes("/chummer/" + strPrefix + "s/" + strPrefix).Count; Grade objTestGrade = objCharacter.GetGradeList(objSource, true).FirstOrDefault(x => x.Name == "Standard"); // Gear. foreach (XmlNode objXmlGear in objXmlDocument.SelectNodes("/chummer/" + strPrefix + "s/" + strPrefix)) { pgbProgress.Value++; Application.DoEvents(); try { Cyberware objTemp = new Cyberware(objCharacter); List <Weapon> lstWeapons = new List <Weapon>(); List <Vehicle> objVehicles = new List <Vehicle>(); objTemp.Create(objXmlGear, objCharacter, objTestGrade, objSource, 1, lstWeapons, objVehicles); try { decimal objValue = objTemp.TotalCost; } catch { txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalCost\r\n"; } try { string objValue = objTemp.TotalAvail(GlobalOptions.CultureInfo, GlobalOptions.Language); } catch { txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalAvail\r\n"; } try { int objValue = objTemp.TotalAgility; } catch { txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalAgility\r\n"; } try { int objValue = objTemp.TotalBody; } catch { txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalBody\r\n"; } try { int objValue = objTemp.TotalStrength; } catch { txtOutput.Text += objXmlGear["name"].InnerText + " failed TotalStrength\r\n"; } try { string objValue = objTemp.CalculatedCapacity; } catch { txtOutput.Text += objXmlGear["name"].InnerText + " failed CalculatedCapacity\r\n"; } try { decimal objValue = objTemp.CalculatedESS(); } catch { txtOutput.Text += objXmlGear["name"].InnerText + " failed CalculatedESS()\r\n"; } } catch { txtOutput.Text += objXmlGear["name"].InnerText + " general failure\r\n"; } } objCharacter.DeleteCharacter(); }
/// Create a Metamagic from an XmlNode and return the TreeNodes for it. /// <param name="objXmlMetamagicNode">XmlNode to create the object from.</param> /// <param name="objCharacter">Character the Gear is being added to.</param> /// <param name="objNode">TreeNode to populate a TreeView.</param> /// <param name="objSource">Source of the Improvement.</param> public void Create(XmlNode objXmlMetamagicNode, Character objCharacter, TreeNode objNode, Improvement.ImprovementSource objSource) { _strName = objXmlMetamagicNode["name"].InnerText; _strSource = objXmlMetamagicNode["source"].InnerText; _strPage = objXmlMetamagicNode["page"].InnerText; _objImprovementSource = objSource; if (objXmlMetamagicNode.InnerXml.Contains("<bonus>")) { _nodBonus = objXmlMetamagicNode["bonus"]; int intRating = 1; if (_objCharacter.SubmersionGrade > 0) intRating = _objCharacter.SubmersionGrade; else intRating = _objCharacter.InitiateGrade; ImprovementManager objImprovementManager = new ImprovementManager(objCharacter); if (!objImprovementManager.CreateImprovements(objSource, _guiID.ToString(), _nodBonus, true, intRating, DisplayNameShort)) { _guiID = Guid.Empty; return; } if (objImprovementManager.SelectedValue != "") _strName += " (" + objImprovementManager.SelectedValue + ")"; } objNode.Text = DisplayName; objNode.Tag = _guiID.ToString(); }
public static bool TestNodeRequirements(XmlNode node, Character character, out string name, string strIgnoreQuality = "", XmlDocument objMetatypeDocument = null, XmlDocument objCritterDocument = null, XmlDocument objQualityDocument = null) { XmlNode nameNode; switch (node.Name) { case "attribute": // Check to see if an Attribute meets a requirement. CharacterAttrib objAttribute = character.GetAttribute(node["name"].InnerText); name = $"\n\t{objAttribute.DisplayAbbrev} {node["total"].InnerText}"; return(objAttribute.TotalValue >= Convert.ToInt32(node["total"].InnerText)); case "attributetotal": // Check if the character's Attributes add up to a particular total. string strAttributes = Character.AttributeStrings.Aggregate(node["attributes"].InnerText, (current, strAttribute) => current.Replace(strAttribute, character.GetAttribute(strAttribute).DisplayAbbrev)); name = $"\n\t{strAttributes} {node["val"].InnerText}"; strAttributes = Character.AttributeStrings.Aggregate(node["attributes"].InnerText, (current, strAttribute) => current.Replace(strAttribute, character.GetAttribute(strAttribute).Value.ToString())); XmlDocument objXmlDocument = new XmlDocument(); XPathNavigator nav = objXmlDocument.CreateNavigator(); XPathExpression xprAttributes = nav.Compile(strAttributes); return(Convert.ToInt32(nav.Evaluate(xprAttributes)) >= Convert.ToInt32(node["val"].InnerText)); case "careerkarma": // Check Career Karma requirement. name = "\n\t" + LanguageManager.Instance.GetString("Message_SelectQuality_RequireKarma") .Replace("{0}", node.InnerText); return(character.CareerKarma >= Convert.ToInt32(node.InnerText)); case "critterpower": // Run through all of the Powers the character has and see if the current required item exists. if (character.CritterEnabled && character.CritterPowers != null) { CritterPower critterPower = character.CritterPowers.FirstOrDefault(p => p.Name == node.InnerText); if (critterPower != null) { name = critterPower.DisplayNameShort; return(true); } XmlDocument critterPowers = XmlManager.Instance.Load("critterpowers.xml"); nameNode = critterPowers.SelectSingleNode($"/chummer/powers/power[name = \"{node.InnerText}\"]"); name = nameNode["translate"] != null ? "\n\t" + nameNode["translate"].InnerText : "\n\t" + node.InnerText; name += $" ({LanguageManager.Instance.GetString("Tab_Critter")})"; return(false); } break; case "bioware": case "cyberware": { int count = node.Attributes?["count"] != null?Convert.ToInt32(node.Attributes?["count"].InnerText) : 1; name = null; name += node.Name == "cyberware" ? "\n\t" + LanguageManager.Instance.GetString("Label_Cyberware") + node.InnerText : "\n\t" + LanguageManager.Instance.GetString("Label_Bioware") + node.InnerText; return (character.Cyberware.Count( objCyberware => objCyberware.Name == node.InnerText && node.Attributes?["select"] == null || node.Attributes?["select"] != null && node.Attributes?["select"].InnerText == objCyberware.Location) >= count); } case "biowarecontains": case "cyberwarecontains": { int count = node.Attributes?["count"] != null?Convert.ToInt32(node.Attributes?["count"].InnerText) : 1; name = null; name += node.Name == "cyberware" ? "\n\t" + LanguageManager.Instance.GetString("Label_Cyberware") + node.InnerText : "\n\t" + LanguageManager.Instance.GetString("Label_Bioware") + node.InnerText; Improvement.ImprovementSource source = Improvement.ImprovementSource.Cyberware; if (node.Name == "biowarecontains") { source = Improvement.ImprovementSource.Bioware; } return(character.Cyberware.Count(objCyberware => objCyberware.SourceType == source && objCyberware.Name.Contains(node.InnerText) && node.Attributes?["select"] == null || node.Attributes?["select"] != null && node.Attributes?["select"].InnerText == objCyberware.Location) >= count); } case "damageresistance": // Damage Resistance must be a particular value. ImprovementManager objImprovementManager = new ImprovementManager(character); name = "\n\t" + LanguageManager.Instance.GetString("String_DamageResistance"); return(character.BOD.TotalValue + objImprovementManager.ValueOf(Improvement.ImprovementType.DamageResistance) >= Convert.ToInt32(node.InnerText)); case "ess": if (node.Attributes["grade"] != null) { decimal decGrade = character.Cyberware.Where( objCyberware => objCyberware.Grade.Name == node.Attributes?["grade"].InnerText) .Sum(objCyberware => objCyberware.CalculatedESS); if (node.InnerText.StartsWith("-")) { // Essence must be less than the value. name = "\n\t" + LanguageManager.Instance.GetString( "Message_SelectQuality_RequireESSGradeBelow") .Replace("{0}", node.InnerText) .Replace("{1}", node.Attributes["grade"].InnerText) .Replace("{2}", decGrade.ToString(CultureInfo.InvariantCulture)); return(decGrade < Convert.ToDecimal(node.InnerText.Replace("-", string.Empty), GlobalOptions.InvariantCultureInfo)); } // Essence must be equal to or greater than the value. name = "\n\t" + LanguageManager.Instance.GetString( "Message_SelectQuality_RequireESSGradeAbove") .Replace("{0}", node.InnerText) .Replace("{1}", node.Attributes["grade"].InnerText) .Replace("{2}", decGrade.ToString(CultureInfo.InvariantCulture)); return(decGrade >= Convert.ToDecimal(node.InnerText, GlobalOptions.InvariantCultureInfo)); } // Check Essence requirement. if (node.InnerText.StartsWith("-")) { // Essence must be less than the value. name = "\n\t" + LanguageManager.Instance.GetString( "Message_SelectQuality_RequireESSBelow") .Replace("{0}", node.InnerText) .Replace("{1}", character.Essence.ToString(CultureInfo.InvariantCulture)); return(character.Essence < Convert.ToDecimal(node.InnerText.Replace("-", string.Empty), GlobalOptions.InvariantCultureInfo)); } // Essence must be equal to or greater than the value. name = "\n\t" + LanguageManager.Instance.GetString( "Message_SelectQuality_RequireESSAbove") .Replace("{0}", node.InnerText) .Replace("{1}", character.Essence.ToString(CultureInfo.InvariantCulture)); return(character.Essence >= Convert.ToDecimal(node.InnerText, GlobalOptions.InvariantCultureInfo)); case "group": // Check that clustered options are present (Magical Tradition + Skill 6, for example) string result = string.Empty; if (node.ChildNodes.Cast <XmlNode>().Any(childNode => !TestNodeRequirements(childNode, character, out result, strIgnoreQuality, objMetatypeDocument, objCritterDocument, objQualityDocument))) { name = result; return(false); } name = result; return(true); case "initiategrade": // Character's initiate grade must be higher than or equal to the required value. name = "\n\t" + LanguageManager.Instance.GetString("String_InitiateGrade") + " >= " + node.InnerText; return(character.InitiateGrade >= Convert.ToInt32(node.InnerText)); case "martialtechnique": // Character needs a specific Martial Arts technique. XmlNode martialDoc = XmlManager.Instance.Load("martialarts.xml"); nameNode = martialDoc.SelectSingleNode($"/chummer/techniques/technique[name = \"{node.InnerText}\"]"); name = nameNode["translate"] != null ? "\n\t" + nameNode["translate"].InnerText : "\n\t" + node.InnerText; name += $" ({LanguageManager.Instance.GetString("String_MartialArt")})"; return(character.MartialArts.Any(martialart => martialart.Advantages.Any(technique => technique.Name == node.InnerText))); case "metamagic": XmlNode metamagicDoc = XmlManager.Instance.Load("metamagic.xml"); nameNode = metamagicDoc.SelectSingleNode($"/chummer/metamagics/metamagic[name = \"{node.InnerText}\"]"); name = nameNode["translate"] != null ? "\n\t" + nameNode["translate"].InnerText : "\n\t" + node.InnerText; name += $" ({LanguageManager.Instance.GetString("String_Metamagic")})"; return(character.Metamagics.Any(objMetamagic => objMetamagic.Name == node.InnerText)); case "metamagicart": case "art": XmlNode metamagicArtDoc = XmlManager.Instance.Load("metamagic.xml"); nameNode = metamagicArtDoc.SelectSingleNode($"/chummer/arts/art[name = \"{node.InnerText}\"]"); name = nameNode["translate"] != null ? "\n\t" + nameNode["translate"].InnerText : "\n\t" + node.InnerText; name += $" ({LanguageManager.Instance.GetString("String_Art")})"; if (character.Options.IgnoreArt) { if (node.Name == "art") { return(true); } foreach (Metamagic metamagic in character.Metamagics) { XmlNode metaNode = metamagicArtDoc.SelectSingleNode($"/chummer/metamagics/metamagic[name = \"{metamagic.Name}\"]/required"); if (metaNode?.InnerXml.Contains($"<art>{node.InnerText}</art>") == true) { return(metaNode.InnerXml.Contains($"<art>{node.InnerText}</art>")); } metaNode = metamagicArtDoc.SelectSingleNode($"/chummer/metamagics/metamagic[name = \"{metamagic.Name}\"]/forbidden"); if (metaNode?.InnerXml.Contains($"<art>{node.InnerText}</art>") == true) { return(metaNode.InnerXml.Contains($"<art>{node.InnerText}</art>")); } } return(false); } return(character.Arts.Any(art => art.Name == node.InnerText)); case "metatype": // Check the Metatype restriction. nameNode = objMetatypeDocument.SelectSingleNode($"/chummer/metatypes/metatype[name = \"{node.InnerText}\"]") ?? objCritterDocument.SelectSingleNode($"/chummer/metatypes/metatype[name = \"{node.InnerText}\"]"); name = nameNode["translate"] != null ? "\n\t" + nameNode["translate"].InnerText : "\n\t" + node.InnerText; name += $" ({LanguageManager.Instance.GetString("String_Metatype")})"; return(node.InnerText == character.Metatype); case "metatypecategory": // Check the Metatype Category restriction. nameNode = objMetatypeDocument.SelectSingleNode($"/chummer/categories/category[. = \"{node.InnerText}\"]") ?? objCritterDocument.SelectSingleNode($"/chummer/categories/category[. = \"{node.InnerText}\"]"); name = nameNode?.Attributes["translate"] != null ? "\n\t" + nameNode.Attributes["translate"].InnerText : "\n\t" + node.InnerText; name += LanguageManager.Instance.GetString("String_MetatypeCategory"); return(node.InnerText == character.MetatypeCategory); case "metavariant": // Check the Metavariant restriction. nameNode = objMetatypeDocument.SelectSingleNode($"/chummer/metavariants/metavariant[name = \"{node.InnerText}\"]") ?? objCritterDocument.SelectSingleNode($"/chummer/metavariants/metavariant[name = \"{node.InnerText}\"]"); name = nameNode["translate"] != null ? "\n\t" + nameNode["translate"].InnerText : "\n\t" + node.InnerText; name += $" ({LanguageManager.Instance.GetString("String_Metavariant")})"; return(node.InnerText == character.Metavariant); case "power": // Run through all of the Powers the character has and see if the current required item exists. Power power = character.Powers.FirstOrDefault(p => p.Name == node.InnerText); if (power != null) { name = power.DisplayNameShort; return(true); } XmlDocument xmlPowers = XmlManager.Instance.Load("powers.xml"); nameNode = xmlPowers.SelectSingleNode($"/chummer/powers/power[name = \"{node.InnerText}\"]"); name = nameNode["translate"] != null ? "\n\t" + nameNode["translate"].InnerText : "\n\t" + node.InnerText; name += $" ({LanguageManager.Instance.GetString("Tab_Adept")})"; return(false); case "quality": Quality quality = character.Qualities.FirstOrDefault(q => q.Name == node.InnerText && q.Name != strIgnoreQuality); if (quality != null) { name = quality.DisplayNameShort; return(true); } // ReSharper disable once RedundantIfElseBlock (Suppresses node warning) else { nameNode = objQualityDocument.SelectSingleNode($"/chummer/qualities/quality[name = \"{node.InnerText}\"]"); name = nameNode?["translate"] != null ? "\n\t" + nameNode["translate"].InnerText : "\n\t" + node.InnerText; name += $" ({LanguageManager.Instance.GetString("String_Quality")})"; return(false); } case "skill": // Check if the character has the required Skill. if (node["type"] != null) { KnowledgeSkill s = character.SkillsSection.KnowledgeSkills .Where(objSkill => objSkill.Name == node["name"]?.InnerText && (node["spec"] == null || objSkill.Specializations.Any(objSpec => objSpec.Name == node["spec"]?.InnerText))) .FirstOrDefault(objSkill => objSkill.LearnedRating >= Convert.ToInt32(node["val"]?.InnerText)); if (s != null) { name = s.DisplayName; if (node["spec"] != null) { name += $" ({node["spec"].InnerText})"; } if (node["val"] != null) { name += $" {node["val"].InnerText}"; } return(true); } } else { Skill s = character.SkillsSection.Skills .Where(objSkill => objSkill.Name == node["name"]?.InnerText && (node["spec"] == null || objSkill.Specializations.Any(objSpec => objSpec.Name == node["spec"]?.InnerText))) .FirstOrDefault(objSkill => objSkill.LearnedRating >= Convert.ToInt32(node["val"]?.InnerText)); if (s != null) { name = s.DisplayName; if (node["spec"] != null) { name += $" ({node["spec"].InnerText})"; } if (node["val"] != null) { name += $" {node["val"].InnerText}"; } return(true); } } XmlDocument xmlSkills = XmlManager.Instance.Load("skills.xml"); nameNode = xmlSkills.SelectSingleNode($"/chummer/skills/skill[name = \"{node["name"].InnerText}\"]"); name = nameNode?["translate"] != null ? "\n\t" + nameNode["translate"].InnerText : "\n\t" + node["name"].InnerText; if (node["spec"] != null) { name += $" ({node["spec"].InnerText})"; } if (node["val"] != null) { name += $" {node["val"].InnerText}"; } name += $" ({LanguageManager.Instance.GetString("Tab_Skills")})"; return(false); case "skillgrouptotal": { // Check if the total combined Ratings of Skill Groups adds up to a particular total. int intTotal = 0; var strGroups = node["skillgroups"].InnerText.Split('+'); string outString = "\n\t"; for (int i = 0; i <= strGroups.Length - 1; i++) { foreach (SkillGroup objGroup in character.SkillsSection.SkillGroups) { if (objGroup.Name == strGroups[i]) { outString += objGroup.DisplayName + ", "; intTotal += objGroup.Rating; break; } } } name = outString; name += $" ({LanguageManager.Instance.GetString("String_ExpenseSkillGroup")})"; return(intTotal >= Convert.ToInt32(node["val"].InnerText)); } case "spell": // Check for a specific Spell. XmlDocument xmlSpell = XmlManager.Instance.Load("spells.xml"); nameNode = xmlSpell.SelectSingleNode($"/chummer/spells/spell[name = \"{node.InnerText}\"]"); name = nameNode["translate"] != null ? "\n\t" + nameNode["translate"].InnerText : "\n\t" + node.InnerText; name += $" ({LanguageManager.Instance.GetString("String_DescSpell")})"; return(character.Spells.Any(spell => spell.Name == node.InnerText)); case "spellcategory": // Check for a specified amount of a particular Spell category. XmlDocument xmlSpells = XmlManager.Instance.Load("spells.xml"); nameNode = xmlSpells.SelectSingleNode($"/chummer/categories/category[. = \"{node["name"].InnerText}\"]"); name = nameNode["translate"] != null ? "\n\t" + nameNode["translate"].InnerText : "\n\t" + node.InnerText; name += $" ({LanguageManager.Instance.GetString("String_SpellCategory")})"; return(character.Spells.Count(objSpell => objSpell.Category == node["name"].InnerText) >= Convert.ToInt32(node["count"].InnerText)); case "spelldescriptor": // Check for a specified amount of a particular Spell Descriptor. name = "\n\t" + LanguageManager.Instance.GetString("Label_Descriptors") + " >= " + node["count"].InnerText; return(character.Spells.Count(objSpell => objSpell.Descriptors.Contains(node["name"].InnerText)) >= Convert.ToInt32(node["count"].InnerText)); case "streetcredvsnotoriety": // Street Cred must be higher than Notoriety. name = "\n\t" + LanguageManager.Instance.GetString("String_StreetCred") + " >= " + LanguageManager.Instance.GetString("String_Notoriety"); return(character.StreetCred >= character.Notoriety); case "tradition": // Character needs a specific Tradition. XmlDocument xmlTradition = XmlManager.Instance.Load("traditions.xml"); nameNode = xmlTradition.SelectSingleNode($"/chummer/traditions/tradition[name = \"{node.InnerText}\"]"); name = nameNode["translate"] != null ? "\n\t" + nameNode["translate"].InnerText : "\n\t" + node.InnerText; name += $" ({LanguageManager.Instance.GetString("String_Tradition")})"; return(character.MagicTradition == node.InnerText); default: Utils.BreakIfDebug(); break; } name = node.InnerText; return(false); }
/// <summary> /// Load the Metamagic from the XmlNode. /// </summary> /// <param name="objNode">XmlNode to load.</param> public void Load(XmlNode objNode) { Improvement objImprovement = new Improvement(); _guidExternalID = Guid.Parse(objNode["eguid"].InnerText); _guiID = Guid.Parse(objNode["guid"].InnerText); _strName = objNode["name"].InnerText; _strSource = objNode["source"].InnerText; _strPage = objNode["page"].InnerText; _blnPaidWithKarma = Convert.ToBoolean(objNode["paidwithkarma"].InnerText); _nodBonus = objNode["bonus"]; _nodConditional = objNode["conditional"]; _objImprovementSource = objImprovement.ConvertToImprovementSource(objNode["improvementsource"].InnerText); _strNotes = objNode["notes"].InnerText; if (GlobalOptions.Instance.Language != "en-us") { string strXmlFile = ""; string strXPath = ""; if (_objImprovementSource == Improvement.ImprovementSource.Metamagic) { strXmlFile = "metamagic.xml"; strXPath = "/chummer/metamagics/metamagic"; } else { strXmlFile = "echoes.xml"; strXPath = "/chummer/echoes/echo"; } XmlDocument objXmlDocument = XmlManager.Instance.Load(strXmlFile); XmlNode objMetamagicNode = objXmlDocument.SelectSingleNode(strXPath + "[id = \"" + ExternalId + "\"]"); if (objMetamagicNode != null) { if (objMetamagicNode["translate"] != null) _strAltName = objMetamagicNode["translate"].InnerText; if (objMetamagicNode["altpage"] != null) _strAltPage = objMetamagicNode["altpage"].InnerText; } } }