Пример #1
0
  /**
   * Check if the skill can be used
   *
   * @return True if the skill can be used
   */
  public boolean canUseSkill() {
    Properties properties = skillTemplate.getProperties();
    if (properties != null && !properties.validate(this)) {
      log.debug("properties failed");
      return false;
    }

    if (!preCastCheck()) return false;

    // check for counter skill
    if (effector instanceof Player) {
      Player player = (Player) effector;
      if (this.skillTemplate.getCounterSkill() != null) {
        long time = player.getLastCounterSkill(skillTemplate.getCounterSkill());
        if ((time + 5000) < System.currentTimeMillis()) {
          log.debug("chain skill failed, too late");
          return false;
        }
      }

      if (skillMethod == SkillMethod.ITEM
          && duration > 0
          && player.getMoveController().isInMove()) {
        PacketSendUtility.sendPacket(
            player,
            SM_SYSTEM_MESSAGE.STR_ITEM_CANCELED(new DescriptionId(getItemTemplate().getNameId())));
        return false;
      }
    }
    if (!validateEffectedList()) return false;

    return true;
  }