예제 #1
0
	def oncreategame(self, player, packet):
		if packet.maxplayers < self.capabilities['minplayers']:
			raise network.SoftNetworkException("You can't run a game with less than %d players" % (self.capabilities['minplayers']))
		if packet.maxplayers > self.capabilities['maxplayers']:
			raise network.SoftNetworkException("You can't run a game with more than %d players" % (self.capabilities['maxplayers']))
		game = Game(packet, player)
		logging.debug("[CREATE] [%s] %s created %s" % (game.uuid, player, game))
		self.games.append(game)
		self.send(player.peer, packets.server.data_gamestate(game))
예제 #2
0
	def on_creategame(self, player: Player, packet: packets.client.cmd_creategame):
		"""
		A client wants to create a new game.
		"""
		if packet.maxplayers < self.capabilities['minplayers']:
			raise network.SoftNetworkException(
				"You can't run a game with less than {} players".
				format(self.capabilities['minplayers']))
		if packet.maxplayers > self.capabilities['maxplayers']:
			raise network.SoftNetworkException(
				"You can't run a game with more than {} players".
				format(self.capabilities['maxplayers']))
		game = Game(packet, player)
		logging.debug("[CREATE] [{}] {} created {}".format(game.uuid, player, game))
		self.games.append(game)
		self.send(player.peer, packets.server.data_gamestate(game))