blob: c0e9643f050a5170aa3114e35d67a696bd22ae3c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
package bjc.dicelang.eval;
import bjc.dicelang.dice.DiceExpression;
import bjc.dicelang.dice.Die;
import bjc.dicelang.dice.DieList;
import bjc.dicelang.dice.ListDiceExpression;
import bjc.dicelang.dice.ScalarDiceExpression;
/**
* Represents a result containing a dice value.
*
* @author student
*
*/
public class DiceEvaluatorResult extends EvaluatorResult {
/**
* The dice value of the result.
*/
public DiceExpression diceVal;
/**
* Create a new result from an expression.
*
* @param expr
* The expression to use.
*/
public DiceEvaluatorResult(DiceExpression expr) {
super(Type.DICE);
diceVal = expr;
}
/**
* Create a new result from a die.
*
* @param die
* The die to use.
*/
public DiceEvaluatorResult(Die die) {
this(new ScalarDiceExpression(die));
}
/**
* Create a new result from a die list.
*
* @param list
* The die list to use.
*/
public DiceEvaluatorResult(DieList list) {
this(new ListDiceExpression(list));
}
/**
* Check if the result is a list.
*
* @return If the result is a list.
*/
public boolean isList() {
return diceVal.isList();
}
}
|