gammatools/app/functions/get_attack_roll_outcome.py

27 lines
785 B
Python

from app.functions.roll_dices import roll_dices
def get_attack_roll_outcome(result, modifier=0):
outcome = 'Unknown'
raw_roll = roll_dices(1, 20, False).get('result')
needed = result['needed']
if modifier != 0:
result["original-roll"] = raw_roll
result["modifier"] = modifier
rolled = raw_roll + modifier # negative modifiers will subtract themselves naturally
result["adjusted-roll"] = rolled
else:
rolled = raw_roll
result["original-roll"] = rolled
if (rolled >= 20) and (needed <= 16):
outcome = "Devastating Success!"
elif needed <= rolled:
outcome = "Attack Successful!"
elif needed > rolled:
outcome = "Attack Failed!"
result['outcome'] = outcome
return result