Interface AttackStrategy

All Known Implementing Classes:
AttackWeakest, Coward, StupidCoward

public interface AttackStrategy
a strategy for choosing an attack target and a mean of attack.
Author:
durkham
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    attack​(Creature creature)
    attacks the target.
    boolean
    canAttackNow​(Creature creature)
    Can the specified creature do an attack now?
    boolean
    canAttackNow​(Creature attacker, RPEntity target)
    Can the specified creature do an attack against a specified target?
    void
    findNewTarget​(Creature creature)
    find a new target.
    void
    Find a better position to do the attack, for example melees should walk closelyto their target but archers should stay away.
    int
    Get the maximum range of the attacking creature.
    boolean
    hasValidTarget​(Creature creature)
    Does the creature have a valid target at the moment?
  • Method Details

    • canAttackNow

      boolean canAttackNow(Creature creature)
      Can the specified creature do an attack now?
      Parameters:
      creature - creature doing the attack
      Returns:
      true, if it can attack, false otherwise
    • canAttackNow

      boolean canAttackNow(Creature attacker, RPEntity target)
      Can the specified creature do an attack against a specified target?
      Parameters:
      attacker - creature doing the attack
      target - potential target
      Returns:
      true, if it can attack, false otherwise
    • attack

      void attack(Creature creature)
      attacks the target.
      Parameters:
      creature - creature doing the attack
    • getRange

      int getRange()
      Get the maximum range of the attacking creature.
      Returns:
      maximum range
    • getBetterAttackPosition

      void getBetterAttackPosition(Creature creature)
      Find a better position to do the attack, for example melees should walk closelyto their target but archers should stay away.
      Parameters:
      creature - creature doing the attack
    • hasValidTarget

      boolean hasValidTarget(Creature creature)
      Does the creature have a valid target at the moment?
      Parameters:
      creature - Creature which is attacking
      Returns:
      true, if it has a valid target; false otherwise
    • findNewTarget

      void findNewTarget(Creature creature)
      find a new target.
      Parameters:
      creature - creature doing the attack