Beispiel #1
0
        private void cmdAddManeuver_Click(object sender, EventArgs e)
        {
            // Characters may only have 2 Maneuvers per Martial Art Rating.
            int intTotalRating = 0;
            foreach (MartialArt objMartialArt in _objCharacter.MartialArts)
                intTotalRating += objMartialArt.Rating * 2;

            if (treMartialArts.Nodes[1].Nodes.Count >= intTotalRating && !_objCharacter.IgnoreRules)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_MartialArtManeuverLimit"), LanguageManager.Instance.GetString("MessageTitle_MartialArtManeuverLimit"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            frmSelectMartialArtManeuver frmPickMartialArtManeuver = new frmSelectMartialArtManeuver(_objCharacter);
            frmPickMartialArtManeuver.ShowDialog(this);

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

            // Open the Martial Arts XML file and locate the selected piece.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("martialarts.xml");

            XmlNode objXmlManeuver = objXmlDocument.SelectSingleNode("/chummer/maneuvers/maneuver[name = \"" + frmPickMartialArtManeuver.SelectedManeuver + "\"]");

            TreeNode objNode = new TreeNode();
            MartialArtManeuver objManeuver = new MartialArtManeuver(_objCharacter);
            objManeuver.Create(objXmlManeuver, objNode);
            _objCharacter.MartialArtManeuvers.Add(objManeuver);

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

            treMartialArts.SelectedNode = objNode;

            CalculateBP();
            treMartialArts.SortCustom();
            UpdateCharacterInfo();

            _blnIsDirty = true;
            UpdateWindowTitle();
        }
Beispiel #2
0
        private void cmdAddManeuver_Click(object sender, EventArgs e)
        {
            // Characters may only have 2 Maneuvers per Martial Art Rating.
            int intTotalRating = 0;
            foreach (MartialArt objMartialArt in _objCharacter.MartialArts)
                intTotalRating += objMartialArt.Rating * 2;

            if (treMartialArts.Nodes[1].Nodes.Count >= intTotalRating)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_MartialArtManeuverLimit"), LanguageManager.Instance.GetString("MessageTitle_MartialArtManeuverLimit"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // Make sure the character has enough Karma.
            int intKarmaCost = _objOptions.KarmaManeuver;

            if (intKarmaCost > _objCharacter.Karma)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughKarma"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughKarma"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            frmSelectMartialArtManeuver frmPickMartialArtManeuver = new frmSelectMartialArtManeuver(_objCharacter);
            frmPickMartialArtManeuver.ShowDialog(this);

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

            // Open the Martial Arts XML file and locate the selected piece.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("martialarts.xml");

            XmlNode objXmlManeuver = objXmlDocument.SelectSingleNode("/chummer/maneuvers/maneuver[name = \"" + frmPickMartialArtManeuver.SelectedManeuver + "\"]");

            TreeNode objNode = new TreeNode();
            MartialArtManeuver objManeuver = new MartialArtManeuver(_objCharacter);
            objManeuver.Create(objXmlManeuver, objNode);
            objNode.ContextMenuStrip = cmsMartialArtManeuver;
            _objCharacter.MartialArtManeuvers.Add(objManeuver);

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

            treMartialArts.SelectedNode = objNode;

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

            ExpenseUndo objUndo = new ExpenseUndo();
            objUndo.CreateKarma(KarmaExpenseType.AddMartialArtManeuver, objManeuver.InternalId);
            objExpense.Undo = objUndo;

            _objFunctions.SortTree(treMartialArts);
            UpdateCharacterInfo();

            _blnIsDirty = true;
            UpdateWindowTitle();
        }