/// <summary>
        /// 
        /// </summary>
        /// <param name="gear"></param>
        /// <param name="attribute"></param>
        public ParameterAttribute(Gear gear, String attribute)
        {
            _gear = gear;
            _attribute = attribute;

            //If we have FixedValues use that
            //I wan't to create array with rating as index for future, but
            //this is keept for backwards/laziness
            if (_attribute.StartsWith("FixedValues"))
            {
                //Regex to extracxt anything between ( ) in Param
                Match m = FixedExtract.Match(_attribute);
                String vals = m.Groups[1].Value;

                //Regex to extract anything inbetween [ ]
                //Not sure why i don't just split by , and remove it durring
                //next phase
                MatchCollection m2 = Regex.Matches(vals, @"\[([^\]]*)\]");

                double junk; //Not used, tryparse needs out

                //LINQ magic to cast matchcollection to the double[]
                fixedDoubles = (from val in m2.Cast<Match>()
                    where double.TryParse(val.Groups[1].Value, out junk)
                    select double.Parse(val.Groups[1].Value)).ToArray();
            }
            else
            {

            }
        }
Example #2
0
 public frmSelectNexus(Character objCharacter, bool blnCareer = false)
 {
     InitializeComponent();
     LanguageManager.Instance.Load(GlobalOptions.Instance.Language, this);
     _objCharacter = objCharacter;
     _objGear = new Gear(objCharacter);
     chkFreeItem.Visible = blnCareer;
     MoveControls();
 }
Example #3
0
        /// <summary>
        /// Move a Gear TreeNode after Drag and Drop, changing its parent.
        /// </summary>
        /// <param name="intNewIndex">Node's new idnex.</param>
        /// <param name="objDestination">Destination Node.</param>
        public void MoveGearParent(int intNewIndex, TreeNode objDestination, TreeView treGear, ContextMenuStrip cmsGear)
        {
            // The item cannot be dropped onto itself.
            if (objDestination == treGear.SelectedNode)
                return;
            // The item cannot be dropped onto one of its children.
            foreach (TreeNode objNode in treGear.SelectedNode.Nodes)
            {
                if (objNode == objDestination)
                    return;
            }

            // Locate the currently selected piece of Gear.
            Gear objGear = new Gear(_objCharacter);
            objGear = _objFunctions.FindGear(treGear.SelectedNode.Tag.ToString(), _objCharacter.Gear);

            // Gear cannot be moved to one if its children.
            bool blnAllowMove = true;
            TreeNode objFindNode = objDestination;
            if (objDestination.Level > 0)
            {
                do
                {
                    objFindNode = objFindNode.Parent;
                    if (objFindNode.Tag.ToString() == objGear.InternalId)
                    {
                        blnAllowMove = false;
                        break;
                    }
                } while (objFindNode.Level > 0);
            }

            if (!blnAllowMove)
                return;

            // Remove the Gear from the character.
            if (objGear.Parent == null)
                _objCharacter.Gear.Remove(objGear);
            else
                objGear.Parent.Children.Remove(objGear);

            if (objDestination.Level == 0)
            {
                // The Gear was moved to a location, so add it to the character instead.
                _objCharacter.Gear.Add(objGear);
                objGear.Location = objDestination.Text;
                objGear.Parent = null;
            }
            else
            {
                Gear objParent = new Gear(_objCharacter);
                // Locate the Gear that the item was dropped on.
                objParent = _objFunctions.FindGear(objDestination.Tag.ToString(), _objCharacter.Gear);

                // Add the Gear as a child of the destination Node and clear its location.
                objParent.Children.Add(objGear);
                objGear.Location = "";
                objGear.Parent = objParent;
            }

            TreeNode objClone = treGear.SelectedNode;
            objClone.ContextMenuStrip = cmsGear;

            // Remove the current Node.
            treGear.SelectedNode.Remove();

            // Add the new Node to the new parent.
            objDestination.Nodes.Add(objClone);
            objDestination.Expand();
        }
Example #4
0
        /// <summary>
        /// Change the Equipped status of a piece of Gear and all of its children.
        /// </summary>
        /// <param name="objGear">Gear object to change.</param>
        /// <param name="blnEquipped">Whether or not the Gear should be marked as Equipped.</param>
        public void ChangeGearEquippedStatus(Gear objGear, bool blnEquipped)
        {
            if (blnEquipped)
            {
                // Add any Improvements from the Gear.
                if (objGear.Bonus != null)
                {
                    bool blnAddImprovement = true;
                    // If this is a Focus which is not bonded, don't do anything.
                    if (objGear.Category != "Stacked Focus")
                    {
                        if (objGear.Category.EndsWith("Foci"))
                            blnAddImprovement = objGear.Bonded;

                        if (blnAddImprovement)
                        {
                            if (objGear.Extra != string.Empty)
                                _objImprovementManager.ForcedValue = objGear.Extra;
                            _objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Gear, objGear.InternalId, objGear.Bonus, false, objGear.Rating, objGear.DisplayNameShort);
                        }
                    }
                    else
                    {
                        // Stacked Foci need to be handled a little differently.
                        foreach (StackedFocus objStack in _objCharacter.StackedFoci)
                        {
                            if (objStack.GearId == objGear.InternalId)
                            {
                                if (objStack.Bonded)
                                {
                                    foreach (Gear objFociGear in objStack.Gear)
                                    {
                                        if (objFociGear.Extra != string.Empty)
                                            _objImprovementManager.ForcedValue = objFociGear.Extra;
                                        _objImprovementManager.CreateImprovements(Improvement.ImprovementSource.StackedFocus, objStack.InternalId, objFociGear.Bonus, false, objFociGear.Rating, objFociGear.DisplayNameShort);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                // Remove any Improvements from the Gear.
                if (objGear.Bonus != null)
                {
                    if (objGear.Category != "Stacked Focus")
                        _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Gear, objGear.InternalId);
                    else
                    {
                        // Stacked Foci need to be handled a little differetnly.
                        foreach (StackedFocus objStack in _objCharacter.StackedFoci)
                        {
                            if (objStack.GearId == objGear.InternalId)
                            {
                                foreach (Gear objFociGear in objStack.Gear)
                                    _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.StackedFocus, objStack.InternalId);
                            }
                        }
                    }
                }
            }

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

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

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

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

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

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

            string strSource = _guiID.ToString();

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

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

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

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

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

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

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

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

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

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

                        Gear objPlugin4 = new Gear(_objCharacter);
                        TreeNode objPlugin4Node = new TreeNode();
                        objPlugin4.Create(objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Optimization\" and category = \"Program Options\"]"), objCharacter, objPlugin4Node, _intRating, null, null);
                        if (_intRating == 0)
                            objPlugin4.Rating = 1;
                        objPlugin4.Avail = "0";
                        objPlugin4.Cost = "0";
                        objPlugin4.Cost3 = "0";
                        objPlugin4.Cost6 = "0";
                        objPlugin4.Cost10 = "0";
                        objPlugin4.Capacity = "[0]";
                        objPlugin4.Parent = this;
                        _objChildren.Add(objPlugin4);
                        objNode.Nodes.Add(objPlugin4Node);
                        objNode.Expand();
                    }
                }
            }
        }
Example #6
0
        /// <summary>
        /// Create a Critter, put them into Career Mode, link them, and open the newly-created Critter.
        /// </summary>
        /// <param name="strCritterName">Name of the Critter's Metatype.</param>
        /// <param name="intForce">Critter's Force.</param>
        private void CreateCritter(string strCritterName, int intForce)
        {
            // The Critter should use the same settings file as the character.
            Character objCharacter = new Character();
            objCharacter.SettingsFile = _objSpirit.CharacterObject.SettingsFile;

            // Override the defaults for the setting.
            objCharacter.IgnoreRules = true;
            objCharacter.IsCritter = true;
            objCharacter.BuildMethod = CharacterBuildMethod.Karma;
            objCharacter.BuildPoints = 0;

            if (txtCritterName.Text != string.Empty)
                objCharacter.Name = txtCritterName.Text;

            // Make sure that Running Wild is one of the allowed source books since most of the Critter Powers come from this book.
            bool blnRunningWild = false;
            blnRunningWild = (objCharacter.Options.Books.Contains("RW"));

            if (!blnRunningWild)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_Main_RunningWild"), LanguageManager.Instance.GetString("MessageTitle_Main_RunningWild"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // Ask the user to select a filename for the new character.
            string strForce = LanguageManager.Instance.GetString("String_Force");
            if (_objSpirit.EntityType == SpiritType.Sprite)
                strForce = LanguageManager.Instance.GetString("String_Rating");
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.Filter = "Chummer5 Files (*.chum5)|*.chum5|All Files (*.*)|*.*";
            saveFileDialog.FileName = strCritterName + " (" + strForce + " " + _objSpirit.Force.ToString() + ").chum5";
            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string strFileName = saveFileDialog.FileName;
                objCharacter.FileName = strFileName;
            }
            else
                return;

            // Code from frmMetatype.
            ImprovementManager objImprovementManager = new ImprovementManager(objCharacter);
            XmlDocument objXmlDocument = XmlManager.Instance.Load("critters.xml");

            XmlNode objXmlMetatype = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + strCritterName + "\"]");

            // If the Critter could not be found, show an error and get out of here.
            if (objXmlMetatype == null)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_UnknownCritterType").Replace("{0}", strCritterName), LanguageManager.Instance.GetString("MessageTitle_SelectCritterType"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Set Metatype information.
            if (strCritterName == "Ally Spirit")
            {
                objCharacter.BOD.AssignLimits(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["bodmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["bodaug"].InnerText, intForce, 0));
                objCharacter.AGI.AssignLimits(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["agimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["agiaug"].InnerText, intForce, 0));
                objCharacter.REA.AssignLimits(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["reamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["reaaug"].InnerText, intForce, 0));
                objCharacter.STR.AssignLimits(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["strmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["straug"].InnerText, intForce, 0));
                objCharacter.CHA.AssignLimits(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["chamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["chaaug"].InnerText, intForce, 0));
                objCharacter.INT.AssignLimits(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["intmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["intaug"].InnerText, intForce, 0));
                objCharacter.LOG.AssignLimits(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["logmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["logaug"].InnerText, intForce, 0));
                objCharacter.WIL.AssignLimits(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["wilmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["wilaug"].InnerText, intForce, 0));
                objCharacter.INI.AssignLimits(ExpressionToString(objXmlMetatype["inimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["iniaug"].InnerText, intForce, 0));
                objCharacter.MAG.AssignLimits(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["magmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["magaug"].InnerText, intForce, 0));
                objCharacter.RES.AssignLimits(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["resmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["resaug"].InnerText, intForce, 0));
                objCharacter.EDG.AssignLimits(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["edgmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["edgaug"].InnerText, intForce, 0));
                objCharacter.ESS.AssignLimits(ExpressionToString(objXmlMetatype["essmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essaug"].InnerText, intForce, 0));
            }
            else
            {
                int intMinModifier = -3;
                if (objXmlMetatype["category"].InnerText == "Mutant Critters")
                    intMinModifier = 0;
                objCharacter.BOD.AssignLimits(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 3));
                objCharacter.AGI.AssignLimits(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 3));
                objCharacter.REA.AssignLimits(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 3));
                objCharacter.STR.AssignLimits(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 3));
                objCharacter.CHA.AssignLimits(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 3));
                objCharacter.INT.AssignLimits(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 3));
                objCharacter.LOG.AssignLimits(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 3));
                objCharacter.WIL.AssignLimits(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 3));
                objCharacter.INI.AssignLimits(ExpressionToString(objXmlMetatype["inimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["iniaug"].InnerText, intForce, 0));
                objCharacter.MAG.AssignLimits(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 3));
                objCharacter.RES.AssignLimits(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 3));
                objCharacter.EDG.AssignLimits(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 3));
                objCharacter.ESS.AssignLimits(ExpressionToString(objXmlMetatype["essmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essaug"].InnerText, intForce, 0));
            }

            // If we're working with a Critter, set the Attributes to their default values.
            objCharacter.BOD.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 0));
            objCharacter.AGI.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 0));
            objCharacter.REA.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 0));
            objCharacter.STR.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 0));
            objCharacter.CHA.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 0));
            objCharacter.INT.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 0));
            objCharacter.LOG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 0));
            objCharacter.WIL.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 0));
            objCharacter.MAG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 0));
            objCharacter.RES.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 0));
            objCharacter.EDG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 0));
            objCharacter.ESS.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0));

            // Sprites can never have Physical Attributes or WIL.
            if (objXmlMetatype["category"].InnerText.EndsWith("Sprite"))
            {
                objCharacter.BOD.AssignLimits("0", "0", "0");
                objCharacter.AGI.AssignLimits("0", "0", "0");
                objCharacter.REA.AssignLimits("0", "0", "0");
                objCharacter.STR.AssignLimits("0", "0", "0");
                objCharacter.WIL.AssignLimits("0", "0", "0");
                objCharacter.INI.MetatypeMinimum = Convert.ToInt32(ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0));
                objCharacter.INI.MetatypeMaximum = Convert.ToInt32(ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0));
            }

            objCharacter.Metatype = strCritterName;
            objCharacter.MetatypeCategory = objXmlMetatype["category"].InnerText;
            objCharacter.Metavariant = "";
            objCharacter.MetatypeBP = 0;

            if (objXmlMetatype["movement"] != null)
                objCharacter.Movement = objXmlMetatype["movement"].InnerText;
            // Load the Qualities file.
            XmlDocument objXmlQualityDocument = XmlManager.Instance.Load("qualities.xml");

            // Determine if the Metatype has any bonuses.
            if (objXmlMetatype.InnerXml.Contains("bonus"))
                objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Metatype, strCritterName, objXmlMetatype.SelectSingleNode("bonus"), false, 1, strCritterName);

            // Create the Qualities that come with the Metatype.
            foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/positive/quality"))
            {
                XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]");
                TreeNode objNode = new TreeNode();
                List<Weapon> objWeapons = new List<Weapon>();
                List<TreeNode> objWeaponNodes = new List<TreeNode>();
                Quality objQuality = new Quality(objCharacter);
                string strForceValue = "";
                if (objXmlQualityItem.Attributes["select"] != null)
                    strForceValue = objXmlQualityItem.Attributes["select"].InnerText;
                QualitySource objSource = new QualitySource();
                objSource = QualitySource.Metatype;
                if (objXmlQualityItem.Attributes["removable"] != null)
                    objSource = QualitySource.MetatypeRemovable;
                objQuality.Create(objXmlQuality, objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue);
                objCharacter.Qualities.Add(objQuality);

                // Add any created Weapons to the character.
                foreach (Weapon objWeapon in objWeapons)
                    objCharacter.Weapons.Add(objWeapon);
            }
            foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/negative/quality"))
            {
                XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]");
                TreeNode objNode = new TreeNode();
                List<Weapon> objWeapons = new List<Weapon>();
                List<TreeNode> objWeaponNodes = new List<TreeNode>();
                Quality objQuality = new Quality(objCharacter);
                string strForceValue = "";
                if (objXmlQualityItem.Attributes["select"] != null)
                    strForceValue = objXmlQualityItem.Attributes["select"].InnerText;
                QualitySource objSource = new QualitySource();
                objSource = QualitySource.Metatype;
                if (objXmlQualityItem.Attributes["removable"] != null)
                    objSource = QualitySource.MetatypeRemovable;
                objQuality.Create(objXmlQuality, objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue);
                objCharacter.Qualities.Add(objQuality);

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

            // Add any Critter Powers the Metatype/Critter should have.
            XmlNode objXmlCritter = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + objCharacter.Metatype + "\"]");

            objXmlDocument = XmlManager.Instance.Load("critterpowers.xml");
            foreach (XmlNode objXmlPower in objXmlCritter.SelectNodes("powers/power"))
            {
                XmlNode objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + objXmlPower.InnerText + "\"]");
                TreeNode objNode = new TreeNode();
                CritterPower objPower = new CritterPower(objCharacter);
                string strForcedValue = "";
                int intRating = 0;

                if (objXmlPower.Attributes["rating"] != null)
                    intRating = Convert.ToInt32(objXmlPower.Attributes["rating"].InnerText);
                if (objXmlPower.Attributes["select"] != null)
                    strForcedValue = objXmlPower.Attributes["select"].InnerText;

                objPower.Create(objXmlCritterPower, objCharacter, objNode, intRating, strForcedValue);
                objCharacter.CritterPowers.Add(objPower);
            }

            //TODO, when is this shit required, 4e holdover or need?
            // Set the Skill Ratings for the Critter.
            //foreach (XmlNode objXmlSkill in objXmlCritter.SelectNodes("skills/skill"))
            //{
            //	if (objXmlSkill.InnerText.Contains("Exotic"))
            //	{
            //		Skill objExotic = new Skill(objCharacter);
            //		objExotic.ExoticSkill = true;
            //		objExotic.Attribute = "AGI";
            //		if (objXmlSkill.Attributes["spec"] != null)
               //                 {
               //                     SkillSpecialization objSpec = new SkillSpecialization(objXmlSkill.Attributes["spec"].InnerText);
               //                     objExotic.Specializations.Add(objSpec);
               //                 }
            //		if (Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)) > 6)
            //			objExotic.RatingMaximum = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0));
            //		objExotic.Rating = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0));
            //		objExotic.Name = objXmlSkill.InnerText;
            //		objCharacter.Skills.Add(objExotic);
            //	}
            //	else
            //	{
            //		foreach (Skill objSkill in objCharacter.Skills)
            //		{
            //			if (objSkill.Name == objXmlSkill.InnerText)
            //			{
            //				if (objXmlSkill.Attributes["spec"] != null)
               //                         {
               //                             SkillSpecialization objSpec = new SkillSpecialization(objXmlSkill.Attributes["spec"].InnerText);
               //                             objSkill.Specializations.Add(objSpec);
               //                         }
            //				if (Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)) > 6)
            //					objSkill.RatingMaximum = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0));
            //				objSkill.Rating = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0));
            //				break;
            //			}
            //		}
            //	}
            //}

            // Set the Skill Group Ratings for the Critter.
            //foreach (XmlNode objXmlSkill in objXmlCritter.SelectNodes("skills/group"))
            //{
            //	foreach (SkillGroup objSkill in objCharacter.SkillGroups)
            //	{
            //		if (objSkill.Name == objXmlSkill.InnerText)
            //		{
            //			objSkill.RatingMaximum = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0));
            //			objSkill.Rating = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0));
            //			break;
            //		}
            //	}
            //}

            //TODO: WHEN IS THIS NEEDED, 4e holdover?
            //// Set the Knowledge Skill Ratings for the Critter.
            //foreach (XmlNode objXmlSkill in objXmlCritter.SelectNodes("skills/knowledge"))
            //{
            //	Skill objKnowledge = new Skill(objCharacter);
            //	objKnowledge.Name = objXmlSkill.InnerText;
            //	objKnowledge.KnowledgeSkill = true;
            //	if (objXmlSkill.Attributes["spec"] != null)
               //             {
               //                 SkillSpecialization objSpec = new SkillSpecialization(objXmlSkill.Attributes["spec"].InnerText);
               //                 objKnowledge.Specializations.Add(objSpec);
               //             }
            //	objKnowledge.SkillCategory = objXmlSkill.Attributes["category"].InnerText;
            //	if (Convert.ToInt32(objXmlSkill.Attributes["rating"].InnerText) > 6)
            //		objKnowledge.RatingMaximum = Convert.ToInt32(objXmlSkill.Attributes["rating"].InnerText);
            //	objKnowledge.Rating = Convert.ToInt32(objXmlSkill.Attributes["rating"].InnerText);
            //	objCharacter.Skills.Add(objKnowledge);
            //}

            //// If this is a Critter with a Force (which dictates their Skill Rating/Maximum Skill Rating), set their Skill Rating Maximums.
            //if (intForce > 0)
            //{
            //	int intMaxRating = intForce;
            //	// Determine the highest Skill Rating the Critter has.
            //	foreach (Skill objSkill in objCharacter.Skills)
            //	{
            //		if (objSkill.RatingMaximum > intMaxRating)
            //			intMaxRating = objSkill.RatingMaximum;
            //	}

            //	// Now that we know the upper limit, set all of the Skill Rating Maximums to match.
            //	foreach (Skill objSkill in objCharacter.Skills)
            //		objSkill.RatingMaximum = intMaxRating;
            //	foreach (SkillGroup objGroup in objCharacter.SkillGroups)
            //		objGroup.RatingMaximum = intMaxRating;

            //	// Set the MaxSkillRating for the character so it can be used later when they add new Knowledge Skills or Exotic Skills.
            //	objCharacter.MaxSkillRating = intMaxRating;
            //}

            // Add any Complex Forms the Critter comes with (typically Sprites)
            XmlDocument objXmlProgramDocument = XmlManager.Instance.Load("complexforms.xml");
            foreach (XmlNode objXmlComplexForm in objXmlCritter.SelectNodes("complexforms/complexform"))
            {
                string strForceValue = "";
                if (objXmlComplexForm.Attributes["select"] != null)
                    strForceValue = objXmlComplexForm.Attributes["select"].InnerText;
                XmlNode objXmlProgram = objXmlProgramDocument.SelectSingleNode("/chummer/complexforms/complexform[name = \"" + objXmlComplexForm.InnerText + "\"]");
                TreeNode objNode = new TreeNode();
                ComplexForm objProgram = new ComplexForm(objCharacter);
                objProgram.Create(objXmlProgram, objCharacter, objNode, strForceValue);
                objCharacter.ComplexForms.Add(objProgram);
            }

            // Add any Gear the Critter comes with (typically Programs for A.I.s)
            XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml");
            foreach (XmlNode objXmlGear in objXmlCritter.SelectNodes("gears/gear"))
            {
                int intRating = 0;
                if (objXmlGear.Attributes["rating"] != null)
                    intRating = Convert.ToInt32(ExpressionToString(objXmlGear.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0));
                string strForceValue = "";
                if (objXmlGear.Attributes["select"] != null)
                    strForceValue = objXmlGear.Attributes["select"].InnerText;
                XmlNode objXmlGearItem = objXmlGearDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objXmlGear.InnerText + "\"]");
                TreeNode objNode = new TreeNode();
                Gear objGear = new Gear(objCharacter);
                List<Weapon> lstWeapons = new List<Weapon>();
                List<TreeNode> lstWeaponNodes = new List<TreeNode>();
                objGear.Create(objXmlGearItem, objCharacter, objNode, intRating, lstWeapons, lstWeaponNodes, strForceValue);
                objGear.Cost = "0";
                objGear.Cost3 = "0";
                objGear.Cost6 = "0";
                objGear.Cost10 = "0";
                objCharacter.Gear.Add(objGear);
            }

            // If this is a Mutant Critter, count up the number of Skill points they start with.
            if (objCharacter.MetatypeCategory == "Mutant Critters")
            {
                foreach (Skill objSkill in objCharacter.SkillsSection.Skills)
                    objCharacter.MutantCritterBaseSkills += objSkill.Rating;
            }

            // Add the Unarmed Attack Weapon to the character.
            try
            {
                objXmlDocument = XmlManager.Instance.Load("weapons.xml");
                XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"Unarmed Attack\"]");
                TreeNode objDummy = new TreeNode();
                Weapon objWeapon = new Weapon(objCharacter);
                objWeapon.Create(objXmlWeapon, objCharacter, objDummy, null, null);
                objCharacter.Weapons.Add(objWeapon);
            }
            catch
            {
            }

            objCharacter.Alias = strCritterName;
            objCharacter.Created = true;
            objCharacter.Save();

            string strOpenFile = objCharacter.FileName;
            objCharacter = null;

            // Link the newly-created Critter to the Spirit.
            _objSpirit.FileName = strOpenFile;
            if (_objSpirit.EntityType == SpiritType.Spirit)
                tipTooltip.SetToolTip(imgLink, LanguageManager.Instance.GetString("Tip_Spirit_OpenFile"));
            else
                tipTooltip.SetToolTip(imgLink, LanguageManager.Instance.GetString("Tip_Sprite_OpenFile"));
            FileNameChanged(this);

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

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

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

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

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

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

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

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

            if (blnCopy)
            {
                _guiID = Guid.NewGuid();
                _blnHomeNode = false;
            }
        }
        /// <summary>
        /// A Metatype has been selected, so fill in all of the necessary Character information.
        /// </summary>
        void MetatypeSelected()
        {
            if (_objCharacter.BuildMethod == CharacterBuildMethod.SumtoTen && (SumtoTen() != _objCharacter.SumtoTen))
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_SumtoTen").Replace("{0}", (_objCharacter.SumtoTen.ToString())).Replace("{1}", (SumtoTen().ToString())));
                return;
            }
            if (cboTalents.SelectedIndex == -1)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_Metatype_SelectTalent"), LanguageManager.Instance.GetString("MessageTitle_Metatype_SelectTalent"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if ((cboSkill1.SelectedIndex == -1 && cboSkill1.Visible) || (cboSkill2.SelectedIndex == -1 && cboSkill2.Visible))
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_Metatype_SelectSkill"), LanguageManager.Instance.GetString("MessageTitle_Metatype_SelectSkill"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (cboSkill1.Visible && cboSkill2.Visible && cboSkill1.SelectedValue.ToString() == cboSkill2.SelectedValue.ToString())
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_Metatype_Duplicate"), LanguageManager.Instance.GetString("MessageTitle_Metatype_Duplicate"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (lstMetatypes.Text != "")
            {
                ImprovementManager objImprovementManager = new ImprovementManager(_objCharacter);
                XmlDocument objXmlDocument = XmlManager.Instance.Load(_strXmlFile);

                XmlNode objXmlMetatype = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + lstMetatypes.SelectedValue + "\"]");
                XmlNode objXmlMetavariant = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + lstMetatypes.SelectedValue + "\"]/metavariants/metavariant[name = \"" + cboMetavariant.SelectedValue + "\"]");

                int intForce = 0;
                if (nudForce.Visible)
                    intForce = Convert.ToInt32(nudForce.Value);

                _objCharacter.MetatypeBP = Convert.ToInt32(lblMetavariantBP.Text);

                // Set Metatype information.
                if (cboMetavariant.SelectedValue.ToString() != "None")
                {
                    _objCharacter.BOD.AssignLimits(ExpressionToString(objXmlMetavariant["bodmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["bodmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["bodaug"].InnerText, intForce, 0));
                    _objCharacter.AGI.AssignLimits(ExpressionToString(objXmlMetavariant["agimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["agimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["agiaug"].InnerText, intForce, 0));
                    _objCharacter.REA.AssignLimits(ExpressionToString(objXmlMetavariant["reamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["reamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["reaaug"].InnerText, intForce, 0));
                    _objCharacter.STR.AssignLimits(ExpressionToString(objXmlMetavariant["strmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["strmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["straug"].InnerText, intForce, 0));
                    _objCharacter.CHA.AssignLimits(ExpressionToString(objXmlMetavariant["chamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["chamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["chaaug"].InnerText, intForce, 0));
                    _objCharacter.INT.AssignLimits(ExpressionToString(objXmlMetavariant["intmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["intmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["intaug"].InnerText, intForce, 0));
                    _objCharacter.LOG.AssignLimits(ExpressionToString(objXmlMetavariant["logmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["logmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["logaug"].InnerText, intForce, 0));
                    _objCharacter.WIL.AssignLimits(ExpressionToString(objXmlMetavariant["wilmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["wilmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["wilaug"].InnerText, intForce, 0));
                    _objCharacter.INI.AssignLimits(ExpressionToString(objXmlMetavariant["inimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["inimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["iniaug"].InnerText, intForce, 0));
                    _objCharacter.MAG.AssignLimits(ExpressionToString(objXmlMetavariant["magmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["magmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["magaug"].InnerText, intForce, 0));
                    _objCharacter.RES.AssignLimits(ExpressionToString(objXmlMetavariant["resmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["resmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["resaug"].InnerText, intForce, 0));
                    _objCharacter.EDG.AssignLimits(ExpressionToString(objXmlMetavariant["edgmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["edgmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["edgaug"].InnerText, intForce, 0));
                    _objCharacter.ESS.AssignLimits(ExpressionToString(objXmlMetavariant["essmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["essmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["essaug"].InnerText, intForce, 0));

                }
                else if (_strXmlFile != "critters.xml" || lstMetatypes.SelectedValue.ToString() == "Ally Spirit")
                {
                    _objCharacter.BOD.AssignLimits(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["bodmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["bodaug"].InnerText, intForce, 0));
                    _objCharacter.AGI.AssignLimits(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["agimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["agiaug"].InnerText, intForce, 0));
                    _objCharacter.REA.AssignLimits(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["reamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["reaaug"].InnerText, intForce, 0));
                    _objCharacter.STR.AssignLimits(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["strmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["straug"].InnerText, intForce, 0));
                    _objCharacter.CHA.AssignLimits(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["chamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["chaaug"].InnerText, intForce, 0));
                    _objCharacter.INT.AssignLimits(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["intmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["intaug"].InnerText, intForce, 0));
                    _objCharacter.LOG.AssignLimits(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["logmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["logaug"].InnerText, intForce, 0));
                    _objCharacter.WIL.AssignLimits(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["wilmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["wilaug"].InnerText, intForce, 0));
                    _objCharacter.INI.AssignLimits(ExpressionToString(objXmlMetatype["inimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["iniaug"].InnerText, intForce, 0));
                    _objCharacter.MAG.AssignLimits(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["magmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["magaug"].InnerText, intForce, 0));
                    _objCharacter.RES.AssignLimits(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["resmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["resaug"].InnerText, intForce, 0));
                    _objCharacter.EDG.AssignLimits(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["edgmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["edgaug"].InnerText, intForce, 0));
                    _objCharacter.ESS.AssignLimits(ExpressionToString(objXmlMetatype["essmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essaug"].InnerText, intForce, 0));
                }
                else
                {
                    int intMinModifier = -3;
                    if (cboCategory.SelectedValue.ToString() == "Mutant Critters")
                        intMinModifier = 0;
                    _objCharacter.BOD.AssignLimits(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 3));
                    _objCharacter.AGI.AssignLimits(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 3));
                    _objCharacter.REA.AssignLimits(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 3));
                    _objCharacter.STR.AssignLimits(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 3));
                    _objCharacter.CHA.AssignLimits(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 3));
                    _objCharacter.INT.AssignLimits(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 3));
                    _objCharacter.LOG.AssignLimits(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 3));
                    _objCharacter.WIL.AssignLimits(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 3));
                    _objCharacter.INI.AssignLimits(ExpressionToString(objXmlMetatype["inimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["iniaug"].InnerText, intForce, 0));
                    _objCharacter.MAG.AssignLimits(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 3));
                    _objCharacter.RES.AssignLimits(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 3));
                    _objCharacter.EDG.AssignLimits(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 3));
                    _objCharacter.ESS.AssignLimits(ExpressionToString(objXmlMetatype["essmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essaug"].InnerText, intForce, 0));
                }

                // If we're working with a Critter, set the Attributes to their default values.
                if (_strXmlFile == "critters.xml")
                {
                    _objCharacter.BOD.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 0));
                    _objCharacter.AGI.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 0));
                    _objCharacter.REA.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 0));
                    _objCharacter.STR.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 0));
                    _objCharacter.CHA.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 0));
                    _objCharacter.INT.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 0));
                    _objCharacter.LOG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 0));
                    _objCharacter.WIL.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 0));
                    _objCharacter.MAG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 0));
                    _objCharacter.RES.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 0));
                    _objCharacter.EDG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 0));
                    _objCharacter.ESS.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0));
                }

                // Sprites can never have Physical Attributes or WIL.
                if (lstMetatypes.SelectedValue.ToString().EndsWith("Sprite"))
                {
                    _objCharacter.BOD.AssignLimits("0", "0", "0");
                    _objCharacter.AGI.AssignLimits("0", "0", "0");
                    _objCharacter.REA.AssignLimits("0", "0", "0");
                    _objCharacter.STR.AssignLimits("0", "0", "0");
                    _objCharacter.WIL.AssignLimits("0", "0", "0");
                    _objCharacter.INI.MetatypeMinimum = Convert.ToInt32(ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0));
                    _objCharacter.INI.MetatypeMaximum = Convert.ToInt32(ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0));
                }

                // If this is a Shapeshifter, a Metavariant must be selected. Default to Human if None is selected.
                if (cboCategory.SelectedValue.ToString() == "Shapeshifter" && cboMetavariant.SelectedValue.ToString() == "None")
                    cboMetavariant.SelectedValue = "Human";

                _objCharacter.Metatype = lstMetatypes.SelectedValue.ToString();
                _objCharacter.MetatypeCategory = cboCategory.SelectedValue.ToString();
                _objCharacter.Metavariant = cboMetavariant.SelectedValue.ToString() == "None" ? "" : cboMetavariant.SelectedValue.ToString();

                if (objXmlMetatype["movement"] != null) // TODO: Replace with Walk/Run
                    _objCharacter.Movement = objXmlMetatype["movement"].InnerText;

                // Load the Qualities file.
                XmlDocument objXmlQualityDocument = XmlManager.Instance.Load("qualities.xml");

                if (cboMetavariant.SelectedValue.ToString() == "None")
                {
                    // Determine if the Metatype has any bonuses.
                    if (objXmlMetatype.InnerXml.Contains("bonus"))
                        objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Metatype, lstMetatypes.SelectedValue.ToString(), objXmlMetatype.SelectSingleNode("bonus"), false, 1, lstMetatypes.SelectedValue.ToString());

                    // Create the Qualities that come with the Metatype.
                    foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/positive/quality"))
                    {
                        XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]");
                        TreeNode objNode = new TreeNode();
                        List<Weapon> objWeapons = new List<Weapon>();
                        List<TreeNode> objWeaponNodes = new List<TreeNode>();
                        Quality objQuality = new Quality(_objCharacter);
                        string strForceValue = "";
                        if (objXmlQualityItem.Attributes["select"] != null)
                            strForceValue = objXmlQualityItem.Attributes["select"].InnerText;
                        QualitySource objSource = new QualitySource();
                        objSource = QualitySource.Metatype;
                        if (objXmlQualityItem.Attributes["removable"] != null)
                            objSource = QualitySource.MetatypeRemovable;
                        objQuality.Create(objXmlQuality, _objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue);
                        objQuality.ContributeToLimit = false;
                        _objCharacter.Qualities.Add(objQuality);

                        // Add any created Weapons to the character.
                        foreach (Weapon objWeapon in objWeapons)
                            _objCharacter.Weapons.Add(objWeapon);
                    }
                    foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/negative/quality"))
                    {
                        XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]");
                        TreeNode objNode = new TreeNode();
                        List<Weapon> objWeapons = new List<Weapon>();
                        List<TreeNode> objWeaponNodes = new List<TreeNode>();
                        Quality objQuality = new Quality(_objCharacter);
                        string strForceValue = "";
                        if (objXmlQualityItem.Attributes["select"] != null)
                            strForceValue = objXmlQualityItem.Attributes["select"].InnerText;
                        QualitySource objSource = new QualitySource();
                        objSource = QualitySource.Metatype;
                        if (objXmlQualityItem.Attributes["removable"] != null)
                            objSource = QualitySource.MetatypeRemovable;
                        objQuality.Create(objXmlQuality, _objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue);
                        objQuality.ContributeToLimit = false;
                        _objCharacter.Qualities.Add(objQuality);

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

                // If a Metavariant has been selected, locate it in the file.
                if (cboMetavariant.SelectedValue.ToString() != "None")
                {
                    // Determine if the Metavariant has any bonuses.
                    if (objXmlMetavariant.InnerXml.Contains("bonus"))
                        objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Metavariant, cboMetavariant.SelectedValue.ToString(), objXmlMetavariant.SelectSingleNode("bonus"), false, 1, cboMetavariant.SelectedValue.ToString());

                    // Create the Qualities that come with the Metatype.
                    foreach (XmlNode objXmlQualityItem in objXmlMetavariant.SelectNodes("qualities/positive/quality"))
                    {
                        XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]");
                        TreeNode objNode = new TreeNode();
                        List<Weapon> objWeapons = new List<Weapon>();
                        List<TreeNode> objWeaponNodes = new List<TreeNode>();
                        Quality objQuality = new Quality(_objCharacter);
                        objQuality.ContributeToLimit = false;
                        string strForceValue = "";
                        if (objXmlQualityItem.Attributes["select"] != null)
                            strForceValue = objXmlQualityItem.Attributes["select"].InnerText;
                        QualitySource objSource = new QualitySource();
                        objSource = QualitySource.Metatype;
                        if (objXmlQualityItem.Attributes["removable"] != null)
                            objSource = QualitySource.MetatypeRemovable;
                        objQuality.Create(objXmlQuality, _objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue);
                        objQuality.ContributeToLimit = false;
                        _objCharacter.Qualities.Add(objQuality);

                        // Add any created Weapons to the character.
                        foreach (Weapon objWeapon in objWeapons)
                            _objCharacter.Weapons.Add(objWeapon);
                    }
                    foreach (XmlNode objXmlQualityItem in objXmlMetavariant.SelectNodes("qualities/negative/quality"))
                    {
                        XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]");
                        TreeNode objNode = new TreeNode();
                        List<Weapon> objWeapons = new List<Weapon>();
                        List<TreeNode> objWeaponNodes = new List<TreeNode>();
                        Quality objQuality = new Quality(_objCharacter);
                        string strForceValue = "";
                        if (objXmlQualityItem.Attributes["select"] != null)
                            strForceValue = objXmlQualityItem.Attributes["select"].InnerText;
                        QualitySource objSource = new QualitySource();
                        objSource = QualitySource.Metatype;
                        if (objXmlQualityItem.Attributes["removable"] != null)
                            objSource = QualitySource.MetatypeRemovable;
                        objQuality.Create(objXmlQuality, _objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue);
                        objQuality.ContributeToLimit = false;
                        _objCharacter.Qualities.Add(objQuality);

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

                // Run through the character's Attributes one more time and make sure their value matches their minimum value.
                if (_strXmlFile == "metatypes.xml")
                {
                    _objCharacter.BOD.Value = _objCharacter.BOD.TotalMinimum;
                    _objCharacter.AGI.Value = _objCharacter.AGI.TotalMinimum;
                    _objCharacter.REA.Value = _objCharacter.REA.TotalMinimum;
                    _objCharacter.STR.Value = _objCharacter.STR.TotalMinimum;
                    _objCharacter.CHA.Value = _objCharacter.CHA.TotalMinimum;
                    _objCharacter.INT.Value = _objCharacter.INT.TotalMinimum;
                    _objCharacter.LOG.Value = _objCharacter.LOG.TotalMinimum;
                    _objCharacter.WIL.Value = _objCharacter.WIL.TotalMinimum;
                    _objCharacter.MAG.Value = _objCharacter.MAG.TotalMinimum;
                    _objCharacter.RES.Value = _objCharacter.RES.TotalMinimum;
                    _objCharacter.DEP.Value = _objCharacter.DEP.TotalMinimum;

                    _objCharacter.BOD.Base = _objCharacter.BOD.TotalMinimum;
                    _objCharacter.AGI.Base = _objCharacter.AGI.TotalMinimum;
                    _objCharacter.REA.Base = _objCharacter.REA.TotalMinimum;
                    _objCharacter.STR.Base = _objCharacter.STR.TotalMinimum;
                    _objCharacter.CHA.Base = _objCharacter.CHA.TotalMinimum;
                    _objCharacter.INT.Base = _objCharacter.INT.TotalMinimum;
                    _objCharacter.LOG.Base = _objCharacter.LOG.TotalMinimum;
                    _objCharacter.WIL.Base = _objCharacter.WIL.TotalMinimum;
                    _objCharacter.MAG.Base = _objCharacter.MAG.TotalMinimum;
                    _objCharacter.RES.Base = _objCharacter.RES.TotalMinimum;
                    _objCharacter.DEP.Base = _objCharacter.DEP.TotalMinimum;

                    _objCharacter.BOD.Karma = 0;
                    _objCharacter.AGI.Karma = 0;
                    _objCharacter.REA.Karma = 0;
                    _objCharacter.STR.Karma = 0;
                    _objCharacter.CHA.Karma = 0;
                    _objCharacter.INT.Karma = 0;
                    _objCharacter.LOG.Karma = 0;
                    _objCharacter.WIL.Karma = 0;
                    _objCharacter.EDG.Karma = 0;
                    _objCharacter.MAG.Karma = 0;
                    _objCharacter.RES.Karma = 0;
                    _objCharacter.DEP.Karma = 0;
                }

                // Add any Natural Weapons the Metavariant should have.
                if (cboMetavariant.SelectedValue.ToString() != "None")
                {
                    if (objXmlMetavariant["naturalweapons"] != null)
                    {
                        foreach (Weapon objWeapon in from XmlNode objXmlNaturalWeapon in objXmlMetavariant["naturalweapons"].SelectNodes("naturalweapon") select new Weapon(_objCharacter)
                        {
                            Name = objXmlNaturalWeapon["name"].InnerText,
                            Category = LanguageManager.Instance.GetString("Tab_Critter"),
                            WeaponType = "Melee",
                            Reach = Convert.ToInt32(objXmlNaturalWeapon["reach"].InnerText),
                            Damage = objXmlNaturalWeapon["damage"].InnerText,
                            AP = objXmlNaturalWeapon["ap"].InnerText,
                            Mode = "0",
                            RC = "0",
                            Concealability = 0,
                            Avail = "0",
                            Cost = 0,
                            UseSkill = objXmlNaturalWeapon["useskill"].InnerText,
                            Source = objXmlNaturalWeapon["source"].InnerText,
                            Page = objXmlNaturalWeapon["page"].InnerText
                        })
                        {
                            _objCharacter.Weapons.Add(objWeapon);
                        }
                    }
                }

                // Add any Critter Powers the Metatype/Critter should have.
                XmlNode objXmlCritter = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");

                objXmlDocument = XmlManager.Instance.Load("critterpowers.xml");
                foreach (XmlNode objXmlPower in objXmlCritter.SelectNodes("powers/power"))
                {
                    XmlNode objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + objXmlPower.InnerText + "\"]");
                    TreeNode objNode = new TreeNode();
                    CritterPower objPower = new CritterPower(_objCharacter);
                    string strForcedValue = "";
                    int intRating = 0;

                    if (objXmlPower.Attributes["rating"] != null)
                        intRating = Convert.ToInt32(objXmlPower.Attributes["rating"].InnerText);
                    if (objXmlPower.Attributes["select"] != null)
                        strForcedValue = objXmlPower.Attributes["select"].InnerText;

                    objPower.Create(objXmlCritterPower, _objCharacter, objNode, intRating, strForcedValue);
                    objPower.CountTowardsLimit = false;
                    _objCharacter.CritterPowers.Add(objPower);
                }

                // Add any Critter Powers the Metavariant should have.
                if (cboMetavariant.SelectedValue.ToString() != "None")
                {
                    foreach (XmlNode objXmlPower in objXmlMetavariant.SelectNodes("powers/power"))
                    {
                        XmlNode objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + objXmlPower.InnerText + "\"]");
                        TreeNode objNode = new TreeNode();
                        CritterPower objPower = new CritterPower(_objCharacter);
                        string strForcedValue = "";
                        int intRating = 0;

                        if (objXmlPower.Attributes["rating"] != null)
                            intRating = Convert.ToInt32(objXmlPower.Attributes["rating"].InnerText);
                        if (objXmlPower.Attributes["select"] != null)
                            strForcedValue = objXmlPower.Attributes["select"].InnerText;

                        objPower.Create(objXmlCritterPower, _objCharacter, objNode, intRating, strForcedValue);
                        objPower.CountTowardsLimit = false;
                        _objCharacter.CritterPowers.Add(objPower);
                    }
                }

                // If this is a Blood Spirit, add their free Critter Powers.
                if (chkBloodSpirit.Checked)
                {
                    XmlNode objXmlCritterPower;
                    TreeNode objNode;
                    CritterPower objPower;
                    bool blnAddPower = _objCharacter.CritterPowers.All(objFindPower => objFindPower.Name != "Energy Drain");

                    // Energy Drain.
                    if (blnAddPower)
                    {
                        objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"Energy Drain\"]");
                        objNode = new TreeNode();
                        objPower = new CritterPower(_objCharacter);
                        objPower.Create(objXmlCritterPower, _objCharacter, objNode, 0, "");
                        objPower.CountTowardsLimit = false;
                        _objCharacter.CritterPowers.Add(objPower);
                    }

                    // Fear.
                    blnAddPower = _objCharacter.CritterPowers.All(objFindPower => objFindPower.Name != "Fear");
                    if (blnAddPower)
                    {
                        objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"Fear\"]");
                        objNode = new TreeNode();
                        objPower = new CritterPower(_objCharacter);
                        objPower.Create(objXmlCritterPower, _objCharacter, objNode, 0, "");
                        objPower.CountTowardsLimit = false;
                        _objCharacter.CritterPowers.Add(objPower);
                    }

                    // Natural Weapon.
                    objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"Natural Weapon\"]");
                    objNode = new TreeNode();
                    objPower = new CritterPower(_objCharacter);
                    objPower.Create(objXmlCritterPower, _objCharacter, objNode, 0, "DV " + intForce.ToString() + "P, AP 0");
                    objPower.CountTowardsLimit = false;
                    _objCharacter.CritterPowers.Add(objPower);

                    // Evanescence.
                    blnAddPower = _objCharacter.CritterPowers.All(objFindPower => objFindPower.Name != "Evanescence");
                    if (blnAddPower)
                    {
                        objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"Evanescence\"]");
                        objNode = new TreeNode();
                        objPower = new CritterPower(_objCharacter);
                        objPower.Create(objXmlCritterPower, _objCharacter, objNode, 0, "");
                        objPower.CountTowardsLimit = false;
                        _objCharacter.CritterPowers.Add(objPower);
                    }
                }

                //// Remove the Critter's Materialization Power if they have it. Add the Possession or Inhabitation Power if the Possession-based Tradition checkbox is checked.
                //if (chkPossessionBased.Checked)
                //{
                //	foreach (CritterPower objCritterPower in _objCharacter.CritterPowers)
                //	{
                //		if (objCritterPower.Name == "Materialization")
                //		{
                //			_objCharacter.CritterPowers.Remove(objCritterPower);
                //			break;
                //		}
                //	}

                //	// Add the selected Power.
                //	XmlNode objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + cboPossessionMethod.SelectedValue.ToString() + "\"]");
                //	TreeNode objNode = new TreeNode();
                //	CritterPower objPower = new CritterPower(_objCharacter);
                //	objPower.Create(objXmlCritterPower, _objCharacter, objNode, 0, "");
                //	objPower.CountTowardsLimit = false;
                //	_objCharacter.CritterPowers.Add(objPower);
                //}

                //// Set the Skill Ratings for the Critter.
                //foreach (XmlNode objXmlSkill in objXmlCritter.SelectNodes("skills/skill"))
                //{
                //	if (objXmlSkill.InnerText.Contains("Exotic"))
                //	{
                //		Skill objExotic = new Skill(_objCharacter);
                //		objExotic.ExoticSkill = true;
                //		objExotic.Attribute = "AGI";
                //		if (objXmlSkill.Attributes["spec"] != null)
            //                    {
            //                        SkillSpecialization objSpec = new SkillSpecialization(objXmlSkill.Attributes["spec"].InnerText);
            //                        objExotic.Specializations.Add(objSpec);
            //                    }
                //		if (Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)) > 6)
                //			objExotic.RatingMaximum = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0));
                //		objExotic.Rating = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0));
                //		objExotic.Name = objXmlSkill.InnerText;
                //		_objCharacter.Skills.Add(objExotic);
                //	}
                //	else
                //	{
                //		foreach (Skill objSkill in _objCharacter.Skills)
                //		{
                //			if (objSkill.Name == objXmlSkill.InnerText)
                //			{
                //				if (objXmlSkill.Attributes["spec"] != null)
            //                            {
            //                                SkillSpecialization objSpec = new SkillSpecialization(objXmlSkill.Attributes["spec"].InnerText);
            //                                objSkill.Specializations.Add(objSpec);
            //                            }
                //				if (Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)) > 6)
                //					objSkill.RatingMaximum = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0));
                //				objSkill.Rating = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0));
                //				break;
                //			}
                //		}
                //	}
                //}

                //// Set the Skill Group Ratings for the Critter.
                //foreach (XmlNode objXmlSkill in objXmlCritter.SelectNodes("skills/group"))
                //{
                //	foreach (SkillGroup objSkill in _objCharacter.SkillGroups)
                //	{
                //		if (objSkill.Name == objXmlSkill.InnerText)
                //		{
                //			objSkill.RatingMaximum = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0));
                //			objSkill.Rating = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0));
                //			break;
                //		}
                //	}
                //}

                //// Set the Knowledge Skill Ratings for the Critter.
                //foreach (XmlNode objXmlSkill in objXmlCritter.SelectNodes("skills/knowledge"))
                //{
                //	Skill objKnowledge = new Skill(_objCharacter);
                //	objKnowledge.Name = objXmlSkill.InnerText;
                //	objKnowledge.KnowledgeSkill = true;
                //	if (objXmlSkill.Attributes["spec"] != null)
            //                {
            //                    SkillSpecialization objSpec = new SkillSpecialization(objXmlSkill.Attributes["spec"].InnerText);
            //                    objKnowledge.Specializations.Add(objSpec);
            //                }
                //	objKnowledge.SkillCategory = objXmlSkill.Attributes["category"].InnerText;
                //	if (Convert.ToInt32(objXmlSkill.Attributes["rating"].InnerText) > 6)
                //		objKnowledge.RatingMaximum = Convert.ToInt32(objXmlSkill.Attributes["rating"].InnerText);
                //	objKnowledge.Rating = Convert.ToInt32(objXmlSkill.Attributes["rating"].InnerText);
                //	_objCharacter.Skills.Add(objKnowledge);
                //}

                //// If this is a Critter with a Force (which dictates their Skill Rating/Maximum Skill Rating), set their Skill Rating Maximums.
                //if (intForce > 0)
                //{
                //	int intMaxRating = intForce;
                //	// Determine the highest Skill Rating the Critter has.
                //	foreach (Skill objSkill in _objCharacter.Skills)
                //	{
                //		if (objSkill.RatingMaximum > intMaxRating)
                //			intMaxRating = objSkill.RatingMaximum;
                //	}

                //	// Now that we know the upper limit, set all of the Skill Rating Maximums to match.
                //	foreach (Skill objSkill in _objCharacter.Skills)
                //		objSkill.RatingMaximum = intMaxRating;
                //	foreach (SkillGroup objGroup in _objCharacter.SkillGroups)
                //		objGroup.RatingMaximum = intMaxRating;

                //	// Set the MaxSkillRating for the character so it can be used later when they add new Knowledge Skills or Exotic Skills.
                //	_objCharacter.MaxSkillRating = intMaxRating;
                //}

                // Add any Complex Forms the Critter comes with (typically Sprites)
                XmlDocument objXmlProgramDocument = XmlManager.Instance.Load("complexforms.xml");
                foreach (XmlNode objXmlComplexForm in objXmlCritter.SelectNodes("complexforms/complexform"))
                {
                    string strForceValue = "";
                    if (objXmlComplexForm.Attributes["select"] != null)
                        strForceValue = objXmlComplexForm.Attributes["select"].InnerText;
                    XmlNode objXmlProgram = objXmlProgramDocument.SelectSingleNode("/chummer/complexforms/complexform[name = \"" + objXmlComplexForm.InnerText + "\"]");
                    TreeNode objNode = new TreeNode();
                    ComplexForm objProgram = new ComplexForm(_objCharacter);
                    objProgram.Create(objXmlProgram, _objCharacter, objNode, strForceValue);
                    _objCharacter.ComplexForms.Add(objProgram);
                }

                // Add any Gear the Critter comes with (typically Programs for A.I.s)
                XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml");
                foreach (XmlNode objXmlGear in objXmlCritter.SelectNodes("gears/gear"))
                {
                    int intRating = 0;
                    if (objXmlGear.Attributes["rating"] != null)
                        intRating = Convert.ToInt32(ExpressionToString(objXmlGear.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0));
                    string strForceValue = "";
                    if (objXmlGear.Attributes["select"] != null)
                        strForceValue = objXmlGear.Attributes["select"].InnerText;
                    XmlNode objXmlGearItem = objXmlGearDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objXmlGear.InnerText + "\"]");
                    TreeNode objNode = new TreeNode();
                    Gear objGear = new Gear(_objCharacter);
                    List<Weapon> lstWeapons = new List<Weapon>();
                    List<TreeNode> lstWeaponNodes = new List<TreeNode>();
                    objGear.Create(objXmlGearItem, _objCharacter, objNode, intRating, lstWeapons, lstWeaponNodes, strForceValue);
                    objGear.Cost = "0";
                    objGear.Cost3 = "0";
                    objGear.Cost6 = "0";
                    objGear.Cost10 = "0";
                    _objCharacter.Gear.Add(objGear);
                }

                // If this is a Mutant Critter, count up the number of Skill points they start with.
                if (_objCharacter.MetatypeCategory == "Mutant Critters")
                {
                    foreach (Skill objSkill in _objCharacter.SkillsSection.Skills)
                        _objCharacter.MutantCritterBaseSkills += objSkill.Rating;
                }

                // begin priority based character settings
                // Load the Priority information.
                XmlDocument objXmlDocumentPriority = XmlManager.Instance.Load(_strPrioritiesXmlFile);

                // Set the character priority selections
                _objCharacter.MetatypePriority = cboHeritage.SelectedValue.ToString();
                _objCharacter.AttributesPriority = cboAttributes.SelectedValue.ToString();
                _objCharacter.SpecialPriority = cboTalent.SelectedValue.ToString();
                _objCharacter.SkillsPriority = cboSkills.SelectedValue.ToString();
                _objCharacter.ResourcesPriority = cboResources.SelectedValue.ToString();
                _objCharacter.TalentPriority = cboTalents.SelectedValue.ToString();
                if (cboSkill1.SelectedValue != null)
                {
                    _objCharacter.PriorityBonusSkill1 = cboSkill1.SelectedValue.ToString();
                    _objCharacter.PriorityBonusSkill2 = cboSkill2.SelectedValue.ToString();
                }

                // Set starting nuyen
                XmlNodeList objXmResourceList = objXmlDocumentPriority.SelectNodes("/chummer/priorities/priority[category = \"Resources\" and gameplayoption = \"" + _objCharacter.GameplayOption + "\" and value = \"" + cboResources.SelectedValue + "\"]");
                if (objXmResourceList.Count > 0)
                {
                    _objCharacter.Nuyen = Convert.ToInt32(objXmResourceList[0]["resources"].InnerText.ToString());
                    _objCharacter.StartingNuyen = _objCharacter.Nuyen;
                }

                if ("Aspected Magician".Equals(cboTalents.SelectedValue))
                {
                    _objCharacter.Pushtext.Push((string) cboSkill1.SelectedValue);
                }

                // Set starting positive qualities
                foreach (XmlNode objXmlQualityItem in objXmlDocumentPriority.SelectNodes("/chummer/priorities/priority[category = \"Talent\" and value = \"" + cboTalent.SelectedValue + "\"]/talents/talent[value = \"" + cboTalents.SelectedValue + "\"]/qualities/quality"))
                {
                    XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]");
                    TreeNode objNode = new TreeNode();
                    List<Weapon> objWeapons = new List<Weapon>();
                    List<TreeNode> objWeaponNodes = new List<TreeNode>();
                    Quality objQuality = new Quality(_objCharacter);
                    string strForceValue = "";
                    if (objXmlQualityItem.Attributes["select"] != null)
                        strForceValue = objXmlQualityItem.Attributes["select"].InnerText;
                    QualitySource objSource = new QualitySource();
                    objSource = QualitySource.Metatype;
                    if (objXmlQualityItem.Attributes["removable"] != null)
                        objSource = QualitySource.MetatypeRemovable;
                    objQuality.Create(objXmlQuality, _objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue);
                    _objCharacter.Qualities.Add(objQuality);

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

                // Set starting magic
                XmlNodeList objXmlTalentList = objXmlDocumentPriority.SelectNodes("/chummer/priorities/priority[category = \"Talent\" and value = \"" + cboTalent.SelectedValue + "\"]/talents/talent[value = \"" + cboTalents.SelectedValue + "\"]");
                if (objXmlTalentList[0]["magic"] != null)
                {
                    _objCharacter.MAG.MetatypeMinimum = Convert.ToInt32(objXmlTalentList[0]["magic"].InnerText);
                    if (_objCharacter.MAG.Value > 0)
                        _objCharacter.MAGEnabled = true;
                    _objCharacter.SpellLimit = objXmlTalentList[0]["spells"] != null ? Convert.ToInt32(objXmlTalentList[0]["spells"].InnerText) : 0;
                }

                if (objXmlTalentList[0]["maxmagic"] != null)
                    _objCharacter.MAG.MetatypeMaximum = Convert.ToInt32(objXmlTalentList[0]["magic"].InnerText);

                // Set starting resonance
                objXmlTalentList = objXmlDocumentPriority.SelectNodes("/chummer/priorities/priority[category = \"Talent\" and value = \"" + cboTalent.SelectedValue + "\"]/talents/talent[value = \"" + cboTalents.SelectedValue + "\"]");
                if (objXmlTalentList[0]["resonance"] != null)
                {
                    _objCharacter.RES.MetatypeMinimum = Convert.ToInt32(objXmlTalentList[0]["resonance"].InnerText);
                    _objCharacter.RESEnabled = true;
                    _objCharacter.CFPLimit = Convert.ToInt32(objXmlTalentList[0]["cfp"].InnerText);
                }

                if (objXmlTalentList[0]["maxresonance"] != null)
                    _objCharacter.RES.MetatypeMaximum = Convert.ToInt32(objXmlTalentList[0]["resonance"].InnerText);

                // Set starting talent tabs
                switch (cboTalents.SelectedValue.ToString())
                {
                    case "Magician":
                        _objCharacter.MagicianEnabled = true;
                        break;
                    case "Aspected Magician":
                        _objCharacter.MagicianEnabled = true;
                        break;
                    case "Adept":
                        _objCharacter.AdeptEnabled = true;
                        break;
                    case "Mystic Adept":
                        _objCharacter.MagicianEnabled = true;
                        _objCharacter.AdeptEnabled = true;
                        break;
                    case "Technomancer":
                        _objCharacter.TechnomancerEnabled = true;
                        break;
                    default:
                        break;
                }

                // Set Free Skills/Skill Groups
                int intFreeLevels = 0;
                bool blnGroup = (cboTalents.SelectedValue.ToString() == "Aspected Magician");
                if ((cboTalent.SelectedValue.ToString().Split(',')[0]) == "A")
                    intFreeLevels = 5;
                else if ((cboTalent.SelectedValue.ToString().Split(',')[0]) == "B")
                    intFreeLevels = 4;
                else if ((cboTalent.SelectedValue.ToString().Split(',')[0]) == "C")
                    intFreeLevels = 2;

                AddFreeSkills(intFreeLevels);

                //foreach (Skill objSkill in _objCharacter.Skills)
                //{
                //    if (cboSkill1.Visible && objSkill.Name == cboSkill1.Text && !blnGroup)
                //    {
                //        objSkill.FreeLevels = intFreeLevels;
                //        if (objSkill.Rating < intFreeLevels)
                //            objSkill.Rating = intFreeLevels;
                //        _objCharacter.PriorityBonusSkill1 = cboSkill1.Text.ToString();
                //    }
                //    else if (cboSkill2.Visible && objSkill.Name == cboSkill2.Text && !blnGroup)
                //    {
                //        objSkill.FreeLevels = intFreeLevels;
                //        if (objSkill.Rating < intFreeLevels)
                //            objSkill.Rating = intFreeLevels;
                //        _objCharacter.PriorityBonusSkill2 = cboSkill2.Text.ToString();
                //    }
                //    else
                //    {
                //        objSkill.FreeLevels = 0;
                //        if (blnGroup)
                //        {
                //            // if this skill is a magical skill not belonging to the selected group, reduce the skill maximum to 0
                //            if (objSkill.SkillGroup == "Conjuring" || objSkill.SkillGroup == "Enchanting" || objSkill.SkillGroup == "Sorcery")
                //            {
                //                if (objSkill.SkillGroup != cboSkill1.SelectedValue.ToString())
                //                    objSkill.RatingMaximum = 0;
                //                else
                //                {
                //                    if (_objCharacter.IgnoreRules)
                //                        objSkill.RatingMaximum = 12;
                //                    else
                //                        objSkill.RatingMaximum = 6;
                //                }
                //                _objCharacter.PriorityBonusSkillGroup = cboSkill1.Text.ToString();
                //            }
                //        }
                //    }
                //}
                //foreach (SkillGroup objSkillGroup in _objCharacter.SkillGroups)
                //{
                //    if (cboSkill1.Visible && objSkillGroup.Name == cboSkill1.Text && blnGroup)
                //    {
                //        objSkillGroup.FreeLevels = intFreeLevels;
                //        if (objSkillGroup.Base < intFreeLevels)
                //            objSkillGroup.Base = intFreeLevels;
                //        _objCharacter.PriorityBonusSkillGroup = cboSkill1.Text.ToString();
                //    }
                //    else
                //        objSkillGroup.FreeLevels = 0;

                //    if (blnGroup)
                //    {
                //        // if this skill is a magical skill not belonging to the selected group, reduce the skill maximum to 0
                //        if (objSkillGroup.Name == "Conjuring" || objSkillGroup.Name == "Enchanting" || objSkillGroup.Name == "Sorcery")
                //        {
                //            if (objSkillGroup.Name != cboSkill1.SelectedValue.ToString())
                //                objSkillGroup.RatingMaximum = 0;
                //            else
                //            {
                //                if (_objCharacter.IgnoreRules)
                //                    objSkillGroup.RatingMaximum = 12;
                //                else
                //                    objSkillGroup.RatingMaximum = 6;
                //            }
                //        }
                //    }
                //}

                // Set Special Attributes
                _objCharacter.Special = Convert.ToInt32(lblSpecial.Text);
                _objCharacter.TotalSpecial = Convert.ToInt32(lblSpecial.Text);

                // Set Attributes
                XmlNodeList objXmlPriorityList = objXmlDocumentPriority.SelectNodes("/chummer/priorities/priority[category = \"Attributes\" and value = \"" + cboAttributes.SelectedValue + "\"]");
                if (objXmlPriorityList[0]["attributes"] != null)
                {
                    _objCharacter.Attributes = Convert.ToInt32(objXmlPriorityList[0]["attributes"].InnerText);
                    _objCharacter.TotalAttributes = _objCharacter.Attributes;
                }

                // Set Skills and Skill Groups
                objXmlPriorityList = objXmlDocumentPriority.SelectNodes("/chummer/priorities/priority[category = \"Skills\" and value = \"" + cboSkills.SelectedValue + "\"]");
                foreach (XmlNode objXmlNode in objXmlPriorityList)
                {
                    if (objXmlNode["gameplayoption"] != null &&
                        objXmlNode["gameplayoption"].InnerText != _objCharacter.GameplayOption)
                    {
                        continue;
                    }
                    if (objXmlNode["skills"] != null)
                    {
                        _objCharacter.SkillsSection.SkillPointsMaximum =
                            Convert.ToInt32(objXmlNode["skills"].InnerText);
                        _objCharacter.SkillsSection.SkillGroupPointsMaximum =
                            Convert.ToInt32(objXmlNode["skillgroups"].InnerText);
                        break;
                    }
                }

                // Load the Priority information.
                XmlDocument objXmlDocumentGameplayOptions = XmlManager.Instance.Load("gameplayoptions.xml");
                XmlNode objXmlGameplayOption = objXmlDocumentGameplayOptions.SelectSingleNode("/chummer/gameplayoptions/gameplayoption[name = \"" + _objCharacter.GameplayOption + "\"]");
                string strKarma = objXmlGameplayOption["karma"].InnerText;
                string strNuyen = objXmlGameplayOption["maxnuyen"].InnerText;
                string strContactMultiplier = objXmlGameplayOption["contactmultiplier"].InnerText;
                _objCharacter.MaxKarma = Convert.ToInt32(strKarma);
                _objCharacter.MaxNuyen = Convert.ToInt32(strNuyen);
                _objCharacter.ContactMultiplier = Convert.ToInt32(strContactMultiplier);

                // Set free contact points
                _objCharacter.ContactPoints = _objCharacter.CHA.Value * _objCharacter.ContactMultiplier;

                // Set starting karma
                _objCharacter.BuildKarma = _objCharacter.MaxKarma;

                // Set starting movement rate
                _objCharacter.Movement = (_objCharacter.AGI.TotalValue * 2).ToString() + "/" + (_objCharacter.AGI.TotalValue * 4).ToString();

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_Metatype_SelectMetatype"), LanguageManager.Instance.GetString("MessageTitle_Metatype_SelectMetatype"), MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #9
0
        private void tsWeaponAccessoryAddGear_Click(object sender, EventArgs e)
        {
            WeaponAccessory objAccessory = _objFunctions.FindWeaponAccessory(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons);

            // Make sure the Weapon Accessory is allowed to accept Gear.
            if (objAccessory.AllowGear == null)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_WeaponGear"), LanguageManager.Instance.GetString("MessageTitle_CyberwareGear"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            frmSelectGear frmPickGear = new frmSelectGear(_objCharacter, false);
            string strCategories = "";
            foreach (XmlNode objXmlCategory in objAccessory.AllowGear)
                strCategories += objXmlCategory.InnerText + ",";
            frmPickGear.AllowedCategories = strCategories;
            frmPickGear.ShowDialog(this);

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

            TreeNode objNode = new TreeNode();

            // Open the Gear XML file and locate the selected piece.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
            XmlNode objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + frmPickGear.SelectedGear + "\" and category = \"" + frmPickGear.SelectedCategory + "\"]");

            // Create the new piece of Gear.
            List<Weapon> objWeapons = new List<Weapon>();
            List<TreeNode> objWeaponNodes = new List<TreeNode>();
            Gear objNewGear = new Gear(_objCharacter);
            switch (frmPickGear.SelectedCategory)
            {
                case "Commlinks":
                case "Cyberdecks":
                case "Rigger Command Consoles":
                    Commlink objCommlink = new Commlink(_objCharacter);
                    objCommlink.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating);
                    objCommlink.Quantity = frmPickGear.SelectedQty;
                    try
                    {
                        _blnSkipRefresh = true;
                        nudGearQty.Increment = objCommlink.CostFor;
                        //nudGearQty.Minimum = nudGearQty.Increment;
                        _blnSkipRefresh = false;
                    }
                    catch
                    {
                    }
                    objNode.Text = objCommlink.DisplayName;

                    objNewGear = objCommlink;
                    break;
                default:
                    Gear objGear = new Gear(_objCharacter);
                    objGear.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, objWeapons, objWeaponNodes, "", frmPickGear.Hacked, frmPickGear.InherentProgram, true, true, frmPickGear.Aerodynamic);
                    objGear.Quantity = frmPickGear.SelectedQty;
                    try
                    {
                        _blnSkipRefresh = true;
                        nudGearQty.Increment = objGear.CostFor;
                        //nudGearQty.Minimum = nudGearQty.Increment;
                        _blnSkipRefresh = false;
                    }
                    catch
                    {
                    }
                    objNode.Text = objGear.DisplayName;

                    objNewGear = objGear;
                    break;
            }

            if (objNewGear.InternalId == Guid.Empty.ToString())
                return;
            objNewGear.DiscountCost = frmPickGear.BlackMarketDiscount;

            // Reduce the cost for Do It Yourself components.
            if (frmPickGear.DoItYourself)
                objNewGear.Cost = (Convert.ToDouble(objNewGear.Cost, GlobalOptions.Instance.CultureInfo) * 0.5).ToString();
            // Reduce the cost to 10% for Hacked programs.
            if (frmPickGear.Hacked)
            {
                if (objNewGear.Cost != "")
                    objNewGear.Cost = "(" + objNewGear.Cost + ") * 0.1";
                if (objNewGear.Cost3 != "")
                    objNewGear.Cost3 = "(" + objNewGear.Cost3 + ") * 0.1";
                if (objNewGear.Cost6 != "")
                    objNewGear.Cost6 = "(" + objNewGear.Cost6 + ") * 0.1";
                if (objNewGear.Cost10 != "")
                    objNewGear.Cost10 = "(" + objNewGear.Cost10 + ") * 0.1";
                if (objNewGear.Extra == "")
                    objNewGear.Extra = LanguageManager.Instance.GetString("Label_SelectGear_Hacked");
                else
                    objNewGear.Extra += ", " + LanguageManager.Instance.GetString("Label_SelectGear_Hacked");
            }
            // If the item was marked as free, change its cost.
            if (frmPickGear.FreeCost)
            {
                objNewGear.Cost = "0";
                objNewGear.Cost3 = "0";
                objNewGear.Cost6 = "0";
                objNewGear.Cost10 = "0";
            }

            // Create any Weapons that came with this Gear.
            foreach (Weapon objWeapon in objWeapons)
                _objCharacter.Weapons.Add(objWeapon);

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

            objAccessory.Gear.Add(objNewGear);

            objNode.ContextMenuStrip = cmsWeaponAccessoryGear;
            treWeapons.SelectedNode.Nodes.Add(objNode);
            treWeapons.SelectedNode.Expand();

            UpdateCharacterInfo();

            if (frmPickGear.AddAgain)
                tsWeaponAccessoryAddGear_Click(sender, e);

            _blnIsDirty = true;
            UpdateWindowTitle();
        }
Example #10
0
        private void tsVehicleAddNexus_Click(object sender, EventArgs e)
        {
            // Make sure a parent items is selected, then open the Select Gear window.
            try
            {
                if (treVehicles.SelectedNode.Level == 0)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectGearVehicle"), LanguageManager.Instance.GetString("MessageTitle_SelectGearVehicle"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            catch
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectGearVehicle"), LanguageManager.Instance.GetString("MessageTitle_SelectGearVehicle"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (treVehicles.SelectedNode.Level > 1)
                treVehicles.SelectedNode = treVehicles.SelectedNode.Parent;

            // Attempt to locate the selected Vehicle.
            Vehicle objSelectedVehicle = _objFunctions.FindVehicle(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles);

            frmSelectNexus frmPickNexus = new frmSelectNexus(_objCharacter);
            frmPickNexus.ShowDialog(this);

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

            Gear objGear = new Gear(_objCharacter);
            objGear = frmPickNexus.SelectedNexus;

            TreeNode nodNexus = new TreeNode();
            nodNexus.Text = objGear.Name;
            nodNexus.Tag = objGear.InternalId;
            nodNexus.ContextMenuStrip = cmsVehicleGear;

            foreach (Gear objChild in objGear.Children)
            {
                TreeNode nodModule = new TreeNode();
                nodModule.Text = objChild.Name;
                nodModule.Tag = objChild.InternalId;
                nodModule.ContextMenuStrip = cmsVehicleGear;
                nodNexus.Nodes.Add(nodModule);
                nodNexus.Expand();
            }

            treVehicles.SelectedNode.Nodes.Add(nodNexus);
            treVehicles.SelectedNode.Expand();

            objSelectedVehicle.Gear.Add(objGear);

            UpdateCharacterInfo();
            RefreshSelectedVehicle();
        }
Example #11
0
        private void tsVehicleAddGear_Click(object sender, EventArgs e)
        {
            // Make sure a parent items is selected, then open the Select Gear window.
            try
            {
                if (treVehicles.SelectedNode.Level == 0)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectGearVehicle"), LanguageManager.Instance.GetString("MessageTitle_SelectGearVehicle"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            catch
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectGearVehicle"), LanguageManager.Instance.GetString("MessageTitle_SelectGearVehicle"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (treVehicles.SelectedNode.Level > 1)
                treVehicles.SelectedNode = treVehicles.SelectedNode.Parent;

            // Locate the selected Vehicle.
            Vehicle objSelectedVehicle = _objFunctions.FindVehicle(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles);

            frmSelectGear frmPickGear = new frmSelectGear(_objCharacter);
            //frmPickGear.ShowPositiveCapacityOnly = true;
            frmPickGear.ShowDialog(this);

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

            // Open the Gear XML file and locate the selected piece.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
            XmlNode objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + frmPickGear.SelectedGear + "\" and category = \"" + frmPickGear.SelectedCategory + "\"]");

            // Create the new piece of Gear.
            List<Weapon> objWeapons = new List<Weapon>();
            List<TreeNode> objWeaponNodes = new List<TreeNode>();
            TreeNode objNode = new TreeNode();
            Gear objGear = new Gear(_objCharacter);

            switch (frmPickGear.SelectedCategory)
            {
                case "Commlinks":
                case "Cyberdecks":
                case "Rigger Command Consoles":
                    Commlink objCommlink = new Commlink(_objCharacter);
                    objCommlink.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, false);
                    objCommlink.DiscountCost = frmPickGear.BlackMarketDiscount;

                    objGear = objCommlink;
                    break;
                default:
                    Gear objNewGear = new Gear(_objCharacter);
                    objNewGear.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, objWeapons, objWeaponNodes, "", frmPickGear.Hacked, frmPickGear.InherentProgram, false, true, frmPickGear.Aerodynamic);
                    objNewGear.Quantity = frmPickGear.SelectedQty;

                    objGear = objNewGear;
                    break;
            }

            objGear.DiscountCost = frmPickGear.BlackMarketDiscount;

            if (objGear.InternalId == Guid.Empty.ToString())
                return;

            // Reduce the cost for Do It Yourself components.
            if (frmPickGear.DoItYourself)
                objGear.Cost = (Convert.ToDouble(objGear.Cost, GlobalOptions.Instance.CultureInfo) * 0.5).ToString();
            // Reduce the cost to 10% for Hacked programs.
            if (frmPickGear.Hacked)
            {
                if (objGear.Cost != "")
                    objGear.Cost = "(" + objGear.Cost + ") * 0.1";
                if (objGear.Cost3 != "")
                    objGear.Cost3 = "(" + objGear.Cost3 + ") * 0.1";
                if (objGear.Cost6 != "")
                    objGear.Cost6 = "(" + objGear.Cost6 + ") * 0.1";
                if (objGear.Cost10 != "")
                    objGear.Cost10 = "(" + objGear.Cost10 + ") * 0.1";
                if (objGear.Extra == "")
                    objGear.Extra = LanguageManager.Instance.GetString("Label_SelectGear_Hacked");
                else
                    objGear.Extra += ", " + LanguageManager.Instance.GetString("Label_SelectGear_Hacked");
            }
            // If the item was marked as free, change its cost.
            if (frmPickGear.FreeCost)
            {
                objGear.Cost = "0";
                objGear.Cost3 = "0";
                objGear.Cost6 = "0";
                objGear.Cost10 = "0";
            }

            objGear.Quantity = frmPickGear.SelectedQty;
            objNode.Text = objGear.DisplayName;
            try
            {
                nudVehicleRating.Increment = objGear.CostFor;
                nudVehicleRating.Minimum = nudGearQty.Increment;
            }
            catch
            {
            }

            // Change the cost of the Sensor itself to 0.
            //if (frmPickGear.SelectedCategory == "Sensors")
            //{
            //    objGear.Cost = "0";
            //    objGear.Cost3 = "0";
            //    objGear.Cost6 = "0";
            //    objGear.Cost10 = "0";
            //}

            objNode.ContextMenuStrip = cmsVehicleGear;

            bool blnMatchFound = false;
            // If this is Ammunition, see if the character already has it on them.
            if (objGear.Category == "Ammunition")
            {
                foreach (Gear objVehicleGear in objSelectedVehicle.Gear)
                {
                    if (objVehicleGear.Name == objGear.Name && objVehicleGear.Category == objGear.Category && objVehicleGear.Rating == objGear.Rating && objVehicleGear.Extra == objGear.Extra)
                    {
                        // A match was found, so increase the quantity instead.
                        objVehicleGear.Quantity += objGear.Quantity;
                        blnMatchFound = true;

                        foreach (TreeNode objGearNode in treVehicles.SelectedNode.Nodes)
                        {
                            if (objVehicleGear.InternalId == objGearNode.Tag.ToString())
                            {
                                objGearNode.Text = objVehicleGear.DisplayName;
                                break;
                            }
                        }

                        break;
                    }
                }
            }

            if (!blnMatchFound)
            {
                treVehicles.SelectedNode.Nodes.Add(objNode);
                treVehicles.SelectedNode.Expand();

                // Add the Gear to the Vehicle.
                objSelectedVehicle.Gear.Add(objGear);
            }

            if (frmPickGear.AddAgain)
                tsVehicleAddGear_Click(sender, e);

            UpdateCharacterInfo();
            RefreshSelectedVehicle();
        }
Example #12
0
        /// <summary>
        /// Refresh the information for the currently displayed Gear.
        /// </summary>
        public void RefreshSelectedGear()
        {
            bool blnClear = false;
            try
            {
                if (treGear.SelectedNode.Level == 0)
                    blnClear = true;
            }
            catch
            {
                blnClear = true;
            }
            if (blnClear)
            {
                _blnSkipRefresh = true;
                nudGearRating.Minimum = 0;
                nudGearRating.Maximum = 0;
                nudGearRating.Enabled = false;
                nudGearQty.Enabled = false;
                chkGearEquipped.Text = LanguageManager.Instance.GetString("Checkbox_Equipped");
                chkGearEquipped.Visible = false;
                chkActiveCommlink.Visible = false;
                _blnSkipRefresh = false;
                return;
            }
            chkGearHomeNode.Visible = false;

            if (treGear.SelectedNode.Level > 0)
            {
                Gear objGear = new Gear(_objCharacter);
                objGear = _objFunctions.FindGear(treGear.SelectedNode.Tag.ToString(), _objCharacter.Gear);

                lblGearName.Text = objGear.DisplayNameShort;
                lblGearCategory.Text = objGear.DisplayCategory;
                lblGearAvail.Text = objGear.TotalAvail(true);
                try
                {
                    lblGearCost.Text = String.Format("{0:###,###,##0Â¥}", objGear.TotalCost);
                }
                catch
                {
                    lblGearCost.Text = objGear.Cost;
                }
                lblGearCapacity.Text = objGear.CalculatedCapacity + " (" + objGear.CapacityRemaining.ToString() + " " + LanguageManager.Instance.GetString("String_Remaining") + ")";
                string strBook = _objOptions.LanguageBookShort(objGear.Source);
                string strPage = objGear.Page;
                lblGearSource.Text = strBook + " " + strPage;
                tipTooltip.SetToolTip(lblGearSource, _objOptions.LanguageBookLong(objGear.Source) + " " + LanguageManager.Instance.GetString("String_Page") + " " + objGear.Page);

                if (objGear.GetType() == typeof(Commlink))
                {
                    Commlink objCommlink = (Commlink)objGear;
                    List<string> objASDF = new List<string>() { objCommlink.Attack.ToString(), objCommlink.Sleaze.ToString(), objCommlink.DataProcessing.ToString(), objCommlink.Firewall.ToString() };

                    cboGearAttack.BindingContext = new BindingContext();
                    cboGearAttack.ValueMember = "Value";
                    cboGearAttack.DisplayMember = "Name";
                    cboGearAttack.DataSource = objASDF;
                    cboGearAttack.SelectedIndex = 0;
                    cboGearAttack.Visible = true;
                    cboGearSleaze.BindingContext = new BindingContext();
                    cboGearSleaze.ValueMember = "Value";
                    cboGearSleaze.DisplayMember = "Name";
                    cboGearSleaze.DataSource = objASDF;
                    cboGearSleaze.SelectedIndex = 1;
                    cboGearDataProcessing.BindingContext = new BindingContext();
                    cboGearDataProcessing.ValueMember = "Value";
                    cboGearDataProcessing.DisplayMember = "Name";
                    cboGearDataProcessing.DataSource = objASDF;
                    cboGearDataProcessing.SelectedIndex = 2;
                    cboGearFirewall.BindingContext = new BindingContext();
                    cboGearFirewall.ValueMember = "Value";
                    cboGearFirewall.DisplayMember = "Name";
                    cboGearFirewall.DataSource = objASDF;
                    cboGearFirewall.SelectedIndex = 3;
                    lblGearDeviceRating.Text = objCommlink.TotalDeviceRating.ToString();

                    lblGearDeviceRating.Visible = true;
                    cboGearAttack.Visible = true;
                    cboGearSleaze.Visible = true;
                    cboGearDataProcessing.Visible = true;
                    cboGearFirewall.Visible = true;
                    lblGearDeviceRatingLabel.Visible = true;
                    lblGearAttackLabel.Visible = true;
                    lblGearSleazeLabel.Visible = true;
                    lblGearDataProcessingLabel.Visible = true;
                    lblGearFirewallLabel.Visible = true;

                    _blnSkipRefresh = true;
                    chkActiveCommlink.Checked = objCommlink.IsActive;
                    _blnSkipRefresh = false;

                    if (objCommlink.Category != "Commlink Upgrade")
                        chkActiveCommlink.Visible = true;

                    if (_objCharacter.Metatype == "A.I.")
                    {
                        chkGearHomeNode.Visible = true;
                        chkGearHomeNode.Checked = objCommlink.HomeNode;
                    }
                }
                else
                {
                    lblGearDeviceRating.Text = objGear.DeviceRating.ToString();
                    chkActiveCommlink.Visible = false;
                    cboGearAttack.Visible = false;
                    cboGearSleaze.Visible = false;
                    cboGearDataProcessing.Visible = false;
                    cboGearFirewall.Visible = false;
                    lblGearAttackLabel.Visible = false;
                    lblGearSleazeLabel.Visible = false;
                    lblGearDataProcessingLabel.Visible = false;
                    lblGearFirewallLabel.Visible = false;
                }

                if (objGear.MaxRating > 0)
                {
                    _blnSkipRefresh = true;
                    if (objGear.MinRating > 0)
                        nudGearRating.Minimum = objGear.MinRating;
                    else if (objGear.MinRating == 0 && objGear.Name.Contains("Credstick,"))
                        nudGearRating.Minimum = 0;
                    else
                        nudGearRating.Minimum = 1;
                    nudGearRating.Maximum = objGear.MaxRating;
                    nudGearRating.Value = objGear.Rating;
                    if (nudGearRating.Minimum == nudGearRating.Maximum)
                        nudGearRating.Enabled = false;
                    else
                        nudGearRating.Enabled = true;
                    _blnSkipRefresh = false;
                }
                else
                {
                    _blnSkipRefresh = true;
                    nudGearRating.Minimum = 0;
                    nudGearRating.Maximum = 0;
                    nudGearRating.Enabled = false;
                    _blnSkipRefresh = false;
                }

                try
                {
                    _blnSkipRefresh = true;
                    //nudGearQty.Minimum = objGear.CostFor;
                    nudGearQty.Increment = objGear.CostFor;
                    nudGearQty.Value = objGear.Quantity;
                    _blnSkipRefresh = false;
                }
                catch
                {
                }

                if (treGear.SelectedNode.Level == 1)
                {
                    _blnSkipRefresh = true;
                    nudGearQty.Enabled = true;
                    nudGearQty.Increment = objGear.CostFor;
                    //nudGearQty.Minimum = objGear.CostFor;
                    chkGearEquipped.Visible = true;
                    chkGearEquipped.Checked = objGear.Equipped;
                    _blnSkipRefresh = false;
                }
                else
                {
                    nudGearQty.Enabled = false;
                    _blnSkipRefresh = true;
                    chkGearEquipped.Visible = true;
                    chkGearEquipped.Checked = objGear.Equipped;

                    // If this is a Program, determine if its parent Gear (if any) is a Commlink. If so, show the Equipped checkbox.
                    if (objGear.IsProgram && _objOptions.CalculateCommlinkResponse)
                    {
                        Gear objParent = new Gear(_objCharacter);
                        objParent = objGear.Parent;
                        if (objParent.Category != string.Empty)
                        {
                            if (objParent.Category == "Commlinks" || objParent.Category == "Cyberdecks" || objParent.Category == "Nexus")
                                chkGearEquipped.Text = LanguageManager.Instance.GetString("Checkbox_SoftwareRunning");
                        }
                    }
                    _blnSkipRefresh = false;
                }

                // Show the Weapon Bonus information if it's available.
                if (objGear.WeaponBonus != null)
                {
                    lblGearDamageLabel.Visible = true;
                    lblGearDamage.Visible = true;
                    lblGearAPLabel.Visible = true;
                    lblGearAP.Visible = true;
                    lblGearDamage.Text = objGear.WeaponBonusDamage();
                    lblGearAP.Text = objGear.WeaponBonusAP;
                }
                else
                {
                    lblGearDamageLabel.Visible = false;
                    lblGearDamage.Visible = false;
                    lblGearAPLabel.Visible = false;
                    lblGearAP.Visible = false;
                }

                treGear.SelectedNode.Text = objGear.DisplayName;
            }
        }
Example #13
0
        private void tsGearAddNexus_Click(object sender, EventArgs e)
        {
            treGear.SelectedNode = treGear.Nodes[0];

            frmSelectNexus frmPickNexus = new frmSelectNexus(_objCharacter);
            frmPickNexus.ShowDialog(this);

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

            Gear objGear = new Gear(_objCharacter);
            objGear = frmPickNexus.SelectedNexus;

            TreeNode nodNexus = new TreeNode();
            nodNexus.Text = objGear.Name;
            nodNexus.Tag = objGear.InternalId;
            nodNexus.ContextMenuStrip = cmsGear;

            foreach (Gear objChild in objGear.Children)
            {
                TreeNode nodModule = new TreeNode();
                nodModule.Text = objChild.Name;
                nodModule.Tag = objChild.InternalId;
                nodModule.ContextMenuStrip = cmsGear;
                nodNexus.Nodes.Add(nodModule);
                nodNexus.Expand();
            }

            treGear.Nodes[0].Nodes.Add(nodNexus);
            treGear.Nodes[0].Expand();

            _objCharacter.Gear.Add(objGear);

            UpdateCharacterInfo();
        }
Example #14
0
        private void treFoci_BeforeCheck(object sender, TreeViewCancelEventArgs e)
        {
            // Don't bother to do anything since a node is being unchecked.
            if (e.Node.Checked)
                return;

            // Locate the Focus that is being touched.
            Gear objSelectedFocus = new Gear(_objCharacter);
            objSelectedFocus = _objFunctions.FindGear(e.Node.Tag.ToString(), _objCharacter.Gear);

            // Set the Focus count to 1 and get its current Rating (Force). This number isn't used in the following loops because it isn't yet checked or unchecked.
            int intFociCount = 1;
            int intFociTotal = 0;

            if (objSelectedFocus != null)
                intFociTotal = objSelectedFocus.Rating;
            else
            {
                // This is a Stacked Focus.
                StackedFocus objStack = new StackedFocus(_objCharacter);
                foreach (StackedFocus objCharacterFocus in _objCharacter.StackedFoci)
                {
                    if (e.Node.Tag.ToString() == objCharacterFocus.InternalId)
                    {
                        objStack = objCharacterFocus;
                        break;
                    }
                }
                intFociTotal = objStack.TotalForce;
            }

            // Run through the list of items. Count the number of Foci the character would have bonded including this one, plus the total Force of all checked Foci.
            foreach (TreeNode objNode in treFoci.Nodes)
            {
                if (objNode.Checked)
                {
                    intFociCount++;
                    foreach (Gear objCharacterFocus in _objCharacter.Gear)
                    {
                        if (objNode.Tag.ToString() == objCharacterFocus.InternalId)
                        {
                            intFociTotal += objCharacterFocus.Rating;
                            break;
                        }
                    }

                    foreach (StackedFocus objStack in _objCharacter.StackedFoci)
                    {
                        if (objNode.Tag.ToString() == objStack.InternalId)
                        {
                            if (objStack.Bonded)
                            {
                                intFociTotal += objStack.TotalForce;
                                break;
                            }
                        }
                    }
                }
            }

            if (intFociTotal > _objCharacter.MAG.TotalValue * 5 && !_objCharacter.IgnoreRules)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_FocusMaximumForce"), LanguageManager.Instance.GetString("MessageTitle_FocusMaximum"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                e.Cancel = true;
                return;
            }

            if (intFociCount > _objCharacter.MAG.TotalValue && !_objCharacter.IgnoreRules)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_FocusMaximumNumber"), LanguageManager.Instance.GetString("MessageTitle_FocusMaximum"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                e.Cancel = true;
            }
        }
Example #15
0
        private void treFoci_AfterCheck(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Checked)
            {
                // Locate the Focus that is being touched.
                Gear objSelectedFocus = new Gear(_objCharacter);
                objSelectedFocus = _objFunctions.FindGear(e.Node.Tag.ToString(), _objCharacter.Gear);

                if (objSelectedFocus != null)
                {
                    Focus objFocus = new Focus();
                    objFocus.Name = e.Node.Text;
                    objFocus.Rating = objSelectedFocus.Rating;
                    objFocus.GearId = e.Node.Tag.ToString();
                    _objCharacter.Foci.Add(objFocus);

                    // Mark the Gear and Bonded and create an Improvements.
                    objSelectedFocus.Bonded = true;
                    if (objSelectedFocus.Equipped)
                    {
                        if (objSelectedFocus.Bonus != null)
                        {
                            if (objSelectedFocus.Extra != "")
                                _objImprovementManager.ForcedValue = objSelectedFocus.Extra;
                            _objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Gear, objSelectedFocus.InternalId, objSelectedFocus.Bonus, false, objSelectedFocus.Rating, objSelectedFocus.DisplayNameShort);

                            foreach (Power objPower in _objCharacter.Powers)
                            {
                                if (objFocus.GearId == objPower.BonusSource)
                                {
                                    objSelectedFocus.Extra = objPower.Name;
                                    break;
                                }
                            }

                            RefreshPowers();
                            _objController.PopulateFocusList(treFoci);
                        }
                    }
                }
                else
                {
                    // This is a Stacked Focus.
                    StackedFocus objStack = new StackedFocus(_objCharacter);
                    foreach (StackedFocus objCharacterFocus in _objCharacter.StackedFoci)
                    {
                        if (e.Node.Tag.ToString() == objCharacterFocus.InternalId)
                        {
                            objStack = objCharacterFocus;
                            break;
                        }
                    }

                    objStack.Bonded = true;
                    Gear objStackGear = _objFunctions.FindGear(objStack.GearId, _objCharacter.Gear);
                    if (objStackGear.Equipped)
                    {
                        foreach (Gear objGear in objStack.Gear)
                        {
                            if (objGear.Bonus != null)
                            {
                                if (objGear.Extra != "")
                                    _objImprovementManager.ForcedValue = objGear.Extra;
                                _objImprovementManager.CreateImprovements(Improvement.ImprovementSource.StackedFocus, objStack.InternalId, objGear.Bonus, false, objGear.Rating, objGear.DisplayNameShort);
                            }
                        }
                    }
                }
            }
            else
            {
                Focus objFocus = new Focus();
                foreach (Focus objCharacterFocus in _objCharacter.Foci)
                {
                    if (objCharacterFocus.GearId == e.Node.Tag.ToString())
                    {
                        objFocus = objCharacterFocus;
                        break;
                    }
                }

                // Mark the Gear as not Bonded and remove any Improvements.
                Gear objGear = new Gear(_objCharacter);
                objGear = _objFunctions.FindGear(objFocus.GearId, _objCharacter.Gear);

                if (objGear != null)
                {
                    objGear.Bonded = false;
                    _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Gear, objGear.InternalId);
                    _objCharacter.Foci.Remove(objFocus);
                    foreach (Power objPower in _objCharacter.Powers)
                    {
                        if (objPower.BonusSource == objGear.InternalId)
                        {
                            //Remove the Bonus Source since this object will not be giving a bonus
                            objPower.BonusSource = "";

                            if (objPower.Free)
                                _objCharacter.Powers.Remove(objPower);
                            else if (objPower.FreeLevels > 0)
                            {
                                int freeLevelsByThisFocus = (int)(Math.Min(objFocus.Rating * .25M, objPower.FreeLevels * objPower.PointsPerLevel) / objPower.PointsPerLevel);
                                if (objPower.Rating > freeLevelsByThisFocus)
                                {
                                    objPower.Rating -= freeLevelsByThisFocus;
                                    objPower.FreeLevels -= freeLevelsByThisFocus;
                                }
                                else
                                {
                                    _objCharacter.Powers.Remove(objPower);
                                }
                            }
                            else if (objPower.FreePoints > 0)
                            {
                                // For complete robustness, a way should be implemented to allow to switch
                                // between Improved Reflexes I/II/III, with Foci, according to the force
                                // of the focus.

                                //In the meantime, calculate if the free points of the focus are equal
                                //to the point cost of the power, and remove it if it is
                                decimal freePointsByThisFocus = Math.Min(objFocus.Rating * .25M, objPower.FreePoints);

                                //This should be the case, always as implemented currently.
                                if (objPower.PointsPerLevel * objPower.Rating == freePointsByThisFocus)
                                {
                                    _objCharacter.Powers.Remove(objPower);
                                }
                                else
                                {
                                    //Should never happen currently.
                                    objPower.FreePoints -= freePointsByThisFocus;
                                    objPower.Rating -= freePointsByThisFocus * objPower.PointsPerLevel;
                                }
                            }
                            else
                                _objCharacter.Powers.Remove(objPower);

                            objGear.Extra = "";
                            _objController.PopulateFocusList(treFoci);
                            break;
                        }
                    }
                    RefreshPowers();
                }
                else
                {
                    // This is a Stacked Focus.
                    StackedFocus objStack = new StackedFocus(_objCharacter);
                    foreach (StackedFocus objCharacterFocus in _objCharacter.StackedFoci)
                    {
                        if (e.Node.Tag.ToString() == objCharacterFocus.InternalId)
                        {
                            objStack = objCharacterFocus;
                            break;
                        }
                    }

                    objStack.Bonded = false;
                    foreach (Gear objFocusGear in objStack.Gear)
                    {
                        _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.StackedFocus, objStack.InternalId);
                    }
                }
            }

            UpdateCharacterInfo();

            _blnIsDirty = true;
            UpdateWindowTitle();
        }
Example #16
0
        private void cmdDeleteGear_Click(object sender, EventArgs e)
        {
            // Delete the selected Gear.
            try
            {
                if (treGear.SelectedNode.Level == 0)
                {
                    if (treGear.SelectedNode.Text == LanguageManager.Instance.GetString("Node_SelectedGear"))
                        return;

                    if (!_objFunctions.ConfirmDelete(LanguageManager.Instance.GetString("Message_DeleteGearLocation")))
                        return;

                    // Move all of the child nodes in the current parent to the Selected Gear parent node.
                    foreach (TreeNode objNode in treGear.SelectedNode.Nodes)
                    {
                        Gear objGear = new Gear(_objCharacter);
                        objGear = _objFunctions.FindGear(objNode.Tag.ToString(), _objCharacter.Gear);

                        // Change the Location for the Gear.
                        objGear.Location = "";
                    }

                    List<TreeNode> lstMoveNodes = new List<TreeNode>();
                    foreach (TreeNode objNode in treGear.SelectedNode.Nodes)
                        lstMoveNodes.Add(objNode);

                    foreach (TreeNode objNode in lstMoveNodes)
                    {
                        treGear.SelectedNode.Nodes.Remove(objNode);
                        treGear.Nodes[0].Nodes.Add(objNode);
                    }

                    // Remove the Location from the character, then remove the selected node.
                    _objCharacter.Locations.Remove(treGear.SelectedNode.Text);
                    treGear.SelectedNode.Remove();
                }
                if (treGear.SelectedNode.Level > 0)
                {
                    if (!_objFunctions.ConfirmDelete(LanguageManager.Instance.GetString("Message_DeleteGear")))
                        return;

                    Gear objGear = new Gear(_objCharacter);
                    objGear = _objFunctions.FindGear(treGear.SelectedNode.Tag.ToString(), _objCharacter.Gear);
                    Gear objParent = new Gear(_objCharacter);
                    objParent = _objFunctions.FindGear(treGear.SelectedNode.Parent.Tag.ToString(), _objCharacter.Gear);

                    _objFunctions.DeleteGear(objGear, treWeapons, _objImprovementManager);

                    _objCharacter.Gear.Remove(objGear);
                    treGear.SelectedNode.Remove();

                    // If the Parent is populated, remove the item from its Parent.
                    if (objParent != null)
                        objParent.Children.Remove(objGear);
                }
                _objController.PopulateFocusList(treFoci);

                _objCharacter.SkillsSection.ForceProperyChangedNotificationAll(nameof(Skill.PoolModifiers));
                UpdateCharacterInfo();
                RefreshSelectedGear();

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

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

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

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

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

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

            if (blnCopy)
            {
                _guiID = Guid.NewGuid();
            }
        }
Example #18
0
        private void tsWeaponAccessoryGearMenuAddAsPlugin_Click(object sender, EventArgs e)
        {
            // Locate the Vehicle Sensor Gear.
            bool blnFound = false;
            WeaponAccessory objFoundAccessory = new WeaponAccessory(_objCharacter);
            Gear objSensor = _objFunctions.FindWeaponGear(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons, out objFoundAccessory);
            if (objSensor != null)
                blnFound = true;

            // Make sure the Gear was found.
            if (!blnFound)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_ModifyVehicleGear"), LanguageManager.Instance.GetString("MessageTitle_SelectGear"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

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

            XmlNode objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objSensor.Name + "\" and category = \"" + objSensor.Category + "\"]");

            frmSelectGear frmPickGear = new frmSelectGear(_objCharacter);
            //frmPickGear.ShowNegativeCapacityOnly = true;

            if (objXmlGear.InnerXml.Contains("<addoncategory>"))
            {
                string strCategories = "";
                foreach (XmlNode objXmlCategory in objXmlGear.SelectNodes("addoncategory"))
                    strCategories += objXmlCategory.InnerText + ",";
                // Remove the trailing comma.
                strCategories = strCategories.Substring(0, strCategories.Length - 1);
                frmPickGear.AllowedCategories = strCategories;
            }

            frmPickGear.ShowDialog(this);

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

            // Open the Gear XML file and locate the selected piece.
            objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + frmPickGear.SelectedGear + "\" and category = \"" + frmPickGear.SelectedCategory + "\"]");

            // Create the new piece of Gear.
            List<Weapon> objWeapons = new List<Weapon>();
            List<TreeNode> objWeaponNodes = new List<TreeNode>();
            TreeNode objNode = new TreeNode();
            Gear objGear = new Gear(_objCharacter);

            switch (frmPickGear.SelectedCategory)
            {
                case "Commlinks":
                case "Cyberdecks":
                case "Rigger Command Consoles":
                    Commlink objCommlink = new Commlink(_objCharacter);
                    objCommlink.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating);
                    objCommlink.Quantity = frmPickGear.SelectedQty;
                    objNode.Text = objCommlink.DisplayName;

                    objGear = objCommlink;
                    break;
                default:
                    Gear objNewGear = new Gear(_objCharacter);
                    objNewGear.Create(objXmlGear, _objCharacter, objNode, frmPickGear.SelectedRating, objWeapons, objWeaponNodes, "", frmPickGear.Hacked, frmPickGear.InherentProgram, true, true, frmPickGear.Aerodynamic);
                    objNewGear.Quantity = frmPickGear.SelectedQty;
                    objNode.Text = objNewGear.DisplayName;

                    objGear = objNewGear;
                    break;
            }

            if (objGear.InternalId == Guid.Empty.ToString())
                return;

            objGear.DiscountCost = frmPickGear.BlackMarketDiscount;

            // Reduce the cost for Do It Yourself components.
            if (frmPickGear.DoItYourself)
                objGear.Cost = (Convert.ToDouble(objGear.Cost, GlobalOptions.Instance.CultureInfo) * 0.5).ToString();
            // Reduce the cost to 10% for Hacked programs.
            if (frmPickGear.Hacked)
            {
                if (objGear.Cost != "")
                    objGear.Cost = "(" + objGear.Cost + ") * 0.1";
                if (objGear.Cost3 != "")
                    objGear.Cost3 = "(" + objGear.Cost3 + ") * 0.1";
                if (objGear.Cost6 != "")
                    objGear.Cost6 = "(" + objGear.Cost6 + ") * 0.1";
                if (objGear.Cost10 != "")
                    objGear.Cost10 = "(" + objGear.Cost10 + ") * 0.1";
                if (objGear.Extra == "")
                    objGear.Extra = LanguageManager.Instance.GetString("Label_SelectGear_Hacked");
                else
                    objGear.Extra += ", " + LanguageManager.Instance.GetString("Label_SelectGear_Hacked");
            }
            // If the item was marked as free, change its cost.
            if (frmPickGear.FreeCost)
            {
                objGear.Cost = "0";
                objGear.Cost3 = "0";
                objGear.Cost6 = "0";
                objGear.Cost10 = "0";
            }

            objNode.Text = objGear.DisplayName;

            objNode.ContextMenuStrip = cmsWeaponAccessoryGear;

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

            objGear.Parent = objSensor;
            objSensor.Children.Add(objGear);

            if (frmPickGear.AddAgain)
                tsWeaponAccessoryGearMenuAddAsPlugin_Click(sender, e);

            UpdateCharacterInfo();
            RefreshSelectedWeapon();
        }
Example #19
0
        /// Create a Vehicle from an XmlNode and return the TreeNodes for it.
        /// <param name="objXmlVehicle">XmlNode of the Vehicle to create.</param>
        /// <param name="objNode">TreeNode to add to a TreeView.</param>
        /// <param name="cmsVehicle">ContextMenuStrip to attach to Weapon Mounts.</param>
        /// <param name="cmsVehicleGear">ContextMenuStrip to attach to Gear.</param>
        /// <param name="cmsVehicleWeapon">ContextMenuStrip to attach to Vehicle Weapons.</param>
        /// <param name="cmsVehicleWeaponAccessory">ContextMenuStrip to attach to Weapon Accessories.</param>
        /// <param name="blnCreateChildren">Whether or not child items should be created.</param>
        public void Create(XmlNode objXmlVehicle, TreeNode objNode, ContextMenuStrip cmsVehicle, ContextMenuStrip cmsVehicleGear, ContextMenuStrip cmsVehicleWeapon, ContextMenuStrip cmsVehicleWeaponAccessory, bool blnCreateChildren = true)
        {
            _strName = objXmlVehicle["name"].InnerText;
            _strCategory = objXmlVehicle["category"].InnerText;
            //Some vehicles have different Offroad Handling speeds. If so, we want to split this up for use with mods and such later.
            if (objXmlVehicle["handling"].InnerText.Contains('/'))
            {
                _intHandling = Convert.ToInt32(objXmlVehicle["handling"].InnerText.Split('/')[0]);
                _intOffroadHandling = Convert.ToInt32(objXmlVehicle["handling"].InnerText.Split('/')[1]);
            }
            else
            {
                _intHandling = Convert.ToInt32(objXmlVehicle["handling"].InnerText);
            }
            _intAccel = Convert.ToInt32(objXmlVehicle["accel"].InnerText);
            _intSpeed = Convert.ToInt32(objXmlVehicle["speed"].InnerText);
            _intPilot = Convert.ToInt32(objXmlVehicle["pilot"].InnerText);
            _intBody = Convert.ToInt32(objXmlVehicle["body"].InnerText);
            _intArmor = Convert.ToInt32(objXmlVehicle["armor"].InnerText);
            _intSensor = Convert.ToInt32(objXmlVehicle["sensor"].InnerText);
            try
            {
                _intDeviceRating = Convert.ToInt32(objXmlVehicle["devicerating"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intSeats = Convert.ToInt32(objXmlVehicle["seats"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intModSlots = Convert.ToInt32(objXmlVehicle["modslots"].InnerText);
            }
            catch (NullReferenceException e)
            {
                _intModSlots = _intBody;
            }
            _strAvail = objXmlVehicle["avail"].InnerText;
            _strCost = objXmlVehicle["cost"].InnerText;
            // Check for a Variable Cost.
            if (objXmlVehicle["cost"].InnerText.StartsWith("Variable"))
            {
                int intMin = 0;
                int intMax = 0;
                string strCost = objXmlVehicle["cost"].InnerText.Replace("Variable(", string.Empty).Replace(")", string.Empty);
                if (strCost.Contains("-"))
                {
                    string[] strValues = strCost.Split('-');
                    intMin = Convert.ToInt32(strValues[0]);
                    intMax = Convert.ToInt32(strValues[1]);
                }
                else
                    intMin = Convert.ToInt32(strCost.Replace("+", string.Empty));

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

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

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

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

            // If there are any VehicleMods that come with the Vehicle, add them.
            if (objXmlVehicle.InnerXml.Contains("<mods>") && blnCreateChildren)
            {
                XmlDocument objXmlDocument = new XmlDocument();
                objXmlDocument = XmlManager.Instance.Load("vehicles.xml");

                XmlNodeList objXmlModList = objXmlVehicle.SelectNodes("mods/name");
                foreach (XmlNode objXmlVehicleMod in objXmlModList)
                {
                    XmlNode objXmlMod = objXmlDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + objXmlVehicleMod.InnerText + "\"]");
                    if (objXmlMod != null)
                    {
                        TreeNode objModNode = new TreeNode();
                        VehicleMod objMod = new VehicleMod(_objCharacter);
                        int intRating = 0;

                        if (objXmlVehicleMod.Attributes["rating"] != null)
                            intRating = Convert.ToInt32(objXmlVehicleMod.Attributes["rating"].InnerText);

                        if (objXmlVehicleMod.Attributes["select"] != null)
                            objMod.Extra = objXmlVehicleMod.Attributes["select"].InnerText;

                        objMod.Create(objXmlMod, objModNode, intRating);
                        objMod.IncludedInVehicle = true;

                        _lstVehicleMods.Add(objMod);
                        objModNode.ForeColor = SystemColors.GrayText;
                        objModNode.ContextMenuStrip = cmsVehicle;

                        objNode.Nodes.Add(objModNode);
                        objNode.Expand();
                    }
                }
                if (objXmlVehicle.SelectSingleNode("mods/addslots") != null)
                    _intAddSlots = Convert.ToInt32(objXmlVehicle.SelectSingleNode("mods/addslots").InnerText);
            }

            // If there is any Gear that comes with the Vehicle, add them.
            if (objXmlVehicle.InnerXml.Contains("<gears>") && blnCreateChildren)
            {
                XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");

                XmlNodeList objXmlGearList = objXmlVehicle.SelectNodes("gears/gear");
                foreach (XmlNode objXmlVehicleGear in objXmlGearList)
                {
                    XmlNode objXmlGear = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objXmlVehicleGear.InnerText + "\"]");
                    if (objXmlGear != null)
                    {
                        TreeNode objGearNode = new TreeNode();
                        Gear objGear = new Gear(_objCharacter);
                        int intRating = 0;
                        int intQty = 1;
                        string strForceValue = "";

                        if (objXmlVehicleGear.Attributes["rating"] != null)
                            intRating = Convert.ToInt32(objXmlVehicleGear.Attributes["rating"].InnerText);

                        int intMaxRating = intRating;
                        if (objXmlVehicleGear.Attributes["maxrating"] != null)
                            intMaxRating = Convert.ToInt32(objXmlVehicleGear.Attributes["maxrating"].InnerText);

                        if (objXmlVehicleGear.Attributes["qty"] != null)
                            intQty = Convert.ToInt32(objXmlVehicleGear.Attributes["qty"].InnerText);

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

                        List<Weapon> objWeapons = new List<Weapon>();
                        List<TreeNode> objWeaponNodes = new List<TreeNode>();
                        objGear.Create(objXmlGear, _objCharacter, objGearNode, intRating, objWeapons, objWeaponNodes, strForceValue);
                        objGear.Cost = "0";
                        objGear.Quantity = intQty;
                        objGear.MaxRating = intMaxRating;
                        objGear.IncludedInParent = true;
                        objGearNode.Text = objGear.DisplayName;
                        objGearNode.ContextMenuStrip = cmsVehicleGear;

                        foreach (Weapon objWeapon in objWeapons)
                            objWeapon.VehicleMounted = true;

                        _lstGear.Add(objGear);

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

            // If there are any Weapons that come with the Vehicle, add them.
            if (objXmlVehicle.InnerXml.Contains("<weapons>") && blnCreateChildren)
            {
                XmlDocument objXmlWeaponDocument = XmlManager.Instance.Load("weapons.xml");

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

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

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

                    // If a free Weapon Mount could not be found, just attach it to the first one found and let the player deal with it.
                    if (!blnAttached)
                    {
                        foreach (VehicleMod objMod in _lstVehicleMods)
                        {
                            if (objMod.Name.Contains("Weapon Mount") || (!String.IsNullOrEmpty(objMod.WeaponMountCategories) && objMod.WeaponMountCategories.Contains(objWeapon.Category)))
                            {
                                objMod.Weapons.Add(objWeapon);
                                foreach (TreeNode objModNode in objNode.Nodes)
                                {
                                    if (objModNode.Tag.ToString() == objMod.InternalId)
                                    {
                                        objWeaponNode.ContextMenuStrip = cmsVehicleWeapon;
                                        objModNode.Nodes.Add(objWeaponNode);
                                        objModNode.Expand();
                                        blnAttached = true;
                                        break;
                                    }
                                }
                                break;
                            }
                        }
                    }

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

                            objWeapon.WeaponAccessories.Add(objMod);

                            objWeaponNode.Nodes.Add(objModNode);
                            objWeaponNode.Expand();
                        }
                    }
                }
            }
        }
Example #20
0
        /// <summary>
        /// Add a piece of Gear that was found in a PACKS Kit.
        /// </summary>
        /// <param name="objXmlGearDocument">XmlDocument that contains the Gear.</param>
        /// <param name="objXmlGear">XmlNode of the Gear to add.</param>
        /// <param name="objParent">TreeNode to attach the created items to.</param>
        /// <param name="objParentObject">Object to associate the newly-created items with.</param>
        /// <param name="cmsContextMenu">ContextMenuStrip to assign to the TreeNodes created.</param>
        /// <param name="blnCreateChildren">Whether or not the default plugins for the Gear should be created.</param>
        private void AddPACKSGear(XmlDocument objXmlGearDocument, XmlNode objXmlGear, TreeNode objParent, Object objParentObject, ContextMenuStrip cmsContextMenu, bool blnCreateChildren)
        {
            int intRating = 0;
            if (objXmlGear["rating"] != null)
                intRating = Convert.ToInt32(objXmlGear["rating"].InnerText);
            int intQty = 1;
            if (objXmlGear["qty"] != null)
                intQty = Convert.ToInt32(objXmlGear["qty"].InnerText);

            XmlNode objXmlGearNode;
            if (objXmlGear["category"] != null)
                objXmlGearNode = objXmlGearDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objXmlGear["name"].InnerText + "\" and category = \"" + objXmlGear["category"].InnerText + "\"]");
            else
                objXmlGearNode = objXmlGearDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objXmlGear["name"].InnerText + "\"]");

            List<Weapon> objWeapons = new List<Weapon>();
            List<TreeNode> objWeaponNodes = new List<TreeNode>();
            TreeNode objNode = new TreeNode();
            string strForceValue = "";
            if (objXmlGear["name"].Attributes["select"] != null)
                strForceValue = objXmlGear["name"].Attributes["select"].InnerText;

            Gear objNewGear = new Gear(_objCharacter);
            if (objXmlGearNode != null)
            {
                switch (objXmlGearNode["category"].InnerText)
                {
                    case "Commlinks":
                    case "Cyberdecks":
                    case "Rigger Command Consoles":
                        Commlink objCommlink = new Commlink(_objCharacter);
                        objCommlink.Create(objXmlGearNode, _objCharacter, objNode, intRating, true, blnCreateChildren);
                        objCommlink.Quantity = intQty;
                        objNewGear = objCommlink;
                        break;
                    default:
                        Gear objGear = new Gear(_objCharacter);
                        objGear.Create(objXmlGearNode, _objCharacter, objNode, intRating, objWeapons, objWeaponNodes, strForceValue, false, false, true, blnCreateChildren);
                        objGear.Quantity = intQty;
                        objNode.Text = objGear.DisplayName;
                        objNewGear = objGear;
                        break;
                }
            }

            if (objParentObject.GetType() == typeof(Character))
                ((Character)objParentObject).Gear.Add(objNewGear);
            if (objParentObject.GetType() == typeof(Gear) || objParentObject.GetType() == typeof(Commlink) || objParentObject.GetType() == typeof(OperatingSystem))
            {
                ((Gear)objParentObject).Children.Add(objNewGear);
                objNewGear.Parent = (Gear)objParentObject;
            }
            if (objParentObject.GetType() == typeof(Armor))
                ((Armor)objParentObject).Gear.Add(objNewGear);
            if (objParentObject.GetType() == typeof(WeaponAccessory))
                ((WeaponAccessory)objParentObject).Gear.Add(objNewGear);
            if (objParentObject.GetType() == typeof(Cyberware))
                ((Cyberware)objParentObject).Gear.Add(objNewGear);

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

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

            objNode.ContextMenuStrip = cmsContextMenu;
            objNode.Text = objNewGear.DisplayName;

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

            foreach (TreeNode objWeaponNode in objWeaponNodes)
            {
                objWeaponNode.ContextMenuStrip = cmsWeapon;
                treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
                treWeapons.Nodes[0].Expand();
            }
        }
Example #21
0
        /// <summary>
        /// Locate a piece of Gear.
        /// </summary>
        /// <param name="strName">Name of the Gear to find.</param>
        /// <param name="lstGear">List of Gear to search.</param>
        private Gear FindGearByName(string strName, List<Gear> lstGear)
        {
            Gear objReturn = new Gear(_objCharacter);
            foreach (Gear objGear in lstGear)
            {
                if (objGear.Name == strName)
                    objReturn = objGear;
                else
                {
                    if (objGear.Children.Count > 0)
                        objReturn = FindGearByName(strName, objGear.Children);
                }

                if (objReturn.InternalId != Guid.Empty.ToString() && objReturn.Name != "")
                    return objReturn;
            }

            return objReturn;
        }
Example #22
0
        /// <summary>
        /// Change the size of a Vehicle's Sensor -- This appears to be obsolete code
        /// </summary>
        /// <param name="objVehicle">Vehicle to modify.</param>
        /// <param name="blnIncrease">True if the Sensor should increase in size, False if it should decrease.</param>
        private void ChangeVehicleSensor(Vehicle objVehicle, bool blnIncrease)
        {
            XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
            XmlNode objNewNode;
            bool blnFound = false;

            Gear objSensor = new Gear(_objCharacter);
            Gear objNewSensor = new Gear(_objCharacter);

            TreeNode objTreeNode = new TreeNode();
            List<Weapon> lstWeapons = new List<Weapon>();
            List<TreeNode> lstWeaponNodes = new List<TreeNode>();
            foreach (Gear objCurrentGear in objVehicle.Gear)
            {
                if (objCurrentGear.Name == "Microdrone Sensor")
                {
                    if (blnIncrease)
                    {
                        objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Minidrone Sensor\" and category = \"Sensors\"]");
                        objNewSensor.Create(objNewNode, _objCharacter, objTreeNode, 0, lstWeapons, lstWeaponNodes);
                        objSensor = objCurrentGear;
                        blnFound = true;
                    }
                    break;
                }
                else if (objCurrentGear.Name == "Minidrone Sensor")
                {
                    if (blnIncrease)
                        objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Small Drone Sensor\" and category = \"Sensors\"]");
                    else
                        objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Microdrone Sensor\" and category = \"Sensors\"]");
                    objNewSensor.Create(objNewNode, _objCharacter, objTreeNode, 0, lstWeapons, lstWeaponNodes);
                    objSensor = objCurrentGear;
                    blnFound = true;
                    break;
                }
                else if (objCurrentGear.Name == "Small Drone Sensor")
                {
                    if (blnIncrease)
                        objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Medium Drone Sensor\" and category = \"Sensors\"]");
                    else
                        objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Minidrone Sensor\" and category = \"Sensors\"]");
                    objNewSensor.Create(objNewNode, _objCharacter, objTreeNode, 0, lstWeapons, lstWeaponNodes);
                    objSensor = objCurrentGear;
                    blnFound = true;
                    break;
                }
                else if (objCurrentGear.Name == "Medium Drone Sensor")
                {
                    if (blnIncrease)
                        objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Large Drone Sensor\" and category = \"Sensors\"]");
                    else
                        objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Small Drone Sensor\" and category = \"Sensors\"]");
                    objNewSensor.Create(objNewNode, _objCharacter, objTreeNode, 0, lstWeapons, lstWeaponNodes);
                    objSensor = objCurrentGear;
                    blnFound = true;
                    break;
                }
                else if (objCurrentGear.Name == "Large Drone Sensor")
                {
                    if (blnIncrease)
                        objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Vehicle Sensor\" and category = \"Sensors\"]");
                    else
                        objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Medium Drone Sensor\" and category = \"Sensors\"]");
                    objNewSensor.Create(objNewNode, _objCharacter, objTreeNode, 0, lstWeapons, lstWeaponNodes);
                    objSensor = objCurrentGear;
                    blnFound = true;
                    break;
                }
                else if (objCurrentGear.Name == "Vehicle Sensor")
                {
                    if (blnIncrease)
                        objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Extra-Large Vehicle Sensor\" and category = \"Sensors\"]");
                    else
                        objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Large Drone Sensor\" and category = \"Sensors\"]");
                    objNewSensor.Create(objNewNode, _objCharacter, objTreeNode, 0, lstWeapons, lstWeaponNodes);
                    objSensor = objCurrentGear;
                    blnFound = true;
                    break;
                }
                else if (objCurrentGear.Name == "Extra-Large Vehicle Sensor")
                {
                    if (!blnIncrease)
                    {
                        objNewNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Vehicle Sensor\" and category = \"Sensors\"]");
                        objNewSensor.Create(objNewNode, _objCharacter, objTreeNode, 0, lstWeapons, lstWeaponNodes);
                        objSensor = objCurrentGear;
                        blnFound = true;
                    }
                    break;
                }
            }

            // If the item was found, update the Vehicle Sensor information.
            if (blnFound)
            {
                objSensor.Name = objNewSensor.Name;
                objSensor.Rating = objNewSensor.Rating;
                objSensor.Capacity = objNewSensor.Capacity;
                objSensor.DeviceRating = objNewSensor.DeviceRating;
                objSensor.Avail = objNewSensor.Avail;
                objSensor.Cost = objNewSensor.Cost;
                objSensor.Source = objNewSensor.Source;
                objSensor.Page = objNewSensor.Page;

                // Update the name of the item in the TreeView.
                TreeNode objNode = _objFunctions.FindNode(objSensor.InternalId, treVehicles);
                objNode.Text = objSensor.DisplayNameShort;
            }
        }
Example #23
0
        /// <summary>
        /// Copy a piece of Gear.
        /// </summary>
        /// <param name="objGear">Gear object to copy.</param>
        /// <param name="objNode">TreeNode created by copying the item.</param>
        /// <param name="objWeapons">List of Weapons created by copying the item.</param>
        /// <param name="objWeaponNodes">List of Weapon TreeNodes created by copying the item.</param>
        public void Copy(Commlink objGear, TreeNode objNode, List<Weapon> objWeapons, List<TreeNode> objWeaponNodes)
        {
            _strName = objGear.Name;
            _strCategory = objGear.Category;
            _intMaxRating = objGear.MaxRating;
            _intMinRating = objGear.MinRating;
            _intRating = objGear.Rating;
            _intQty = objGear.Quantity;
            _strCapacity = objGear.Capacity;
            _strArmorCapacity = objGear.ArmorCapacity;
            _strAvail = objGear.Avail;
            _strAvail3 = objGear.Avail3;
            _strAvail6 = objGear.Avail6;
            _strAvail10 = objGear.Avail10;
            _intCostFor = objGear.CostFor;
            _strOverclocked = objGear.Overclocked;
            _intDeviceRating = objGear.DeviceRating;
            _intAttack = objGear.Attack;
            _intDataProcessing = objGear.DataProcessing;
            _intFirewall = objGear.Firewall;
            _intSleaze = objGear.Sleaze;
            _strCost = objGear.Cost;
            _strCost3 = objGear.Cost3;
            _strCost6 = objGear.Cost6;
            _strCost10 = objGear.Cost10;
            _strSource = objGear.Source;
            _strPage = objGear.Page;
            _strExtra = objGear.Extra;
            _blnBonded = objGear.Bonded;
            _blnEquipped = objGear.Equipped;
            _blnHomeNode = objGear.HomeNode;
            _nodBonus = objGear.Bonus;
            _nodWeaponBonus = objGear.WeaponBonus;
            _guiWeaponID = Guid.Parse(objGear.WeaponID);
            _strNotes = objGear.Notes;
            _strLocation = objGear.Location;

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

            foreach (Gear objGearChild in objGear.Children)
            {
                TreeNode objChildNode = new TreeNode();
                Gear objChild = new Gear(_objCharacter);
                if (objGearChild.GetType() == typeof(Commlink))
                {
                    Commlink objCommlink = new Commlink(_objCharacter);
                    objCommlink.Copy(objGearChild, objChildNode, objWeapons, objWeaponNodes);
                    objChild = objCommlink;
                }
                else
                    objChild.Copy(objGearChild, objChildNode, objWeapons, objWeaponNodes);
                _objChildren.Add(objChild);

                objNode.Nodes.Add(objChildNode);
                objNode.Expand();
            }
        }
Example #24
0
        private void chkActiveCommlink_CheckedChanged(object sender, EventArgs e)
        {
            if (_blnSkipRefresh)
                return;

            Gear objSelectedGear = new Gear(_objCharacter);

            // Attempt to locate the selected piece of Gear.
            try
            {
                objSelectedGear = _objFunctions.FindGear(treGear.SelectedNode.Tag.ToString(), _objCharacter.Gear);

                if (objSelectedGear.GetType() != typeof(Commlink))
                    return;

                Commlink objCommlink = (Commlink)objSelectedGear;
                objCommlink.IsActive = chkActiveCommlink.Checked;

                ChangeActiveCommlink(objCommlink);

                RefreshSelectedGear();
                UpdateCharacterInfo();

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

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

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

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

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

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

            if (blnCopy)
            {
                _guiID = Guid.NewGuid();
                _strLocation = string.Empty;
                _blnHomeNode = false;
            }
        }
Example #26
0
        private void chkGearEquipped_CheckedChanged(object sender, EventArgs e)
        {
            if (_blnSkipRefresh)
                return;

            Gear objSelectedGear = new Gear(_objCharacter);

            // Attempt to locate the selected piece of Gear.
            try
            {
                objSelectedGear = _objFunctions.FindGear(treGear.SelectedNode.Tag.ToString(), _objCharacter.Gear);
                objSelectedGear.Equipped = chkGearEquipped.Checked;

                _objController.ChangeGearEquippedStatus(objSelectedGear, chkGearEquipped.Checked);

                RefreshSelectedGear();
                UpdateCharacterInfo();

                _blnIsDirty = true;
                UpdateWindowTitle();
            }
            catch
            {
            }
        }
Example #27
0
        /// <summary>
        /// Move a Gear TreeNode after Drag and Drop.
        /// </summary>
        /// <param name="intNewIndex">Node's new index.</param>
        /// <param name="objDestination">Destination Node.</param>
        public void MoveGearNode(int intNewIndex, TreeNode objDestination, TreeView treGear)
        {
            Gear objGear = new Gear(_objCharacter);
            // Locate the currently selected piece of Gear.
            foreach (Gear objCharacterGear in _objCharacter.Gear)
            {
                if (objCharacterGear.InternalId == treGear.SelectedNode.Tag.ToString())
                {
                    objGear = objCharacterGear;
                    break;
                }
            }
            _objCharacter.Gear.Remove(objGear);
            if (intNewIndex > _objCharacter.Gear.Count)
                _objCharacter.Gear.Add(objGear);
            else
                _objCharacter.Gear.Insert(intNewIndex, objGear);

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

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

            // Change the Location on the Gear item.
            if (objNewParent.Text == LanguageManager.Instance.GetString("Node_SelectedGear"))
                objGear.Location = "";
            else
                objGear.Location = objNewParent.Text;

            TreeNode objClone = treGear.SelectedNode;

            objOldParent.Nodes.Remove(treGear.SelectedNode);
            objNewParent.Nodes.Insert(intNewIndex, objClone);
            objNewParent.Expand();
        }
Example #28
0
        private void chkWeaponAccessoryInstalled_CheckedChanged(object sender, EventArgs e)
        {
            bool blnAccessory = false;

            // Locate the selected Weapon Accessory or Modification.
            WeaponAccessory objAccessory = _objFunctions.FindWeaponAccessory(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons);
            if (objAccessory != null)
                blnAccessory = true;

            if (blnAccessory)
            {
                objAccessory.Installed = chkWeaponAccessoryInstalled.Checked;
            }
            else
            {
                    // Determine if this is an Underbarrel Weapon.
                    bool blnUnderbarrel = false;
                    Weapon objWeapon = _objFunctions.FindWeapon(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons);
                    if (objWeapon != null)
                    {
                        objWeapon.Installed = chkWeaponAccessoryInstalled.Checked;
                        blnUnderbarrel = true;
                    }

                    if (!blnUnderbarrel)
                    {
                        // Find the selected Gear.
                        Gear objSelectedGear = new Gear(_objCharacter);

                        try
                        {
                            objSelectedGear = _objFunctions.FindWeaponGear(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons, out objAccessory);
                            objSelectedGear.Equipped = chkWeaponAccessoryInstalled.Checked;

                            _objController.ChangeGearEquippedStatus(objSelectedGear, chkWeaponAccessoryInstalled.Checked);

                            UpdateCharacterInfo();
                        }
                        catch
                        {
                        }
                    }
            }

            _blnIsDirty = true;
            UpdateWindowTitle();
        }
Example #29
0
 /// <summary>
 /// Load the Stacked Focus from the XmlNode.
 /// </summary>
 /// <param name="objNode">XmlNode to load.</param>
 public void Load(XmlNode objNode)
 {
     _guiID = Guid.Parse(objNode["guid"].InnerText);
     _guiGearId = Guid.Parse(objNode["gearid"].InnerText);
     _blnBonded = Convert.ToBoolean(objNode["bonded"].InnerText);
     XmlNodeList nodGears = objNode.SelectNodes("gears/gear");
     foreach (XmlNode nodGear in nodGears)
     {
         Gear objGear = new Gear(_objCharacter);
         objGear.Load(nodGear);
         _lstGear.Add(objGear);
     }
 }
Example #30
0
        private void cmdCreateStackedFocus_Click(object sender, EventArgs e)
        {
            int intFree = 0;
            List<Gear> lstGear = new List<Gear>();
            List<Gear> lstStack = new List<Gear>();

            // Run through all of the Foci the character has and count the un-Bonded ones.
            foreach (Gear objGear in _objCharacter.Gear)
            {
                if (objGear.Category == "Foci" || objGear.Category == "Metamagic Foci")
                {
                    if (!objGear.Bonded)
                    {
                        intFree++;
                        lstGear.Add(objGear);
                    }
                }
            }

            // If the character does not have at least 2 un-Bonded Foci, display an error and leave.
            if (intFree < 2)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotStackFoci"), LanguageManager.Instance.GetString("MessageTitle_CannotStackFoci"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            frmSelectItem frmPickItem = new frmSelectItem();

            // Let the character select the Foci they'd like to stack, stopping when they either click Cancel or there are no more items left in the list.
            do
            {
                frmPickItem.Gear = lstGear;
                frmPickItem.AllowAutoSelect = false;
                frmPickItem.Description = LanguageManager.Instance.GetString("String_SelectItemFocus");
                frmPickItem.ShowDialog(this);

                if (frmPickItem.DialogResult == DialogResult.OK)
                {
                    // Move the item from the Gear list to the Stack list.
                    foreach (Gear objGear in lstGear)
                    {
                        if (objGear.InternalId == frmPickItem.SelectedItem)
                        {
                            objGear.Bonded = true;
                            lstStack.Add(objGear);
                            lstGear.Remove(objGear);
                            break;
                        }
                    }
                }
            } while (lstGear.Count > 0 && frmPickItem.DialogResult != DialogResult.Cancel);

            // Make sure at least 2 Foci were selected.
            if (lstStack.Count < 2)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_StackedFocusMinimum"), LanguageManager.Instance.GetString("MessageTitle_CannotStackFoci"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // Make sure the combined Force of the Foci do not exceed 6.
            if (!_objOptions.AllowHigherStackedFoci)
            {
                int intCombined = 0;
                foreach (Gear objGear in lstStack)
                    intCombined += objGear.Rating;
                if (intCombined > 6)
                {
                    foreach (Gear objGear in lstStack)
                        objGear.Bonded = false;
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_StackedFocusForce"), LanguageManager.Instance.GetString("MessageTitle_CannotStackFoci"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            // Create the Stacked Focus.
            StackedFocus objStack = new StackedFocus(_objCharacter);
            objStack.Gear = lstStack;
            _objCharacter.StackedFoci.Add(objStack);

            // Remove the Gear from the character and replace it with a Stacked Focus item.
            int intCost = 0;
            foreach (Gear objGear in lstStack)
            {
                intCost += objGear.TotalCost;
                _objCharacter.Gear.Remove(objGear);

                // Remove the TreeNode from Gear.
                foreach (TreeNode nodRoot in treGear.Nodes)
                {
                    foreach (TreeNode nodItem in nodRoot.Nodes)
                    {
                        if (nodItem.Tag.ToString() == objGear.InternalId)
                        {
                            nodRoot.Nodes.Remove(nodItem);
                            break;
                        }
                    }
                }
            }

            Gear objStackItem = new Gear(_objCharacter);
            objStackItem.Category = "Stacked Focus";
            objStackItem.Name = "Stacked Focus: " + objStack.Name;
            objStackItem.MinRating = 0;
            objStackItem.MaxRating = 0;
            objStackItem.Source = "SM";
            objStackItem.Page = "84";
            objStackItem.Cost = intCost.ToString();
            objStackItem.Avail = "0";

            TreeNode nodStackNode = new TreeNode();
            nodStackNode.Text = objStackItem.DisplayNameShort;
            nodStackNode.Tag = objStackItem.InternalId;

            treGear.Nodes[0].Nodes.Add(nodStackNode);

            _objCharacter.Gear.Add(objStackItem);

            objStack.GearId = objStackItem.InternalId;

            _blnIsDirty = true;
            _objController.PopulateFocusList(treFoci);
            UpdateCharacterInfo();
            UpdateWindowTitle();
        }