gammatools/app/functions/roll_ability_scores.py

30 lines
1.1 KiB
Python
Raw Normal View History

from app.functions.roll_dices import roll_dices
def roll_ability_scores(chartype, attribute=None):
if attribute is None or attribute == "all":
ability_list = ['p-strength', 'm-strength', 'constitution', 'dexterity', 'charisma', 'intelligence']
else:
ability_list = [attribute]
ability_scores = {}
for abil in ability_list:
if ((chartype == 'human') and
((abil == 'intelligence') or
(abil == 'charisma') or
(abil == 'constitution'))):
roll = roll_dices(4, 6, False) # humans are special
if (abil == 'constitution') and roll["result"] > 18:
roll["capped"] = True
roll["result"] = 18
if (abil == 'intelligence' or abil == 'charisma') and roll["result"] > 21:
roll["capped"] = True
roll["result"] = 21
ability_scores[abil] = roll["result"]
else:
roll = roll_dices(4, 6, True) # nothing else is special
ability_scores[abil] = roll["result"]
return ability_scores