FormerlyDickensC
First Post
This is not a compiled app, just one class written in C#.
This is a static class 'Dice' using a static method 'Roll(string)' that accepts any normal type die roll string (including parenthetical groupings) and outputs the individual rolls, grouping break-downs, and totals as a string. I took this code from HERE , and hacked the java code into C#.
It works really well. Very versatile. It can take any number of dice, and any number of sides per dice, and any amount of modifiers. Spaces are not a problem for the string. Leave them in or out.
I love the use of parenthetical groupings. I think this is where it really shines.
EXAMPLE Input strings:
"(3d6+5)+10d12+(5d6+2)"
"10(10d100)"
"2d42+6d7-44"
EXAMPLE Output Strings:
"(5d6+15)+1d6 = 4+1+2+3+4+15+2 = 29+2 = 31"
"(5d6+15)+1d6 = 4+2+4+2+1+15+1 = 28+1 = 29"
"2d6+15 = 2+5+15 = 7+15 = 22"
This from the original coder: ...as you can see the parenthesis collect the different dice into separate groups in the next-to-last column, so for example:
(1+2+3)+4 = 1+2+3+4 = 6+4 = 10
To implement, call the Dice.Roll(string) method. There are actually two overloaded Roll methods. The second takes three int's and is used by the first.
The reason I made this was b/c I could find an infinite number of die rollers on the web, but no die roller that could accept complex roll strings AND was written in C# AND had the code available to look at. Hence the reason I post the code, and not a compiled app. There are enough of those. But I did find a java version here on these forums, and translated that and added some more code to it. Use it to make your own app. If you can't code, buy a book and learn how. I was an English major and I taught myself to code. .NET is a decent platform with good, free IDE's. Ideal for the hobbyist.
Check it out, take a look at the comments. Since I basically took all the code and cobbled pieces together, there might be ways to make it more efficient or elegant. But it can roll over a thousand rolls in a second, so whats the need to worry about it? I suggest you enter the string "1000(1000d100)" and see how long it takes. I guess that'd be like a million rolls, right?
Code is posted as is, use it at your own peril. I encourage reuse and modification of it, just include the original author's name etc etc. All the normal stuff. I'm not responsible for any of your own stupid decisions.
This is the first, and probably last thing I will ever contribute. But, hey...at least its something!
Bitches!
P.S. If you find any bugs, let me know here.
This is a static class 'Dice' using a static method 'Roll(string)' that accepts any normal type die roll string (including parenthetical groupings) and outputs the individual rolls, grouping break-downs, and totals as a string. I took this code from HERE , and hacked the java code into C#.
It works really well. Very versatile. It can take any number of dice, and any number of sides per dice, and any amount of modifiers. Spaces are not a problem for the string. Leave them in or out.
I love the use of parenthetical groupings. I think this is where it really shines.
EXAMPLE Input strings:
"(3d6+5)+10d12+(5d6+2)"
"10(10d100)"
"2d42+6d7-44"
EXAMPLE Output Strings:
"(5d6+15)+1d6 = 4+1+2+3+4+15+2 = 29+2 = 31"
"(5d6+15)+1d6 = 4+2+4+2+1+15+1 = 28+1 = 29"
"2d6+15 = 2+5+15 = 7+15 = 22"
This from the original coder: ...as you can see the parenthesis collect the different dice into separate groups in the next-to-last column, so for example:
(1+2+3)+4 = 1+2+3+4 = 6+4 = 10
To implement, call the Dice.Roll(string) method. There are actually two overloaded Roll methods. The second takes three int's and is used by the first.
The reason I made this was b/c I could find an infinite number of die rollers on the web, but no die roller that could accept complex roll strings AND was written in C# AND had the code available to look at. Hence the reason I post the code, and not a compiled app. There are enough of those. But I did find a java version here on these forums, and translated that and added some more code to it. Use it to make your own app. If you can't code, buy a book and learn how. I was an English major and I taught myself to code. .NET is a decent platform with good, free IDE's. Ideal for the hobbyist.
Check it out, take a look at the comments. Since I basically took all the code and cobbled pieces together, there might be ways to make it more efficient or elegant. But it can roll over a thousand rolls in a second, so whats the need to worry about it? I suggest you enter the string "1000(1000d100)" and see how long it takes. I guess that'd be like a million rolls, right?
Code is posted as is, use it at your own peril. I encourage reuse and modification of it, just include the original author's name etc etc. All the normal stuff. I'm not responsible for any of your own stupid decisions.
This is the first, and probably last thing I will ever contribute. But, hey...at least its something!
Bitches!
P.S. If you find any bugs, let me know here.