Module containing classes to represent dungeon
Represents a level
Add a creature to level @param creature: creature to add @param location: optional location for the creature
Add an item to this level @param item: item to add @param location: location where to put the item
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
Checks if there’s LOS-blocking wall at given coordinates
Dump this level into a string
Finds free space where stuff can be placed
Get list of creatures at given location @param location: location to check @return: creature if found
Get list of items at location @param location: location to check
Check if there is a portal at given location @return: Portal if found, otherwise None
Gets size of level @returns: tupple, with width and length of level
Get square at given coordinates
Get tile at given location @param loc_x: x-coordinate of the location @param loc_y: y-coordinate of the location
Get wall tile at given location @param loc_x: x-coordinate of the location @param loc_y: y-coordinate of the location
Remove creature from level @param creature: creature to remove
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.
Portal linking two levels together
Generates level if this is a proxy portal
Returns the other end of the portal
Set the other end of the portal @param portal: portal where this one leads
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 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.