DnD_5e.weapons package

Module contents

class DnD_5e.weapons.Weapon(**kwargs)[source]

Bases: object

This class represents weapons

get_properties() set[source]
Returns:

properties

Return type:

set of strings

has_prop(prop) bool[source]

Determine whether self has a given property

Parameters:

prop – the property to check for

Returns:

True if self has property prop, False otherwise

Return type:

bool

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

range for ranged attacks

Return type:

TYPE_RANGE_TUPLE

get_melee_range() int[source]
Returns:

melee range

Return type:

non-negative integer

get_damage_dice() DamageDice[source]
Returns:

damage dice

Return type:

dice.DamageDice

get_damage_type()[source]
Returns:

damage type

has_damage_type(damage_type: str) bool[source]
Parameters:

damage_type (str) – the damage type to look for

Returns:

True if damage dice has the specified damage type, False otherwise

Return type:

bool

get_versatile() Tuple[int, int] | None[source]
Returns:

dice for two-handed attack with versatile weapon

Return type:

TYPE_DICE_TUPLE or None

get_name() str[source]
Returns:

name

Return type:

str

get_owner()[source]
Returns:

owner

get_attack_mod() int[source]
Returns:

attack mod

Return type:

int

get_damage_mod() int[source]
Returns:

damage mod

Return type:

int

set_name(name: str)[source]

Set self._name

Parameters:

name (str) – the name to change to

Returns:

None

Raise:

ValueError if name is not a string

set_owner(owner)[source]

Set self._owner to a given owner (not typechecked)

Parameters:

owner – the new owner of self

Returns:

None

set_attack_mod(attack_mod: int)[source]

Set self._attack_mod

Parameters:

attack_mod (int) – the new attack mod

Returns:

None

Raise:

ValueError if attack_mod is not an integer

set_damage_mod(damage_mod)[source]

Set self._damage_mod

Parameters:

damage_mod (int) – the new attack mod

Returns:

None

Raise:

ValueError if damage_mod is not an integer

get_attack_kwargs()[source]

Get the kwargs dictionaries for each Attack that can be made using this weapon. I would use this to build the attack themselves, but I need to avoid a circular import.

Returns:

a list of dicts, with one dictionary for each attack

Return type:

dict of dicts: key is the attack name, value is the attack kwargs

DnD_5e.weapons.weapon_list_equals(list1: list, list2: list) bool[source]

Function to compare two lists of Weapon s . Order matters for equality; [a, b, c] is not equal to [b, a, c]

Parameters:
  • list1 (list of Weapon s) – list of Weapons

  • list2 (list of Weapon s) – list of Weapons

Returns:

True if the lists are equal, False otherwise