Exemplo n.º 1
0
        /// <summary>
        /// Gets the minimum width.
        /// </summary>
        /// <returns></returns>
        private int GetMinimumWidth(Graphics g)
        {
            if (m_minWidth != 0)
            {
                return(m_minWidth);
            }

            int longestSkillNameLength = StaticSkills.AllSkills.Max(skill => skill.Name.
                                                                    Length);
            StaticSkill longestSkill = StaticSkills.AllSkills.First(skill => skill.Name.
                                                                    Length == longestSkillNameLength);

            m_minWidth = (int)g.MeasureString($"{longestSkill.Name} {Skill.GetRomanFromInt(3)}",
                                              FontFactory.GetFont("Tahoma", m_regularFontSize)).Width;
            return(m_minWidth);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deserialization constructor.
        /// </summary>
        /// <param name="owner">The owner.</param>
        /// <param name="serial">The serial.</param>
        internal PlanEntry(BasePlan owner, SerializablePlanEntry serial)
        {
            m_owner     = owner;
            m_entryType = serial.Type;
            m_skill     = GetSkill(serial);
            m_level     = serial.Level;
            m_notes     = serial.Notes;
            m_priority  = serial.Priority;

            m_planGroups.AddRange(serial.PlanGroups);

            if (serial.Remapping != null)
            {
                m_remapping = new RemappingPoint(serial.Remapping);
            }
        }
//    private Dictionary<int, int> dict = new Dictionary<int, int>();
    public static StaticSkill Instance()
    {
        if (_instance == null)
        {
            lock (lockHelper)
            {
                if (_instance == null)
                {
                    _instance = new StaticSkill();
//#if UNITY_EDITOR
                    _instance.readData();
//#endif
                }
            }
        }
        return _instance;
    }
Exemplo n.º 4
0
        /// <summary>
        /// Adds the reprocessing skill.
        /// </summary>
        /// <param name="group">The listGroup.</param>
        /// <param name="items">The list of items.</param>
        private void AddReprocessingSkill(ListViewGroup group, ICollection <ListViewItem> items)
        {
            // Create the list of labels
            List <string> labels = new List <string>();

            foreach (Item obj in SelectControl.SelectedObjects)
            {
                // Add a placeholder if no materials
                if (obj.ReprocessingMaterials == null)
                {
                    labels.Add("None");
                    continue;
                }

                string skillName = obj.ReprocessingSkill?.Name ?? EveMonConstants.UnknownText;
                labels.Add(skillName);
            }

            // Create the list view item
            EveProperty  property = StaticProperties.GetPropertyByID(DBConstants.ReprocessingSkillPropertyID);
            ListViewItem item     = new ListViewItem(group);

            if (property != null)
            {
                item.ToolTipText = property.Description;
                item.Text        = property.Name;

                StaticSkill skill = SelectControl.SelectedObjects.Select(obj => obj.ReprocessingSkill).FirstOrDefault();
                if (skill != null && SelectControl.SelectedObjects.All(obj => obj.ReprocessingSkill == skill))
                {
                    item.Tag = Character?.Skills[skill.ID] ?? SkillCollection.Skills.FirstOrDefault(x => x.ID == skill.ID);
                }
                else
                {
                    item.Tag = property.ID;
                }
            }

            items.Add(item);

            // Add the value for every selected item
            AddValueForSelectedObjects(null, item, labels, new Double[] { });
        }
Exemplo n.º 5
0
        /// <summary>
        /// Deserialization constructor
        /// </summary>
        /// <param name="character"></param>
        /// <param name="serial"></param>
        internal PlanEntry(BasePlan owner, SerializablePlanEntry serial)
        {
            m_owner     = owner;
            m_entryType = serial.Type;
            m_skill     = StaticSkills.GetSkillByName(serial.SkillName);
            m_level     = serial.Level;
            m_notes     = serial.Notes;
            m_priority  = serial.Priority;

            foreach (var group in serial.PlanGroups)
            {
                m_planGroups.Add(group);
            }

            if (serial.Remapping != null)
            {
                m_remapping = new RemappingPoint(serial.Remapping);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Computes the number of SP to train
        /// </summary>
        /// <param name="skill"></param>
        /// <param name="level"></param>
        /// <param name="origin"></param>
        /// <returns></returns>
        public int GetSPToTrain(StaticSkill skill, int level, TrainingOrigin origin)
        {
            if (level == 0)
            {
                return(0);
            }
            int sp = skill.GetPointsRequiredForLevel(level);

            // Deals with the origin
            int result;

            switch (origin)
            {
            // Include current SP
            case TrainingOrigin.FromCurrent:
                result = sp - GetSkillPoints(skill);
                break;

            // This level only (previous are known)
            case TrainingOrigin.FromPreviousLevel:
                result = sp - skill.GetPointsRequiredForLevel(level - 1);
                break;

            case TrainingOrigin.FromPreviousLevelOrCurrent:
                result = sp - Math.Max(GetSkillPoints(skill), skill.GetPointsRequiredForLevel(level - 1));
                break;

            // Include nothing
            default:
                result = sp;
                break;
            }

            // Returns result
            if (result < 0)
            {
                return(0);
            }

            return(result);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Set the planned level to the given one, lowering it if it's higher than the targetted one.
        /// When the skill is not planned already, the prerequisites are automatically added.
        /// Note this method won't remove entries other entries depend of.
        /// </summary>
        /// <param name="skill">The skill we want to plan</param>
        /// <param name="level">The level we want to train to</param>
        /// <param name="priority">The priority.</param>
        /// <param name="noteForNewEntries">The reason we want to train this skill</param>
        public void PlanTo(StaticSkill skill, long level, int priority, string noteForNewEntries)
        {
            int plannedLevel = GetPlannedLevel(skill);

            if (level == plannedLevel)
            {
                return;
            }

            using (SuspendingEvents())
            {
                // We may either have to add or remove entries. First, we assume we have to add ones
                if (level > plannedLevel)
                {
                    List <StaticSkillLevel> skillsToAdd = new List <StaticSkillLevel> {
                        new StaticSkillLevel(skill, level)
                    };

                    // None added ? Then return
                    IPlanOperation operation = TryAddSet(skillsToAdd, noteForNewEntries);
                    operation.PerformAddition(priority);
                }
                else
                {
                    level = Math.Max(level, GetMinimumLevel(skill));

                    // If we reach this point, then we have to remove entries
                    for (int i = 5; i > level; i--)
                    {
                        PlanEntry entry = GetEntry(skill, i);
                        if (entry == null)
                        {
                            continue;
                        }

                        RemoveCore(Items.IndexOf(entry));
                    }
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Checks whether a matching entry exists between before the provided <c>insertionIndex</c>.
        /// If the entry exist and is trained, remove it.
        /// If the entry exist later, it is moved to this <c>insertionIndex</c>.
        /// If the entry does not exit, it is inserted at <c>insertionIndex</c>.
        /// </summary>
        /// <param name="skill"></param>
        /// <param name="level"></param>
        /// <param name="insertionIndex"></param>
        /// <param name="newEntriesPriority"></param>
        /// <returns>True if the searched entry existed or is already trained; false if an insertion or a move was required.</returns>
        private bool EnsurePrerequisiteExistBefore(StaticSkill skill, Int64 level, int insertionIndex, int newEntriesPriority)
        {
            int skillIndex = IndexOf(skill, level);

            // Is the level already trained by the character ?
            if (Character.GetSkillLevel(skill) >= level)
            {
                // If the level is planned, remove it
                if (skillIndex != -1)
                {
                    RemoveCore(skillIndex);
                }

                return(true);
            }

            // Is the prerequisite already planned before this very entry ?
            // Then we continue the foreach loop to the next prereq
            if (skillIndex != -1 && skillIndex < insertionIndex)
            {
                return(true);
            }

            // The prerequisite is not planned yet, we insert it just before this very entry
            if (skillIndex == -1)
            {
                PlanEntry newEntry = new PlanEntry(this, skill, level)
                {
                    Type = PlanEntryType.Prerequisite, Priority = newEntriesPriority
                };

                InsertCore(insertionIndex, newEntry);
                return(false);
            }

            // The prerequisite exists but it's located later in the plan
            // So we move it at the insertion index
            MoveCore(skillIndex, insertionIndex);
            return(false);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Gets the minimum level the given skill is required by other entries.
        /// </summary>
        /// <param name="skill"></param>
        /// <returns>The minimum required level, between 0 and 5.</returns>
        public int GetMinimumLevel(StaticSkill skill)
        {
            // Search the minimum level this skill is required by other entries
            int minNeeded = 0;

            foreach (PlanEntry pe in m_items)
            {
                int         required;
                StaticSkill tSkill = pe.Skill;

                if (tSkill.HasAsPrerequisite(skill, out required) && tSkill != skill)
                {
                    // All 5 levels are needed, fail now
                    if (required == 5)
                    {
                        return(5);
                    }
                    minNeeded = Math.Max(minNeeded, required);
                }
            }
            return(minNeeded);
        }
Exemplo n.º 10
0
 /// <summary>
 /// Gets the minimum width.
 /// </summary>
 /// <returns></returns>
 private int GetMinimumWidth(Graphics g)
 {
     if (m_minWidth <= 0)
     {
         // Determine longest skill name
         StaticSkill longestSkill = null;
         int         maxLength    = 0;
         foreach (var skill in StaticSkills.AllSkills)
         {
             int len = skill.Name.Length;
             if (longestSkill == null || len > maxLength)
             {
                 maxLength    = len;
                 longestSkill = skill;
             }
         }
         // Use the actual font on the display
         m_minWidth = (int)Math.Ceiling(g.MeasureString(longestSkill.Name + " " + Skill.
                                                        GetRomanFromInt(3), lblSkillInTraining.Font).Width);
     }
     return(m_minWidth);
 }
Exemplo n.º 11
0
        /// <summary>
        /// Gets the minimum level the given skill is required by other entries.
        /// </summary>
        /// <param name="skill"></param>
        /// <returns>The minimum required level, between 0 and 5.</returns>
        public Int64 GetMinimumLevel(IStaticSkill skill)
        {
            // Search the minimum level this skill is required by other entries
            Int64 minNeeded = 0;

            foreach (PlanEntry pe in Items)
            {
                Int64       required;
                StaticSkill tSkill = pe.Skill;

                if (!tSkill.HasAsPrerequisite(skill, out required) || tSkill == skill)
                {
                    continue;
                }

                // All 5 levels are needed, fail now
                if (required == 5)
                {
                    return(5);
                }
                minNeeded = Math.Max(minNeeded, required);
            }
            return(minNeeded);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Applies the effect of a learning skill
        /// </summary>
        /// <param name="staticSkill"></param>
        /// <param name="level"></param>
        private void ApplyEffects(StaticSkill staticSkill, int level)
        {
            switch (staticSkill.LearningClass)
            {
            case LearningClass.Learning:
                m_learningFactor = 1.0f + 0.02f * level;
                for (int i = 0; i < m_attributes.Length; i++)
                {
                    m_attributes[i].Update(m_learningFactor);
                }
                return;

            case LearningClass.LowerTierAttribute:
                m_attributes[(int)staticSkill.AttributeModified].LowerSkillBonus = level;
                return;

            case LearningClass.UpperTierAttribute:
                m_attributes[(int)staticSkill.AttributeModified].UpperSkillBonus = level;
                return;

            default:
                return;
            }
        }
Exemplo n.º 13
0
        public static SkillViewModel GetSkillViewModel_NotOwned(int skillSourceId)
        {
            ISkillRepository skillRepo = new EFSkillRepository();

            var tempskill = new Skill_VM
            {
                Id = skillSourceId
            };

            var dbstatic   = skillRepo.DbStaticSkills.FirstOrDefault(s => s.Id == skillSourceId);
            var tempstatic = new StaticSkill
            {
                Id                      = dbstatic.Id,
                FriendlyName            = dbstatic.FriendlyName,
                GivesEffectSourceId     = dbstatic.GivesEffectSourceId,
                Description             = dbstatic.Description,
                FormSourceId            = dbstatic.FormSourceId,
                ManaCost                = dbstatic.ManaCost,
                HealthDamageAmount      = dbstatic.HealthDamageAmount,
                TFPointsAmount          = dbstatic.TFPointsAmount,
                DiscoveryMessage        = dbstatic.DiscoveryMessage,
                ExclusiveToFormSourceId = dbstatic.ExclusiveToFormSourceId,
                ExclusiveToItemSourceId = dbstatic.ExclusiveToItemSourceId,
                LearnedAtLocation       = dbstatic.LearnedAtLocation,
                LearnedAtRegion         = dbstatic.LearnedAtRegion,
                IsPlayerLearnable       = dbstatic.IsPlayerLearnable
            };

            var output = new SkillViewModel
            {
                dbSkill     = tempskill,
                StaticSkill = tempstatic,
            };

            return(output);
        }
Exemplo n.º 14
0
 /// <summary>
 /// Set the planned level to the given one, lowering it if it's higher than the targetted one.
 /// When the skill is not planned already, the prerequisites are automatically added.
 /// </summary>
 /// <param name="skill">The skill we want to plan</param>
 /// <param name="level">The level we want to train to</param>
 public void PlanTo(StaticSkill skill, int level)
 {
     PlanTo(skill, level, PlanEntry.DefaultPriority, skill.Name);
 }
Exemplo n.º 15
0
 public abstract long GetSkillPoints(StaticSkill skill);
Exemplo n.º 16
0
 public abstract long GetSkillLevel(StaticSkill skill);
Exemplo n.º 17
0
 /// <summary>
 /// Gets the time span for a specific number of skill points.
 /// </summary>
 /// <param name="points">The points to calculate points.</param>
 /// <param name="skill">The skill to train.</param>
 /// <returns></returns>
 public TimeSpan GetTimeSpanForPoints(StaticSkill skill, long points)
 => GetTrainingTime(points, GetBaseSPPerHour(skill));
Exemplo n.º 18
0
 /// <summary>
 /// Computes the SP per hour for the given skill, without factoring in the newbies bonus.
 /// </summary>
 /// <param name="skill">The skill.</param>
 /// <returns>SP earned per hour.</returns>
 /// <exception cref="System.ArgumentNullException">skill</exception>
 public virtual float GetBaseSPPerHour(StaticSkill skill)
 {
     return(GetOmegaSPPerHour(skill) * EffectiveCharacterStatus.GetTrainingRate());
 }
Exemplo n.º 19
0
 /// <summary>
 /// Computes the training time for the given skill
 /// </summary>
 /// <param name="skill"></param>
 /// <param name="level"></param>
 /// <returns></returns>
 public TimeSpan GetTrainingTime(StaticSkill skill, int level)
 {
     return(GetTrainingTime(skill, level, TrainingOrigin.FromCurrent));
 }
Exemplo n.º 20
0
 /// <summary>
 /// Changes the level of the provided skill, updating the results
 /// </summary>
 /// <param name="skill"></param>
 /// <param name="level"></param>
 public void SetSkillLevel(StaticSkill skill, int level)
 {
     SetSkillLevel(skill, level, LearningOptions.None);
 }
Exemplo n.º 21
0
 /// <summary>
 /// Peforms the given training. Same as <see cref="SetSkillLevel"/> but only applied when the given level is greater than the current one.
 /// </summary>
 /// <param name="skill"></param>
 /// <param name="level"></param>
 public void Train(StaticSkill skill, int level)
 {
     SetSkillLevel(skill, level, LearningOptions.UpgradeOnly);
 }
Exemplo n.º 22
0
 /// <summary>
 /// Gets the time span for a specific number of skill points.
 /// </summary>
 /// <param name="points">The points to calculate points.</param>
 /// <param name="skill">The skill to train.</param>
 /// <returns></returns>
 public TimeSpan GetTimeSpanForPoints(StaticSkill skill, int points)
 {
     return(GetTrainingTime(points, GetBaseSPPerHour(skill)));
 }
Exemplo n.º 23
0
 /// <summary>
 /// Gets the adjusted base skill points per hour
 /// based upon skill, attributes, and account status.
 /// </summary>
 /// <param name="skill">The skill.</param>
 /// <returns>Skill points earned per hour when training this skill</returns>
 public override float GetBaseSPPerHour(StaticSkill skill)
 {
     return(CharacterStatus.TrainingRate * base.GetBaseSPPerHour(skill));
 }
Exemplo n.º 24
0
        /// <summary>
        /// Gets the level of the given skill.
        /// </summary>
        /// <param name="skill"></param>
        /// <returns></returns>
        public override Int64 GetSkillLevel(StaticSkill skill)
        {
            skill.ThrowIfNull(nameof(skill));

            return(Skills[skill.ID].Level);
        }
Exemplo n.º 25
0
 /// <summary>
 /// Gets true if the skill is planned at the given level.
 /// </summary>
 /// <param name="skill">The skill.</param>
 /// <param name="level">The level.</param>
 /// <returns></returns>
 public bool IsPlanned(StaticSkill skill, Int64 level) => GetEntry(skill, level) != null;
Exemplo n.º 26
0
 /// <summary>
 /// Internal constructor, only used for character creation and updates
 /// </summary>
 /// <param name="owner"></param>
 /// <param name="group"></param>
 /// <param name="skill"></param>
 internal Skill(Character owner, SkillGroup group, StaticSkill skill)
 {
     Character  = owner;
     StaticData = skill;
     Group      = group;
 }
Exemplo n.º 27
0
        /// <summary>
        /// Gets the current level of the given skill.
        /// </summary>
        /// <param name="skill"></param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">skill</exception>
        public override long GetSkillPoints(StaticSkill skill)
        {
            skill.ThrowIfNull(nameof(skill));

            return(m_skillSP[skill.ArrayIndex]);
        }
Exemplo n.º 28
0
        /// <summary>
        /// Gets the level of the given skill.
        /// </summary>
        /// <param name="skill">The skill.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">skill</exception>
        public override Int64 GetSkillPoints(StaticSkill skill)
        {
            skill.ThrowIfNull(nameof(skill));

            return(Skills[skill.ID].SkillPoints);
        }
Exemplo n.º 29
0
 /// <summary>
 /// Gets the current level of the given skill.
 /// </summary>
 /// <param name="skill"></param>
 /// <returns></returns>
 public override int GetSkillLevel(StaticSkill skill)
 {
     return(m_skillLevels[skill.ArrayIndex]);
 }
Exemplo n.º 30
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="skill">The skill.</param>
 /// <param name="level">The level.</param>
 public PlanEntry(StaticSkill skill, Int64 level)
     : this(null, skill, level)
 {
 }
Exemplo n.º 31
0
 /// <summary>
 /// Gets the current level of the given skill.
 /// </summary>
 /// <param name="skill"></param>
 /// <returns></returns>
 public override int GetSkillPoints(StaticSkill skill)
 {
     return(m_skillSP[skill.ArrayIndex]);
 }