Search in sources :

Example 6 with Load

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

the class UnencumberedArmorFacet method dataAdded.

/**
	 * Stores in this facet the Load for any Unencumbered Armor Values granted
	 * by a CDOMObject added to a Player Character.
	 * 
	 * Triggered when one of the Facets to which UnencumberedArmorFacet listens
	 * fires a DataFacetChangeEvent to indicate a CDOMObject was added to a
	 * Player Character.
	 * 
	 * @param dfce
	 *            The DataFacetChangeEvent containing the information about the
	 *            change
	 * 
	 * @see pcgen.cdom.facet.event.DataFacetChangeListener#dataAdded(pcgen.cdom.facet.event.DataFacetChangeEvent)
	 */
@Override
public void dataAdded(DataFacetChangeEvent<CharID, CDOMObject> dfce) {
    CDOMObject cdo = dfce.getCDOMObject();
    Load load = cdo.get(ObjectKey.UNENCUMBERED_ARMOR);
    if (load != null) {
        add(dfce.getCharID(), load, cdo);
    }
}
Also used : Load(pcgen.util.enumeration.Load) CDOMObject(pcgen.cdom.base.CDOMObject)

Example 7 with Load

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

the class UnencumberedLoadFacet method dataAdded.

/**
	 * Stores in this facet the Load for any Unencumbered Load Values granted by
	 * a CDOMObject added to a Player Character.
	 * 
	 * Triggered when one of the Facets to which UnencumberedLoadFacet listens
	 * fires a DataFacetChangeEvent to indicate a CDOMObject was added to a
	 * Player Character.
	 * 
	 * @param dfce
	 *            The DataFacetChangeEvent containing the information about the
	 *            change
	 * 
	 * @see pcgen.cdom.facet.event.DataFacetChangeListener#dataAdded(pcgen.cdom.facet.event.DataFacetChangeEvent)
	 */
@Override
public void dataAdded(DataFacetChangeEvent<CharID, CDOMObject> dfce) {
    CDOMObject cdo = dfce.getCDOMObject();
    Load load = cdo.get(ObjectKey.UNENCUMBERED_LOAD);
    if (load != null) {
        add(dfce.getCharID(), load, cdo);
    }
}
Also used : Load(pcgen.util.enumeration.Load) CDOMObject(pcgen.cdom.base.CDOMObject)

Example 8 with Load

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

the class CharacterFacadeImpl method refreshTotalWeight.

/**
	 * Refreshes the total weight by reading it from the current equipment set.  
	 */
private void refreshTotalWeight() {
    String weight = Globals.getGameModeUnitSet().displayWeightInUnitSet(charDisplay.totalWeight().doubleValue());
    carriedWeightRef.set(weight);
    Load load = charDisplay.getLoadType();
    loadRef.set(CoreUtility.capitalizeFirstLetter(load.toString()));
    Float mult = SettingsHandler.getGame().getLoadInfo().getLoadMultiplier(load.toString());
    double limit = 0.0f;
    if (mult != null) {
        limit = charDisplay.getLoadToken(load.toString());
    }
    double lowerLimit = 0.0f;
    for (Load testLoad : Load.values()) {
        double testLimit = charDisplay.getLoadToken(testLoad.toString());
        if (testLoad.compareTo(load) < 0 && testLimit > lowerLimit) {
            lowerLimit = testLimit;
        }
    }
    StringBuilder loadLimit = new StringBuilder(Globals.getGameModeUnitSet().displayWeightInUnitSet(lowerLimit));
    if (limit > 0) {
        loadLimit.append(" - ");
        loadLimit.append(Globals.getGameModeUnitSet().displayWeightInUnitSet(limit));
    } else {
        loadLimit.append("+ ");
    }
    loadLimit.append(Globals.getGameModeUnitSet().getWeightUnit());
    weightLimitRef.set(loadLimit.toString());
}
Also used : Load(pcgen.util.enumeration.Load)

Example 9 with Load

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

the class UnencumberedmoveLst method parseTokenWithSeparator.

@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, CDOMObject obj, String value) {
    if (obj instanceof Ungranted) {
        return new ParseResult.Fail("Cannot use " + getTokenName() + " on an Ungranted object type: " + obj.getClass().getSimpleName(), context);
    }
    StringTokenizer tok = new StringTokenizer(value, Constants.PIPE);
    boolean hasArmor = false;
    boolean hasMove = false;
    Load loadMove = null;
    Load loadArmor = null;
    while (tok.hasMoreTokens()) {
        String loadString = tok.nextToken();
        if (loadString.equalsIgnoreCase("MediumLoad")) {
            ParseResult pr = validateOnlyMove(hasMove);
            if (!pr.passed()) {
                return pr;
            }
            loadMove = Load.MEDIUM;
            hasMove = true;
        } else if (loadString.equalsIgnoreCase("HeavyLoad")) {
            ParseResult pr = validateOnlyMove(hasMove);
            if (!pr.passed()) {
                return pr;
            }
            loadMove = Load.HEAVY;
            hasMove = true;
        } else if (loadString.equalsIgnoreCase("Overload")) {
            ParseResult pr = validateOnlyMove(hasMove);
            if (!pr.passed()) {
                return pr;
            }
            loadMove = Load.OVERLOAD;
            hasMove = true;
        } else if (loadString.equalsIgnoreCase("MediumArmor")) {
            ParseResult pr = validateOnlyArmor(hasArmor);
            if (!pr.passed()) {
                return pr;
            }
            loadArmor = Load.MEDIUM;
            hasArmor = true;
        } else if (loadString.equalsIgnoreCase("HeavyArmor")) {
            ParseResult pr = validateOnlyArmor(hasArmor);
            if (!pr.passed()) {
                return pr;
            }
            loadArmor = Load.OVERLOAD;
            hasArmor = true;
        } else if (loadString.equalsIgnoreCase("LightLoad")) {
            ParseResult pr = validateOnlyMove(hasMove);
            if (!pr.passed()) {
                return pr;
            }
            loadMove = Load.LIGHT;
            hasMove = true;
        } else if (loadString.equalsIgnoreCase("LightArmor")) {
            ParseResult pr = validateOnlyMove(hasArmor);
            if (!pr.passed()) {
                return pr;
            }
            loadArmor = Load.LIGHT;
            hasArmor = true;
        } else {
            return new ParseResult.Fail("Invalid value of \"" + loadString + "\" for UNENCUMBEREDMOVE in \"" + obj.getDisplayName() + "\".", context);
        }
    }
    context.getObjectContext().put(obj, ObjectKey.UNENCUMBERED_LOAD, loadMove);
    context.getObjectContext().put(obj, ObjectKey.UNENCUMBERED_ARMOR, loadArmor);
    return ParseResult.SUCCESS;
}
Also used : StringTokenizer(java.util.StringTokenizer) Load(pcgen.util.enumeration.Load) ParseResult(pcgen.rules.persistence.token.ParseResult) Ungranted(pcgen.cdom.base.Ungranted)

Example 10 with Load

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

the class UnencumberedmoveLst method unparse.

@Override
public String[] unparse(LoadContext context, CDOMObject obj) {
    Load load = context.getObjectContext().getObject(obj, ObjectKey.UNENCUMBERED_LOAD);
    Load at = context.getObjectContext().getObject(obj, ObjectKey.UNENCUMBERED_ARMOR);
    if (load == null && at == null) {
        return null;
    }
    StringBuilder sb = new StringBuilder();
    if (load != null) {
        if (Load.OVERLOAD.equals(load)) {
            sb.append("Overload");
        } else if (Load.HEAVY.equals(load)) {
            sb.append("HeavyLoad");
        } else if (Load.MEDIUM.equals(load)) {
            sb.append("MediumLoad");
        } else if (Load.LIGHT.equals(load)) {
            sb.append("LightLoad");
        } else {
            context.addWriteMessage(getTokenName() + " encountered unknown Movement Load: " + load);
            return null;
        }
    }
    if (at != null) {
        if (sb.length() != 0) {
            sb.append(Constants.PIPE);
        }
        if (Load.OVERLOAD.equals(at)) {
            sb.append("HeavyArmor");
        } else if (Load.MEDIUM.equals(at)) {
            sb.append("MediumArmor");
        } else if (Load.LIGHT.equals(at)) {
            sb.append("LightArmor");
        } else {
            context.addWriteMessage(getTokenName() + " encountered invalid Armor Load: " + load);
            return null;
        }
    }
    return new String[] { sb.toString() };
}
Also used : Load(pcgen.util.enumeration.Load)

Aggregations

Load (pcgen.util.enumeration.Load)12 CDOMObject (pcgen.cdom.base.CDOMObject)4 StringTokenizer (java.util.StringTokenizer)3 PCTemplate (pcgen.core.PCTemplate)2 Race (pcgen.core.Race)2 Color (java.awt.Color)1 Font (java.awt.Font)1 IdentityList (pcgen.base.util.IdentityList)1 Ungranted (pcgen.cdom.base.Ungranted)1 ParseResult (pcgen.rules.persistence.token.ParseResult)1