public DiceGroupRollResult RollDiceGroup(DiceGroup diceGroup) { var result = new DiceGroupRollResult(); foreach (var dice in diceGroup.Dice) { var rollResult = RollSingleDice(dice); result.MaxSum += rollResult.MaxResult; result.Sum += rollResult.Result; result.DiceResults.Add(rollResult); } return(result); }
private bool TryParseDiceGroup(string diceGroup, out DiceGroup result) { var diceGroupEntries = diceGroup.Split("+", StringSplitOptions.RemoveEmptyEntries); result = new DiceGroup(); foreach (var diceGroupEntry in diceGroupEntries) { if (TryParseDiceGroupEntry(diceGroupEntry, out var dice)) { foreach (var item in dice) { result.Dice.Add(item); } } } return(result.Dice.Any()); }