summaryrefslogtreecommitdiff
path: root/dice-lang/src/bjc/dicelang/v1/IDiceExpression.java
diff options
context:
space:
mode:
Diffstat (limited to 'dice-lang/src/bjc/dicelang/v1/IDiceExpression.java')
-rw-r--r--dice-lang/src/bjc/dicelang/v1/IDiceExpression.java28
1 files changed, 14 insertions, 14 deletions
diff --git a/dice-lang/src/bjc/dicelang/v1/IDiceExpression.java b/dice-lang/src/bjc/dicelang/v1/IDiceExpression.java
index 86c4d6a..5bf062b 100644
--- a/dice-lang/src/bjc/dicelang/v1/IDiceExpression.java
+++ b/dice-lang/src/bjc/dicelang/v1/IDiceExpression.java
@@ -4,7 +4,7 @@ import bjc.utils.funcutils.StringUtils;
/**
* An expression for something that can be rolled like a polyhedral die
- *
+ *
* @author ben
*
*/
@@ -12,7 +12,7 @@ import bjc.utils.funcutils.StringUtils;
public interface IDiceExpression {
/**
* Parse a string into an expression.
- *
+ *
* It can accept the following types of expressions
* <ul>
* <li>Simple integers - '2'</li>
@@ -21,13 +21,13 @@ public interface IDiceExpression {
* <li>Number concatenation - '2c6'</li>
* <li>Dice concatenation - '1d10c1d10</li>
* </ul>
- *
+ *
* Dice concatenation is like using 2 d10s to emulate a d100, so instead
* of adding them, it reads them side by side.
- *
+ *
* @param expression
* The string to convert to an expression
- *
+ *
* @return The string, converted into expression form
*/
static IDiceExpression toExpression(String expression) {
@@ -35,22 +35,22 @@ public interface IDiceExpression {
String diceMatcher = "\\Ad\\d+\\Z";
- if (StringUtils.containsInfixOperator(literalData, "c")) {
+ if(StringUtils.containsInfixOperator(literalData, "c")) {
// Parse a compound die
String[] strangs = literalData.split("c");
return new CompoundDice(strangs);
- } else if (StringUtils.containsInfixOperator(literalData, "d")) {
+ } else if(StringUtils.containsInfixOperator(literalData, "d"))
// Handle groups of similiar dice
return ComplexDice.fromString(literalData);
- } else if (literalData.matches(diceMatcher)) {
+ else if(literalData.matches(diceMatcher))
// Handle people who put 'd6' instead of '1d6'
return new Die(Integer.parseInt(literalData.substring(1)));
- } else {
+ else {
// Parse a scalar number
try {
return new ScalarDie(Integer.parseInt(literalData));
- } catch (NumberFormatException nfex) {
+ } catch(NumberFormatException nfex) {
UnsupportedOperationException usex = new UnsupportedOperationException(
"Found malformed leaf token " + expression + ". Floating point numbers "
+ "are not supported.");
@@ -64,7 +64,7 @@ public interface IDiceExpression {
/**
* Check if this expression can be optimized to a scalar value
- *
+ *
* @return Whether or not this expression can be optimized to a scalar
* value
*/
@@ -74,9 +74,9 @@ public interface IDiceExpression {
/**
* Optimize this expression to a scalar value
- *
+ *
* @return This expression, optimized to a scalar value
- *
+ *
* @throws UnsupportedOperationException
* if this type of expression can't be optimized
*/
@@ -86,7 +86,7 @@ public interface IDiceExpression {
/**
* Roll the dice once
- *
+ *
* @return The result of rowing the dice
*/
public int roll();