Esempio n. 1
0
def spawn_player(array_dungeon_level):
	""" |  Spawns the player on an unblocked spot in the given level of the given dungeon, or, if the level has upstairs,
		|  spawns the player at the upstairs' position
		|  Also it invokes the generation of a new random map, if the next level isn't yet defined.
	"""
	from nightcaste import initialize_fov

	dungeon = array_dungeon_level[0]
	level = array_dungeon_level[1]

	if len(dungeon.maps) <= level:
		dungeon.addRandomMap()

	map = dungeon.maps[level]
	map.objects.append(gvar.game.player)

	if map.upstairs is not None:
		player_spawn = (map.upstairs.x, map.upstairs.y)
	else:
		room = map.random_room()
		player_spawn = room.random_spot()
		while map.is_blocked(player_spawn[0], player_spawn[1], ai=True):
			room = map.random_room()
			player_spawn = room.random_spot()

	gvar.game.player.relocate(dungeon=dungeon, level=level, x=player_spawn[0], y=player_spawn[1])
	initialize_fov()
def open_door(x, y):
    """ |  Use function:
            |  Open the door. Set the Character to '/', tile_type to 'door' and do not block or block_sight.
            |  Also, checks direct adjacent (not diagonal) tiles for doors, and opens them too. (As if they were double doors.)
    """
    from nightcaste import initialize_fov
    map = gvar.game.player.currentmap()
    tile = map.map[x][y]
    if tile is not None and tile.tile_type == 'door':
        tile.blocked = False
        tile.block_sight = False
        tile.char = '/'
        # double doors
        for t in map.adjacent(x, y, diagonal=False):
            next_tile = map.map[t[0]][t[1]]
            if next_tile.tile_type == 'door':
                next_tile.blocked = False
                next_tile.block_sight = False
                next_tile.char = '/'
    initialize_fov()