Esempio n. 1
0
  /**
   * Get the range of gifts available to a unit.
   *
   * @param unit The <code>Unit</code> to check.
   * @return A range of gifts, or null if none applicable.
   */
  public final RandomRange getGifts(Unit unit) {
    if (gifts == null) return null;

    for (RandomRange range : gifts) {
      List<Scope> scopes = range.getScopes();
      if (scopes.isEmpty()) return range;
      for (Scope scope : scopes) {
        if (scope.appliesTo(unit)) return range;
      }
    }
    return null;
  }
Esempio n. 2
0
  /**
   * Gets the plunder range available for the supplied unit.
   *
   * @param unit The <code>Unit</code> to check.
   * @return The plunder range, or null if none applicable.
   */
  public final RandomRange getPlunderRange(Unit unit) {
    if (plunder == null) return null;

    for (RandomRange range : plunder) {
      List<Scope> scopes = range.getScopes();
      if (scopes.isEmpty()) return range;
      for (Scope scope : scopes) {
        if (scope.appliesTo(unit)) return range;
      }
    }
    return null;
  }