當前位置: 首頁>>代碼示例>>Python>>正文


Python SavegameAccessor.get_players_num方法代碼示例

本文整理匯總了Python中horizons.util.savegameaccessor.SavegameAccessor.get_players_num方法的典型用法代碼示例。如果您正苦於以下問題:Python SavegameAccessor.get_players_num方法的具體用法?Python SavegameAccessor.get_players_num怎麽用?Python SavegameAccessor.get_players_num使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在horizons.util.savegameaccessor.SavegameAccessor的用法示例。


在下文中一共展示了SavegameAccessor.get_players_num方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __create_game

# 需要導入模塊: from horizons.util.savegameaccessor import SavegameAccessor [as 別名]
# 或者: from horizons.util.savegameaccessor.SavegameAccessor import get_players_num [as 別名]
	def __create_game(self, load=None, chosen_map=None):
		"""
		Actually create a game, join it, and display the lobby.

		@param load: game data tuple for creating loaded games
		@param chosen_map: the name of the map to start a new game on (overrides the gui)
		"""
		# create the game
		if load:
			mapname, gamename, gamepassword = load
			path = SavegameManager.get_multiplayersave_map(mapname)
			maxplayers = SavegameAccessor.get_players_num(path)
			password = gamepassword
			maphash = SavegameAccessor.get_hash(path)
		else:
			mapindex = None
			if chosen_map is not None:
				for i, map in enumerate(self.maps_display):
					if map == chosen_map:
						mapindex = i
						break

			if mapindex is None:
				mapindex = self.current.collectData('maplist')
			mapname = self.maps_display[mapindex]
			maxplayers = self.current.collectData('playerlimit') + 2 # 1 is the first entry
			gamename = self.current.collectData('gamename')
			password = self.current.collectData('password')
			maphash = ""


		password = hashlib.sha1(password).hexdigest() if password != "" else ""
		game = NetworkInterface().creategame(mapname, maxplayers, gamename, maphash, password)
		if game is None:
			return

		self.__show_gamelobby()
開發者ID:Hadescho,項目名稱:unknown-horizons,代碼行數:39,代碼來源:multiplayermenu.py


注:本文中的horizons.util.savegameaccessor.SavegameAccessor.get_players_num方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。