public DiceResults GenerateRollResults(DiceCommand command) { var diceResults = new DiceResults() { Roller = command.Roller, Bonus = command.Bonus, OriginalRoll = GenerateRollString(command) }; for(var i=0;i<command.Dice;i++) { var outputRoll = randomizer.Next(1, command.Sides); diceResults.Rolls.Add(outputRoll); } return diceResults; }
public string GenerateOutputMessage(DiceResults diceResult) { var totalScore = totalScoreGenerator.GenerateTotalScore(diceResult); var outputMessage = new StringBuilder(); outputMessage.AppendFormat("{0} rolled ({1}) yielding {2}{3}", diceResult.Roller, diceResult.OriginalRoll, totalScore, Environment.NewLine); if (diceResult.Rolls.Count > 1) { outputMessage.AppendFormat("- Consisting of "); foreach (var roll in diceResult.Rolls) { outputMessage.AppendFormat("{0} ", roll); } if (diceResult.Bonus != 0) { outputMessage.AppendFormat("with a bonus of {0}", diceResult.Bonus); } } return outputMessage.ToString(); }
public int GenerateTotalScore(DiceResults diceResults) { return diceResults.Bonus + diceResults.Rolls.Sum(); }