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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations