/// <summary> /// Formats a single set into it's string representation. /// </summary> /// <param name="set">The set to format.</param> /// <returns>A string representing the set.</returns> private static string FormatSet(List <RollResult> set) { List <string> rollTextList = new List <string>(); foreach (var roll in set) { rollTextList.Add(RollFormater.FormatRoll(roll)); } var rollsText = string.Join(", ", rollTextList); return((set.Count > 1) ? $"({rollsText})" : rollsText); }
/// <summary> /// Format the results of rolls into a string. /// </summary> /// <param name="result">The results of various rolls.</param> /// <returns>A string representing the rolls.</returns> public static String Format(List <List <RollResult> > result) { var setsTextList = new List <string>(); foreach (var set in result) { setsTextList.Add(RollFormater.FormatSet(set)); } var totalSum = result.Sum(x => x.Where(y => y.Valid).Sum(z => z.Result)); var setsText = string.Join(", ", setsTextList); return($"{setsText} = {totalSum}"); }
/// <summary> /// Generates a discord builder that can be sent via a message. /// </summary> /// <param name="result">The results of various rolls.</param> /// <param name="context">The context of the original request.</param> /// <returns>A builder that is ready to be used.</returns> public static EmbedBuilder GenerateDiscordBuilder(List <List <RollResult> > result, SocketCommandContext context) { string display = RollFormater.Format(result); // Create a builder to construct the output. EmbedBuilder builder = new EmbedBuilder(); // Set author and image builder.WithAuthor("Dice Roller", "https://cdn.pixabay.com/photo/2017/08/31/04/01/d20-2699387_960_720.png"); // Set outline to be red. builder.WithColor(Color.Red); // Set the description to show results. builder.WithDescription($"{context.User.Mention}: {display}"); return(builder); }