当前位置: 首页>>代码示例>>Python>>正文


Python startgameoptions.StartGameOptions类代码示例

本文整理汇总了Python中horizons.util.startgameoptions.StartGameOptions的典型用法代码示例。如果您正苦于以下问题:Python StartGameOptions类的具体用法?Python StartGameOptions怎么用?Python StartGameOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了StartGameOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load

	def load(self, savegame, players, is_ai_test, is_map):
		# keep a reference on the savegame, so we can cleanup in `end`
		self.savegame = savegame
		self.started_from_map = is_map
		if is_ai_test:
			# enable trader, pirate and natural resources in AI tests.
			options = StartGameOptions.create_ai_test(savegame, players)
		else:
			# disable the above in usual game tests for simplicity.
			options = StartGameOptions.create_game_test(savegame, players)
			options.is_map = is_map
		super(SPTestSession, self).load(options)
开发者ID:Octavianuspg,项目名称:unknown-horizons,代码行数:12,代码来源:__init__.py

示例2: prepare_multiplayer

def prepare_multiplayer(game, trader_enabled=True, pirate_enabled=True, natural_resource_multiplier=1):
	"""Starts a multiplayer game server
	TODO: actual game data parameter passing
	"""
	_modules.gui.show_loading_screen()

	global preloading
	preload_game_join(preloading)

	# remove cursor while loading
	horizons.globals.fife.cursor.set(fife_module.CURSOR_NONE)
	horizons.globals.fife.engine.pump()
	horizons.globals.fife.set_cursor_image('default')

	# destruct old session (right now, without waiting for gc)
	if _modules.session is not None and _modules.session.is_alive:
		_modules.session.end()
	# start new session
	from horizons.mpsession import MPSession
	# get random seed for game
	uuid = game.uuid
	random = sum([ int(uuid[i : i + 2], 16) for i in range(0, len(uuid), 2) ])
	_modules.session = MPSession(horizons.globals.db, NetworkInterface(), rng_seed=random)

	# NOTE: this data passing is only temporary, maybe use a player class/struct
	if game.is_savegame:
		map_file = SavegameManager.get_multiplayersave_map(game.map_name)
	else:
		map_file = SavegameManager.get_map(game.map_name)

	options = StartGameOptions.create_start_multiplayer(map_file, game.get_player_list(), not game.is_savegame)
	_modules.session.load(options)
开发者ID:Rareson,项目名称:unknown-horizons,代码行数:32,代码来源:main.py

示例3: test_save_load_ticket_1421

def test_save_load_ticket_1421(gui):
	"""
	Boatbuilder crashes when saving/loading while a ship is being produced.
	"""

	# Select boat builder
	gui.cursor_click(64, 10, 'left')

	# Select trade ships tab
	gui.trigger('tab_base', '1')

	# Build huker
	gui.trigger('boatbuilder_showcase', 'ok_0')

	# Select war ships tab
	gui.trigger('tab_base', '2')

	# Build frigate
	gui.trigger('boatbuilder_showcase', 'ok_0')

	fd, filename = tempfile.mkstemp()
	os.close(fd)

	assert gui.session.save(savegamename=filename)

	options = StartGameOptions.create_load_game(filename, None)
	horizons.main.start_singleplayer(options)
开发者ID:BenjaminHarper,项目名称:unknown-horizons,代码行数:27,代码来源:test_boatbuilder.py

示例4: _start_map

def _start_map(
    map_name,
    ai_players=0,
    is_scenario=False,
    pirate_enabled=True,
    trader_enabled=True,
    force_player_id=None,
    is_map=False,
):
    """Start a map specified by user
	@param map_name: name of map or path to map
	@return: bool, whether loading succeeded"""
    if is_scenario:
        savegames = SavegameManager.get_available_scenarios(locales=True)
    else:
        savegames = SavegameManager.get_maps()
    map_file = _find_matching_map(map_name, savegames)
    if not map_file:
        return False

    options = StartGameOptions.create_start_singleplayer(
        map_file, is_scenario, ai_players, trader_enabled, pirate_enabled, force_player_id, is_map
    )
    start_singleplayer(options)
    return True
开发者ID:squiddy,项目名称:unknown-horizons,代码行数:25,代码来源:main.py

示例5: act

	def act(self, player_name, player_color):
		map_file = self._get_selected_map()

		try:
			options = StartGameOptions.create_start_scenario(map_file)
			options.set_human_data(player_name, player_color)
			horizons.main.start_singleplayer(options)
		except InvalidScenarioFileFormat as e:
			self._show_invalid_scenario_file_popup(e)
开发者ID:Rareson,项目名称:unknown-horizons,代码行数:9,代码来源:singleplayermenu.py

示例6: start_single

	def start_single(self):
		""" Starts a single player horizons. """
		assert self.current is self.widgets['singleplayermenu']
		playername = self.current.playerdata.get_player_name()
		if not playername:
			self.show_popup(_("Invalid player name"), _("You entered an invalid playername."))
			return
		playercolor = self.current.playerdata.get_player_color()
		self._save_player_name()

		if self.current.collectData('random'):
			map_file = self._get_random_map_file()
		else:
			assert self.active_right_side.collectData('maplist') != -1
			map_file = self._get_selected_map()

		is_scenario = bool(self.current.collectData('scenario'))
		if not is_scenario:
			ai_players = int(self.current.aidata.get_ai_players())
			horizons.globals.fife.set_uh_setting("AIPlayers", ai_players)
		horizons.globals.fife.save_settings()

		self.mainmenu.show_loading_screen()
		if is_scenario:
			try:
				options = StartGameOptions.create_start_scenario(map_file)
				options.set_human_data(playername, playercolor)
				horizons.main.start_singleplayer(options)
			except InvalidScenarioFileFormat as e:
				self._show_invalid_scenario_file_popup(e)
				self._select_single(show='scenario')
		else: # free play/random map
			options = StartGameOptions.create_start_map(map_file)
			options.set_human_data(playername, playercolor)
			options.ai_players = ai_players
			options.trader_enabled = self.widgets['game_settings'].findChild(name='free_trader').marked
			options.pirate_enabled = self.widgets['game_settings'].findChild(name='pirates').marked
			options.disasters_enabled = self.widgets['game_settings'].findChild(name='disasters').marked
			options.natural_resource_multiplier = self._get_natural_resource_multiplier()
			horizons.main.start_singleplayer(options)

		ExtScheduler().rem_all_classinst_calls(self)
开发者ID:Antagonym,项目名称:unknown-horizons,代码行数:42,代码来源:singleplayermenu.py

示例7: act

	def act(self):
		for size in self.sizes:
			option_name = 'size_%d' % size
			if self._gui.findChild(name=option_name).marked:
				self._windows.close()

				# the empty list is interpreted as the empty list of random map island strings
				options = StartGameOptions.create_editor_load([])
				options.map_padding = size // 2
				horizons.main.start_singleplayer(options)
				return
开发者ID:STEVEOO6,项目名称:unknown-horizons,代码行数:11,代码来源:editorstartmenu.py

示例8: _edit_map

def _edit_map(map_file):
	"""
	Start editing the specified map file.

	@param map_file: path to the map file or a list of random island strings
	@return: bool, whether loading succeeded
	"""
	if not map_file:
		return False

	options = StartGameOptions.create_editor_load(map_file)
	start_singleplayer(options)
	return True
开发者ID:Rareson,项目名称:unknown-horizons,代码行数:13,代码来源:main.py

示例9: _load_cmd_map

def _load_cmd_map(savegame, ai_players, force_player_id=None):
	"""Load a map specified by user.
	@param savegame: either the displayname of a savegame or a path to a savegame
	@return: bool, whether loading succeeded"""
	# first check for partial or exact matches in the normal savegame list
	savegames = SavegameManager.get_saves()
	map_file = _find_matching_map(savegame, savegames)
	if not map_file:
		return False

	options = StartGameOptions.create_load_game(map_file, force_player_id)
	start_singleplayer(options)
	return True
开发者ID:Rareson,项目名称:unknown-horizons,代码行数:13,代码来源:main.py

示例10: act

	def act(self):
		for size in self.sizes:
			option_name = 'size_%d' % size
			if self._gui.findChild(name=option_name).marked:
				self.parent.hide()
				self.parent.parent.show_loading_screen()

				# the empty list is interpreted as the empty list of random map island strings
				options = StartGameOptions.create_editor_load([])
				options.map_padding = size // 2
				session = horizons.main.start_singleplayer(options)
				session.world_editor = WorldEditor(session.world)
				return
开发者ID:Antagonym,项目名称:unknown-horizons,代码行数:13,代码来源:editorstartmenu.py

示例11: act

	def act(self, player_name, player_color):
		self.end()
		self._mainmenu.show_loading_screen()

		map_file = generate_random_map(*self._get_map_parameters())

		options = StartGameOptions.create_start_map(map_file)
		options.set_human_data(player_name, player_color)
		options.ai_players = self._aidata.get_ai_players()
		options.trader_enabled = self._game_settings.free_trader
		options.pirate_enabled = self._game_settings.pirates
		options.disasters_enabled = self._game_settings.disasters
		options.natural_resource_multiplier = self._game_settings.natural_resource_multiplier
		horizons.main.start_singleplayer(options)
开发者ID:ChrisOelmueller,项目名称:unknown-horizons,代码行数:14,代码来源:singleplayermenu.py

示例12: saveload

def saveload(gui):
	"""Save and load the game (gui test version). Use like this:

	# For gui tests
	saveload(gui)
	"""
	fd, filename = tempfile.mkstemp()
	os.close(fd)
	assert gui.session.save(savegamename=filename)
	options = StartGameOptions.create_load_game(filename, None)
	# This hands out a new session, but `gui.session` is a property.
	horizons.main.start_singleplayer(options)
	# Restore some properties that were changed for tests:
	# Set game speed to maximum, and disable autoscroll.
	gui.setup()
开发者ID:Octavianuspg,项目名称:unknown-horizons,代码行数:15,代码来源:helper.py

示例13: _edit_map

def _edit_map(map_file):
	"""
	Start editing the specified map file.

	@param map_file: path to the map file or a list of random island strings
	@return: bool, whether loading succeeded
	"""
	if not map_file:
		return False

	options = StartGameOptions.create_editor_load(map_file)
	start_singleplayer(options)

	from horizons.editor.worldeditor import WorldEditor
	_modules.session.world_editor = WorldEditor(_modules.session.world)
	return True
开发者ID:Antagonym,项目名称:unknown-horizons,代码行数:16,代码来源:main.py

示例14: _load_last_quicksave

def _load_last_quicksave(session=None, force_player_id=None):
	"""Load last quicksave
	@param session: value of session
	@return: bool, whether loading succeeded"""
	save_files = SavegameManager.get_quicksaves()[0]
	if _modules.session is not None:
		if not save_files:
			_modules.session.ingame_gui.open_popup(_("No quicksaves found"),
			                                       _("You need to quicksave before you can quickload."))
			return False
	else:
		if not save_files:
			print "Error: No quicksave found."
			return False

	save = max(save_files)
	options = StartGameOptions.create_load_game(save, force_player_id)
	start_singleplayer(options)
	return True
开发者ID:Rareson,项目名称:unknown-horizons,代码行数:19,代码来源:main.py

示例15: _start_random_map

def _start_random_map(ai_players, seed=None, force_player_id=None):
	options = StartGameOptions.create_start_random_map(ai_players, seed, force_player_id)
	start_singleplayer(options)
	return True
开发者ID:Rareson,项目名称:unknown-horizons,代码行数:4,代码来源:main.py


注:本文中的horizons.util.startgameoptions.StartGameOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。