diff options
| author | bjcul <bjcul@192.168.1.26> | 2022-09-27 19:15:16 -0400 |
|---|---|---|
| committer | bjcul <bjcul@192.168.1.26> | 2022-09-27 19:15:16 -0400 |
| commit | e151e8490ed40231399618bf2dc4204c2ce99a82 (patch) | |
| tree | dce61b6e1a7f20bcba8411d412c83692e6019ed8 /dice/src/example/java/bjc/dicelang/neodice/commands/PolyhedralDieCommand.java | |
| parent | da0b133cedf9fe4e464aadad1a451dacbf4d2b30 (diff) | |
Merge branch 'master' of git@github.com:bculkin2442/dice-lang.git
Diffstat (limited to 'dice/src/example/java/bjc/dicelang/neodice/commands/PolyhedralDieCommand.java')
| -rw-r--r-- | dice/src/example/java/bjc/dicelang/neodice/commands/PolyhedralDieCommand.java | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/dice/src/example/java/bjc/dicelang/neodice/commands/PolyhedralDieCommand.java b/dice/src/example/java/bjc/dicelang/neodice/commands/PolyhedralDieCommand.java index e0f66b1..ed74507 100644 --- a/dice/src/example/java/bjc/dicelang/neodice/commands/PolyhedralDieCommand.java +++ b/dice/src/example/java/bjc/dicelang/neodice/commands/PolyhedralDieCommand.java @@ -18,24 +18,24 @@ public class PolyhedralDieCommand implements Command { public StatementValue execute(Iterator<String> words, DieBoxCLI state) { if (!words.hasNext()) { throw new DieBoxException("Number of sides to polyhedral-die must be provided"); - } else { - StatementValue sideValue = state.runStatement(words); + } + + StatementValue sideValue = state.runStatement(words); + + if (sideValue.type == INTEGER) { + int numSides = ((IntegerStatementValue)sideValue).value; + + if (numSides < 0) throw new DieBoxException("Number of sides to polyhedral-die was not valid (must be less than 0, was %d)", numSides); + + Die<StatementValue> die = Die + .polyhedral(numSides) + .transform(IntegerStatementValue::new); - if (sideValue.type == INTEGER) { - int numSides = ((IntegerStatementValue)sideValue).value; - - if (numSides < 0) throw new DieBoxException("Number of sides to polyhedral-die was not valid (must be less than 0, was %d)", numSides); - - Die<StatementValue> die = Die - .polyhedral(numSides) - .transform(IntegerStatementValue::new); - - return new DieStatementValue(INTEGER, die); - } else { - throw new DieBoxException("Number of sides to polyhedral-die wasn't an integer (was %s, of type %s)", - sideValue, sideValue.type); - } + return new DieStatementValue(INTEGER, die); } + + throw new DieBoxException("Number of sides to polyhedral-die wasn't an integer (was %s, of type %s)", + sideValue, sideValue.type); } @Override |
