gammatools/app/functions/role_physical_attack.py

33 lines
1.5 KiB
Python
Raw Normal View History

2024-06-29 14:40:39 +00:00
from app.functions.get_attack_roll_outcome import get_attack_roll_outcome
from app.tables.physattack import AttackerHitDiceMatrix, AttackerWeaponClassMatrix
def roll_physical_attack(weapon_attack, dac, modifier, awc=0, ahd=0):
"""
:param weapon_attack: boolean. required. Determines which attack matrix to use.
:param dac: integer. required. defender armour class. used in both matrices.
:param modifier: integer. required. any pluses or minuses to be applied to roll
:param awc: integer. optional(*). Attacker weapon class. This is required, if weapon attack == True.
:param ahd: integer. optional(*). Attacker hit dice. This is required, if weapon attack == False.
:return:
"""
result = {}
if weapon_attack:
if awc == 0:
print("Attacker Weapon Class is required for Weapon Attacks!")
result["outcome"] = "Attacker Weapon Class is required for Weapon Attacks!"
return result
else:
hit_table = AttackerWeaponClassMatrix()
result["needed"] = hit_table.get_attack_score(awc, dac)
else:
if ahd == 0:
print("Attacker Hit Dice is required for Non-Weapon Attacks!")
result["outcome"] = "Attacker Hit Dice is required for Non-Weapon Attacks!"
return result
else:
hit_table = AttackerHitDiceMatrix()
result["needed"] = hit_table.get_attack_score(ahd, dac)
return get_attack_roll_outcome(result, modifier)