From eda9a86d8d48758e9982cfffd470c3b38a0a4b0b Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Sat, 21 Nov 2020 23:11:43 -0500 Subject: Make dice generic Convert dice from dealing exclusively with ints, to deal with objects of arbitrary types --- .../java/bjc/dicelang/neodice/commands/PolyhedralDieCommand.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'dice/src/example/java/bjc/dicelang/neodice/commands/PolyhedralDieCommand.java') 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 95e9dff..6af495e 100644 --- a/dice/src/example/java/bjc/dicelang/neodice/commands/PolyhedralDieCommand.java +++ b/dice/src/example/java/bjc/dicelang/neodice/commands/PolyhedralDieCommand.java @@ -20,7 +20,11 @@ public class PolyhedralDieCommand implements Command { if (numSides < 0) throw new DieBoxException("Number of sides to polyhedral-die was not valid (must be less than 0, was %d)", numSides); - return new DieStatementValue(Die.polyhedral(numSides)); + IDie die = IDie + .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); -- cgit v1.2.3