Esempio n. 1
0
  /**
   * This function tries to match the name given as parameter to one of the skills.
   *
   * @param name the name of the skill
   * @return the matched skill
   */
  public Skill getSkill(final String name) {
    final String cleanName = name.trim().toLowerCase();

    for (final Skill skill : skillMap.values()) {
      if (cleanName.equalsIgnoreCase(skill.getName())
          || cleanName.equalsIgnoreCase(skill.getNameGerman())
          || cleanName.equalsIgnoreCase(skill.getNameEnglish())) {
        return skill;
      }
    }

    if ("lumberjacking".equalsIgnoreCase(cleanName)) {
      return getSkill("woodcutting");
    }

    if ("peasantry".equalsIgnoreCase(cleanName)) {
      return getSkill("farming");
    }

    if ((cleanName.contains("baking") || cleanName.contains("cooking"))
        && !"cookingAndBaking".equalsIgnoreCase(cleanName)) {
      return getSkill("cookingAndBaking");
    }

    if (cleanName.contains(" ")) {
      return getSkill(cleanName.replace(" ", ""));
    }

    return null;
  }
Esempio n. 2
0
 /**
  * Add a skill to this class.
  *
  * @param skill the skill to add
  */
 void addSkill(final Skill skill) {
   skillMap.put(skill.getId(), skill);
 }