Esempio n. 1
0
 /// <summary>
 /// Checks whether those prerequisites contains the provided skill, returning the need level
 /// </summary>
 /// <param name="src"></param>
 /// <param name="skill"></param>
 /// <param name="neededLevel"></param>
 /// <returns></returns>
 public static bool Contains(this IEnumerable<SkillLevel> src, Skill skill, out Int64 neededLevel)
 {
     neededLevel = 0;
     foreach (SkillLevel prereq in src.Where(prereq => prereq.Skill == skill))
     {
         neededLevel = prereq.Level;
         return true;
     }
     return false;
 }
Esempio n. 2
0
        /// <summary>
        /// Updates a regular "Plan to X" menu : text, tag, enable/disable.
        /// </summary>
        /// <param name="plan">The plan.</param>
        /// <param name="menu">The menu.</param>
        /// <param name="skill">The skill.</param>
        /// <param name="level">The level.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">menu
        /// or
        /// plan</exception>
        public static bool UpdatesRegularPlanToMenu(this Plan plan, ToolStripItem menu, Skill skill, int level)
        {
            menu.ThrowIfNull(nameof(menu));

            plan.ThrowIfNull(nameof(plan));

            menu.Text = level == 0 ? "Remove" : $"Level {level}";

            menu.Enabled = plan.EnablePlanTo(skill, level);
            if (menu.Enabled)
            {
                IPlanOperation operation = plan.TryPlanTo(skill, level);
                menu.Tag = operation;
                if (RequiresWindow(operation))
                    menu.Text += @"...";
            }

            ToolStripMenuItem menuItem = menu as ToolStripMenuItem;
            if (menuItem != null)
                menuItem.Checked = plan.GetPlannedLevel(skill) == level;

            return menu.Enabled;
        }
Esempio n. 3
0
 /// <summary>
 /// Constructor from the skill object.
 /// </summary>
 /// <param name="skill"></param>
 /// <param name="level"></param>
 public SkillLevel(Skill skill, Int64 level)
 {
     Skill = skill;
     Level = level;
 }
Esempio n. 4
0
 /// <summary>
 /// Completes the initialization once all the character's skills have been initialized
 /// </summary>
 /// <param name="skills">The array of the character's skills.</param>
 public void CompleteInitialization(Skill[] skills)
 {
     m_prereqs.AddRange(StaticData.Prerequisites
         .Select(staticSkillLevel =>
             new SkillLevel(skills[staticSkillLevel.Skill.ArrayIndex], staticSkillLevel.Level)));
 }
Esempio n. 5
0
 /// <summary>
 /// Gets the levels of the given skill.
 /// </summary>
 /// <param name="skill"></param>
 /// <returns></returns>
 public IEnumerable <T> GetLevelsOf(Skill skill) => GetLevelsOf(skill.ArrayIndex);
Esempio n. 6
0
 /// <summary>
 /// Gets a string representation of this skill.
 /// </summary>
 /// <returns></returns>
 public override string ToString() => $"{SkillName} {Skill.GetRomanFromInt(Level)}";
Esempio n. 7
0
        /// <summary>
        /// Gets the skill properties of a merged skill with a plan entry, if one is provided.
        /// If no plan is provided, the skill properties are returned unmodified.
        /// </summary>
        /// <param name="plan"></param>
        /// <param name="skill"></param>
        /// <returns>The skill properties after the merge</returns>
        private static SerializableCharacterSkill GetMergedSkill(Plan plan, Skill skill)
        {
            SerializableCharacterSkill mergedSkill = new SerializableCharacterSkill
            {
                ID = skill.ID,
                Name = skill.Name,
                IsKnown = skill.IsKnown,
                OwnsBook = skill.IsOwned,
                Level = skill.Level,
                Skillpoints = skill.SkillPoints
            };

            plan?.Merge(mergedSkill);

            return mergedSkill;
        }
Esempio n. 8
0
        /// <summary>
        /// Adds the skills.
        /// </summary>
        /// <param name="character">The character.</param>
        /// <param name="plan">The plan.</param>
        /// <param name="builder">The builder.</param>
        /// <param name="skill">The skill.</param>
        private static void AddSkills(Character character, Plan plan, StringBuilder builder, Skill skill)
        {
            SerializableCharacterSkill mergedSkill = GetMergedSkill(plan, skill);

            string skillPointsText = FormattableString.Invariant($"{mergedSkill.Skillpoints:N0}");
            string pointToLevelFiveText = FormattableString.Invariant($"{skill.StaticData.GetPointsRequiredForLevel(5):N0}");
            string skillDesc = $"{skill} ({skill.Rank})";
            builder.AppendLine($"  {skillDesc.PadRight(45)} " +
                               $"L{mergedSkill.Level} ".PadLeft(5) +
                               $"{skillPointsText}/{pointToLevelFiveText} Points");

            // If the skill is in training...
            if (!skill.IsTraining)
                return;

            string levelText = Skill.GetRomanFromInt(character.CurrentlyTrainingSkill.Level);
            string adjustedEndTimeText = character.CurrentlyTrainingSkill.EndTime.DateTimeToTimeString();
            builder.AppendLine($":  (Currently training to level {levelText}, completes {adjustedEndTimeText} UTC)");
        }
Esempio n. 9
0
        /// <summary>
        /// Adds the skill.
        /// </summary>
        /// <param name="plan">The plan.</param>
        /// <param name="outGroup">The out group.</param>
        /// <param name="skill">The skill.</param>
        private static void AddSkill(Plan plan, OutputSkillGroup outGroup, Skill skill)
        {
            SerializableCharacterSkill mergedSkill = GetMergedSkill(plan, skill);

            outGroup.Skills.Add(new OutputSkill
            {
                Name = mergedSkill.Name,
                Rank = skill.Rank,
                Level = mergedSkill.Level,
                SkillPoints = FormattableString.Invariant($"{mergedSkill.Skillpoints:N0}"),
                RomanLevel = Skill.GetRomanFromInt(mergedSkill.Level),
                MaxSkillPoints = FormattableString.Invariant($"{skill.StaticData.GetPointsRequiredForLevel(5):N0}")
            });
        }
Esempio n. 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SkillClickedEventArgs"/> class.
 /// </summary>
 /// <param name="skill">The skill.</param>
 /// <param name="button">The button.</param>
 /// <param name="location">The location.</param>
 public SkillClickedEventArgs(Skill skill, MouseButtons button, Point location)
 {
     Skill = skill;
     Button = button;
     Location = location;
 }