Ejemplo n.º 1
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            if (!ApplyAll)
            {
                if (MasterController.Settings.SkillStamps.Count == 1)
                {
                    if (!AcceptCancelDialog.Show(Common.Localize("SkillStamp:Prompt", me.IsFemale, new object[] { me })))
                    {
                        return false;
                    }

                    mChoice = MasterController.Settings.SkillStamps[0];
                }
                else
                {
                    List<Item> allOptions = new List<Item>();
                    foreach (SkillStamp stamp in MasterController.Settings.SkillStamps)
                    {
                        allOptions.Add(new ApplySkillStamp.Item(stamp));
                    }

                    Item choice = new CommonSelection<ApplySkillStamp.Item>(Name, allOptions).SelectSingle();
                    if (choice == null) return false;

                    mChoice = choice.mStamp;
                }
            }

            foreach (KeyValuePair<SkillNames, int> skill in mChoice.Skills)
            {
                if (me.SkillManager.GetSkillLevel(skill.Key) > skill.Value)
                {
                    continue;
                }

                Skill mySkill = me.SkillManager.GetElement(skill.Key);
                if ((mySkill == null) && (skill.Value >= 0))
                {
                    mySkill = me.SkillManager.AddElement(skill.Key);
                }

                if (mySkill != null)
                {
                    try
                    {
                        mySkill.ForceSkillLevelUp(skill.Value);
                    }
                    catch (Exception e)
                    {
                        Common.Exception(me, null, "Skill: " + skill.Key, e);
                    }
                }
            }

            return true;
        }
Ejemplo n.º 2
0
        public static List<SkillStamp> Create(List<string> values)
        {
            List<SkillStamp> result = new List<SkillStamp>();

            SkillStamp stamp = null;
            foreach (string value in values)
            {
                string[] split = value.Split(':');

                if (split.Length == 1)
                {
                    stamp = new SkillStamp(split[0]);
                    result.Add(stamp);
                }
                else if (split.Length == 2)
                {
                    if (stamp == null)
                    {
                        stamp = new SkillStamp(Common.Localize("SkillStamp:MenuName"));
                        result.Add(stamp);
                    }

                    SkillNames skill = SkillManager.sSkillEnumValues.ParseEnumValue(split[0]);
                    if (skill == SkillNames.None) continue;

                    int level;
                    if (!int.TryParse(split[1], out level)) continue;

                    if (!stamp.mSkills.ContainsKey(skill))
                    {
                        stamp.mSkills.Add(skill, level);
                    }
                }
            }

            return result;
        }
Ejemplo n.º 3
0
 public Item(SkillStamp stamp)
     : base(stamp.Name)
 {
     mStamp = stamp;
 }