public Dice(ushort count, ushort sides, int modifier) { SidesPerDie = sides; NumberDice = count; Modifier = modifier; IndividualDice = Roll(count, sides); Result = IndividualDice.Sum() + modifier; }
public string ToEquationString() { using (var b = new StringWriter()) { b.Write($"({IndividualDice.First()}"); foreach (var num in IndividualDice.Skip(1)) { b.Write($"+{num}"); } b.Write($"){(Modifier < 0 ? '-' : '+')}{Math.Abs(Modifier)}={Result}"); return(b.ToString()); } }
IEnumerator IEnumerable.GetEnumerator() { return(IndividualDice.GetEnumerator()); }
public IEnumerator <int> GetEnumerator() { return(IndividualDice.GetEnumerator()); }