Search in sources :

Example 1 with Visibility

use of pcgen.util.enumeration.Visibility in project pcgen by PCGen.

the class BasePCCountAbilitiesTermEvaluator method countVisibleAbility.

/**
	 * 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;
}
Also used : Visibility(pcgen.util.enumeration.Visibility)

Example 2 with Visibility

use of pcgen.util.enumeration.Visibility in project pcgen by PCGen.

the class ContentDefinition method activate.

/**
	 * Activates this ContentDefinition by performing the necessary steps to
	 * link it to other subsystems.
	 * 
	 * @param context
	 *            The LoadContext to initialize with tokens, if required
	 */
public void activate(LoadContext context) {
    activateKey();
    Visibility vis = (visibility == null) ? Visibility.HIDDEN : visibility;
    if (vis.isVisibleTo(View.VISIBLE_EXPORT)) {
        activateOutput(context.getDataSetID());
    }
    activateTokens(context);
}
Also used : Visibility(pcgen.util.enumeration.Visibility)

Example 3 with Visibility

use of pcgen.util.enumeration.Visibility in project pcgen by PCGen.

the class Gui2InfoFactory method appendFacts.

private void appendFacts(HtmlInfoBuilder infoText, CDOMObject cdo) {
    Class<? extends CDOMObject> cl = cdo.getClass();
    LoadContext context = Globals.getContext();
    Collection<FactDefinition> defs = context.getReferenceContext().getConstructedCDOMObjects(FactDefinition.class);
    for (FactDefinition<?, ?> def : defs) {
        if (def.getUsableLocation().isAssignableFrom(cl)) {
            Visibility visibility = def.getVisibility();
            if (visibility != null && visibility.isVisibleTo(View.VISIBLE_DISPLAY)) {
                FactKey<?> fk = def.getFactKey();
                Indirect<?> fact = cdo.get(fk);
                if (fact != null) {
                    infoText.appendSpacer();
                    infoText.append("<b>");
                    infoText.append(fk.toString());
                    infoText.append(":</b>&nbsp;");
                    infoText.append(fact.getUnconverted());
                }
            }
        }
    }
    Collection<FactSetDefinition> setdefs = context.getReferenceContext().getConstructedCDOMObjects(FactSetDefinition.class);
    for (FactSetDefinition<?, ?> def : setdefs) {
        if (def.getUsableLocation().isAssignableFrom(cl)) {
            Visibility visibility = def.getVisibility();
            if (visibility != null && visibility.isVisibleTo(View.VISIBLE_DISPLAY)) {
                FactSetKey<?> fk = def.getFactSetKey();
                String s = getSetString(cdo, fk);
                if (s != null) {
                    infoText.appendSpacer();
                    infoText.append("<b>");
                    infoText.append(fk.toString());
                    infoText.append(":</b>&nbsp;");
                    infoText.append(s);
                }
            }
        }
    }
}
Also used : FactDefinition(pcgen.cdom.content.fact.FactDefinition) FactSetDefinition(pcgen.cdom.content.factset.FactSetDefinition) LoadContext(pcgen.rules.context.LoadContext) Visibility(pcgen.util.enumeration.Visibility)

Example 4 with Visibility

use of pcgen.util.enumeration.Visibility in project pcgen by PCGen.

the class VisibleToken method parseNonEmptyToken.

@Override
protected ParseResult parseNonEmptyToken(LoadContext context, PCClass pcc, String value) {
    Visibility vis;
    if (value.equals("NO")) {
        vis = Visibility.HIDDEN;
    } else if (value.equalsIgnoreCase("Y") || value.equals("YES")) {
        vis = Visibility.DEFAULT;
    } else {
        return new ParseResult.Fail("Can't understand Visibility: " + value, context);
    }
    context.getObjectContext().put(pcc, ObjectKey.VISIBILITY, vis);
    return ParseResult.SUCCESS;
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) Visibility(pcgen.util.enumeration.Visibility)

Example 5 with Visibility

use of pcgen.util.enumeration.Visibility in project pcgen by PCGen.

the class VisibleToken method unparse.

@Override
public String[] unparse(LoadContext context, Ability ability) {
    Visibility vis = context.getObjectContext().getObject(ability, ObjectKey.VISIBILITY);
    if (vis == null) {
        return null;
    }
    String visString;
    if (vis.equals(Visibility.DEFAULT)) {
        visString = "YES";
    } else if (vis.equals(Visibility.DISPLAY_ONLY)) {
        visString = "DISPLAY";
    } else if (vis.equals(Visibility.OUTPUT_ONLY)) {
        visString = "EXPORT";
    } else if (vis.equals(Visibility.HIDDEN)) {
        visString = "NO";
    } else {
        context.addWriteMessage("Visibility " + vis + " is not a valid Visibility for an Ability");
        return null;
    }
    return new String[] { visString };
}
Also used : Visibility(pcgen.util.enumeration.Visibility)

Aggregations

Visibility (pcgen.util.enumeration.Visibility)23 ParseResult (pcgen.rules.persistence.token.ParseResult)4 Skill (pcgen.core.Skill)2 ComplexParseResult (pcgen.rules.persistence.token.ComplexParseResult)2 FactDefinition (pcgen.cdom.content.fact.FactDefinition)1 FactSetDefinition (pcgen.cdom.content.factset.FactSetDefinition)1 LoadContext (pcgen.rules.context.LoadContext)1