DnD_5e.character_classes package

Submodules

DnD_5e.character_classes.barbarian module

class DnD_5e.character_classes.barbarian.Barbarian(**kwargs)[source]

Bases: Character

Barbarian character class

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: rage slots, rage state

Parameters:

other – the Barbarian to compare

Returns:

True if self is identical to other, False otherwise

Return type:

bool

get_rage_slots() int[source]
Returns:

rage slots

Return type:

non-negative integer

get_rage_damage_bonus() int[source]
Returns:

rage damage bonus

Return type:

int

is_raging() bool[source]
Returns:

True if self is raging, False otherwise

Return type:

bool

start_rage()[source]

Go into a rage state

Returns:

None

stop_rage()[source]

Stop the rage state

Returns:

None

start_reckless()[source]

Enter this state when attacking recklessly. It lasts for one round.

Returns:

None

stop_reckless()[source]

End the reckless state. This happens after one round of recklessly attacking.

Returns:

None

make_saving_throw(save_type: str, adv=0)[source]

Roll a saving throw of the given type. This is different from the superclass method in that it is affected by raging and the “danger sense” feature.

Parameters:
  • save_type (one of these strings: "strength", "dexterity", "constitution", "intelligence", "wisdom", "charisma") – the kind of saving throw to make

  • adv (int) – indicates advantage (positive), disadvantage (negative), or neither (0)

Returns:

the number rolled for the saving throw

Return type:

int

become_unconscious()[source]

Go unconscious. This differs from the superclass method in that self may drop to 1 hit point instead due to the “relentless rage” feature. If self saves, then self drops to 1 hit point. Otherwise, self is unconscious and has current hp of 0

Returns:

None

send_attack(target, attack, adv=0)[source]

Attack a given target using a given attack. This differs from the superclass method in that if self is recklessly attacking, the attack has advantage

Parameters:
  • target (Combatant) – the Combatant to attack

  • attack (Attack) – the Attack being made

  • adv (int) – indicates whether self has advantage for this attack

Returns:

the damage target took from attack, or None if the attack failed to hit

DnD_5e.character_classes.bard module

class DnD_5e.character_classes.bard.Bard(**kwargs)[source]

Bases: SpellCaster, Character

Bard character class

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: inspiration slots

Parameters:

other – the Bard to compare

Returns:

True if self is identical to other, False otherwise

Return type:

bool

get_inspiration_dice() Tuple[int, int][source]
Returns:

inspiration dice

Return type:

TYPE_DICE_TUPLE

get_inspiration_slots() int[source]
Returns:

inspiration slots

Return type:

non-negative integer

send_inspiration(target: Combatant)[source]

Give an inspiration die to target. NOT IMPLEMENTED YET (i.e., nobody can take inspiration)

Parameters:

target (Combatant) – the Combatant to give inspiration to

Returns:

None

DnD_5e.character_classes.cleric module

class DnD_5e.character_classes.cleric.Cleric(**kwargs)[source]

Bases: SpellCaster, Character

Cleric character class

current_eq(other) bool[source]

Check to see if self is identical to other by looking at everything in equals as well as the following attributes: channel divinity slots

Parameters:

other (Cleric) – the Cleric to be compared

Returns:

True if self is identical to other, False otherwise

Return type:

bool

get_channel_divinity_slots() int[source]
Returns:

channel divinity slots

Return type:

non-negative integer

channel_divinity(use_type: str = 'turn undead')[source]

Channel divinity (uses 1 Channel Divinity slot)

Parameters:

use_type (str) – the kind of use (e.g., “turn undead”)

Returns:

None

get_destroy_undead_cr()[source]
Returns:

Max challenge rating of Creatures that will be destroyed with Destroy Undead

Return type:

number

DnD_5e.character_classes.druid module

class DnD_5e.character_classes.druid.Druid(**kwargs)[source]

Bases: SpellCaster, Character

Druid character class

current_eq(other) bool[source]

Check to see if self is identical to other by looking at everything in equals as well as the following attributes: wild shape slots, wild shapes, current shape

Parameters:

other (Druid) – the Druid to be compared

Returns:

True if self is identical to other, False otherwise

Return type:

bool

get_wild_shape_slots() int[source]
Returns:

wild shape slots

Return type:

int

get_wild_shapes() set[source]
Returns:

wild shapes

Return type:

set of Creatures

get_current_shape() Creature | None[source]
Returns:

current shape (or None if in original shape)

Return type:

Creature (or None)

get_ac() int[source]

If a wild shape is active, use the statistics of the wild shape

Returns:

armor class

Return type:

positive integer

get_hit_dice() Tuple[int, int][source]

If a wild shape is active, use the statistics of the wild shape

Returns:

hit dice

Return type:

TYPE_DICE_TUPLE

get_max_hp() int[source]

If a wild shape is active, use the statistics of the wild shape

Returns:

max hit points

Return type:

positive integer

get_temp_hp() int[source]

If a wild shape is active, use the statistics of the wild shape

Returns:

temporary hit points

Return type:

non-negative integer

get_current_hp() int[source]

If a wild shape is active, use the statistics of the wild shape

Returns:

current hit points

Return type:

non-negative integer

is_bloodied() bool[source]

Tell whether self is bloodied (current hit points at or below half of maximum). If a wild shape is active, use the statistics of the wild shape.

Returns:

True if self is bloodied, False otherwise

Return type:

bool

is_hp_max() bool[source]

If a wild shape is active, use the statistics of the wild shape

Returns:

True if current hp equals max hp, False otherwise

Return type:

bool

get_speed() int[source]

If a wild shape is active, use the statistics of the wild shape

Returns:

speed

Return type:

positive integer

get_vision() str[source]

If a wild shape is active, use the statistics of the wild shape

Returns:

vision

Return type:

one of these strings: “normal”, “darkvision”, “blindsight”, “truesight”

get_ability(ability: str) int[source]

If a wild shape is active, use the statistics of the wild shape

Parameters:

ability (one of these strings: "strength", "dexterity", "constitution", "intelligence", "wisdom", "charisma") – the name of an ability score

Returns:

the ability score modifier

Return type:

int

Raise:

ValueError if ability is not valid

get_strength() int[source]

If a wild shape is active, use the statistics of the wild shape

Returns:

strength modifier

Return type:

int

get_dexterity() int[source]

If a wild shape is active, use the statistics of the wild shape

Returns:

dexterity modifier

Return type:

int

get_constitution() int[source]

If a wild shape is active, use the statistics of the wild shape

Returns:

constitution modifier

Return type:

int

get_proficiencies() set[source]

If a wild shape is active, use the statistics of the wild shape

Returns:

proficiencies

Return type:

set of strings

get_vulnerabilities() set[source]

If a wild shape is active, use the statistics of the wild shape

Returns:

vulnerabilities

Return type:

set of strings

get_resistances() set[source]

If a wild shape is active, use the statistics of the wild shape

Returns:

resistances

Return type:

set of strings

get_immunities() set[source]

If a wild shape is active, use the statistics of the wild shape

Returns:

immunities

Return type:

set of strings

get_saving_throw(ability: str) int[source]

Get the modifier for an ability saving throw. Note: this does NOT roll the saving throw. If a wild shape is active, use the statistics of the wild shape.

Parameters:

ability (one of these strings: "strength", "dexterity", "constitution", "intelligence", "wisdom", "charisma') – an ability score name

Returns:

the modifier for an ability saving throw

Return type:

int

Raise:

ValueError if ability is not valid

get_attacks() list[source]

If a wild shape is active, use the statistics of the wild shape

Returns:

attacks

Return type:

list of Attacks

add_wild_shape(beast: Creature)[source]

Add a wild shape

Parameters:

beast (Creature) – the wild shape to add

Returns:

None

can_cast(spell)[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

take_damage(damage, damage_type=None, is_critical: bool = False)[source]

Take damage, applying vulnerabilities, resistances, and immunities as necessary. If self has a wild shape active, that beast takes damage first. If the beast reaches 0 hit points, the wild shape ends and self goes back to their original form and takes the rest of the damage.

Parameters:
  • damage (positive integer) – the number of hit points of damage to take

  • damage_type (str) – the type of damage

  • is_critical (bool) – whether the damage is from a critical hit

Returns:

the actual damage taken

Return type:

int

start_shape(beast: Creature)[source]

Shift into the given wild shape

Parameters:

beast (Creature) – the beast to shift into

Returns:

None

Raise:

ValueError if self has no wild shape slots left

end_shape()[source]

End the current wild shape

Returns:

None

Raise:

ValueError if self has no wild shape active

DnD_5e.character_classes.fighter module

class DnD_5e.character_classes.fighter.Fighter(**kwargs)[source]

Bases: Character

Fighter character class

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: action surge slots, indomitable

Parameters:

other (Fighter) – the Fighter to compare

Returns:

True if self is identical to other, False otherwise

Return type:

bool

get_second_wind_slots() int[source]
Returns:

second wind slots

Return type:

non-negative integer

get_action_surge_slots() int[source]
Returns:

action surge slots

Return type:

non-negative integer

get_extra_attack_num() int[source]
Returns:

the number of extra attacks (additional attacks allowed when using the attack action)

Return type:

non-negative integer

get_indomitable_slots() int[source]
Returns:

indomitable slots

Return type:

non-negative integer

take_action_surge()[source]

Do an action surge. NOT IMPLEMENTED YET.

Returns:

None

Raise:

ValueError if self has no action surge slots left

take_extra_attack()[source]

Make an extra attack. NOT IMPLEMENTED YET.

Returns:

None

Raise:

ValueError if self has no extra attack slots left

take_indomitable()[source]

Use the indomitable feature. NOT IMPLEMENTED YET.

Returns:

None

Raise:

ValueError if self doesn’t have indomitable slots

take_second_wind()[source]

Use the second wind feature. NOT IMPLEMENTED YET (i.e., this isn’t called anywhere).

Returns:

None

Raise:

ValueError if self doesn’t have second wind slots

DnD_5e.character_classes.monk module

class DnD_5e.character_classes.monk.Monk(**kwargs)[source]

Bases: Character

Monk character class

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: ki points

Parameters:

other (Monk) – the Monk to compare

Returns:

True if self is identical to other, False otherwise

Return type:

bool

get_martial_arts_dice() Tuple[int, int][source]
Returns:

martial arts dice

Return type:

TYPE_DICE_TUPLE

get_ki_points() int[source]
Returns:

ki points

Return type:

non-negative integer

get_ki_save_dc() int[source]
Returns:

ki save dc

Return type:

positive integer

spend_ki_points(num: int) int[source]

Spend num number of ki points

Parameters:

num – the number of ki points to spend

Returns:

None

Raise:

ValueError if self doesn’t have enough ki points or num is invalid

add_attack(attack)[source]

Add the given attack. If the attack is related to a monk weapon and dexterity mod is less than strength mod, change strength mod for attack and damage to dexterity mod.

Parameters:

attack (Attack) – the Attack to add

Returns:

None

DnD_5e.character_classes.paladin module

class DnD_5e.character_classes.paladin.Paladin(**kwargs)[source]

Bases: SpellCaster, Character

Paladin character class

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: divine sense slots, lay on hands pool, cleansing touch slots

Parameters:

other (Paladin) – the Paladin to compare

Returns:

True if self is identical to other, False otherwise

Return type:

bool

get_divine_sense_slots() int[source]
Returns:

divine sense slots

Return type:

non-negative integer

get_lay_on_hands_pool() int[source]
Returns:

the hit points in the lay on hands pool

Return type:

non-negative integer

get_aura() int[source]
Returns:

the number of feet for the aura features

Return type:

non-negative integer

get_cleansing_touch_slots() int[source]
Returns:

cleansing touch slots

Return type:

non-negative integer

spend_divine_sense_slot()[source]

Spend a divine sense slot

Returns:

None

Raise:

ValueError if self has no divine sense slots left

spend_cleansing_touch_slot()[source]

Spend a cleansing touch slot

Returns:

None

Raise:

ValueError if self has no cleansing touch slots left

send_lay_on_hands(hp: int, target=None, use='healing')[source]

Use the Lay on Hands feature

Parameters:
  • hp (non-negative integer) – the number of hit points to take from the Lay on Hands pool

  • target (Combatant) – the Combatant to use Lay on Hands on

  • use (str) – what to use Lay on Hands for

Returns:

the hit points healed for, if use is “healing”

Raise:

ValueError if self doesn’t have enough Lay on Hands points

send_divine_smite(target: Combatant, level=1) int[source]

Use Divine Smite on a specified target

Parameters:
  • target (Combatant) – the Combatant to use Divine Smite on

  • level (integer between 1 and 9 (inclusive)) – the level to cast Divine Smite at

Returns:

the damage taken

Return type:

non-negative integer

Raise:

ValueError if self doesn’t have the Divine Smite feature

DnD_5e.character_classes.ranger module

class DnD_5e.character_classes.ranger.Ranger(**kwargs)[source]

Bases: SpellCaster, Character

Ranger character class

get_favored_enemies()[source]
Returns:

favored enemies

Return type:

set of strings

has_favored_enemy(enemy) bool[source]

Determine whether the given enemy is favored or not

Parameters:

enemy (Creature or str) – the enemy or name of the enemy

Returns:

True if enemy is a favored enemy, False otherwise

Return type:

bool

get_favored_terrains() set[source]
Returns:

favored terrains

Return type:

set of strings

has_favored_terrain(terrain) bool[source]

Determine whether the given terrain is favored or not

Parameters:

terrain (str) – the terrain to look at

Returns:

True if terrain is a favored terrain, False otherwise

Return type:

bool

DnD_5e.character_classes.rogue module

class DnD_5e.character_classes.rogue.Rogue(**kwargs)[source]

Bases: Character

Rogue character class

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: stroke of luck slots

Parameters:

other (Rogue) – the Rogue to compare

Returns:

True if self is identical to other, False otherwise

Return type:

bool

can_see(light_src: str) bool[source]

Determine whether self can see a given light source. If self can’t see according to superclass method, look at blindsense feature.

Parameters:

light_src (one of these strings: "normal", "dark", "magic") – a kind of light

Returns:

True if self can see light_src, False otherwise

Return type:

bool

get_adv_to_be_hit() int[source]

The sum of advantage (+1) and disadvantage (-1) circumstances affecting self is stored in self._adv_to_be_hit. Look at this number and return an integer indicating whether an attack against self has advantage, disadvantage, or neither. Look at the “elusive” feature.

Returns:

positive if attacks against self have advantage, negative if they have disadvantage, and 0 otherwise

Return type:

one of these integers: -1, 0, 1

get_stroke_of_luck_slots() int[source]
Returns:

stroke of luck slots

Return type:

non-negative integer

get_sneak_attack_dice() Tuple[int, int][source]
Returns:

sneak attack dice

Return type:

TYPE_DICE_TUPLE

can_make_sneak_attack(weapon, target, adv) bool[source]

Determine if self can make a sneak attack against target. NOT IMPLEMENTED YET

Parameters:
  • weapon (Weapon) – the Weapon used for the attack

  • target (Combatant) – the Combatant being attacked

  • adv (int) – advantage (positive), disadvantage (negative), or neither (0)

Returns:

True if self can make a sneak attack against target, False otherwise

Return type:

bool

roll_sneak_attack_dice() int[source]

Roll sneak attack dice

Returns:

the number rolled by the sneak attack dice

Return type:

non-negative integer

take_stroke_of_luck()[source]

Use the Stroke of Luck feature. NOT IMPLEMENTED YET.

Returns:

None

Raise:

ValueError if self has no stroke of luck slots

send_attack(target, attack, adv=0) int | None[source]

Attack a given target using a given attack. Roll and add sneak attack damage if applicable

Parameters:
  • target (Combatant) – the Combatant to attack

  • attack (Attack) – the Attack being made

  • adv (int) – indicates whether self has advantage for this attack

Returns:

the damage target took from attack, or None if the attack failed to hit

DnD_5e.character_classes.sorcerer module

class DnD_5e.character_classes.sorcerer.Sorcerer(**kwargs)[source]

Bases: SpellCaster, Character

Sorcerer character class

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: sorcery points

Parameters:

other (Sorcerer) – the Sorcerer to compare

Returns:

True if self is identical to other, False otherwise

Return type:

bool

get_sorcery_points() int[source]
Returns:

sorcery points

Return type:

non-negative integer

get_full_sorcery_points() int[source]
Returns:

full sorcery points

Return type:

non-negative integer

get_metamagic() set[source]
Returns:

metamagic

Return type:

set of strings

has_metamagic(item: str) bool[source]

Determine whether self has a given metamagic

Parameters:

item (str) – the metamagic to check for

Returns:

True if self has the metamagic item, False otherwise

Return type:

bool

spend_sorcery_points(points: int) int[source]

Spend a given number of sorcery points

Parameters:

points (non-negative integer) – the number of sorcery points to spend

Returns:

the number of sorcery points spent

Return type:

positive integer

Raise:

ValueError if points is invalid or self doesn’t have enough sorcery points

reset_sorcery_points()[source]

Reset sorcery points

Returns:

None

spell_slot_to_sorcery_points(level: int)[source]

Convert a spell slot to sorcery points

Parameters:

level (integer between 1 and 9 (inclusive)) – the level of the spell slot being used

Returns:

None

Raise:

ValueError if level is invalid

sorcery_points_to_spell_slot(level: int) int[source]

Convert sorcery points to a spell slot

Parameters:

level (integer between 1 and 5 (inclusive)) – the level of spell slot to gain

Returns:

the number of sorcery points spent

Return type:

positive integer

:raise ValueError if level is invalid

add_metamagic(item: str)[source]

Add the given metamagic

Parameters:

item (one of these strings: "careful", "distant", "empowered", "extended", "heightened", "quickened", "subtle", "twinned") – the metamagic to add

Returns:

None

Raise:

ValueError if item is invalid

DnD_5e.character_classes.warlock module

class DnD_5e.character_classes.warlock.Warlock(**kwargs)[source]

Bases: SpellCaster, Character

Warlock character class

get_pact_boon() str | None[source]
Returns:

pact boon

Return type:

str (or None)

get_eldritch_invocations() set | None[source]
Returns:

eldritch invocations

Return type:

set of strings (or None)

has_eldritch_invocation(invocation: str) bool[source]

Determine if self has a given eldritch invocation

Parameters:

invocation (str) – the eldritch invocation to look for

Returns:

True if self has the eldritch invocation invocation, False otherwise

Return type:

bool

DnD_5e.character_classes.wizard module

class DnD_5e.character_classes.wizard.Wizard(**kwargs)[source]

Bases: SpellCaster, Character

Wizard character class

current_eq(other)[source]

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

Parameters:

other (Wizard) – the Wizard to compare

Returns:

True if self is identical to other, False otherwise

Return type:

bool

get_spell_mastery_names() set[source]
Returns:

name of Spells that self has Spell Mastery for

Return type:

set of strings

has_spell_mastery(item) bool[source]

Determine if self has mastery of a given spell

Parameters:

item (Spell or str) – a Spell or name of a Spell

Returns:

True if self has mastery of the spell item, False otherwise

Return type:

bool

get_signature_spell_slots() dict[source]
Returns:

signature spell slots

Return type:

dict mapping spell names to the number of slots left to use that as a signature spell

get_signature_spells() list[source]
Returns:

singature spell names

Return type:

list of strings

has_signature_spell(item) bool[source]

Determine whether a given spell is a signature spell

Parameters:

item (Spell or str) – a Spell or the name of a Spell

Returns:

True if item is a signature spell, False otherwise

Return type:

bool

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

Spend a spell slot of the given level. Deal with spell mastery and signature spells appropriately.

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

Module contents