Beispiel #1
0
        private void cmdDelete_Click(object sender, EventArgs e)
        {
            //Cache the parentform prior to deletion, otherwise the relationship is broken.
            Form frmParent = ParentForm;

            if (PowerObject.FreeLevels > 0)
            {
                string strImprovementSourceName = PowerObject.CharacterObject.Improvements.FirstOrDefault(x => x.ImproveType == Improvement.ImprovementType.AdeptPowerFreePoints && x.ImprovedName == PowerObject.Name && x.UniqueName == PowerObject.Extra)?.SourceName;
                Gear   objGear = PowerObject.CharacterObject.Gear.FirstOrDefault(x => x.Bonded && x.InternalId == strImprovementSourceName);
                if (objGear != null)
                {
                    objGear.Equipped = false;
                    objGear.Extra    = string.Empty;
                }
            }
            PowerObject.Deleting = true;
            ImprovementManager.RemoveImprovements(PowerObject.CharacterObject, Improvement.ImprovementSource.Power, PowerObject.InternalId);
            PowerObject.CharacterObject.Powers.Remove(PowerObject);

            if (_objPower.CharacterObject.Created)
            {
                frmCareer parent = frmParent as frmCareer;
                parent.ScheduleCharacterUpdate();
            }
            else
            {
                frmCreate parent = frmParent as frmCreate;
                parent.ScheduleCharacterUpdate();
            }
        }
Beispiel #2
0
        private void btnAddSpec_Click(object sender, EventArgs e)
        {
            frmCareer parrent = ParentForm as frmCareer;

            if (parrent != null)
            {
                string confirmstring = string.Format(LanguageManager.Instance.GetString("Message_ConfirmKarmaExpenseSkillSpecialization"),
                                                     _skill.CharacterObject.Options.KarmaSpecialization);

                if (!parrent.ConfirmKarmaExpense(confirmstring))
                {
                    return;
                }
            }

            frmSelectSpec selectForm = new frmSelectSpec(_skill);

            selectForm.Mode = "Knowledge";
            selectForm.ShowDialog();

            if (selectForm.DialogResult != DialogResult.OK)
            {
                return;
            }

            _skill.AddSpecialization(selectForm.SelectedItem);

            //TODO turn this into a databinding, but i don't care enough right now
            lblSpec.Text = string.Join(", ", _skill.Specializations.Select(x => x.Name));

            parrent?.ScheduleCharacterUpdate();
        }
        private void btnAddSpec_Click(object sender, EventArgs e)
        {
            frmCareer parrent = ParentForm as frmCareer;

            if (parrent != null)
            {
                int price = _skill.CharacterObject.Options.KarmaKnowledgeSpecialization;

                int     intExtraSpecCost      = 0;
                int     intTotalBaseRating    = _skill.TotalBaseRating;
                decimal decSpecCostMultiplier = 1.0m;
                foreach (Improvement objLoopImprovement in _skill.CharacterObject.Improvements)
                {
                    if (objLoopImprovement.Minimum <= intTotalBaseRating &&
                        (string.IsNullOrEmpty(objLoopImprovement.Condition) || (objLoopImprovement.Condition == "career") == _skill.CharacterObject.Created || (objLoopImprovement.Condition == "create") != _skill.CharacterObject.Created) && objLoopImprovement.Enabled)
                    {
                        if (objLoopImprovement.ImprovedName == _skill.SkillCategory)
                        {
                            if (objLoopImprovement.ImproveType == Improvement.ImprovementType.SkillCategorySpecializationKarmaCost)
                            {
                                intExtraSpecCost += objLoopImprovement.Value;
                            }
                            else if (objLoopImprovement.ImproveType == Improvement.ImprovementType.SkillCategorySpecializationKarmaCostMultiplier)
                            {
                                decSpecCostMultiplier *= objLoopImprovement.Value / 100.0m;
                            }
                        }
                    }
                }
                if (decSpecCostMultiplier != 1.0m)
                {
                    price = decimal.ToInt32(decimal.Ceiling(price * decSpecCostMultiplier));
                }
                price += intExtraSpecCost; //Spec

                string confirmstring = string.Format(LanguageManager.GetString("Message_ConfirmKarmaExpenseSkillSpecialization"), price.ToString());

                if (!parrent.ConfirmKarmaExpense(confirmstring))
                {
                    return;
                }
            }

            frmSelectSpec selectForm = new frmSelectSpec(_skill);

            selectForm.Mode = "Knowledge";
            selectForm.ShowDialog();

            if (selectForm.DialogResult != DialogResult.OK)
            {
                return;
            }

            _skill.AddSpecialization(selectForm.SelectedItem);

            //TODO turn this into a databinding, but i don't care enough right now
            lblSpec.Text = string.Join(", ", _skill.Specializations.Select(x => x.Name));

            parrent?.ScheduleCharacterUpdate();
        }