/**
   * Count the number of times the character has the ability. This can be limited to either hidden
   * or visible Abilities, and can be limited to only counting once per ability rather than once per
   * time taken (e.g. Weapon Specialisation in two weapons would count as 2 unless the onceOnly flag
   * was true).
   *
   * @param pc the Character with the abilities
   * @param cna The feat to be counted.
   * @param visible Should it be counted if it is visible?
   * @param hidden Should it be counted if it is hidden?
   * @param onceOnly Should it be counted as one if was taken multiple times?
   * @return The number of occurrences of the ability.
   */
  protected Float countVisibleAbility(
      PlayerCharacter pc,
      final CNAbility cna,
      final boolean visible,
      final boolean hidden,
      final boolean onceOnly) {
    Visibility v = cna.getAbility().getSafe(ObjectKey.VISIBILITY);

    // TODO This is a bug, it assumes export
    boolean abilityInvisibile = v.isVisibleTo(View.HIDDEN_EXPORT);

    int count = 0;

    if (abilityInvisibile) {
      if (hidden) {
        count += onceOnly ? 1 : Math.max(1, pc.getSelectCorrectedAssociationCount(cna));
      }
    } else {
      if (visible) {
        count += onceOnly ? 1 : Math.max(1, pc.getSelectCorrectedAssociationCount(cna));
      }
    }

    return (float) count;
  }
示例#2
0
 public String[] unparse(LoadContext context, PCClass pcc) {
   Visibility vis = context.getObjectContext().getObject(pcc, ObjectKey.VISIBILITY);
   if (vis == null) {
     return null;
   }
   String visString;
   if (vis.equals(Visibility.DEFAULT)) {
     visString = "YES";
   } else if (vis.equals(Visibility.HIDDEN)) {
     visString = "NO";
   } else {
     context.addWriteMessage("Visibility " + vis + " is not a valid Visibility for a PCClass");
     return null;
   }
   return new String[] {visString};
 }
示例#3
0
 public String[] unparse(LoadContext context, EquipmentModifier eqm) {
   Visibility vis = context.getObjectContext().getObject(eqm, ObjectKey.VISIBILITY);
   if (vis == null) {
     return null;
   }
   String visString;
   if (vis.equals(Visibility.DEFAULT)) {
     visString = "YES";
   } else if (vis.equals(Visibility.QUALIFY)) {
     visString = "QUALIFY";
   } else if (vis.equals(Visibility.HIDDEN)) {
     visString = "NO";
   } else {
     context.addWriteMessage("Visibility " + vis + " is not a valid Visibility for a EqMod");
     return null;
   }
   return new String[] {visString};
 }
示例#4
0
 @Override
 public String[] unparse(LoadContext context, AbilityCategory ac) {
   Visibility vis = ac.getVisibility();
   String visString;
   if (vis.equals(Visibility.DEFAULT)) {
     visString = "YES";
   } else if (vis.equals(Visibility.QUALIFY)) {
     visString = "QUALIFY";
   } else if (vis.equals(Visibility.HIDDEN)) {
     visString = "NO";
   } else {
     context.addWriteMessage(
         "Visibility "
             + vis
             + " is not a valid Visibility for "
             + ac.getClass().getSimpleName()
             + " "
             + ac.getKeyName());
     return null;
   }
   return new String[] {visString};
 }