pyherc.data.dungeon

Module containing classes to represent dungeon

Classes:
Level Dungeon Portal

Dungeon

class pyherc.data.dungeon.Dungeon

Represents the dungeon

Level

class pyherc.data.dungeon.Level(size=(0, 0), floor_type=None, wall_type=None)

Represents a level

add_creature(creature, location=None)

Add a creature to level @param creature: creature to add @param location: optional location for the creature

add_item(item, location)

Add an item to this level @param item: item to add @param location: location where to put the item

add_portal(portal, location, other_end=None)

Adds precreated portal on level at given location If secondary portal is specified, link them together @param portal: portal to add @param location: location where to add portal @param other_end: optional other end of the portal

blocks_los(x_coordinate, y_coordinate)

Checks if there’s LOS-blocking wall at given coordinates

dump_string()

Dump this level into a string

find_free_space()

Finds free space where stuff can be placed

get_creature_at(location)

Get list of creatures at given location @param location: location to check @return: creature if found

get_items_at(location)

Get list of items at location @param location: location to check

get_portal_at(location)

Check if there is a portal at given location @return: Portal if found, otherwise None

get_size()

Gets size of level @returns: tupple, with width and length of level

get_square(x_coordinate, y_coordinate)

Get square at given coordinates

get_tile(loc_x, loc_y)

Get tile at given location @param loc_x: x-coordinate of the location @param loc_y: y-coordinate of the location

get_wall_tile(loc_x, loc_y)

Get wall tile at given location @param loc_x: x-coordinate of the location @param loc_y: y-coordinate of the location

remove_creature(creature)

Remove creature from level @param creature: creature to remove

Portal

Portals are used to link levels together. They can be stairs, ladders or magical portals. Anything that allows characters to move from one level to another is a portal.

class pyherc.data.dungeon.Portal

Portal linking two levels together

generate_level()

Generates level if this is a proxy portal

get_other_end()

Returns the other end of the portal

set_other_end(portal)

Set the other end of the portal @param portal: portal where this one leads

Connecting levels

Two levels can be connected in following way

level_a = Level()
level_b = Level()

portal_a = Portal()
portal_b = Portal()

level_a.add_portal(portal_a, (5, 10))
level_b.add_portal(portal_b, (2, 2), portal_a)

Proxies

Proxies are special type of portal. They have only one end, while another end is left unspecified. They also have reference to a level generator. When a character tries to enter a proxy portal, new level is generated and linked with old level, via the portal. After this level generator is removed.

Proxies are used to generate dungeon while the player descents deeper and deeper. This speeds up start up of the game, allows game to adapt to player progress and reduces memory consumption.

Table Of Contents

Previous topic

pyherc.data

Next topic

pyherc.data.item

This Page