Beispiel #1
0
 @Override
 public boolean allow(CategorizedAbilitySelection choice, PlayerCharacter pc, boolean allowStack) {
   // Only allow those already selected
   for (Ability a : pc.getAbilityList(AbilityCategory.FEAT, Nature.NORMAL)) {
     if (a.getKeyName().equals(choice.getAbilityKey())) {
       Boolean multYes = a.getSafe(ObjectKey.MULTIPLE_ALLOWED);
       if (!multYes || multYes && hasAssoc(pc.getAssociationList(a), choice)) {
         return true;
       }
     }
   }
   return false;
 }
Beispiel #2
0
 @Override
 public boolean allow(CategorizedAbilitySelection choice, PlayerCharacter pc, boolean allowStack) {
   // Remove any already selected
   for (Ability a : pc.getAllAbilities()) {
     if (AbilityCategory.FEAT.equals(a.getCDOMCategory().getParentCategory())) {
       if (a.getKeyName().equals(choice.getAbilityKey())) {
         if (!pc.canSelectAbility(a, false)
             || !a.getSafe(ObjectKey.VISIBILITY).equals(Visibility.DEFAULT)
             || !allowStack(a, allowStack) && hasAssoc(pc.getAssociationList(a), choice)) {
           return false;
         }
       }
     }
   }
   return true;
 }
Beispiel #3
0
  /**
   * Gets the name string after having substituting all variables.
   *
   * @param aPC The PlayerCharacter used to evaluate formulas.
   * @param theOwner the owning Ability object
   * @return The fully substituted description string.
   */
  public String getAspectText(final PlayerCharacter aPC, List<CNAbility> abilities) {
    final StringBuilder buf = new StringBuilder();

    if ((abilities == null) || (abilities.size() == 0)) {
      return "";
    }
    Ability sampleAbilityObject = abilities.get(0).getAbility();
    if (!qualifies(aPC, sampleAbilityObject)) {
      return "";
    }
    for (final String comp : theComponents) {
      if (comp.startsWith(VAR_MARKER)) {
        final int ind = Integer.parseInt(comp.substring(VAR_MARKER.length()));
        if (theVariables == null || ind > theVariables.size()) {
          buf.append(Constants.EMPTY_STRING);
          continue;
        }
        final String var = theVariables.get(ind - 1);
        if (var.equals(VAR_NAME)) {
          buf.append(sampleAbilityObject.getOutputName());
        } else if (var.equals(VAR_LIST)) {
          List<String> assocList = new ArrayList<String>();
          for (CNAbility cna : abilities) {
            assocList.addAll(aPC.getAssociationList(cna));
          }
          String joinString;
          if (assocList.size() == 2) {
            joinString = " and ";
          } else {
            joinString = ", ";
          }
          Collections.sort(assocList);
          buf.append(StringUtil.joinToStringBuilder(assocList, joinString));
        } else if (var.startsWith("\"")) // $NON-NLS-1$
        {
          buf.append(var.substring(1, var.length() - 1));
        } else {
          buf.append(aPC.getVariableValue(var, "Aspect").intValue()); // $NON-NLS-1$
        }
      } else {
        buf.append(comp);
      }
    }
    return buf.toString();
  }