private void RollNested(StandardOracle oracleResult, int depth, OracleTable parentTable) { if (oracleResult == null || oracleResult.Oracles == null) { return; } //Todo fix it so the JSON can tell us what size die to roll int roll = RollerRandom.Next(1, 101); var innerRow = oracleResult.Oracles.LookupOracle(roll); if (innerRow == null) { return; } RollResultList.Add(new RollResult { Roll = roll, Result = innerRow, Depth = depth, ParentTable = parentTable }); if (innerRow.Oracles != null) { RollNested(innerRow, depth + 1, parentTable); } }
private void MultiRollFacade(string value, OracleTable multiRollTable, int depth, string[] additionalSearchTerms = null) { int numberOfRolls; // Match [2x] style entries if (Regex.IsMatch(value, @"\[\d+x\]")) { var match = Regex.Match(value, @"\[(\d+)x\]"); int.TryParse(match.Groups[1].Value, out numberOfRolls); } else { if (!int.TryParse(value, out numberOfRolls)) { throw new ArgumentException($"Couldn't parse {value} as int"); } } for (int i = 1; i <= numberOfRolls; i++) { RollFacade(multiRollTable.Name, depth + 1, additionalSearchTerms); } }