示例#1
0
        private void tsCreateSpell_Click(object sender, EventArgs e)
        {
            // Count the number of Spells the character currently has and make sure they do not try to select more Spells than they are allowed.
            // The maximum number of Spells a character can start with is 2 x (highest of Spellcasting or Ritual Spellcasting Skill).
            int intSpellCount = 0;
            foreach (TreeNode nodCategory in treSpells.Nodes)
            {
                foreach (TreeNode nodSpell in nodCategory.Nodes)
                {
                    intSpellCount++;
                }
            }

            // Run through the list of Active Skills and pick out the two applicable ones.
            int intSkillValue = 0;
            foreach (SkillControl objSkillControl in panActiveSkills.Controls)
            {
                if ((objSkillControl.SkillName == "Spellcasting" || objSkillControl.SkillName == "Ritual Spellcasting") && objSkillControl.SkillRating > intSkillValue)
                    intSkillValue = objSkillControl.SkillRating;
            }

            if (intSpellCount >= ((2 * intSkillValue) + _objImprovementManager.ValueOf(Improvement.ImprovementType.SpellLimit)) && !_objCharacter.IgnoreRules)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_SpellLimit"), LanguageManager.Instance.GetString("MessageTitle_SpellLimit"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // The character is still allowed to add Spells, so show the Create Spell window.
            frmCreateSpell frmSpell = new frmCreateSpell(_objCharacter);
            frmSpell.ShowDialog(this);

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

            Spell objSpell = frmSpell.SelectedSpell;
            TreeNode objNode = new TreeNode();
            objNode.Text = objSpell.DisplayName;
            objNode.Tag = objSpell.InternalId;
            objNode.ContextMenuStrip = cmsSpell;

            _objCharacter.Spells.Add(objSpell);

            switch (objSpell.Category)
            {
                case "Combat":
                    treSpells.Nodes[0].Nodes.Add(objNode);
                    treSpells.Nodes[0].Expand();
                    break;
                case "Detection":
                    treSpells.Nodes[1].Nodes.Add(objNode);
                    treSpells.Nodes[1].Expand();
                    break;
                case "Health":
                    treSpells.Nodes[2].Nodes.Add(objNode);
                    treSpells.Nodes[2].Expand();
                    break;
                case "Illusion":
                    treSpells.Nodes[3].Nodes.Add(objNode);
                    treSpells.Nodes[3].Expand();
                    break;
                case "Manipulation":
                    treSpells.Nodes[4].Nodes.Add(objNode);
                    treSpells.Nodes[4].Expand();
                    break;
                case "Rituals":
                    int intNode = 5;
                    if (_objCharacter.AdeptEnabled && !_objCharacter.MagicianEnabled)
                        intNode = 0;
                    treSpells.Nodes[intNode].Nodes.Add(objNode);
                    treSpells.Nodes[intNode].Expand();
                    break;
            }

            treSpells.SelectedNode = objNode;

            treSpells.SortCustom();
            UpdateCharacterInfo();

            _blnIsDirty = true;
            UpdateWindowTitle();
        }
示例#2
0
        private void tsCreateSpell_Click(object sender, EventArgs e)
        {
            // Make sure the character has enough Karma before letting them select a Spell.
            if (_objCharacter.Karma < _objOptions.KarmaSpell)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughKarma"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughKarma"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // Run through the list of Active Skills and pick out the two applicable ones.
            int intSkillValue = 0;
            foreach (SkillControl objSkillControl in panActiveSkills.Controls)
            {
                if ((objSkillControl.SkillName == "Spellcasting" || objSkillControl.SkillName == "Ritual Spellcasting") && objSkillControl.SkillRating > intSkillValue)
                    intSkillValue = objSkillControl.SkillRating;
            }

            // The character is still allowed to add Spells, so show the Create Spell window.
            frmCreateSpell frmSpell = new frmCreateSpell(_objCharacter);
            frmSpell.ShowDialog(this);

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

            Spell objSpell = frmSpell.SelectedSpell;
            TreeNode objNode = new TreeNode();
            objNode.Text = objSpell.DisplayName;
            objNode.Tag = objSpell.InternalId;
            objNode.ContextMenuStrip = cmsSpell;

            if (!ConfirmKarmaExpense(LanguageManager.Instance.GetString("Message_ConfirmKarmaExpenseSpend").Replace("{0}", objSpell.DisplayName).Replace("{1}", _objOptions.KarmaSpell.ToString())))
                return;

            _objCharacter.Spells.Add(objSpell);

            switch (objSpell.Category)
            {
                case "Combat":
                    treSpells.Nodes[0].Nodes.Add(objNode);
                    treSpells.Nodes[0].Expand();
                    break;
                case "Detection":
                    treSpells.Nodes[1].Nodes.Add(objNode);
                    treSpells.Nodes[1].Expand();
                    break;
                case "Health":
                    treSpells.Nodes[2].Nodes.Add(objNode);
                    treSpells.Nodes[2].Expand();
                    break;
                case "Illusion":
                    treSpells.Nodes[3].Nodes.Add(objNode);
                    treSpells.Nodes[3].Expand();
                    break;
                case "Manipulation":
                    treSpells.Nodes[4].Nodes.Add(objNode);
                    treSpells.Nodes[4].Expand();
                    break;
                case "Rituals":
                    int intNode = 5;
                    if (_objCharacter.AdeptEnabled && !_objCharacter.MagicianEnabled)
                        intNode = 0;
                    treSpells.Nodes[intNode].Nodes.Add(objNode);
                    treSpells.Nodes[intNode].Expand();
                    break;
            }

            treSpells.SelectedNode = objNode;

            // Create the Expense Log Entry.
            ExpenseLogEntry objEntry = new ExpenseLogEntry();
            objEntry.Create(_objOptions.KarmaSpell * -1, LanguageManager.Instance.GetString("String_ExpenseLearnSpell") + " " + objSpell.Name, ExpenseType.Karma, DateTime.Now);
            _objCharacter.ExpenseEntries.Add(objEntry);
            _objCharacter.Karma -= _objOptions.KarmaSpell;

            ExpenseUndo objUndo = new ExpenseUndo();
            objUndo.CreateKarma(KarmaExpenseType.AddSpell, objSpell.InternalId);
            objEntry.Undo = objUndo;

            _objFunctions.SortTree(treSpells);
            UpdateCharacterInfo();

            _blnIsDirty = true;
            UpdateWindowTitle();
        }