DnD_5e.combatant.spellcaster module

class DnD_5e.combatant.spellcaster.SpellCaster(**kwargs)[source]

Bases: Combatant

A Combatant that can cast spells

current_eq(other) bool[source]

Compare self and other to determine if they are identical based on the attributes checked in equals and also these attributes: spell_slots

Parameters:

other (SpellCaster) – the SpellCaster to compare

Returns:

True if self is identical to other, False otherwise

Return type:

bool

get_spell_ability() str[source]
Returns:

spell ability

Return type:

str

get_spell_ability_mod() int[source]
Returns:

spell ability mod

Return type:

int

get_spell_save_dc() int[source]
Returns:

spell save dc

Return type:

int

get_spell_attack_mod() int[source]
Returns:

spell attack mod

Return type:

int

get_spell_slots() dict[source]
Returns:

spell slots

Return type:

dict mapping int to int

get_full_spell_slots() dict[source]
Returns:

full/maximum spell slots

Return type:

dict mapping int to int

get_level_spell_slots(level: int) int[source]

Determine the number of spell slots available for a given level

Parameters:

level (integer from 1 to 9 (inclusive)) – the spell level to look at

Returns:

the number of available spell slots

Return type:

int

Raise:

ValueError if level is invalid

get_spells() list[source]
Returns:

spells

Return type:

list of Spells

can_cast(spell: Spell) bool[source]

Determine if self can cast the given Spell. Note: does not check spell slots.

Parameters:

spell (py:class:Spell) – the Spell self is trying to cast

Returns:

True if self can cast spell, False otherwise

Return type:

bool

add_spell(spell: Spell)[source]

Add a given spell

Parameters:

spell (Spell) – the Spell to add

Returns:

None

Raise:

ValueError if spell is not a Spell

spend_spell_slot(level: int, spell=None)[source]

Spend a spell slot of the given level

Parameters:
  • level (an integer from 0 to 9 (inclusive)) – the spell level

  • spell (Spell) – the spell that is being used

Returns:

None

Raise:

ValueError if self doesn’t have any spell slots of level level

reset_spell_slots()[source]

Set spell slots to the maximum/full amount

Returns:

None