Created
May 25, 2017 17:52
-
-
Save luismasuelli/420f1a300d8570034e4d01d555516737 to your computer and use it in GitHub Desktop.
Dice rolling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Random.srand | |
class Integer | |
def d n | |
times.map{|_e| Random.rand(n) + 1}.inject 0, :+ | |
end | |
private :d | |
def d2 | |
d 2 | |
end | |
def d4 | |
d 4 | |
end | |
def d6 | |
d 6 | |
end | |
def d8 | |
d 8 | |
end | |
def d10 | |
d 10 | |
end | |
def d12 | |
d 12 | |
end | |
def d20 | |
d 20 | |
end | |
def d100 | |
d 100 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment