예제 #1
0
 def process(self):
     TeamLeftMessage(self.client,
                     self.player).sendWithLowID(self.player.low_id)
     DataBase.replaceGameroomValue(self, str(self.player.room_id),
                                   self.player.low_id, "removePlayer")
     DataBase.replaceValue(self, 'roomID', self.player.room_id)
     self.player.room_id = 0
예제 #2
0
    def encode(self):
        DataBase.CountClub(self, 1, 100, 2, 30)
        self.writeString(self.requestedName)
        self.writeVint(self.count)

        for i in self.club_list:
            if self.requestedName.lower() in self.club_data[self.club_list.index(i)]['name'].lower():
                DataBase.loadClub(self, i)
                self.writeInt(0)  # ClubHighID
                self.writeInt(i)  # ClubLowID
                self.writeString(self.clubName)  # Club name

                self.writeVint(8)  # BadgeID type
                self.writeVint(self.clubbadgeID)  # Club badge number

                self.writeVint(self.clubtype)  # Club type

                self.writeVint(self.clubmembercount)  # Member count

                self.writeVint(self.clubtrophies)  # Trophies total
                self.writeVint(self.clubtrophiesneeded)  # Trophies needed
                self.writeVint(0)  # Unknown

                self.writeString(self.clubregion)  # Region
                self.writeVint(self.clubmembercount)  # Members online
                self.writeVint(self.clubfriendlyfamily)  # Family friendly
    def encode(self):
        DataBase.CountClub(self, 1, 100, 2, 50)

        self.writeVint(self.AllianceCount)

        for i in self.club_list:
            DataBase.loadClub(self, i)
            self.writeInt(0)  # ClubHighID
            self.writeInt(i)  # ClubLowID
            self.writeString(self.clubName)  # Club name

            self.writeVint(8)  # BadgeID type
            self.writeVint(self.clubbadgeID)  # Club badge number

            self.writeVint(self.clubtype)  # Club type

            self.writeVint(self.clubmembercount)  # Member count

            self.writeVint(self.clubtrophies)  # Trophies total
            self.writeVint(self.clubtrophiesneeded)  # Trophies needed
            self.writeVint(0)  # Unknown

            self.writeString(self.clubregion)  # Region
            self.writeVint(self.clubmembercount)  # Members online
            self.writeVint(self.clubfriendlyfamily)  # Family friendly
    def encode(self):
        DataBase.loadClub(self, self.clubLowID)

        if self.player.club_low_id != 0:
            self.writeVint(0)
        else:
            self.writeVint(2)

        # ClubID
        self.writeInt(0)  # Club high id
        self.writeInt(self.clubLowID)  # Club low id

        self.writeString(self.clubName)  # Club name

        # Badge
        self.writeVint(8)
        self.writeVint(self.clubbadgeID)  # Club badge id

        # Club settings
        self.writeVint(
            self.clubtype)  # Club type [1 = open, 2 = invite only, 3 = closed]
        self.writeVint(len(self.plrids))  # Club members count

        # Club trophies
        self.writeVint(self.clubtrophies)  # Club total trophies
        self.writeVint(self.clubtrophiesneeded)  # Club required trophies

        # Club Info
        self.writeVint(0)
        self.writeString(self.clubregion)  # Region
        self.writeVint(0)
        self.writeVint(
            self.clubfriendlyfamily
        )  # Family friendly status | 0 = Can be activated, 1 = Activated

        self.writeString(self.clubdescription)  # Description

        # Members list
        self.writeVint(len(self.plrids))  # Members list count

        for id in self.plrids:
            DataBase.GetMemberData(self, id)

            self.writeInt(0)  # High Id
            self.writeInt(id)  # Low Id

            self.writeVint(
                self.plrrole
            )  # player club role | 0 = Nothing, 1 = Member, 2 = President, 3 = Senior, 4 = Vice President
            self.writeVint(self.plrtrophies)  # trophies
            self.writeVint(
                8
            )  # Player states | 0 = last online 1 hour ago, 1 = battling, 2 = menu, 4 = matchmaking, 6 = last online 1 month ago, 7 = spectating, 8 = practicing
            self.writeVint(0)  # Player states Timer
            self.writeVint(0)
            self.writeString(self.plrname)
            self.writeVint(self.plrexperience)
            self.writeVint(28000000 + self.plricon)
            self.writeVint(43000000 + self.plrnamecolor)
예제 #5
0
    def process(self):
        print("HighID", self.TargetHighID, "LowID", self.TargetLowID, "Role", self.TargetedRole)

        # Replacing value
        DataBase.replaceOtherValue(self, self.TargetLowID, 'clubRole', self.TargetedRole)
        
        # Sending confirmation and updated data
        AllianceRoleChangedOKMessage(self.client, self.player).send()
 def res(type):
     if type == 0 or type == 2:
         newGems = self.player.gems - cost
         self.player.gems = newGems
         DataBase.replaceValue(self, 'gems', newGems)
     elif type == 3:
         newStarPoints = self.player.star_points - cost
         self.player.star_points = newStarPoints
         DataBase.replaceValue(self, 'starpoints', newStarPoints)
예제 #7
0
    def process(self):

        # Removing member
        DataBase.loadClub(self, self.player.club_low_id)

        if self.clubmembercount == 1:
            DataBase.AddMember(self, self.player.club_low_id,
                               self.player.low_id, self.player.name, 0)

        else:
            DataBase.AddMember(self, self.player.club_low_id,
                               self.player.low_id, self.player.name, 2)
            DataBase.Addmsg(self, self.player.club_low_id, 4, 0,
                            self.player.low_id, self.player.name,
                            self.player.club_role, 4)

        # Info

        AllianceLeaveOkMessage(self.client, self.player).send()
        MyAllianceMessage(self.client, self.player, 0).send()
        for player in self.plrids:
            if player != self.player.low_id:
                AllianceDataMessage(
                    self.client, self.player, 0,
                    self.player.club_low_id).sendWithLowID(player)
                AllianceChatServerMessage(self.client, self.player,
                                          4).sendWithLowID(player)

        DataBase.replaceValue(self, 'clubID', 0)
        self.player.club_low_id = 0
        DataBase.replaceValue(self, 'clubRole', 0)
        self.player.club_role = 0
    def process(self):
        cost = Shop.gold[self.gold]['Cost']
        value = Shop.gold[self.gold]['Amount']

        newGold = self.player.gold + value
        self.player.gold = newGold
        newGems = self.player.gems - cost
        self.player.gems = newGems

        DataBase.replaceValue(self, 'gold', newGold)
        DataBase.replaceValue(self, 'gems', newGems)
예제 #9
0
    def process(self):
        cost = Shop.token_doubler['Cost']
        value = Shop.token_doubler['Amount']

        newGems = self.player.gems - cost
        self.player.gems = newGems
        DataBase.replaceValue(self, 'gems', newGems)

        newTokens = self.player.tokens + value
        self.player.tokens = newTokens
        DataBase.replaceValue(self, 'tokens', newTokens)
예제 #10
0
    def process(self):
        # Replacing value
        DataBase.replaceClubValue(self, self.player.club_low_id,
                                  self.clubDescription, self.badgeID,
                                  self.clubType, self.requiredTrophies,
                                  self.friendlyFamilly)

        # Sending confirmation and updated data
        AllianceEditOkMessage(self.client, self.player).send()
        MyAllianceMessage(self.client, self.player,
                          self.player.club_low_id).send()
    def encode(self):
        self.indexOfPlayer = 1

        self.writeInt(len(self.players))  # Playera Count
        for player in self.players:
            if player["lowID"] == self.player.low_id:
                self.indexOfPlayer = self.players.index(player) + 1

            self.writeInt(0)  # Games Played Together Recently

            self.writeInt(0)  # HighID
            self.writeInt(player["lowID"])  # LowID

            self.writeString()
            self.writeString()
            self.writeString()
            self.writeString()
            self.writeString()
            self.writeString()

            self.writeInt(
                player['trophies']
            )  # Friend state 0 = friend, 1 = not friend, 2 = request sent, 3 = you have an invite from him??, 4 = friend list
            self.writeInt(4)
            self.writeInt(0)
            self.writeInt(0)
            self.writeInt(0)

            if player["clubID"] != 0:
                DataBase.loadClub(self, player["clubID"])

                self.writeBoolean(True)  # Is in club

                self.writeInt(0)
                self.writeInt(0)
                self.writeInt(0)
                self.writeString(self.clubName)
                self.writeInt(0)
                self.writeInt(0)

            else:
                self.writeBoolean(False)  # Is in club

            self.writeString()
            self.writeInt(0)

            self.writeBoolean(True)  # ?? is a player?

            self.writeString(player['name'])
            self.writeVint(100)
            self.writeVint(28000000 + player["profileIcon"])
            self.writeVint(43000000 + player["namecolor"])
예제 #12
0
 def encode(self):
     DataBase.GetmsgCount(self, self.player.club_low_id)
     db = TinyDB('Database/Club/chat.db')
     query = Query()
     data = db.search(query.clubID == self.player.club_low_id)
     data = data[0]
     self.writeVint(data['info'][str(self.MessageCount)]['Event'])
     self.writeVint(0)
     self.writeVint(self.MessageCount + 1)
     self.writeVint(0)
     self.writeVint(data['info'][str(self.MessageCount)]['PlayerID'])
     self.writeString(data['info'][str(self.MessageCount)]['PlayerName'])
     self.writeVint(data['info'][str(self.MessageCount)]['PlayerRole'])
     self.writeVint(0)
     self.writeVint(0)
     if data['info'][str(self.MessageCount)]['Event'] == 4:
         self.writeVint(
             data['info'][str(self.MessageCount)]['Message']
         )  # 1 = Kicked, 2 = Join request accepted, 3 = Join the club, 4 = Leave the club
         self.writeVint(1)
         self.writeVint(0)
         self.writeVint(data['info'][str(self.MessageCount)]['PlayerID'])
         self.writeString(data['info'][str(
             self.MessageCount)]['PlayerName'])
     else:
         self.writeString(data['info'][str(self.MessageCount)]['Message'])
예제 #13
0
    def process(self):
        DataBase.replaceValue(self, 'skinID', self.player.skin_id)
        self.player.brawlers_skins[str(
            self.player.brawler_id)] = self.player.skin_id
        DataBase.replaceValue(self, 'brawlersSkins',
                              self.player.brawlers_skins)

        self.player.starpower = Cards.get_spg_by_brawler_id(
            self, self.player.brawler_id, 4)
        self.player.gadget = Cards.get_spg_by_brawler_id(
            self, self.player.brawler_id, 5)

        DataBase.replaceValue(self, 'starpower', self.player.starpower)
        DataBase.replaceValue(self, 'gadget', self.player.gadget)

        DataBase.replaceValue(self, 'brawlerID', self.player.brawler_id)
예제 #14
0
    def process(self):
        if self.IsAcmd == False:
            DataBase.Addmsg(self, 2, 0, self.player.low_id, self.player.name,
                            self.player.club_role, self.msg)
            DataBase.loadClub(self, self.player.club_low_id)
            for i in self.plrids:
                AllianceChatServerMessage(self.client, self.player,
                                          self.msg).sendWithLowID(i)

        if self.bot_msg != '':
            AllianceBotChatServerMessage(self.client, self.player,
                                         self.bot_msg).send()

        if self.send_ofs:
            OutOfSyncMessage(self.client, self.player,
                             'Changes have been applied').send()
예제 #15
0
    def process(self):
        def by_trophy(plr):
            return plr['trophies']

        players = DataBase.getAllPlayers(self)
        players.sort(key=by_trophy, reverse=True)
        FriendListMessage(self.client, self.player, players).send()
예제 #16
0
 def process(self):
     DataBase.CountClub(self, 1, 100, 2, 30)
     self.AllianceCount = 0
     for i in self.club_list:
         if self.RequestedName.lower() in self.club_data[
                 self.club_list.index(i)]['name'].lower():
             self.AllianceCount += 1
     AllianceSearchResultMessage(self.client, self.player,
                                 self.RequestedName,
                                 self.AllianceCount).send()
예제 #17
0
    def process(self):
        if self.csv_id == 29:
            self.player.brawler_id = Characters.get_brawler_by_skin_id(
                self, self.BrawlerSkinId)
            self.player.starpower = Cards.get_spg_by_brawler_id(
                self, self.player.brawler_id, 4)
            self.player.gadget = Cards.get_spg_by_brawler_id(
                self, self.player.brawler_id, 5)
        else:
            self.player.starpower = self.StarpowerID
            self.player.gadget = Cards.get_spg_by_brawler_id(
                self, self.player.brawler_id, 5)

        DataBase.replaceValue(self, 'starpower', self.player.starpower)
        DataBase.replaceValue(self, 'gadget', self.player.gadget)

        DataBase.UpdateGameroomPlayerInfo(self, self.player.low_id)

        TeamGameroomDataMessage(self.client, self.player).send()
예제 #18
0
 def sendToOthers(self):
     self.encode()
     packet = self.buffer
     self.buffer = self.id.to_bytes(2, 'big', signed=True)
     self.writeInt(len(packet), 3)
     if hasattr(self, 'version'):
         self.writeInt16(self.version)
     else:
         self.writeInt16(0)
     self.buffer += packet + b'\xff\xff\x00\x00\x00\x00\x00'
     for Client in range(self.player.ClientDict["ClientCounts"]):
         for client_id, value in self.player.ClientDict["Clients"].items():
             DataBase.loadOtherAccount(self, int(client_id))
             if client_id != self.player.low_id and self.ClubID == self.player.club_low_id:
                 self.player.ClientDict["Clients"][str(
                     client_id)]["SocketInfo"].send(self.buffer)
         break
     if packet_settings["ShowPacketsInLog"] == True:
         print(self.id, self.__class__.__name__)
예제 #19
0
    def process(self):
        if self.major != 26:
            self.player.err_code = 8
            LoginFailedMessage(
                self.client, self.player,
                "Your client is outdated, click below to download the new version!"
            ).send()

        if self.player.maintenance:
            LoginFailedMessage(self.client, self.player, "").send()

        if self.fingerprint_sha != self.player.patch_sha and self.player.patch:
            LoginFailedMessage(self.client, self.player, "").send()

        elif self.player.low_id != 0:
            LoginOkMessage(self.client, self.player).send()
            DataBase.loadAccount(self)  # load account
            OwnHomeDataMessage(self.client, self.player).send()
            try:
                MyAllianceMessage(self.client, self.player,
                                  self.player.club_low_id).send()
                AllianceStreamMessage(self.client, self.player,
                                      self.player.club_low_id, 0).send()
                DataBase.GetmsgCount(self, self.player.club_low_id)
            except:
                MyAllianceMessage(self.client, self.player, 0).send()
                AllianceStreamMessage(self.client, self.player, 0, 0).send()
            FriendListMessage(self.client, self.player).send()

            if self.player.do_not_distrub == 1:
                DoNotDistrubOkMessage(self.client, self.player).send()
            if self.player.room_id > 0:
                TeamGameroomDataMessage(self.client, self.player).send()

        else:
            self.player.low_id = Helpers.randomID(self)
            self.player.high_id = 0
            self.player.token = Helpers.randomStringDigits(self)

            LoginOkMessage(self.client, self.player).send()
            OwnHomeDataMessage(self.client, self.player).send()
            MyAllianceMessage(self.client, self.player,
                              self.player.club_low_id).send()
예제 #20
0
 def encode(self):
     DataBase.GetmsgCount(self, self.player.club_low_id)
     self.writeVint(2)
     self.writeVint(0)
     self.writeVint(self.MessageCount)
     self.writeVint(1)
     self.writeVint(1)
     self.writeString("Club Bot")
     self.writeVint(3)
     self.writeVint(0)
     self.writeVint(0)
     self.writeString(self.bot_msg_content)
예제 #21
0
    def process(self):
        self.player.IsFacebookLinked = 1
        DataBase.replaceValue(self, 'isFBLinked', 1)
        DataBase.replaceValue(self, 'facebookID', self.player.FacebookID)
        DataBase.replaceValue(self, 'facebookToken', self.player.FacebookToken)

        FacebookBindOKMessage(self.client, self.player).send()
예제 #22
0
 def process(self):
     if self.player.box_id == 5:
         DataBase.replaceValue(self, 'brawlBoxes',
                               self.player.brawl_boxes - 100)
         LogicBoxDataCommand(self.client, self.player).send()
     elif self.player.box_id == 4:
         DataBase.replaceValue(self, 'bigBoxes', self.player.big_boxes - 10)
         LogicBoxDataCommand(self.client, self.player).send()
     elif self.player.box_id == 3:
         DataBase.replaceValue(self, 'gems', self.player.gems - 80)
         LogicBoxDataCommand(self.client, self.player).send()
     elif self.player.box_id == 2:
         DataBase.replaceValue(self, 'gems', self.player.gems - 30)
         LogicBoxDataCommand(self.client, self.player).send()
예제 #23
0
    def process(self):
        if self.player.IsFacebookLinked == 1:
            self.player.IsFacebookLinked = 0
            DataBase.replaceValue(self, 'isFBLinked', 0)
            DataBase.replaceValue(self, 'facebookID', "None")
            DataBase.replaceValue(self, 'facebookToken', "None")

            FBAccountDisconnectedOKMessage(self.client, self.player).send()
예제 #24
0
    def encode(self):
        self.indexOfClub = 0
        self.writeVint(2)
        self.writeVint(0)
        self.writeVint(0)
        self.writeString(self.player.region)  # Player Region

        DataBase.CountClub(self, 1, 100, 2, 200)

        def by_trophy(club):
            print(club)
            return club['trophies']

        self.writeVint(self.AllianceCount)
        self.club_data.sort(key=by_trophy, reverse=True)

        for club in self.club_data:
            if club["clubID"] == self.player.club_low_id:
                self.indexOfClub = self.club_data.index(club) + 1
            DataBase.loadClub(self, club['clubID'])
            self.writeVint(0)  # Club High ID
            self.writeVint(club['clubID'])  # Club Low ID

            self.writeVint(1)
            self.writeVint(self.clubtrophies)  # Club Trophies
            self.writeVint(2)

            self.writeString(self.clubName)  # Club Name
            self.writeVint(self.clubmembercount)  # Club Members Count

            self.writeVint(8)  # Club Badge
            self.writeVint(self.clubbadgeID)  # Club Name Color

        self.writeVint(0)
        self.writeVint(self.indexOfClub)  # Index of the club
        self.writeVint(0)
        self.writeVint(0)
        self.writeString(self.player.region)
예제 #25
0
    def encode(self):
        if self.clubid != 0:
            DataBase.loadClub(self, self.clubid)
            self.writeVint(self.clubmembercount)
            self.writeVint(1)
            self.writeVint(25)

            self.writeVint(self.player.club_role)

            # Club info
            self.writeInt(0)  # Club high id
            self.writeInt(self.clubid)  # Club low id
            self.writeString(self.clubName)  # Club name

            # Badge
            self.writeVint(8)
            self.writeVint(self.clubbadgeID)  # Club badge id

            # Club settings
            self.writeVint(self.clubtype)  # Club type
            self.writeVint(self.clubmembercount)  # Club members count

            # Club trophies
            self.writeVint(self.clubtrophies)  # Club total trophies
            self.writeVint(self.clubtrophiesneeded)  # Club required trophies

            self.writeVint(0)
            self.writeString(self.clubregion)  # Region

            self.writeVint(0)
            self.writeVint(
                self.clubfriendlyfamily
            )  # Family friendly status | 0 = Can be activated, 1 = Activated

        else:
            self.writeVint(0)
            self.writeVint(0)
    def encode(self):
        self.indexOfPlayer = 1
        self.writeBoolean(True)
        self.writeVint(0)
        self.writeVint(0)
        self.writeString()

        self.writeVint(len(self.players))  # Players Count

        for player in self.players:
            if player["lowID"] == self.player.low_id:
                self.indexOfPlayer = self.players.index(player) + 1
            self.writeVint(0)  # High ID
            self.writeVint(player["lowID"])  # Low ID

            self.writeVint(1)
            self.writeVint(player['trophies'])  # Player Trophies

            self.writeVint(1)

            if player["clubID"] != 0:
                DataBase.loadClub(self, player["clubID"])
                self.writeString(self.clubName)
            else:
                self.writeString()

            self.writeString(player['name'])  # Player Name
            self.writeVint(player['playerExp'])  # Player Level
            self.writeVint(28000000 + player['profileIcon'])
            self.writeVint(43000000 + player['namecolor'])
            self.writeVint(0)

        self.writeVint(0)
        self.writeVint(self.indexOfPlayer)
        self.writeVint(0)
        self.writeVint(0)  # Leaderboard global TID
        self.writeString(self.player.region)
예제 #27
0
    def encode(self):
        self.writeVint(2)
        self.writeVint(0)
        self.writeVint(0)
        self.writeString()

        DataBase.CountClub(self, 1, 100, 2, 200)

        def by_trophy(club):
            print(club)
            return club['trophies']

        self.writeVint(self.AllianceCount)
        self.club_data.sort(key=by_trophy, reverse=True)

        for club in self.club_data:
            DataBase.loadClub(self, club['clubID'])
            self.writeVint(0)  # Club High ID
            self.writeVint(club['clubID'])  # Club Low ID

            self.writeVint(1)
            self.writeVint(self.clubtrophies)  # Club Trophies
            self.writeVint(2)

            self.writeString(self.clubName)  # Club Name
            self.writeVint(self.clubmembercount)  # Club Members Count

            self.writeVint(8)  # Club Badge
            self.writeVint(self.clubbadgeID)  # Club Name Color

        self.writeVint(0)
        self.writeVint(0)
        self.writeVint(0)
        self.writeVint(0)

        self.writeString("RO")
예제 #28
0
 def get_id(id):
     if id == 5:  # Brawl Box
         DataBase.replaceValue(self, 'brawlBoxes',
                               self.player.brawl_boxes - 100)
         return 10
     elif id == 4:  # Big Box
         self.box_index = 1
         DataBase.replaceValue(self, 'bigBoxes',
                               self.player.big_boxes - 10)
         return 12
     elif id == 3:  # Shop Mega Box
         self.box_index = 3
         DataBase.replaceValue(self, 'gems', self.player.gems - 80)
         return 11
     elif id == 1:  # Shop Big Box
         self.box_index = 2
         DataBase.replaceValue(self, 'gems', self.player.gems - 30)
         return 12
예제 #29
0
    def process(self):
        DataBase.replaceValue(self, 'clubID', self.clubLowID)
        self.player.club_low_id = self.clubLowID
        DataBase.replaceValue(self, 'clubRole', 2)
        self.player.club_role = 2

        # Club creation
        DataBase.createClub(self, self.clubLowID)

        # Club data
        AllianceJoinOkMessage(self.client, self.player).send()
        MyAllianceMessage(self.client, self.player, self.clubLowID).send()
예제 #30
0
    def process(self):
        self.player.club_role = 1
        DataBase.replaceValue(self, 'clubRole', 1)
        DataBase.replaceValue(self, 'clubID', self.player.club_low_id)

        # Member adding
        DataBase.AddMember(self, self.player.club_low_id, self.player.low_id,
                           self.player.name, 1)
        DataBase.Addmsg(self, self.player.club_low_id, 4, 0,
                        self.player.low_id, self.player.name,
                        self.player.club_role, 3)

        # Info
        AllianceJoinOkMessage(self.client, self.player).send()
        MyAllianceMessage(self.client, self.player,
                          self.player.club_low_id).send()
        AllianceStreamMessage(self.client, self.player,
                              self.player.club_low_id, 0).send()
        DataBase.loadClub(self, self.player.club_low_id)
        for i in self.plrids:
            AllianceChatServerMessage(self.client, self.player,
                                      3).sendWithLowID(i)