dungeon
index
/home/achifaifa/git/kirino/source/dungeon.py

#usr/bin/env python

 
Modules
       
common
math
mob
npc
os
player
random

 
Classes
       
dungeon

 
class dungeon
    Creates and manages dungeons and dungeon displaying features
 
#Size variables
xsize=0       #Horizontal dungeon size
ysize=0       #Vertical dungeon size
 
#Dungeon arrays
dungarray=[]  #Contains rock, empty, loot, etc
filled=[]     #This is what will be displayed to the player
explored=[]   #No use
traps=[]      #Array with the traps on that floor
 
#Mob and peddler data
mobarray=[]   #Array of mobs walking through the dungeon
vendorvar=0   #If 1, a vendor is generated in the floor
 
  Methods defined here:
__init__(self, x, y, vendor)
Class constructor. 
 
Receives two integers (x,y) that define the horizontal and vertical size.
 
It also receives a vendor variable. If set to 1 it generates a shop in a random position inside the dungeon.
 
Minimum size is 40x20. If something smaller is given, defaults at the minimum.
advmap(self, x, y, xmapsize, ymapsize)
Advanced map function. 
 
Displays a small area of the map. 
 
x and y are the coordinates of the dungeon array in which the advanced map is centered.
xmapsize and ymapsize are the horizontal and vertical size of the map. 
 
minimum size is 20x10. If something smaller is entered, it defaults at the smallest value. 
If the coordinates are too close to the edge, they are replaced so the map does not show anything outside the dungeon array.
advmapcoords(self, x, y)
Generates an advanced map (20x10) centered on the position (x,y)
debug(self)
Debug dungeon 
 
Returns an integer as error condition code:
  EC0: (Not actually an error, everything is fine)
  EC1: There is no entrance or exit
  EC2: It's below the minimum size
  EC3: Can't reach the exit from the entrance (pending)
  EC4: There are halls unconnected or unreachable (pending)
 
Used in the constructor on this class, although it can be invoked anytime.
dumpdung(self, place)
Generates a list of coordinates and tile type.
 
Needs a Place parameter indicatis where. 0 is return to console, anything else dumps it to a file
 
Avoid dumping to console with big dungeons, output turns out unreadable
fill(self, player, fog)
Fills the dungeon temporarily with PC and NPC object and mob markers. 
 
Needs a player and the fog parameter
 
Does not return anything, but modifies the filled array
if the parameter fog is 1, it displays a fogged minimap.
map(self)
Map generator. 
 
Creates a map of the dungeon on screen.
This shows the entire dungarray[][], so dungeons with a horizontal size larger than the horizontal console size will look weird.
minimap(self, player, fog)
Generates a minimap (advmap centered on the player object passed)
 
Uses the function fill(), so it needs the fog parameter too.
1=fog enabled, anything else fog disabled.
remember(self, player)
Processes the explored array.
 
For every intelligence point, a player can "memorize" up to 100 tiles.
If the explored map has more explored tiles than that, deletes random tiles until numbers fix.
 
This function should only be called when the fog is on
report(self)
Appends a map of the dungeon and a report message into a text file.
 
File is ../logs/report