Class Formula
java.lang.Object
studio.magemonkey.fabled.data.formula.Formula
- All Implemented Interfaces:
IValue
Represents a basic math equation read from left to right, ignoring
order of operations. Currently this only supports addition, subtraction,
multiplication, and division.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFormula
(String equation, CustomValue... defined) Creates a new formula from a config string -
Method Summary
Modifier and TypeMethodDescriptiondouble
compute
(double... input) Calculates the formula using the given base value and attribute.boolean
isValid()
Whether the equation was valid when parsed.negate()
Negates the output of the formula for future computationstoString()
Returns the equation string for toString
-
Field Details
-
DEG_TO_RAD
public static final double DEG_TO_RAD- See Also:
-
-
Constructor Details
-
Formula
Creates a new formula from a config string- Parameters:
equation
- equation string
-
-
Method Details
-
negate
Negates the output of the formula for future computations- Returns:
- the negated Formula
-
compute
public double compute(double... input) Calculates the formula using the given base value and attribute. If the formula is invalid, this returns the value. -
toString
Returns the equation string for toString -
isValid
public boolean isValid()Whether the equation was valid when parsed.- Returns:
- whether the equation was valid
-