Esempio n. 1
0
	def deletegame(self, game: Game):
		"""
		Remove the game from the server.
		"""
		logging.debug("[REMOVE] [{}] {} removed".format(game.uuid, game))
		game.clear()
		self.games.remove(game)
	def deletegame(self, game: Game):
		"""
		Remove the game from the server.
		"""
		logging.debug("[REMOVE] [{}] {} removed".format(game.uuid, game))
		game.clear()
		self.games.remove(game)
Esempio n. 3
0
	def startgame(self, game: Game):
		"""
		Instruct all players to start the game.
		"""
		logging.debug("[START] [{}] Players: {}".
			format(game.uuid, [str(i) for i in game.players]))
		game.state = Game.State.Running
		self.send_to_game(game, packets.server.cmd_startgame())
Esempio n. 4
0
	def preparegame(self, game: Game):
		"""
		Instruct all players to start loading the game.
		"""
		logging.debug("[PREPARE] [{}] Players: {}".
			format(game.uuid, [str(i) for i in game.players]))
		game.state = Game.State.Prepare
		self.send_to_game(game, packets.server.cmd_preparegame())
	def startgame(self, game: Game):
		"""
		Instruct all players to start the game.
		"""
		logging.debug("[START] [{}] Players: {}".
			format(game.uuid, [str(i) for i in game.players]))
		game.state = Game.State.Running
		self.send_to_game(game, packets.server.cmd_startgame())
	def preparegame(self, game: Game):
		"""
		Instruct all players to start loading the game.
		"""
		logging.debug("[PREPARE] [{}] Players: {}".
			format(game.uuid, [str(i) for i in game.players]))
		game.state = Game.State.Prepare
		self.send_to_game(game, packets.server.cmd_preparegame())
Esempio n. 7
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))
Esempio n. 8
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))
Esempio n. 9
0
	def terminategame(self, game: Game, player=None):
		"""
		Forcefully end the game.
		"""
		logging.debug("[TERMINATE] [{}] (by {})".
			format(game.uuid, player if player is not None else None))
		if game.creator.protocol >= 1 and game.is_open():
			# NOTE: works with protocol >= 1
			for p in game.players:
				self.error(p, T("The game has been terminated. The creator has left the game."), ErrorType.TerminateGame)
		else:
			for p in game.players:
				if p.peer.state == enet.PEER_STATE_CONNECTED:
					self.fatal_error(p,
						T("One player has terminated their game. "
						"For technical reasons, this currently means the game cannot continue. "
						"We are very sorry about that."))
		self.events.broadcast('deletegame', game)
Esempio n. 10
0
	def terminategame(self, game: Game, player=None):
		"""
		Forcefully end the game.
		"""
		logging.debug("[TERMINATE] [{}] (by {})".
			format(game.uuid, player if player is not None else None))
		if game.creator.protocol >= 1 and game.is_open():
			# NOTE: works with protocol >= 1
			for p in game.players:
				self.error(p, T("The game has been terminated. The creator has left the game."), ErrorType.TerminateGame)
		else:
			for p in game.players:
				if p.peer.state == enet.PEER_STATE_CONNECTED:
					self.fatal_error(p,
						T("One player has terminated their game. "
						"For technical reasons, this currently means the game cannot continue. "
						"We are very sorry about that."))
		self.events.broadcast('deletegame', game)