Ejemplo n.º 1
0
        private void cmdAddComplexForm_Click(object sender, EventArgs e)
        {
            if (_objCharacter.BuildMethod == CharacterBuildMethod.Priority || _objCharacter.BuildMethod == CharacterBuildMethod.SumtoTen)
            {
                // The number of Complex Form Points cannot exceed the priority limit.
                int intCFP = 0;
                foreach (ComplexForm tp in _objCharacter.ComplexForms)
                {
                    intCFP++;
                }
            }
            else
            {
                // The number of Complex Forms cannot exceed twice the character's LOG.
                if (_objCharacter.ComplexForms.Count >= ((_objCharacter.LOG.Value * 2) + _objImprovementManager.ValueOf(Improvement.ImprovementType.ComplexFormLimit)) && !_objCharacter.IgnoreRules)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_ComplexFormLimit"), LanguageManager.Instance.GetString("MessageTitle_ComplexFormLimit"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            // Let the user select a Program.
            frmSelectProgram frmPickProgram = new frmSelectProgram(_objCharacter);
            frmPickProgram.ShowDialog(this);

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

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

            XmlNode objXmlProgram = objXmlDocument.SelectSingleNode("/chummer/complexforms/complexform[name = \"" + frmPickProgram.SelectedProgram + "\"]");

            // Check for SelectText.
            string strExtra = "";
            if (objXmlProgram["bonus"] != null)
            {
                if (objXmlProgram["bonus"]["selecttext"] != null)
                {
                    frmSelectText frmPickText = new frmSelectText();
                    frmPickText.Description = LanguageManager.Instance.GetString("String_Improvement_SelectText").Replace("{0}", frmPickProgram.SelectedProgram);
                    frmPickText.ShowDialog(this);
                    strExtra = frmPickText.SelectedValue;
                }
            }

            TreeNode objNode = new TreeNode();
            ComplexForm objProgram = new ComplexForm(_objCharacter);
            objProgram.Create(objXmlProgram, _objCharacter, objNode, strExtra);
            if (objProgram.InternalId == Guid.Empty.ToString())
                return;

            _objCharacter.ComplexForms.Add(objProgram);

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

            _blnIsDirty = true;
            UpdateWindowTitle();

            int intComplexForms = 0;
            foreach (ComplexForm tp in _objCharacter.ComplexForms)
            {
                intComplexForms++;
            }

            //if (_objCharacter.CFPLimit - intComplexForms < 0)
            //    lblPBuildComplexForms.Text = String.Format("{0} " + LanguageManager.Instance.GetString("String_Of") + " {1}", (0).ToString(), _objCharacter.CFPLimit.ToString());
            //else
            lblPBuildComplexForms.Text = String.Format("{0} " + LanguageManager.Instance.GetString("String_Of") + " {1}", (_objCharacter.CFPLimit - intComplexForms).ToString(), _objCharacter.CFPLimit.ToString());

            if (frmPickProgram.AddAgain)
                cmdAddComplexForm_Click(sender, e);
        }
Ejemplo n.º 2
0
        private void cmdAddComplexForm_Click(object sender, EventArgs e)
        {
            // The number of Complex Forms cannot exceed the character's LOG.
            if (_objCharacter.ComplexForms.Count >= ((_objCharacter.RES.Value * 2) + _objImprovementManager.ValueOf(Improvement.ImprovementType.ComplexFormLimit)))
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_ComplexFormLimitCareer"), LanguageManager.Instance.GetString("MessageTitle_ComplexFormLimit"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            // Let the user select a Program.
            frmSelectProgram frmPickProgram = new frmSelectProgram(_objCharacter);
            frmPickProgram.ShowDialog(this);

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

            int intKarmaCost = _objOptions.KarmaNewComplexForm;

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

            XmlNode objXmlProgram = objXmlDocument.SelectSingleNode("/chummer/complexforms/complexform[name = \"" + frmPickProgram.SelectedProgram + "\"]");

            // Check for SelectText.
            string strExtra = "";
            if (objXmlProgram["bonus"] != null)
            {
                if (objXmlProgram["bonus"]["selecttext"] != null)
                {
                    frmSelectText frmPickText = new frmSelectText();
                    frmPickText.Description = LanguageManager.Instance.GetString("String_Improvement_SelectText").Replace("{0}", frmPickProgram.SelectedProgram);
                    frmPickText.ShowDialog(this);
                    strExtra = frmPickText.SelectedValue;
                }
            }

            TreeNode objNode = new TreeNode();
            ComplexForm objProgram = new ComplexForm(_objCharacter);
            objProgram.Create(objXmlProgram, _objCharacter, objNode, strExtra);
            if (objProgram.InternalId == Guid.Empty.ToString())
                return;

            _objCharacter.ComplexForms.Add(objProgram);

            // If using the optional rule for costing the same as Spells, change the Karma cost.
            if (_objOptions.AlternateComplexFormCost)
                intKarmaCost = _objOptions.KarmaSpell;

            // Make sure the character has enough Karma before letting them select a Complex Form.
            if (_objCharacter.Karma < intKarmaCost)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughKarma"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughKarma"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                // Remove the Improvements created by the Complex Form.
                _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.ComplexForm, objProgram.InternalId);
                return;
            }

            if (!ConfirmKarmaExpense(LanguageManager.Instance.GetString("Message_ConfirmKarmaExpenseSpend").Replace("{0}", objProgram.DisplayNameShort).Replace("{1}", intKarmaCost.ToString())))
            {
                // Remove the Improvements created by the Complex Form.
                _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.ComplexForm, objProgram.InternalId);
                return;
            }

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

            // Create the Expense Log Entry.
            ExpenseLogEntry objExpense = new ExpenseLogEntry();
            objExpense.Create(intKarmaCost * -1, LanguageManager.Instance.GetString("String_ExpenseLearnComplexForm") + " " + objProgram.DisplayNameShort, ExpenseType.Karma, DateTime.Now);
            _objCharacter.ExpenseEntries.Add(objExpense);
            _objCharacter.Karma -= intKarmaCost;

            ExpenseUndo objUndo = new ExpenseUndo();
            objUndo.CreateKarma(KarmaExpenseType.AddComplexForm, objProgram.InternalId);
            objExpense.Undo = objUndo;

            _objFunctions.SortTree(treComplexForms);
            UpdateCharacterInfo();

            _blnIsDirty = true;
            UpdateWindowTitle();

            if (frmPickProgram.AddAgain)
                cmdAddComplexForm_Click(sender, e);
        }
Ejemplo n.º 3
0
        private void cmdAddComplexForm_Click(object sender, EventArgs e)
        {
            // The number of Complex Forms cannot exceed twice the character's LOG.
            if (_objCharacter.TechPrograms.Count >= ((_objCharacter.LOG.Value * 2) + _objImprovementManager.ValueOf(Improvement.ImprovementType.ComplexFormLimit)) && !_objCharacter.IgnoreRules)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_ComplexFormLimit"), LanguageManager.Instance.GetString("MessageTitle_ComplexFormLimit"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // Let the user select a Program.
            frmSelectProgram frmPickProgram = new frmSelectProgram(_objCharacter);
            frmPickProgram.ShowDialog(this);

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

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

            XmlNode objXmlProgram = objXmlDocument.SelectSingleNode("/chummer/programs/program[name = \"" + frmPickProgram.SelectedProgram + "\"]");

            TreeNode objNode = new TreeNode();
            TechProgram objProgram = new TechProgram(_objCharacter);
            objProgram.Create(objXmlProgram, _objCharacter, objNode);
            if (objProgram.InternalId == Guid.Empty.ToString())
                return;

            _objCharacter.TechPrograms.Add(objProgram);

            if (objProgram.CalculatedCapacity > 0)
                objNode.ContextMenuStrip = cmsComplexForm;

            switch (objProgram.Category)
            {
                case "Advanced":
                    treComplexForms.Nodes[0].Nodes.Add(objNode);
                    treComplexForms.Nodes[0].Expand();
                    break;
                case "ARE Programs":
                    treComplexForms.Nodes[1].Nodes.Add(objNode);
                    treComplexForms.Nodes[1].Expand();
                    break;
                case "Autosoft":
                    treComplexForms.Nodes[2].Nodes.Add(objNode);
                    treComplexForms.Nodes[2].Expand();
                    break;
                case "Common Use":
                    treComplexForms.Nodes[3].Nodes.Add(objNode);
                    treComplexForms.Nodes[3].Expand();
                    break;
                case "Hacking":
                    treComplexForms.Nodes[4].Nodes.Add(objNode);
                    treComplexForms.Nodes[4].Expand();
                    break;
                case "Malware":
                    treComplexForms.Nodes[5].Nodes.Add(objNode);
                    treComplexForms.Nodes[5].Expand();
                    break;
                case "Sensor Software":
                    treComplexForms.Nodes[6].Nodes.Add(objNode);
                    treComplexForms.Nodes[6].Expand();
                    break;
                case "Skillsofts":
                    treComplexForms.Nodes[7].Nodes.Add(objNode);
                    treComplexForms.Nodes[7].Expand();
                    break;
                case "Tactical AR Software":
                    treComplexForms.Nodes[8].Nodes.Add(objNode);
                    treComplexForms.Nodes[8].Expand();
                    break;
            }

            _objFunctions.SortTree(treComplexForms);
            UpdateCharacterInfo();

            _blnIsDirty = true;
            UpdateWindowTitle();

            if (frmPickProgram.AddAgain)
                cmdAddComplexForm_Click(sender, e);
        }
Ejemplo n.º 4
0
        private void cmdAddComplexForm_Click(object sender, EventArgs e)
        {
            // Let the user select a Program.
            frmSelectProgram frmPickProgram = new frmSelectProgram(_objCharacter);
            frmPickProgram.ShowDialog(this);

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

            int intKarmaCost = _objOptions.KarmaNewComplexForm;

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

            XmlNode objXmlProgram = objXmlDocument.SelectSingleNode("/chummer/programs/program[name = \"" + frmPickProgram.SelectedProgram + "\"]");

            TreeNode objNode = new TreeNode();
            TechProgram objProgram = new TechProgram(_objCharacter);
            objProgram.Create(objXmlProgram, _objCharacter, objNode);
            if (objProgram.InternalId == Guid.Empty.ToString())
                return;

            _objCharacter.TechPrograms.Add(objProgram);

            // Skillsofts only cost KarmaComplexFormSkillsoft Karma.
            if (objProgram.Category == "Skillsofts")
                intKarmaCost = _objOptions.KarmaComplexFormSkillsoft;

            // If using the optional rule for costing the same as Spells, change the Karma cost.
            if (_objOptions.AlternateComplexFormCost)
                intKarmaCost = _objOptions.KarmaSpell;

            // Make sure the character has enough Karma before letting them select a Complex Form.
            if (_objCharacter.Karma < intKarmaCost)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughKarma"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughKarma"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                // Remove the Improvements created by the Complex Form.
                _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.ComplexForm, objProgram.InternalId);
                return;
            }

            if (!ConfirmKarmaExpense(LanguageManager.Instance.GetString("Message_ConfirmKarmaExpenseSpend").Replace("{0}", objProgram.DisplayNameShort).Replace("{1}", intKarmaCost.ToString())))
            {
                // Remove the Improvements created by the Complex Form.
                _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.ComplexForm, objProgram.InternalId);
                return;
            }

            if (Convert.ToInt32(objProgram.CalculatedCapacity) > 0)
                objNode.ContextMenuStrip = cmsComplexForm;

            switch (objProgram.Category)
            {
                case "Advanced":
                    treComplexForms.Nodes[0].Nodes.Add(objNode);
                    treComplexForms.Nodes[0].Expand();
                    break;
                case "ARE Programs":
                    treComplexForms.Nodes[1].Nodes.Add(objNode);
                    treComplexForms.Nodes[1].Expand();
                    break;
                case "Autosoft":
                    treComplexForms.Nodes[2].Nodes.Add(objNode);
                    treComplexForms.Nodes[2].Expand();
                    break;
                case "Common Use":
                    treComplexForms.Nodes[3].Nodes.Add(objNode);
                    treComplexForms.Nodes[3].Expand();
                    break;
                case "Hacking":
                    treComplexForms.Nodes[4].Nodes.Add(objNode);
                    treComplexForms.Nodes[4].Expand();
                    break;
                case "Malware":
                    treComplexForms.Nodes[5].Nodes.Add(objNode);
                    treComplexForms.Nodes[5].Expand();
                    break;
                case "Sensor Software":
                    treComplexForms.Nodes[6].Nodes.Add(objNode);
                    treComplexForms.Nodes[6].Expand();
                    break;
                case "Skillsofts":
                    treComplexForms.Nodes[7].Nodes.Add(objNode);
                    treComplexForms.Nodes[7].Expand();
                    break;
                case "Tactical AR Software":
                    treComplexForms.Nodes[8].Nodes.Add(objNode);
                    treComplexForms.Nodes[8].Expand();
                    break;
            }

            // Create the Expense Log Entry.
            ExpenseLogEntry objExpense = new ExpenseLogEntry();
            objExpense.Create(intKarmaCost * -1, LanguageManager.Instance.GetString("String_ExpenseLearnComplexForm") + " " + objProgram.DisplayNameShort, ExpenseType.Karma, DateTime.Now);
            _objCharacter.ExpenseEntries.Add(objExpense);
            _objCharacter.Karma -= intKarmaCost;

            ExpenseUndo objUndo = new ExpenseUndo();
            objUndo.CreateKarma(KarmaExpenseType.AddComplexForm, objProgram.InternalId);
            objExpense.Undo = objUndo;

            _objFunctions.SortTree(treComplexForms);
            UpdateCharacterInfo();

            _blnIsDirty = true;
            UpdateWindowTitle();

            if (frmPickProgram.AddAgain)
                cmdAddComplexForm_Click(sender, e);
        }