2024-07-01 00:56:11 +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(dac, modifier=0, awc=None, ahd=None):
|
|
|
|
"""
|
|
|
|
: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:
|
|
|
|
"""
|
2024-07-01 10:26:54 +00:00
|
|
|
if modifier is None:
|
|
|
|
modifier = 0
|
2024-07-01 00:56:11 +00:00
|
|
|
|
2024-07-01 10:26:54 +00:00
|
|
|
result = {}
|
2024-07-01 00:56:11 +00:00
|
|
|
if isinstance(awc, int):
|
|
|
|
hit_table = AttackerWeaponClassMatrix()
|
|
|
|
result["needed"] = hit_table.get_attack_score(awc, dac)
|
|
|
|
elif isinstance(ahd, int):
|
|
|
|
hit_table = AttackerHitDiceMatrix()
|
|
|
|
result["needed"] = hit_table.get_attack_score(ahd, dac)
|
|
|
|
# use non-weapon attack lookup table
|
|
|
|
else:
|
|
|
|
# handle error state where neither awc nor ahd are integers (None or other non-integer value)
|
|
|
|
result["outcome"] = "Attacker Hit Dice is required for Non-Weapon Attacks!"
|
|
|
|
return result
|
|
|
|
|
|
|
|
return get_attack_roll_outcome(result, modifier)
|