Class Skill


  • public class Skill
    extends java.lang.Object
    A class representing a certain skill level of a unit for some skill type. Since there is no strict mapping of skill points to skill levels, this class allows to specify points and levels independently of each other but also offers convenience functions for converting the values between each other.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int SPECIAL_LEVEL
      DOCUMENT-ME
    • Constructor Summary

      Constructors 
      Constructor Description
      Skill​(SkillType type, int points, int level, int persons, boolean noSkillPoints)
      Creates a new Skill object.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      int getChangeLevel()
      The level of change.
      int getLevel()
      Returns the level of the skill.
      static int getLevel​(int pointsPerPerson, int raceBonus, int terrainBonus, int buildingBonus, boolean isStarving)
      Calculate the skill level from skill points according to the formula getLevelAtPoints(int) including given bonuses.
      int getLevel​(Unit unit, boolean includeBuilding)
      Re-calculate the skill level from the skillPoints including race bonus, terrain bonus and (if includeBuilding==true) building bonus of the given unit.
      static int getLevelAtPoints​(int points)
      Returns the skill level gained at the specified number of skill points according to getPointsAtLevel(int).
      int getModifiedLevel​(Unit unit, boolean includeBuilding)
      Deprecated.
      (stm) This is not used by anyone and I'm not sure if it's correct any more.
      static int getModifier​(SkillType skillType, Race race, RegionType terrain)
      Returns the modifier that the specified race has on the specified skill in the specified terrain.
      static int getModifier​(SkillType skillType, Unit unit)
      Returns the modifier that the specified unit's race has on the specified skill in the terrain the specified unit resides in.
      int getModifier​(Unit unit)
      Returns the modifier that the specified unit's race has on this skill in the terrain the specified unit resides in.
      java.lang.String getName()
      Return the name of this skill (which is the name of its SkillType).
      int getPoints()
      Returns the number of skill points
      static int getPointsAtLevel​(int level)
      Returns the skill points required to reach the specified level.
      int getPointsPerPerson()
      Deprecated.
      This seems to be somewhat obsolete as skill points are not used consequently any more.
      int getRealLevel()
      Return the level of the skill, which may be negative (indicating a lost skill).
      SkillType getSkillType()
      Return the skill type of this skill.
      boolean isLevelChanged()
      Getter for property levelChanged.
      boolean isLostSkill()
      Should return true if this skill was present in the previous round.
      boolean noSkillPoints()
      Indicated whether the skill points value of this Skill object has relevance, i.e. was either read from a report or calculated as there can be reports with only skill levels and no points.
      void setChangeLevel​(int change)
      Set the level of change.
      void setLevel​(int l)
      Sets the level of the skill to l.
      void setLevelChanged​(boolean levelChanged)
      Deprecated.
      void setLostLevel​(int oldLevel)
      Indicates a lost skill
      void setPersons​(int p)
      Deprecated.
      (stm) This information seems to be obsolete.
      void setPoints​(int d)
      Sets the number of skill points.
      java.lang.String toString()
      Get a string representation of this skill.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Skill

        public Skill​(SkillType type,
                     int points,
                     int level,
                     int persons,
                     boolean noSkillPoints)
        Creates a new Skill object.
        Parameters:
        type -
        points -
        level -
        persons -
        noSkillPoints - Indicated whether the skill points value of this Skill object has relevance
    • Method Detail

      • getPointsAtLevel

        public static final int getPointsAtLevel​(int level)
        Returns the skill points required to reach the specified level. They are given by the formula pointsAtLevel(level) = 30 * (((level + 1) * level) / 2).
      • getLevelAtPoints

        public static final int getLevelAtPoints​(int points)
        Returns the skill level gained at the specified number of skill points according to getPointsAtLevel(int).
      • getLevel

        public static final int getLevel​(int pointsPerPerson,
                                         int raceBonus,
                                         int terrainBonus,
                                         int buildingBonus,
                                         boolean isStarving)
        Calculate the skill level from skill points according to the formula getLevelAtPoints(int) including given bonuses.
        Parameters:
        pointsPerPerson -
        raceBonus -
        terrainBonus -
        buildingBonus -
        isStarving -
      • getLevel

        public int getLevel​(Unit unit,
                            boolean includeBuilding)
        Re-calculate the skill level from the skillPoints including race bonus, terrain bonus and (if includeBuilding==true) building bonus of the given unit. This skill is not changed by this method.
        Parameters:
        unit -
        includeBuilding -
        Returns:
        The changed skill level.
      • getModifiedLevel

        @Deprecated
        public int getModifiedLevel​(Unit unit,
                                    boolean includeBuilding)
        Deprecated.
        (stm) This is not used by anyone and I'm not sure if it's correct any more.
        Calculates the skill level for the given modified number of persons in the unit and the skill points of this skill.
      • getModifier

        public static int getModifier​(SkillType skillType,
                                      Race race,
                                      RegionType terrain)
        Returns the modifier that the specified race has on the specified skill in the specified terrain.
        Parameters:
        skillType -
        race -
        terrain -
      • getModifier

        public static int getModifier​(SkillType skillType,
                                      Unit unit)
        Returns the modifier that the specified unit's race has on the specified skill in the terrain the specified unit resides in.
        Parameters:
        skillType -
        unit -
      • getModifier

        public int getModifier​(Unit unit)
        Returns the modifier that the specified unit's race has on this skill in the terrain the specified unit resides in.
        Parameters:
        unit -
      • noSkillPoints

        public boolean noSkillPoints()
        Indicated whether the skill points value of this Skill object has relevance, i.e. was either read from a report or calculated as there can be reports with only skill levels and no points.
      • getSkillType

        public SkillType getSkillType()
        Return the skill type of this skill.
      • getName

        public java.lang.String getName()
        Return the name of this skill (which is the name of its SkillType).
      • setLevel

        public void setLevel​(int l)
        Sets the level of the skill to l. A level < 0 indicates a skill that was present in the last round but is lost now.
        Parameters:
        l -
      • setLostLevel

        public void setLostLevel​(int oldLevel)
        Indicates a lost skill. -getChangeLevel() is the old level.
        Parameters:
        oldLevel -
      • getLevel

        public int getLevel()
        Returns the level of the skill. Returns 0 if level is less than 0.
      • getRealLevel

        public int getRealLevel()
        Return the level of the skill, which may be negative (indicating a lost skill).
      • setPoints

        public void setPoints​(int d)
        Sets the number of skill points.
      • getPoints

        public int getPoints()
        Returns the number of skill points
      • setPersons

        @Deprecated
        public void setPersons​(int p)
        Deprecated.
        (stm) This information seems to be obsolete.
        The number of persons in the unit this skill belongs to.
        Parameters:
        p -
      • getPointsPerPerson

        @Deprecated
        public int getPointsPerPerson()
        Deprecated.
        This seems to be somewhat obsolete as skill points are not used consequently any more.
      • getChangeLevel

        public int getChangeLevel()
        The level of change. Only important in merged reports (?).
      • setChangeLevel

        public void setChangeLevel​(int change)
        Set the level of change. Only important in merged reports (?).
      • toString

        public java.lang.String toString()
        Get a string representation of this skill.
        Overrides:
        toString in class java.lang.Object
      • isLevelChanged

        public boolean isLevelChanged()
        Getter for property levelChanged.
        Returns:
        Value of property levelChanged.
      • setLevelChanged

        @Deprecated
        public void setLevelChanged​(boolean levelChanged)
        Deprecated.
        Setter for property levelChanged.
        Parameters:
        levelChanged - New value of property levelChanged.
      • isLostSkill

        public boolean isLostSkill()
        Should return true if this skill was present in the previous round.