DnD_5e.attack_class.saving_throw_attacks module
- class DnD_5e.attack_class.saving_throw_attacks.SavingThrowMixin(**kwargs)[source]
Bases:
object- get_save_type() str[source]
- Returns:
ability score for saving throws
- Return type:
one of these strings: “strength”, “dexterity”, “constitution”, “intelligence”, “wisdom”, “charisma”
- get_prob_fail_save(**kwargs)[source]
- Parameters:
target (
Combatant) – the target you are forcing to make the saving throwmod (int) – the modifier for the target’s saving throw. Use this or target
- Returns:
the probability that target (or somebody with a saving throw modifier of mod) fails the saving throw
- class DnD_5e.attack_class.saving_throw_attacks.SavingThrowAttack(**kwargs)[source]
Bases:
SavingThrowMixin,AttackThis class represents Attacks that require a saving throw from the target instead of a roll to hit
- get_prob_hit(**kwargs) float[source]
- Parameters:
target – the target who is making the saving throw
mod – the target’s modifier to the saving throw
- Returns:
the probability of target failing their saving throw
- get_dpr(**kwargs) float[source]
- Parameters:
target (
Combatant) – the target you are trying to hit- Returns:
the average damage per round (dpr)
- make_attack(source, target, adv=0) int | None[source]
Call target.
take_saving_throw()to see if the target makes the save. Callsend_damage()(that method will handle whether to damage on a successful save).- Parameters:
- Returns:
the damage taken (if the attack misses, damage taken is None)
- Return type:
non-negative integer or None
- Raise:
ValueError if target can’t take attacks
- on_hit(source, target, adv=0, crit=0)[source]
The target failed the save, now do whatever happens on a failed save
- on_miss(source, target, adv=0, crit=0)[source]
The target made the save, now do whatever happens on a successful save
- class DnD_5e.attack_class.saving_throw_attacks.SaveOrDieAttack(**kwargs)[source]
Bases:
SavingThrowMixin,AttackAttacks where the target must make a saving throw and if it fails it dies. Does not work for attacks that have a saving throw and then a save or die. For that, you need a different approach (maybe a MultiAttack?)
- get_save_on_miss() bool[source]
- Returns:
True if the target still has to make the saving throw if the main attack missed, False otherwise
- get_dpr(**kwargs) float[source]
Calculate the damage per round, assuming that if the target fails the saving throw (and thus dies), they also take the damage of
- Parameters:
target (
Combatant) – the target you are trying to hit- Returns:
the average damage per round (dpr)
- make_attack(source, target, adv: int = 0)[source]
Roll attack using
roll_attack()and store the result in variable result. Call target.take_attack()to see if the attack hits. If the attack hits, callsend_damage().- Parameters:
- Returns:
the damage taken (if the attack misses, damage taken is None)
- Return type:
non-negative integer or None
- Raise:
ValueError if source can’t send attacks or target can’t take attacks
- class DnD_5e.attack_class.saving_throw_attacks.HitAndSaveAttack(**kwargs)[source]
Bases:
SavingThrowMixin,AttackAttacks where the attacker makes a regular (roll to hit) attack and then, if that hits, makes a saving throw attack
- on_hit(source, target, adv=0, crit=0)[source]
The attack hit! Do all the normal Attack stuff (i.e., send damage), then have the target make a saving throw. :param source: the Combatant that is making the attack :type source: Combatant :param target: the Combatant that source is attacking :type target: Combatant :param adv: advantage, disadvantage, or neither on the attack roll :type adv: one of these integers: -1, 0, 1 :type crit: whether or not the hit was a crit :return: the total damage taken
- roll_save_damage()[source]
Roll
_damage_dice(if crit == 1, multiply the number of dice to roll by crit_multiplier), then add_damage_mod- Returns:
the damage rolled
- Return type:
namedtuple
- Raise:
ValueError if crit_multiplier is invalid