def climb_up_stairs(): combine = False location_name = game.current_map.location_name location_abbr = game.current_map.location_abbr location_id = game.current_map.location_id threat_level = game.current_map.threat_level dungeon_type = game.current_map.type map_width = game.DUNGEON_MAP_WIDTH map_height = game.DUNGEON_MAP_HEIGHT if game.current_map.tile[game.char.x][game.char.y]['icon'] != '<': game.message.new('You see no stairs going in that direction!', game.turns) else: if game.current_map.location_level > 1: level = game.current_map.location_level - 1 game.message.new('You climb up the stairs.', game.turns) else: combine = True (level, game.char.x, game.char.y) = game.current_map.overworld_position location_id = 0 location_name = 'Wilderness' location_abbr = 'WD' game.message.new('You return to the ' + location_name + '.', game.turns) util.store_map(game.current_map) util.loadgen_message() IO.autosave(False) if not combine: game.current_map = util.fetch_map({'name': location_name, 'id': location_id, 'abbr': location_abbr, 'level': level, 'threat': threat_level, 'map_width': map_width, 'map_height': map_height, 'type': dungeon_type}, dir='down') IO.autosave_current_map() else: game.current_map = util.fetch_map({'name': location_name, 'id': location_id, 'abbr': location_abbr, 'level': level, 'map_width': game.current_map.map_width, 'map_height': game.current_map.map_height}) util.fetch_border_maps() IO.autosave_current_map() util.combine_maps() game.current_map.check_player_position() util.initialize_fov() game.fov_recompute = True game.player_move = True
def climb_down_stairs(): location_name = game.current_map.location_name location_abbr = game.current_map.location_abbr location_id = game.current_map.location_id threat_level = game.current_map.threat_level dungeon_type = game.current_map.type map_width = game.DUNGEON_MAP_WIDTH map_height = game.DUNGEON_MAP_HEIGHT op = (0, 0, 0) if game.current_map.tile[game.char.x][game.char.y]['icon'] != '>': game.message.new('You see no stairs going in that direction!', game.turns) else: if game.current_map.location_id > 0: level = game.current_map.location_level + 1 game.message.new('You climb down the stairs.', game.turns) util.store_map(game.current_map) IO.autosave(False) map_width = game.current_map.map_width map_height = game.current_map.map_height dice = util.roll_dice(1, 10) if dice == 10: threat_level += 1 else: level = 1 for (id, name, abbr, x, y, tlevel, dtype) in game.worldmap.dungeons: if y * game.WORLDMAP_WIDTH + x == game.current_map.location_level: location_id = id location_name = name location_abbr = abbr threat_level = tlevel dungeon_type = dtype if dtype == 'Maze': map_width = game.MAP_WIDTH map_height = game.MAP_HEIGHT game.message.new('You enter the ' + location_name + '.', game.turns) util.decombine_maps() op = (game.current_map.location_level, game.char.x, game.char.y) util.store_map(game.current_map) for i in range(len(game.border_maps)): util.store_map(game.border_maps[i]) IO.autosave() util.loadgen_message() game.current_map = util.fetch_map({'name': location_name, 'id': location_id, 'abbr': location_abbr, 'level': level, 'threat': threat_level, 'map_width': map_width, 'map_height': map_height, 'type': dungeon_type}, dir='up') game.current_map.overworld_position = op IO.autosave_current_map() game.current_map.check_player_position() util.initialize_fov() game.fov_recompute = True game.player_move = True