コード例 #1
0
    def Talk(self, message):
        if not message or not message.IsValid:
            return

        packet = PacketUtility.GetTalkPacket(message)

        reply = self.Send(packet)

        return reply
コード例 #2
0
    def Whisper(self, message):
        if not message or not message.IsValid:
            return

        packet = PacketUtility.GetWhisperPacket(message)

        reply = self.Send(packet)

        return reply
コード例 #3
0
    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
コード例 #4
0
    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
コード例 #5
0
    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
コード例 #6
0
    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
コード例 #7
0
    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
コード例 #8
0
    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
コード例 #9
0
    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
コード例 #10
0
    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
コード例 #11
0
    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
コード例 #12
0
    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
コード例 #13
0
    def GetGamesList(self):
        packet = PacketUtility.GetGamesPacket()

        reply = self.Send(packet)

        return reply