diff options
author | Dennis Kobert <d-kobert@web.de> | 2019-06-11 23:38:13 +0200 |
---|---|---|
committer | Dennis Kobert <d-kobert@web.de> | 2019-06-11 23:38:13 +0200 |
commit | 2fa4a0e50ebfc97059c8b84dbd17e79f9afc8a8d (patch) | |
tree | c3b34ccb2737e347a73768536895cbbaab13cc01 /dsa/DiscoBot/Auxiliary/RandomMisc.cs | |
parent | ec991104f56e90d7bb2878da2fe6ed4e585dfc46 (diff) | |
parent | af74efccf8d21e6151022b71f3cacd3fa83024ee (diff) |
Merge branch 'rework-backend'
Diffstat (limited to 'dsa/DiscoBot/Auxiliary/RandomMisc.cs')
-rw-r--r-- | dsa/DiscoBot/Auxiliary/RandomMisc.cs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/dsa/DiscoBot/Auxiliary/RandomMisc.cs b/dsa/DiscoBot/Auxiliary/RandomMisc.cs new file mode 100644 index 0000000..205b3a7 --- /dev/null +++ b/dsa/DiscoBot/Auxiliary/RandomMisc.cs @@ -0,0 +1,36 @@ +using System; +using System.Linq; +using System.Text; + +namespace DiscoBot.Auxiliary +{ + public static class RandomMisc + { + public static string Roll(string input) + { + var output = new StringBuilder(); + var strings = input.Split('w', 'd').ToList(); + var count = Convert.ToInt32(strings[0]); + strings = strings[1].Split(' ').ToList(); + var d = Convert.ToInt32(strings[0]); + + if (strings.Count > 0) + { + } + + var sum = 0; + for (var i = 0; i < count; i++) + { + var roll = Dice.Roll(d); + sum += roll; + output.Append("[" + roll + "] "); + } + + if (strings.Count <= 1) return output.ToString(); + sum += Convert.ToInt32(strings[1]); + output.Append("sum: " + sum); + + return output.ToString(); + } + } +}
\ No newline at end of file |