DnD_5e.encounter package

Module contents

class DnD_5e.encounter.Encounter(**kwargs)[source]

Bases: object

This class is used for running encounters

get_copy_of_teams_and_combatants()[source]

Make a copy of the teams (and the combatants within them), so we have a state to reset to :return:

get_initial_teams()[source]
Returns:

the copy of self._teams that is stored in self._initial_state

get_initial_combatants()[source]
Returns:

the copy of self._combatants that is stored in self._initial_state

get_name() str[source]
Returns:

name

set_name(name: str)[source]
get_logger() Logger[source]
Returns:

logger

get_teams() list[source]
Returns:

teams

get_combatants() list[source]
Returns:

list of Combatant s

get_current_combatant()[source]
Returns:

the Combatant who should take a turn now

Return type:

Combatant

get_max_rounds() int[source]
Returns:

maximum number of rounds before aborting this encounter

get_round() int[source]
Returns:

round number

get_end_condition() bool[source]

Check to see if it is time to end this encounter

Returns:

False if at least two teams have some alive members, True otherwise

get_team_stats() dict[source]

Get stats for every Team :return:

get_combatant_stats() dict[source]

Get stats for every Combatant :return:

get_encounter_statnames()[source]

Return the stats (besides the ones for Combatant and Team) that this Encounter tracks. Used by a Simulation to know which stats to keep track of.

TODO: should this be a static method or a class method?

Returns:

get_stats() dict[source]

Get various stats about how the Encounter went

Returns:

a dict containing the stats

set_logger(logger: str)[source]

Set self._logger to the logger with the name specified in logger

Parameters:

logger – the name of the Logger to use, or the logging.Logger object itself

Returns:

None

add_team(the_team)[source]

Add a given Team to the encounter :param the_team: the Team to add :type the_team: Team :return:

roll_initiative()[source]
take_turn(comb)[source]

The specified Combatant takes their turn in combat

Parameters:

comb (Combatant) – the Combatant whose turn it is

Returns:

run()[source]

Run the encounter

Returns:

reset()[source]

Reset attributes of self and of the Combatants in this Encounter. Do this to prepare to run the Encounter again.

Returns:

None