DnD_5e.attack_class.spell_attacks module

class DnD_5e.attack_class.spell_attacks.Spell(**kwargs)[source]

Bases: Attack

This class represents spells

get_level() int[source]
Returns:

level

Return type:

integer between 1 and 9 (inclusive)

get_school()[source]
Returns:

school of magic

get_casting_time() int[source]
Returns:

amount of time it takes cast self, in rounds

Return type:

a positive integer for the number of rounds, or one of these strings: “1 action”, “1 bonus action”, “1 reaction”

get_components() list[source]
Returns:

the components needed to cast self

Return type:

list of strings

has_component(component: str) bool[source]
Parameters:

component (str) – the component in question

Returns:

True if self has that component, False otherwise

Return type:

bool

get_duration() int[source]
Returns:

duration in rounds

Return type:

non-negative integer

get_ritual() bool[source]
Returns:

whether spell can be cast as a ritual

make_attack(source, target, adv: int = 0, level: int | None = None) int[source]

First, try to spend the appropriate spell slot. Then, call the superclass method.

Parameters:
  • source (Combatant) – the Combatant that is making the attack

  • target (Combatant) – the Combatant that source is attacking

  • adv (one of these integers: -1, 0, 1) – advantage, disadvantage, or neither on the attack roll

  • level (integer between 1 and 9 (inclusive)) – the level the spell is being cast at

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.spell_attacks.SavingThrowSpell(**kwargs)[source]

Bases: Spell, SavingThrowAttack

Spells that require the target to make a saving throw

class DnD_5e.attack_class.spell_attacks.HealingSpell(**kwargs)[source]

Bases: Spell

Spells that heal (i.e., add hit points) instead of dealing damage; damage is used as healing

make_attack(source, target, adv: int = 0, level=None) int[source]

Spend the appropriate spell slot, then roll damage and heal the target for that amount

Parameters:
  • source (Combatant) – the Combatant that is sending the healing

  • target (Combatant) – the Combatant that source is healing

  • adv (one of these integers: -1, 0, 1) – advantage, disadvantage, or neither on the attack roll (NOT USED FOR THIS METHOD)

  • level (integer between 1 and 9 (inclusive)) – the level the spell is being cast at

Returns:

the points the target is healed for

Return type:

non-negative integer

Raise:

ValueError if input is invalid