3
namespace VQDR.Expression {
6
* A Simple Represetation of a dice.
9
public int times { get; set; }
10
public int faces { get; set; }
11
public int modifier { get; set; }
14
public Dice (int times = 1, int faces = 6, int modifier = 0) {
17
this.modifier = modifier;
30
return times + modifier;
33
int retval = modifier;
34
for (size_t i = 1; i <= times; i++) {
35
int r = (VQDR.Common.Random.get_static_int () % faces).abs ();
43
public string to_string () {
44
if ((times == 0) && (faces == 0)) {
48
StringBuilder retval = new StringBuilder ();
51
retval.append (times.to_string ()).append_c ('d').append (faces.to_string ());
54
retval.append_c ('+').append (modifier.to_string ());
55
} else if (modifier < 0) {
56
retval.append (modifier.to_string ());
59
return (string) retval.data;