Skip to content

Instantly share code, notes, and snippets.

@stewsters
Created April 9, 2017 02:25
Show Gist options
  • Save stewsters/7d3a0c75b3f7ba60ea18defa8d6416b6 to your computer and use it in GitHub Desktop.
Save stewsters/7d3a0c75b3f7ba60ea18defa8d6416b6 to your computer and use it in GitHub Desktop.
Roll a number of 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