Maps

This shows all the maps objects and usages.

All of these classes are importable from dofutils.maps

BattleFieldCell

class dofutils.maps.BattleFieldCell(id: 'int', walkable: 'bool', map: 'AbstractMap', coordinate: 'CoordinateCell', sight_blocking: bool)
sight_blocking: bool

Check if the cell block line of sight

CoordinateCell

class dofutils.maps.CoordinateCell(cell: 'AbstractMapCell')
direction_to(target: CoordinateCell) Direction

Compute the direction to the target cell

Parameters:

target (AbstractCoordinateCell) – The target cell

Returns:

The Direction

Return type:

Direction

distance(target: CoordinateCell) int

Get the cell distance Note: Don’t compute a pythagorean distance but “square” distance.

Parameters:

target (AbstractCoordinateCell) – The target cell

Returns:

The distance, in cell numbers

Return type:

int

x: int
y: int

Maps/Constant

This shows all the Constant maps objects and usages.

All of these classes are importable from dofutils.maps.constant

CellMovement

class dofutils.maps.constant.CellMovement(value)

An enumeration.

DEFAULT = 4
LESS_WALKABLE = 3
MOST_WALKABLE = 7
NOT_WALKABLE = 0
NOT_WALKABLE_INTERACTIVE = 1
PADDOCK = 5
ROAD = 6
TRIGGER = 2
static by_value(value: int) CellMovement

Get a cell movement by its value. Value must be in range [0-7]

Parameters:

value – The movement id

Returns:

The movement object

Raises:

ValueError – When value is not in range [0-7]

walkable() bool

Check if the current movement is for a walkable cell

Returns:

True if the cell is walkable, false otherwise

Direction

class dofutils.maps.constant.Direction(value)

An enumeration.

EAST = (0, <function Direction.<lambda>>)
NORTH = (6, <function Direction.<lambda>>)
NORTH_EAST = (7, <function Direction.<lambda>>)
NORTH_WEST = (5, <function Direction.<lambda>>)
SOUTH = (2, <function Direction.<lambda>>)
SOUTH_EAST = (1, <function Direction.<lambda>>)
SOUTH_WEST = (3, <function Direction.<lambda>>)
WEST = (4, <function Direction.<lambda>>)
static by_char(c: str) Direction

Get the direction by its char value

Parameters:

c – The direction character value

Returns:

The direction

next_cell_increment(width: int) int

Get the increment to apply to cell id for get the next cell on the direction

Parameters:

width – The map width

Returns:

The next cell id increment

Return type:

int

opposite() Direction

Get the opposite direction

Returns:

The opposite direction

Return type:

Direction

orthogonal() Direction

Get the orthogonal direction

Returns:

The orthogonal direction

Return type:

Direction

restricted() bool

Check if the direction is restricted. A restricted direction can be used in fight, or by monsters’s sprites Restricted direction do not allow diagonal

Returns:

True if the direction can be used when restrictions are enabled

static restricted_directions() list

Get the restricted direction (i.e can be used on fight)

Returns:

A list of restricted direction

Return type:

list

to_char() str

Get the char value of the direction

Returns:

The direction char value