def Talk(self, message): if not message or not message.IsValid: return packet = PacketUtility.GetTalkPacket(message) reply = self.Send(packet) return reply
def Whisper(self, message): if not message or not message.IsValid: return packet = PacketUtility.GetWhisperPacket(message) reply = self.Send(packet) return reply
def RemoveAgentFromGame(self): if not self.Client.GameIdentifier: return None dto = PlayerGameIdentifierDto(self.Client.Player, self.Client.GameIdentifier) packet = PacketUtility.GetRemoveAgentFromGamePacket(dto) reply = self.Send(packet) return reply
def AddAgentToGame(self, agentType): if not self.Client.GameIdentifier or not agentType: return None dto = AddAgentGameDto(self.Client.Player, self.Client.GameIdentifier, agentType) packet = PacketUtility.GetAddAgentToGamePacket(dto) reply = self.Send(packet) return reply
def JoinGame(self, gameIdentifier): dto = PlayerGameIdentifierDto(self.Client.Player, gameIdentifier) packet = PacketUtility.GetJoinGamePacket(dto) reply = self.Send(packet) self.Client.SetGame(reply.Entity) self.__lastUpdatedUtc = reply.UpdatedUtc return reply
def VoteStart(self): if not self.Client.GameIdentifier: return None dto = PlayerGameIdentifierDto(self.Client.Player, self.Client.GameIdentifier) wrapperDto = UpdatedEntityDto(dto, self.__lastUpdatedUtc) packet = PacketUtility.GetVoteGameStartPacket(wrapperDto) reply = self.Send(packet) return reply
def LeaveGame(self): if not self.Client.GameIdentifier: return dto = PlayerGameIdentifierDto(self.Client.Player, self.Client.GameIdentifier) packet = PacketUtility.GetLeaveGamePacket(dto) reply = self.Send(packet) if reply: self.Client.SetGame(None) return reply
def Wait(self): if not self.Client or\ not self.Client.GameIdentifier or\ not self.Client.Player: return dto = GameActionDto(self.Client.GameIdentifier, self.Client.Player, None) packet = PacketUtility.GetVotePlayerPacket(dto) reply = self.Send(packet) return reply
def CreateGame(self, gameName): dto = CreateGameDto(self.Client.Player, gameName) packet = PacketUtility.GetCreateGamePacket(dto) reply = self.Send(packet) if not reply: return None self.Client.SetGame(reply.Entity) self.__lastUpdatedUtc = reply.UpdatedUtc return reply
def Guard(self, targetPlayerIdentifier): if not self.Client or\ not self.Client.GameIdentifier or\ not self.Client.Player or\ not targetPlayerIdentifier: # null check both the current player and the target player return dto = GameActionDto(self.Client.GameIdentifier, self.Client.Player, targetPlayerIdentifier) packet = PacketUtility.GetGuardPlayerPacket(dto) reply = self.Send(packet) return reply
def GetGameLobby(self): if not self.Client.GameIdentifier: return None dto = PlayerGameIdentifierDto(self.Client.Player, self.Client.GameIdentifier) wrapperDto = UpdatedEntityDto(dto, self.__lastUpdatedUtc) packet = PacketUtility.GetGameLobbyPacket(wrapperDto) reply = self.Send(packet) self.Client.SetGame(reply.Entity.Game) self.Client.SetPlayer(reply.Entity.Player) self.__lastUpdatedUtc = reply.UpdatedUtc return self.Client.Game
def Connect(self): try: self.__connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.__connection.connect(NetConstants.ADDRESS) dto = ConnectDto(self.Client.Name, self.Client.Identifier) packet = PacketUtility.GetConnectPacket(dto) reply = self.Send(packet) self.Client.SetPlayer(reply) return reply except Exception as error: print(LogConstants.ERROR + " " + str(error)) return
def GetGamesList(self): packet = PacketUtility.GetGamesPacket() reply = self.Send(packet) return reply