/// <summary> /// Process a string into a RollBuilder. /// </summary> /// <param name="str">The string to convert.</param> /// <returns>A {RollBuilder} containing the rolls represented by the string.</returns> public static RollBuilder Parse(string str) { // Prepare the string string preparedString = RollParser.Prepare(str); // Parse Out Roll Signs List <int> signTable = RollParser.GetSignTable(preparedString); // Parse out Roll Text List <string> rollTable = RollParser.GetRollTextTable(preparedString); // Parse and construct the builder. return(RollParser.ParseAndBuild(rollTable, signTable)); }
/// <summary> /// Parses the string to determine the filter applied and its parameters. /// </summary> /// <param name="v">The string to parse.</param> /// <returns>A tuple containing the actual roll text, the type of filter, and it's parameter.</returns> private static (string nakedRollText, FilterType filterType, int filterValue) PaseFilter(string v) { if (v.Contains("kh")) { throw new NotImplementedException(); } else if (v.Contains("kl")) { throw new NotImplementedException(); } else if (v.Contains("adv")) { return(RollParser.Advantage(v)); } else if (v.Contains("dis")) { return(RollParser.Disadvantage(v)); } else { return(v, FilterType.NONE, 0); } }
/// <summary> /// Parse details for disadvantage. /// </summary> /// <param name="v">String to parse.</param> /// <returns> tuple containing the actual roll text, the type of filter, and it's parameter.</returns> private static (string nakedRollText, FilterType filterType, int filterValue) Advantage(string v) { (string text, int _) = RollParser.ParseFilter(v, "adv"); return(text, FilterType.ADVANTAGE, 0); }