Beispiel #1
0
def load_game():
	if not game.savefiles:
		contents = ['There are no saved games.']
		game.messages.box('Saved games', None, 'center_screenx', 'center_screeny', len(max(contents, key=len)) + 16, len(contents) + 4, contents, input=False, align=libtcod.CENTER)
	else:
		desc = []
		for i in range(len(game.savefiles)):
			f = open('saves/' + game.savefiles[i], 'rb')
			pl = pickle.load(f)
			desc.append(pl.name + ', a level ' + str(pl.level) + ' ' + pl.gender + ' ' + pl.race + ' ' + pl.profession)
			f.close()
		choice = game.messages.box('Saved games', None, (game.SCREEN_WIDTH - (max(60, len(max(desc, key=len)) + 20))) / 2, ((game.SCREEN_HEIGHT + 1) - max(16, len(desc) + 4)) / 2, max(60, len(max(desc, key=len)) + 20), max(16, len(desc) + 4), desc, step=2, mouse_exit=True)
		if choice != -1:
			contents = ['Loading.....']
			game.messages.box(None, None, 'center_screenx', 'center_screeny', len(max(contents, key=len)) + 16, len(contents) + 4, contents, input=False, align=libtcod.CENTER, nokeypress=True)
			f = open('saves/' + game.savefiles[choice], 'rb')
			game.player = pickle.load(f)
			game.worldmap = pickle.load(f)
			game.current_map = pickle.load(f)
			game.old_maps = pickle.load(f)
			game.message = pickle.load(f)
			game.rnd = pickle.load(f)
			game.turns = pickle.load(f)
			game.gametime = pickle.load(f)
			game.fov_torch = pickle.load(f)
			game.game_state = pickle.load(f)
			game.times_saved = pickle.load(f)
			f.close()
			fetch_autosave()
			game.rnd = libtcod.random_new_from_seed(game.rnd)
			game.char = game.current_map.objects[0]
			game.worldmap.create_map_images(1)
			game.message.empty()
			game.message.trim_history()
			game.message.new('Welcome back, ' + game.player.name + '!', game.turns, libtcod.Color(96, 212, 238))
			if game.current_map.location_id == 0:
				util.fetch_border_maps()
				util.combine_maps()
			game.current_map.check_player_position()
			#print game.worldmap.dungeons
			return True
	return False
Beispiel #2
0
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