async def chat_send(self, message: str, team_only: bool): """ Writes a message to the chat """ ch = ChatChannel.Team if team_only else ChatChannel.Broadcast r = await self._execute(action=sc_pb.RequestAction(actions=[ sc_pb.Action(action_chat=sc_pb.ActionChat(channel=ch.value, message=message)) ]))
def chat(self, message): """Send chat message as a broadcast.""" if message: action_chat = sc_pb.ActionChat(channel=sc_pb.ActionChat.Broadcast, message=message) action = sc_pb.Action(action_chat=action_chat) return self.act(action)
async def chat_send(self, message, team_only): ch = ChatChannel.Team if team_only else ChatChannel.Broadcast r = await self._execute(action=sc_pb.RequestAction( actions=[sc_pb.Action(action_chat=sc_pb.ActionChat( channel=ch.value, message=message ))] ))
async def chat_send(self, messages, team_only): if not isinstance(messages, list): return await self.chat_send([messages], team_only) ch = ChatChannel.Team if team_only else ChatChannel.Broadcast r = await self._execute(action=sc_pb.RequestAction(actions=[ sc_pb.Action(chat=[ sc_pb.ActionChat(channel=ch.value, message=message) for message in messages ]) ])) print(r) exit("-")
async def parse_response(self, response_bytes): response = sc_pb.Response() response.ParseFromString(response_bytes) if not response.HasField("status"): logger.critical("Proxy: RESPONSE HAS NO STATUS {response}") else: new_status = Status(response.status) if new_status != self.controller._status: logger.info( f"Controller({self.player.name}): {self.controller._status}->{new_status}" ) self.controller._status = new_status if self.player_id is None: if response.HasField("join_game"): self.player_id = response.join_game.player_id logger.info( f"Proxy({self.player.name}): got join_game for {self.player_id}" ) if self.result is None: if response.HasField("observation"): obs: sc_pb.ResponseObservation = response.observation if obs.player_result: self.result = { pr.player_id: Result(pr.result) for pr in obs.player_result } elif (self.timeout_loop and obs.HasField("observation") and obs.observation.game_loop > self.timeout_loop): self.result = {i: Result.Tie for i in range(1, 3)} logger.info(f"Proxy({self.player.name}) timing out") act = [ sc_pb.Action(action_chat=sc_pb.ActionChat( message="Proxy: Timing out")) ] await self.controller._execute(action=sc_pb.RequestAction( actions=act)) return response