You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.8 KiB
66 lines
1.8 KiB
score_to_points = {
|
|
15:9,
|
|
14:7,
|
|
13:5,
|
|
12:4,
|
|
11:3,
|
|
10:2,
|
|
9:1,
|
|
8:0
|
|
}
|
|
abilities = ['strength', 'dexterity', 'constitution', 'intelligence', 'wisdom', 'charisma']
|
|
|
|
def check_scores(scores):
|
|
total = 0
|
|
for score in scores.values():
|
|
total += score_to_points[score]
|
|
if total == 27:
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
def generates_scores(ability_index,ability_scores, possibilities):
|
|
if ability_index > 5:
|
|
if check_scores(ability_scores):
|
|
possibilities.append(ability_scores.copy())
|
|
else:
|
|
for score in score_to_points:
|
|
ability_scores[abilities[ability_index]] = score
|
|
generates_scores(ability_index+1, ability_scores, possibilities)
|
|
return possibilities
|
|
|
|
def print_possibilities(possibilities):
|
|
for possibility in possibilities:
|
|
object_string = ''
|
|
for ability in abilities:
|
|
object_string += ability + ': ' + str(possibility[ability]) + ', '
|
|
print(object_string)
|
|
|
|
def determine_modifier(score):
|
|
return int((score - 10) / 2)
|
|
|
|
def generate_ordered_scores_obj():
|
|
obj = {}
|
|
for i in range(0,19):
|
|
obj[i] = []
|
|
return obj
|
|
|
|
possibilities = generates_scores(0, {}, [])
|
|
|
|
ordered_possibilities = generate_ordered_scores_obj()
|
|
|
|
for possibility in possibilities:
|
|
total_modifiers = 0
|
|
for score in possibility:
|
|
total_modifiers += determine_modifier(possibility[score])
|
|
ordered_possibilities[total_modifiers].append(possibility)
|
|
|
|
for i in range(0,19):
|
|
if ordered_possibilities[i]:
|
|
print('=================')
|
|
print('')
|
|
print(i)
|
|
print('')
|
|
print('=================')
|
|
print_possibilities(ordered_possibilities[i])
|