コード例 #1
0
ファイル: IO.py プロジェクト: pom2ter/immortal
def save_game(chargen=False):
	if not chargen:
		contents = ['Saving.....']
		game.messages.box(None, None, 'center_screenx', 'center_screeny', len(max(contents, key=len)) + 28, len(contents) + 4, contents, input=False, align=libtcod.CENTER, nokeypress=True)
		delete_game()
	if game.current_map.location_id == 0:
		if not chargen:
			util.decombine_maps()
		util.store_map(game.current_map)
		for i in range(len(game.border_maps)):
			util.store_map(game.border_maps[i])

	f = open('saves/' + game.player.name.lower() + '.sav', 'wb')
	pickle.dump(game.player, f, game.PICKLE_PROTOCOL)
	pickle.dump(game.worldmap, f, game.PICKLE_PROTOCOL)
	pickle.dump(game.current_map, f, game.PICKLE_PROTOCOL)
	pickle.dump(game.old_maps, f, game.PICKLE_PROTOCOL)
	pickle.dump(game.message, f, game.PICKLE_PROTOCOL)
	pickle.dump(game.rnd, f, game.PICKLE_PROTOCOL)
	pickle.dump(game.turns, f, game.PICKLE_PROTOCOL)
	pickle.dump(game.gametime, f, game.PICKLE_PROTOCOL)
	pickle.dump(game.fov_torch, f, game.PICKLE_PROTOCOL)
	pickle.dump(game.game_state, f, game.PICKLE_PROTOCOL)
	pickle.dump(game.times_saved + 1, f, game.PICKLE_PROTOCOL)
	f.close()
コード例 #2
0
ファイル: commands.py プロジェクト: pom2ter/immortal
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