Created
April 9, 2017 02:25
-
-
Save stewsters/7d3a0c75b3f7ba60ea18defa8d6416b6 to your computer and use it in GitHub Desktop.
Roll a number of characters
This file contains hidden or 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
int numberOfCharacter = 5 | |
def stats = ['str', 'dex', 'con', 'wis', 'int', 'cha'] | |
stats.each { | |
print it + "\t" | |
} | |
println() | |
numberOfCharacter.times { | |
for (String stat : stats) { | |
def rolls = [] | |
4.times { | |
rolls += d(6) | |
} | |
total = rolls.sum() - rolls.min() | |
print total + "\t" | |
} | |
println() | |
} | |
int d(int max) { | |
new Random().nextInt(max) + 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment