Search in sources :

Example 46 with Formula

use of pcgen.base.formula.Formula in project pcgen by PCGen.

the class SelectToken method parseNonEmptyToken.

@Override
protected ParseResult parseNonEmptyToken(LoadContext context, KitSelect kitSelect, String value) {
    Formula formula = FormulaFactory.getFormulaFor(value);
    if (!formula.isValid()) {
        return new ParseResult.Fail("Formula in " + getTokenName() + " was not valid: " + formula.toString(), context);
    }
    kitSelect.setFormula(formula);
    return ParseResult.SUCCESS;
}
Also used : Formula(pcgen.base.formula.Formula)

Example 47 with Formula

use of pcgen.base.formula.Formula in project pcgen by PCGen.

the class LevelToken method parseNonEmptyToken.

@Override
protected ParseResult parseNonEmptyToken(LoadContext context, KitClass kitClass, String value) {
    Formula formula = FormulaFactory.getFormulaFor(value);
    if (!formula.isValid()) {
        return new ParseResult.Fail("Formula in " + getTokenName() + " was not valid: " + formula.toString(), context);
    }
    kitClass.setLevel(formula);
    return ParseResult.SUCCESS;
}
Also used : Formula(pcgen.base.formula.Formula)

Example 48 with Formula

use of pcgen.base.formula.Formula in project pcgen by PCGen.

the class QtyToken method parseNonEmptyToken.

@Override
protected ParseResult parseNonEmptyToken(LoadContext context, KitFunds kitFunds, String value) {
    Formula formula = FormulaFactory.getFormulaFor(value);
    if (!formula.isValid()) {
        return new ParseResult.Fail("Formula in " + getTokenName() + " was not valid: " + formula.toString(), context);
    }
    kitFunds.setQuantity(formula);
    return ParseResult.SUCCESS;
}
Also used : Formula(pcgen.base.formula.Formula)

Example 49 with Formula

use of pcgen.base.formula.Formula in project pcgen by PCGen.

the class Kit method getTotalCost.

/**
	 * Gets the specified total cost of the kit. Note this is a base total cost 
	 * which would then be modified by the chosen gear purchase rate on the gear 
	 * tab. 
	 *
	 * @param	aPC The character used to evaluate expressions in relation to
	 * @return  total cost, or null if no total cost was specified.
	 */
public BigDecimal getTotalCost(PlayerCharacter aPC) {
    QualifiedObject<Formula> buy = get(ObjectKey.KIT_TOTAL_COST);
    Formula f = (buy == null ? null : buy.getObject(aPC, this));
    BigDecimal totalCost = null;
    if (f != null) {
        totalCost = new BigDecimal(f.resolve(aPC, "").doubleValue());
    }
    return totalCost;
}
Also used : Formula(pcgen.base.formula.Formula) BigDecimal(java.math.BigDecimal)

Example 50 with Formula

use of pcgen.base.formula.Formula in project pcgen by PCGen.

the class Kit method getBuyRate.

/**
	 * Gets the buy rate of the kit.
	 *
	 * @param	aPC The character used to evaluate expressions in relation to
	 * @return  String
	 */
public int getBuyRate(PlayerCharacter aPC) {
    QualifiedObject<Formula> buy = get(ObjectKey.EQUIP_BUY);
    Formula f = (buy == null ? null : buy.getObject(aPC, this));
    int buyRate;
    if (f == null) {
        buyRate = SettingsHandler.getGearTab_BuyRate();
    } else {
        buyRate = f.resolve(aPC, "").intValue();
        if (buyRate == 100) {
            buyRate = SettingsHandler.getGearTab_BuyRate();
        }
    }
    return buyRate;
}
Also used : Formula(pcgen.base.formula.Formula)

Aggregations

Formula (pcgen.base.formula.Formula)106 ArrayList (java.util.ArrayList)30 ParsingSeparator (pcgen.base.text.ParsingSeparator)26 ConcretePersistentTransitionChoice (pcgen.cdom.base.ConcretePersistentTransitionChoice)18 ParseResult (pcgen.rules.persistence.token.ParseResult)18 CDOMReference (pcgen.cdom.base.CDOMReference)16 StringTokenizer (java.util.StringTokenizer)15 ChoiceSet (pcgen.cdom.base.ChoiceSet)11 Ungranted (pcgen.cdom.base.Ungranted)10 CDOMObject (pcgen.cdom.base.CDOMObject)9 PersistentTransitionChoice (pcgen.cdom.base.PersistentTransitionChoice)9 ReferenceChoiceSet (pcgen.cdom.choiceset.ReferenceChoiceSet)8 PCClass (pcgen.core.PCClass)7 Prerequisite (pcgen.core.prereq.Prerequisite)7 Map (java.util.Map)6 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)6 PCTemplate (pcgen.core.PCTemplate)6 Race (pcgen.core.Race)6 Spell (pcgen.core.spell.Spell)6 HashMap (java.util.HashMap)5