Ejemplo n.º 1
0
        /// <summary>
        /// Build the list of Skill Groups.
        /// </summary>
        private void BuildSkillGroupList()
        {
            XmlDocument objXmlDocument = XmlManager.Instance.Load("skills.xml");

            // Populate the Skill Group list.
            XmlNodeList objXmlGroupList = objXmlDocument.SelectNodes("/chummer/skillgroups/name");

            // First pass, build up a list of all of the Skill Groups so we can sort them in alphabetical order for the current language.
            List<ListItem> lstSkillOrder = new List<ListItem>();
            foreach (XmlNode objXmlGroup in objXmlGroupList)
            {
                ListItem objGroup = new ListItem();
                objGroup.Value = objXmlGroup.InnerText;
                if (objXmlGroup.Attributes["translate"] != null)
                    objGroup.Name = objXmlGroup.Attributes["translate"].InnerText;
                else
                    objGroup.Name = objXmlGroup.InnerText;
                lstSkillOrder.Add(objGroup);
            }
            SortListItem objSort = new SortListItem();
            lstSkillOrder.Sort(objSort.Compare);

            // Second pass, retrieve the Skill Groups in the order they're presented in the list.
            foreach (ListItem objItem in lstSkillOrder)
            {
                XmlNode objXmlGroup = objXmlDocument.SelectSingleNode("/chummer/skillgroups/name[. = \"" + objItem.Value + "\"]");
                SkillGroup objGroup = new SkillGroup();
                objGroup.Name = objXmlGroup.InnerText;
                // Maximum Skill Group Rating
                objGroup.RatingMaximum = 6;
                _lstSkillGroups.Add(objGroup);
            }
        }
Ejemplo n.º 2
0
        private void objSkill_BreakGroupClicked(Object sender)
        {
            SkillControl objSkillControl = (SkillControl)sender;

            SkillGroup objSkillGroup = new SkillGroup();
            foreach (SkillGroupControl objSkillGroupControl in panSkillGroups.Controls)
            {
                if (objSkillGroupControl.GroupName == objSkillControl.SkillGroup)
                {
                    objSkillGroup = objSkillGroupControl.SkillGroupObject;
                    break;
                }
            }

            // Verify that the user wants to break the Skill Group.
            if (MessageBox.Show(LanguageManager.Instance.GetString("Message_BreakSkillGroup").Replace("{0}", objSkillGroup.DisplayName), LanguageManager.Instance.GetString("MessageTitle_BreakSkillGroup"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                return;
            else
            {
                string strSkillGroup = objSkillControl.SkillGroup;
                int intRating = 0;

                // Break the Skill Group itself.
                foreach (SkillGroupControl objSkillGroupControl in panSkillGroups.Controls)
                {
                    if (objSkillGroupControl.GroupName == strSkillGroup)
                    {
                        intRating = objSkillGroupControl.GroupRating;
                        objSkillGroupControl.Broken = true;
                        break;
                    }
                }

                // Remove all of the Active Skills from the Skill Group being broken.
                string strGroup = objSkillControl.SkillGroup;
                foreach (SkillControl objActiveSkill in panActiveSkills.Controls)
                {
                    if (objActiveSkill.SkillGroup == strGroup)
                    {
                        objActiveSkill.IsGrouped = false;
                        objActiveSkill.SkillRating = intRating;
                        objActiveSkill.SkillObject.FreeLevels = intRating;
                        if (objSkillGroup.FreeLevels > 0)
                            objActiveSkill.SkillObject.FreeLevels = intRating;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void objSkill_KarmaClicked(Object sender)
        {
            SkillControl objSkillControl = (SkillControl)sender;

            // Make sure the character has enough Karma to improve the Skill Group.
            int intKarmaCost = 0;
            if (objSkillControl.SkillRating == 0)
                intKarmaCost = _objOptions.KarmaNewActiveSkill;
            else
            {
                intKarmaCost = (objSkillControl.SkillRating + 1) * _objOptions.KarmaImproveActiveSkill;
            }

            // If the character is Uneducated and the Skill is a Technical Active Skill, Uncouth and a Social Active Skill or Infirm and a Physical Active Skill, double its cost.
            if ((_objCharacter.Uneducated && objSkillControl.SkillCategory == "Technical Active") ||
                (_objCharacter.Uncouth && objSkillControl.SkillCategory == "Social Active") ||
                (_objCharacter.Infirm && objSkillControl.SkillCategory == "Physical Active"))
            {
                intKarmaCost *= 2;
                }

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

            if (!ConfirmKarmaExpense(LanguageManager.Instance.GetString("Message_ConfirmKarmaExpense").Replace("{0}", objSkillControl.SkillObject.DisplayName).Replace("{1}", (objSkillControl.SkillRating + 1).ToString()).Replace("{2}", intKarmaCost.ToString())))
                return;

            SkillGroup objSkillGroup = new SkillGroup();
            foreach (SkillGroupControl objSkillGroupControl in panSkillGroups.Controls)
            {
                if (objSkillGroupControl.GroupName == objSkillControl.SkillGroup)
                {
                    objSkillGroup = objSkillGroupControl.SkillGroupObject;
                    break;
                }
            }

            // If the Skill is Grouped, verify that the user wants to break the Group.
            if (objSkillControl.IsGrouped)
            {
                if (MessageBox.Show(LanguageManager.Instance.GetString("Message_BreakSkillGroup").Replace("{0}", objSkillGroup.DisplayName), LanguageManager.Instance.GetString("MessageTitle_BreakSkillGroup"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    return;
                else
                {
                    string strSkillGroup = objSkillControl.SkillGroup;
                    int intRating = 0;

                    // Break the Skill Group itself.
                    foreach (SkillGroupControl objSkillGroupControl in panSkillGroups.Controls)
                    {
                        if (objSkillGroupControl.GroupName == strSkillGroup)
                        {
                            intRating = objSkillGroupControl.GroupRating;
                            objSkillGroupControl.Broken = true;
                            break;
                        }
                    }

                    // Remove all of the Active Skills from the Skill Group being broken.
                    string strGroup = objSkillControl.SkillGroup;
                    foreach (SkillControl objActiveSkilll in panActiveSkills.Controls)
                    {
                        if (objActiveSkilll.IsGrouped && objActiveSkilll.SkillGroup == strGroup)
                        {
                            objActiveSkilll.SkillRating = intRating;
                            objActiveSkilll.IsGrouped = false;
                        }
                    }
                }
            }
            else
            {
                // If the Skill is not Grouped, the Group should still be broken since a Skill from it has been advanced on its own.
                if (objSkillControl.SkillGroup != "")
                {
                    // Break the Skill Group.
                    foreach (SkillGroupControl objSkillGroupControl in panSkillGroups.Controls)
                    {
                        if (objSkillGroupControl.GroupName == objSkillControl.SkillGroup)
                        {
                            objSkillGroupControl.Broken = true;
                            break;
                        }
                    }
                }
            }

            // Create the Karma Expense.
            ExpenseLogEntry objExpense = new ExpenseLogEntry();
            objExpense.Create(intKarmaCost * -1, LanguageManager.Instance.GetString("String_ExpenseActiveSkill") + " " + objSkillControl.SkillObject.DisplayName + " " + objSkillControl.SkillRating.ToString() + " -> " + (objSkillControl.SkillRating + 1).ToString(), ExpenseType.Karma, DateTime.Now);
            _objCharacter.ExpenseEntries.Add(objExpense);

            ExpenseUndo objUndo = new ExpenseUndo();
            string strSkill = objSkillControl.SkillName;
            if (objSkillControl.SkillName.Contains("Exotic"))
                strSkill += " (" + objSkillControl.SkillSpec + ")";
            objUndo.CreateKarma(KarmaExpenseType.ImproveSkill, strSkill);
            objExpense.Undo = objUndo;

            _objCharacter.Karma -= intKarmaCost;

            objSkillControl.SkillRating += 1;

            UpdateCharacterInfo();

            _blnIsDirty = true;
            UpdateWindowTitle();
        }