Esempio n. 1
0
 def getLoot(self, e):
     lootItems = []
     lootItems.append( (const.GOLD, random.randrange(enemyScr.lootDict[e]-3, 
                                          enemyScr.lootDict[e]+3) ) )
     if misc.rollDie(0, 4):
         lootItems.append( (const.PARCHMENT, random.choice( mapScr.parchByLevel[self.myWorld.currentMap.level] ) ) )
     return lootItems
Esempio n. 2
0
 def getLoot(self, e):
     lootItems = []
     lootItems.append((const.GOLD,
                       random.randrange(enemyScr.lootDict[e] - 3,
                                        enemyScr.lootDict[e] + 3)))
     if misc.rollDie(0, 4):
         lootItems.append(
             (const.PARCHMENT,
              random.choice(
                  mapScr.parchByLevel[self.myWorld.currentMap.level])))
     return lootItems
Esempio n. 3
0
    def heroTurn(self, game, enemy, board_):
        hero = game.myHero
        (cHP, mHP, cMP, mMP, sth, dex, itl, scr, kys, cEX, nEX,
         psn) = hero.getPlayerStats()
        (armor, weapon) = (hero.getArmorEquipped(), hero.getWeaponEquipped())
        action = self.getAction(game)
        if action == 'Fight':
            #hero attacks
            #self.heroImg = self.heroImgs[1]
            self.drawHeroAttack(game, enemy)
            a = random.randrange(0, dex + 5)
            if not (a > dex):
                dmg = random.randrange(sth / 2, sth) + weapon.getLevel()**2
                game.textMessage('You hit the ' + enemy.getName() + ' for ' +
                                 str(dmg) + ' points!')
                game.SFX.play(1)
                self.damageEnemy(game, enemy, dmg)
            else:
                game.textMessage("You missed The " + enemy.getName() + "!")
                game.SFX.play(2)
            return True
        elif action == 'Magic':
            dmg = hero.castSpell(
                self.myMenu.invMenu(game, hero.getSpells(), "Spells:",
                                    ['Cast', 'Return']), game, True)
            if dmg in [True, False]: return dmg
            else:
                self.damageEnemy(game, enemy, dmg)
                return True

        elif action == 'Item':
            dmg = hero.useItem(
                self.myMenu.invMenu(game, hero.getItems(), "Items:",
                                    ['Use', 'Return']), game, True)
            if dmg in [True, False]: return dmg
            else:
                self.damageEnemy(game, enemy, dmg)
                return True

        elif action == 'Flee':
            if misc.rollDie(1, 3):
                game.textMessage("You escaped safely.")
                game.FX.scrollFromCenter(self.battleField, board_)
                return 'escaped'
            else:
                game.textMessage("You can't escape!")
                return True
Esempio n. 4
0
    def generateMap(self):
        self.Z = self.maze()
        self.matrixToMap(self.Z)

        while not self.generalmap.pathfinder((1, self.DIM - 2),
                                             (self.DIM - 2, 1)):
            self.Z = self.maze()
            self.matrixToMap(self.Z)

        self.generalmap.setEntry(0, 0, 40)
        self.generalmap.setEntry(1, self.DIM - 2, const.STAIRDN)
        self.generalmap.pointOfExit = (1, self.DIM - 2)
        self.generalmap.setEntry(self.DIM - 2, 1, const.STAIRUP)
        self.generalmap.pointOfEntry = (self.DIM - 2, 1)
        self.generalmap.heroStart = (self.DIM - 2, 1)

        i = 0
        while i < 15:
            tile = self.getRandomTile('open')
            if tile == None:
                pass
            else:
                self.generalmap.NPCs.append(
                    (tile,
                     choice(
                         enemyScr.enemiesByDungeonLevel[self.generalmap.level])
                     ))
                i += 1
        i = 0
        chestList = []
        while i < 5:
            chestItems = []
            tile = self.getRandomTile('closed')
            if tile == None:
                pass
            else:
                chestItems.append((const.PARCHMENT - const.FRUIT1,
                                   choice(mapScr.parchByLevel[self.level])))
                if misc.rollDie(0, 2):
                    chestItems.append(
                        (13, choice(range(15, 50) + range(15, 30))))
                chestList.append((tile, chestItems))
                (x, y) = tile
                self.generalmap.setEntry(x, y, 110)
                i += 1
        self.generalmap.chests = dict(chestList)
Esempio n. 5
0
 def generateMap(self):
     for i in range(self.generalmap.DIM):
         for j in range(self.generalmap.DIM):
             if misc.rollDie(50,100):
                 self.generalmap.setEntry(i,j, const.DFLOOR1)
             else:
                 self.generalmap.setEntry(i,j, const.CAVEWALL1)
     #borders
     for i in range(self.generalmap.DIM):
         self.generalmap.setEntry(i,0, const.CAVEWALL1)
         self.generalmap.setEntry(i,self.generalmap.DIM-1, const.CAVEWALL1)
         self.generalmap.setEntry(0,i, const.CAVEWALL1)
         self.generalmap.setEntry(self.generalmap.DIM-1,i, const.CAVEWALL1)
     for i in range(4):
         self.singlePass()
         #self.draw()
     self.generalmap.pointOfEntry = ( 0,0 )
     self.generalmap.pointOfExit = ( 0,0 )
     self.generalmap.heroStart = ( 0,0 )
Esempio n. 6
0
 def heroTurn(self, game, enemy, board_):
     hero = game.myHero
     (cHP, mHP, cMP, mMP, sth, dex, itl, scr, kys, cEX, nEX, psn) = hero.getPlayerStats()
     (armor, weapon) = ( hero.getArmorEquipped(), hero.getWeaponEquipped() )
     action = self.getAction(game)
     if action == 'Fight':
         #hero attacks
         #self.heroImg = self.heroImgs[1]
         self.drawHeroAttack(game, enemy)
         a = random.randrange(0, dex+5)
         if not (a > dex):
             dmg = random.randrange(sth/2,sth) + weapon.getLevel()**2
             game.textMessage('You hit the '+enemy.getName() +' for '+str(dmg)+' points!')
             game.SFX.play(1)
             self.damageEnemy(game, enemy, dmg)
         else:
             game.textMessage("You missed The "+enemy.getName()+"!")
             game.SFX.play(2)
         return True
     elif action == 'Magic':
         dmg = hero.castSpell( self.myMenu.invMenu(game, hero.getSpells(), "Spells:", ['Cast', 'Return'] ), game, True )
         if dmg in [True, False]: return dmg
         else:
             self.damageEnemy(game, enemy, dmg)
             return True
         
     elif action == 'Item':
         dmg = hero.useItem(self.myMenu.invMenu(game, hero.getItems(), "Items:", ['Use', 'Return'] ), game, True )
         if dmg in [True, False]: return dmg
         else:
             self.damageEnemy(game, enemy, dmg)
             return True
         
     elif action == 'Flee':
         if misc.rollDie(1,3):
             game.textMessage("You escaped safely.")
             game.FX.scrollFromCenter(self.battleField, board_)
             return 'escaped'
         else:
             game.textMessage("You can't escape!")
             return True
Esempio n. 7
0
 def stockStore(self, level):
     itemsList = shopScr.armoriesByLevel[ level ]
     items = []
     self.prices[level] = {}
     for i in range(4):
         cItem = random.choice( itemsList )
         if misc.rollDie(level, level+5):
             resist = random.choice( armorScr.resists )
         else: resist = None
         if cItem == const.RING:
             enh = random.choice( shopScr.enhancementsByLevel[level] )
             A = armor.Ring( cItem, resist, (enh, random.randrange(level, level+2)) )
             A.priceID = i
             items.append( A )
         else:
             #items.append( armor.Armor( cItem, resist ) )
             A = armor.Armor( cItem, resist )
             A.priceID = i
             items.append( A )
         self.prices[level][i] = prices.priceItem(A)
     return items
Esempio n. 8
0
 def generateMap(self):
     self.Z = self.maze()
     self.matrixToMap(self.Z)
     
     while not self.generalmap.pathfinder( (1, self.DIM-2), (self.DIM-2, 1) ):
         self.Z = self.maze()
         self.matrixToMap(self.Z)
     
     self.generalmap.setEntry(0, 0, 40)
     self.generalmap.setEntry( 1, self.DIM-2, const.STAIRDN)
     self.generalmap.pointOfExit = ( 1, self.DIM-2 )
     self.generalmap.setEntry( self.DIM-2, 1, const.STAIRUP)
     self.generalmap.pointOfEntry = ( self.DIM-2, 1)
     self.generalmap.heroStart = ( self.DIM-2, 1 )
     
     i = 0
     while i < 15:
         tile = self.getRandomTile('open')
         if tile == None:
             pass
         else:
             self.generalmap.NPCs.append( ( tile, choice(enemyScr.enemiesByDungeonLevel[self.generalmap.level] ) ) )
             i += 1
     i = 0
     chestList = []
     while i < 5:
         chestItems = []
         tile = self.getRandomTile('closed')
         if tile == None:
             pass
         else:
             chestItems.append( (const.PARCHMENT-const.FRUIT1, choice(mapScr.parchByLevel[self.level]) ) )
             if misc.rollDie(0, 2):
                 chestItems.append( (13, choice( range(15, 50)+range(15,30) ) ))
             chestList.append( (tile, chestItems) )
             (x,y) = tile
             self.generalmap.setEntry( x, y, 110)
             i += 1
     self.generalmap.chests = dict(chestList)
Esempio n. 9
0
 def generateMap(self, orientation):
     if orientation == 'h':
         for x in range( 0, self.generalmap.getDIM() ):
             self.generalmap.setEntry(x, 0, const.PINE1)
             self.generalmap.setTileBG(x, 0, const.GRASS3)
             self.generalmap.setEntry(x, self.generalmap.getDIM()/2, const.PINE1)
             self.generalmap.setTileBG(x, self.generalmap.getDIM()/2, const.GRASS3)
             for y in range( 1, self.generalmap.getDIM()/2 ):
                 if x == 0 or x == self.generalmap.getDIM()-1:
                     self.generalmap.setEntry(x, y, const.GRASS1 )
                 else: self.generalmap.setEntry(x, y, misc.weightedChoice(mapScr.wildsTilesList) )
                 self.generalmap.setTileBG(x, y, const.GRASS3)
     elif orientation == 'v':
         for x in range( 0, self.generalmap.getDIM() ):
             self.generalmap.setEntry(0, x, const.PINE1)
             self.generalmap.setTileBG(0, x, const.GRASS3)
             self.generalmap.setEntry(self.generalmap.getDIM()/2, x, const.PINE1)
             self.generalmap.setTileBG(self.generalmap.getDIM()/2, x, const.GRASS3)
             for y in range( 1, self.generalmap.getDIM()/2 ):
                 if x == 0 or x == self.generalmap.getDIM()-1:
                     self.generalmap.setEntry(y, x, const.GRASS1 )
                 else: self.generalmap.setEntry(y, x, misc.weightedChoice(mapScr.wildsTilesList) )
                 self.generalmap.setTileBG(y, x, const.GRASS3)
     #self.draw()
     self.generalmap.pointOfEntry = None
     self.generalmap.pointOfExit = None
     self.generalmap.heroStart = None
     #add chests
     chestlist = []
     i = 0
     while i < 5:
         # get random empty tile
         (rX, rY) = self.getTileByNumber(const.GRASS1)
         chestItems = []
         
         if misc.rollDie(0, 2):
             chestItems.append( (randrange(const.WSWORD,const.HELMET), self.level/4,
                                                            [randrange( (self.level/4)+1, (self.level/4)+3 ),
                                                             randrange( (self.level/4)+1, (self.level/4)+3 ),
                                                             randrange( (self.level/4)+1, (self.level/4)+3 )] ) )
         else: chestItems.append( (randrange(31,34), self.level/4, randrange(0, 3) ) )
         
         if misc.rollDie(0, 8):
             chestItems.append( (randrange(26,29),self.level/4, # weapon level
                                 [randrange( (self.level/4)+1, (self.level/4)+3 ),     # plus str
                                  randrange( (self.level/4)+1, (self.level/4)+3 ),     # plus int
                                  randrange( (self.level/4)+1, (self.level/4)+3 )] ) ) # plus dex
         elif misc.rollDie(0, 5):
             chestItems.append( (const.PARCHMENT-const.FRUIT1, choice(mapScr.parchByLevel[self.level]) ) )
         elif misc.rollDie(0, 3):
             chestItems.append( (const.GOLD, choice( range(15, 50)+range(15,30) ) ))
         else:
             chestItems.append( (misc.weightedChoice( zip( [randrange(1,3),randrange(1,3),randrange(1,3)],
                                                            mapScr.fruitList ) ), 
                                 1 ) )
         self.generalmap.setEntry( rX, rY, const.CHEST)
         chestlist += [( (rX, rY), chestItems )]
         
         i += 1
         
     self.generalmap.chests = dict(chestlist)
     '''
Esempio n. 10
0
    def fightBattle(self, game, enemy, board_, enemyImgs, heroImgs):
        self.heroImgs = heroImgs
        self.enemyImgs = enemyImgs
        self.enemyAvatar = enemyImgs[self.enemyImgIdx]
        self.heroAvatar = heroImgs[self.heroImgIdx]
        self.drawBattleScreen(game, enemy)
        game.FX.scrollFromCenter(board_, self.battleField)
        hero = game.myHero
        (cHP, mHP, cMP, mMP, sth, dex, itl, scr, kys, cEX, nEX,
         psn) = hero.getPlayerStats()
        (armor, weapon) = (hero.getArmorEquipped(), hero.getWeaponEquipped())
        if enemy.getLevel() > 0:
            game.textMessage('You are facing a level {} {}!'.format(
                enemy.getLevel(), enemy.getName()))
        else:
            game.textMessage('You are facing the {}!'.format(enemy.getName()))
        time = 0
        while enemy.getHP() > 0:
            self.drawBattleScreen(game, enemy)
            if not hero.updateStatus(game):
                return False
            # hero turn
            while not self.heroTurn(game, enemy, board_):
                pass
            game.myInterface.update(game)
            self.drawBattleScreen(game, enemy)

            game.Ticker.tick(10)
            #enemy attacks
            self.drawEnemyAttack(game, enemy)
            if enemy.getHP() > 0:
                if not misc.rollDie(hero.dex, const.maxStats):
                    dmg = random.randrange(
                        enemy.getBaseAttack() - 5,
                        enemy.getBaseAttack() + 5) - (hero.armorClass)
                    if dmg > 0:
                        game.textMessage("The " + enemy.getName() +
                                         " hits you for " + str(dmg) +
                                         " points!")
                        if enemy.poison:
                            if misc.rollDie(0, 3):
                                if hero.isDamned:
                                    hero.isDamned = False
                                hero.isPoisoned = True
                                hero.poisonedAt = game.Ticker.getTicks()
                                game.textMessage("You are poisoned!")
                        elif enemy.damned:
                            if misc.rollDie(0, 3):
                                if hero.isPoisoned:
                                    hero.isPoisoned = False
                                hero.isDamned = True
                                hero.damnedAt = game.Ticker.getTicks()
                                game.textMessage("You are damned!")
                        game.SFX.play(1)
                        self.enemyImg = self.enemyImgs[1]
                        if android:
                            android.vibrate(0.1)
                    else:
                        game.textMessage(
                            "The {} attack is ineffective.".format(
                                enemy.getName()))
                    if hero.takeDmg(dmg) < 1:
                        game.textMessage("You have died!")
                        #game.FX.scrollFromCenter(self.battleField, board_)
                        return 'died'
                else:
                    game.textMessage("The " + enemy.getName() + " missed you!")
                    game.SFX.play(2)
            game.Ticker.tick(10)
            game.myInterface.update(game)
            self.drawBattleScreen(game, enemy)
            pygame.time.wait(1000)
        game.textMessage("The " + enemy.getName() + " is dead!")
        if hero.increaseExp(enemyScr.expDict[enemy.getName()] +
                            random.randrange(enemy.getLevel() * 2,
                                             enemy.getLevel() * 4)):
            game.textMessage("Congratulations! You have gained a level.")
        game.FX.scrollFromCenter(self.background, board_)
        return 'won'
        return 'won'
Esempio n. 11
0
 def fightBattle(self, game, enemy, board_, enemyImgs, heroImgs):
     self.heroImgs = heroImgs
     self.enemyImgs = enemyImgs
     self.enemyAvatar = enemyImgs[self.enemyImgIdx]
     self.heroAvatar = heroImgs[self.heroImgIdx]
     self.drawBattleScreen(game, enemy)
     game.FX.scrollFromCenter(board_, self.battleField)
     hero = game.myHero
     (cHP, mHP, cMP, mMP, sth, dex, itl, scr, kys, cEX, nEX, psn) = hero.getPlayerStats()
     (armor, weapon) = (hero.getArmorEquipped(), hero.getWeaponEquipped())
     if enemy.getLevel() > 0:
         game.textMessage('You are facing a level {} {}!'.format(enemy.getLevel(), enemy.getName()))
     else:
         game.textMessage('You are facing the {}!'.format(enemy.getName()))
     time = 0
     while enemy.getHP() > 0:
         self.drawBattleScreen(game, enemy)
         if not hero.updateStatus(game):
             return False
         # hero turn
         while not self.heroTurn(game, enemy, board_):
             pass
         game.myInterface.update(game)
         self.drawBattleScreen(game, enemy)
         
         game.Ticker.tick(10)
         #enemy attacks
         self.drawEnemyAttack(game, enemy)
         if enemy.getHP() > 0:
             if not misc.rollDie(hero.dex, const.maxStats):
                 dmg = random.randrange(enemy.getBaseAttack()-5,enemy.getBaseAttack()+5) - ( hero.armorClass )
                 if dmg > 0:
                     game.textMessage("The "+enemy.getName()+" hits you for "+str(dmg)+" points!")
                     if enemy.poison:
                         if misc.rollDie(0,3):
                             if hero.isDamned:
                                 hero.isDamned = False
                             hero.isPoisoned = True
                             hero.poisonedAt = game.Ticker.getTicks()
                             game.textMessage("You are poisoned!")
                     elif enemy.damned:
                         if misc.rollDie(0,3):
                             if hero.isPoisoned:
                                 hero.isPoisoned = False
                             hero.isDamned = True
                             hero.damnedAt = game.Ticker.getTicks()
                             game.textMessage("You are damned!")
                     game.SFX.play(1)
                     self.enemyImg = self.enemyImgs[1]
                     if android:
                         android.vibrate(0.1)
                 else: game.textMessage("The {} attack is ineffective.".format(enemy.getName()))
                 if hero.takeDmg(dmg) < 1:
                     game.textMessage("You have died!")
                     #game.FX.scrollFromCenter(self.battleField, board_)
                     return 'died'
             else:
                 game.textMessage("The "+enemy.getName()+" missed you!")
                 game.SFX.play(2)
         game.Ticker.tick(10)
         game.myInterface.update(game)
         self.drawBattleScreen(game, enemy)
         pygame.time.wait(1000)
     game.textMessage("The "+enemy.getName()+" is dead!")
     if hero.increaseExp( enemyScr.expDict[enemy.getName()] + random.randrange(enemy.getLevel()*2, enemy.getLevel()*4)  ):
         game.textMessage("Congratulations! You have gained a level.")
     game.FX.scrollFromCenter(self.background, board_)
     return 'won'
     return 'won'
Esempio n. 12
0
 def generateMap(self, maxRooms):
     self.rooms = []
     startingRoom = self.genRoom((0,0),'round')
     (xdim, ydim) = startingRoom.getDimensions()
     startingRoom.setPos( ( (self.generalmap.DIM/2)-(xdim/2), (self.generalmap.DIM/2) - (ydim/2)))
     self.rooms += [startingRoom]
     self.addRoom(self.generalmap, startingRoom, startingRoom.getPos() )
     self.secretRooms = []
     
     while len(self.rooms) < maxRooms:
         # 4 select random room
         
         candidateRoom = choice(self.rooms)
         
         # 5 select random wall tile from above room
         
         tile, dir = self.branchTile(self.generalmap, candidateRoom)
         
         # 6 generate new room
         '''
         if len(rooms) in [5,10,15]:
             newRoom = self.genRoom((0,0), 'round')
         else: newRoom = self.genRoom()
         '''
         newRoom = self.genRoom( )
         
         # 7 see if new room fits next to selected room
         if self.checkNewRoom(self.generalmap, newRoom, tile, dir):
             startingRoom.setPos( ( (self.generalmap.DIM/2)-(xdim/2), (self.generalmap.DIM/2)-(ydim/2) ) )
         # 8  if yes - continue, if not go back to step 4
         
         # 9 add new room to generalmap and list of rooms
             self.rooms += [newRoom]
             self.addRoom(self.generalmap, newRoom, newRoom.getPos() )
         
         # 9.a add rooms as neighbors
             candidateRoom.neighbors.append(newRoom)
             newRoom.neighbors.append(candidateRoom)
         # 9.b make room secret?
             if len(self.rooms) == maxRooms - 1:
                 newRoom.secret = True
                 self.secretRooms.append(newRoom)
             
         #10 create doorway into new room
             roomtools.addDoorway(tile, dir, newRoom, candidateRoom, self)
         # 10a check to see if more neighbors can be added
             roomtools.checkForNeighbors(newRoom, candidateRoom, self)
             
         # 11 repeat step 4
         
     # set staircases
     '''
     choice1 = choice(rooms)
     (xpos, ypos) = choice1.getPos()
     (xdim, ydim) = choice1.getDimensions()
     self.generalmap.setEntry( xpos + xdim/2, ypos + ydim/2, 120)
     self.POE = ( xpos + xdim/2, ypos + ydim/2 )
     rooms.remove(choice1)
     '''
     # down
     choice1 = choice(self.rooms)
     # find room with only 1 entrance to place stairs leading down and dungeon door
     # WARNING: this algorithm not guaranteed to stop.
     while len(choice1.entrances) > 1 or choice1.secret or choice1.neighbors[0].secret:
         choice1 = choice(self.rooms)
     (xpos, ypos) = choice1.getPos()
     (xdim, ydim) = choice1.getDimensions()
     (doorX, doorY) = choice1.entrances[0]
     self.generalmap.setEntry( xpos + xdim/2, ypos + ydim/2, const.STAIRDN, len(self.rooms))
     self.generalmap.setEntry( doorX, doorY, const.DOOR, len(self.rooms))
     self.generalmap.pointOfExit = ( xpos + xdim/2, ypos + ydim/2 )
     
     # up
     choice2 = choice1.neighbors[0]
     (xpos, ypos) = choice2.getPos()
     (xdim, ydim) = choice2.getDimensions()
     self.generalmap.setEntry( xpos + xdim/2, ypos + ydim/2, const.STAIRUP, len(self.rooms))
     self.generalmap.pointOfEntry = ( xpos + xdim/2, ypos + ydim/2 )
     self.generalmap.heroStart = ( xpos + xdim/2, ypos + ydim/2 )
     self.rooms.remove(choice1)
     
     self.rooms.remove(choice2)
     # set hero starting location - optional
     choice3 = choice(self.rooms)
     (xpos, ypos) = choice3.getPos()
     (xdim, ydim) = choice3.getDimensions()
     self.generalmap.hs = ( xpos + xdim/2, ypos + ydim/2 )
     self.rooms.remove(choice3)
     
     #add chests
     chestlist = []
     for i in range(maxRooms/5):
         choice4 = choice(self.rooms)
         (xpos, ypos) = choice4.getPos()
         (xdim, ydim) = choice4.getDimensions()
         chestItems = []
         '''
         if misc.rollDie(0, 2):
             chestItems.append( (randrange(26,29), self.level/4,
                                                            [randrange( (self.level/4)+1, (self.level/4)+3 ),
                                                             randrange( (self.level/4)+1, (self.level/4)+3 ),
                                                             randrange( (self.level/4)+1, (self.level/4)+3 )] ) )
         else: chestItems.append( (randrange(31,34), self.level/4, randrange(0, 3) ) )
         '''
         chestItems.append( (const.PARCHMENT, choice(mapScr.parchByLevel[self.level]) ) )
         if misc.rollDie(0, 2):
             chestItems.append( (const.GOLD, choice( range(15, 50)+range(15,30) ) ))
         self.generalmap.setEntry( xpos + xdim/2, ypos + ydim/2, const.CHEST, len(self.rooms))
         chestlist += [( ( xpos + xdim/2, ypos + ydim/2), chestItems )]
         self.rooms.remove(choice4)
     
     for room in self.secretRooms:
         (xpos, ypos) = room.getPos()
         (xdim, ydim) = room.getDimensions()
         self.generalmap.setEntry( xpos + xdim/2, ypos + ydim/2, const.CHEST, len(self.rooms))
         sItem = choice( mapScr.specialByLevel[self.level] )
         if sItem in range(const.WSWORD, const.RING):
             mods = [randrange( (self.level/4)+1, 
                                (self.level/4)+3 ),
                     randrange( (self.level/4)+1, 
                                (self.level/4)+3 ),
                     randrange( (self.level/4)+1, 
                                (self.level/4)+3 )]
             chestlist += [( ( xpos + xdim/2, 
                               ypos + ydim/2), 
                             [ (sItem, mods)] )]
         elif sItem in range(const.HELMET, const.SSHIELD+1):
             chestlist += [ ( ( xpos + xdim/2, 
                                ypos + ydim/2), 
                            [(sItem,None)] )]
         
     self.generalmap.chests = dict(chestlist)
     # add enemies
     while len(self.rooms) > 1:
         room = choice(self.rooms)
         (xpos, ypos) = room.getPos()
         (xdim, ydim) = room.getDimensions()
         self.generalmap.NPCs.append( (( xpos + xdim/2, 
                                  ypos + ydim/2), 
                                choice(enemyScr.enemiesByDungeonLevel[self.generalmap.level] ) ) )
         self.rooms.remove(room)
     
     # add key for door
     keyRoom = self.rooms[0]
     (xpos, ypos) = keyRoom.getPos()
     (xdim, ydim) = keyRoom.getDimensions()
     self.generalmap.setEntry( xpos + xdim/2, ypos + ydim/2, const.KEY, len(self.rooms))
     self.rooms.remove(keyRoom)