コード例 #1
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()

        elif self.player.low_id != 0:

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

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

            LoginOkMessage(self.client, self.player).send()
            DataBase.loadAccount(self)  # load account
            OwnHomeDataMessage(self.client, self.player).send()
            MyAllianceMessage(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).send()
コード例 #2
0
ファイル: LoginMessage.py プロジェクト: nako75/Classic-Brawl
    def process(self):
        if self.major != 26:
            LoginFailedMessage(
                self.client, self.player,
                "The server does not support your version").send()

        elif self.player.LowID != 0:

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

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

            LoginOkMessage(self.client, self.player).send()
            DataBase.loadAccount(self)  # load account
            OwnHomeDataMessage(self.client, self.player).send()
            MyAllianceMessage(self.client, self.player).send()
            if self.player.DoNotDistrub == 1:
                DoNotDistrubOkMessage(self.client, self.player).send()
            if self.player.roomID > 0:
                TeamGameroomDataMessage(self.client, self.player).send()

        else:
            self.player.LowID = Helpers.randomID(self)
            self.player.HighID = 0
            self.player.Token = Helpers.randomStringDigits(self)
            LoginOkMessage(self.client, self.player).send()
            OwnHomeDataMessage(self.client, self.player).send()
            MyAllianceMessage(self.client, self.player).send()
コード例 #3
0
    def encode(self):
        DataBase.loadAccount(self)

        self.writeVint(0)
        self.writeVint(int(datetime.timestamp(datetime.now())))  # Timestamp

        self.writeVint(self.player.trophies)  # Player Trophies
        self.writeVint(self.player.trophies)  # Player Max Reached Trophies

        self.writeVint(0)
        self.writeVint(95)  # Trophy Road Reward

        self.writeVint(500)  # Starting Level (exp points)

        self.writeScId(28, self.player.profile_icon)  # Player Icon ID
        self.writeScId(43, self.player.name_color)  # Player Name Color ID

        self.writeVint(0)  # array

        # Selected Skins array
        self.writeVint(len(self.player.brawlers_skins))
        for brawler_id in self.player.brawlers_skins:
            self.writeVint(29)
            self.writeVint(self.player.brawlers_skins[brawler_id])  # skinID

        # Unlocked Skins array
        self.writeVint(len(self.player.skins_id))

        for skin_id in self.player.skins_id:
            self.writeScId(29, skin_id)

        self.writeVint(0)  # array

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

        self.writeBoolean(False)
        self.writeVint(1)
        self.writeBoolean(True)

        self.writeVint(0)  # Remaining Tokens
        self.writeVint(0)  # Season End Timer
        self.writeVint(0)
        self.writeVint(0)

        self.writeVint(0)
        self.writeVint(0)
        self.writeVint(0)  # array

        self.writeByte(8)  # related to shop token doubler

        self.writeBoolean(True)
        self.writeBoolean(True)
        self.writeBoolean(True)

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

        # Shop Offers array

        count = len(Shop.offers)

        self.writeVint(count)
        for i in range(count):
            item = Shop.offers[i]

            self.writeVint(1)

            self.writeVint(item['ID'])
            self.writeVint(item['Multiplier'])
            self.writeVint(0)
            self.writeVint(item['SkinID'])
            self.writeVint(
                item['ShopType'])  # [0 = Offer, 2 = Skins 3 = Star Shop]

            self.writeVint(item['Cost'])  # Cost
            self.writeVint(item['Timer'])

            self.writeVint(1)
            self.writeVint(100)
            self.writeBoolean(False)  # is Offer Purchased

            self.writeBoolean(False)
            self.writeVint(
                item['ShopDisplay'])  # [0 = Normal, 1 = Daily Deals]
            self.writeBoolean(False)
            self.writeVint(0)

            self.writeInt(0)

            self.write_string_reference(item['OfferTitle'])

            self.writeBoolean(False)
            self.writeString()
            self.writeVint(0)
            self.writeBoolean(False)

        self.writeVint(0)  # array

        self.writeVint(200)  # Available Tokens
        self.writeVint(0)  # Time till Bonus Tokens (seconds)

        self.writeVint(0)  # array

        self.writeVint(self.player.tickets)  # Tickets
        self.writeVint(0)

        self.writeScId(16, self.player.brawler_id)  # Selected Brawler

        self.writeString("RO")  # Location
        self.writeString("26.165")  # Supported Content Creator

        self.writeVint(0)  # array
        self.writeVint(0)  # array
        self.writeVint(0)  # array
        self.writeVint(0)  # array

        self.writeBoolean(False)

        self.writeVint(2019049)

        self.writeVint(100)
        self.writeVint(10)

        for item in Shop.boxes:
            self.writeVint(item['Cost'])
            self.writeVint(item['Multiplier'])

        self.writeVint(Shop.token_doubler['Cost'])
        self.writeVint(Shop.token_doubler['Amount'])

        self.writeVint(500)
        self.writeVint(50)
        self.writeVint(999900)

        self.writeVint(0)  # array

        self.writeVint(8)  # array
        for i in range(1, 8 + 1):
            self.writeVint(i)

        # Logic Events
        count = len(EventSlots.maps)
        self.writeVint(count)

        for map in EventSlots.maps:

            self.writeVint(8)
            self.writeVint(EventSlots.maps.index(map) + 1)
            self.writeVint(0)
            self.writeVint(2802)
            self.writeVint(0)

            self.writeScId(15, map['ID'])

            self.writeVint(map['Status'])

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

        self.writeVint(0)  # array

        # Logic Shop

        self.writeVint(8)
        for i in [20, 35, 75, 140, 290, 480, 800, 1250]:
            self.writeVint(i)

        self.writeVint(8)
        for i in [1, 2, 3, 4, 5, 10, 15, 20]:
            self.writeVint(i)

        self.writeVint(3)
        for i in [10, 30, 80]:  # Tickets price
            self.writeVint(i)

        self.writeVint(3)
        for i in [6, 20, 60]:  # Tickets amount
            self.writeVint(i)

        self.writeVint(len(Shop.gold))
        for item in Shop.gold:
            self.writeVint(item['Cost'])

        self.writeVint(len(Shop.gold))
        for item in Shop.gold:
            self.writeVint(item['Amount'])

        self.writeVint(2)

        self.writeVint(200)  # Max Tokens
        self.writeVint(20)  # Plus Tokens

        self.writeVint(8640)
        self.writeVint(10)
        self.writeVint(5)

        self.writeByte(6)

        self.writeVint(50)
        self.writeVint(604800)

        self.writeBoolean(True)

        self.writeVint(0)  # array

        self.writeVint(2)  # Menu Theme
        self.writeInt(1)
        self.writeInt(41000011)  # Theme ID
        self.writeInt(30)
        self.writeInt(1)

        self.writeVint(0)  # array

        self.writeInt(0)
        self.writeInt(1)

        self.writeVint(0)  # array

        self.writeVint(1)

        self.writeBoolean(True)

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

        self.writeVint(0)  # High Id
        self.writeVint(1)  # Low Id

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

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

        if self.player.name == "Guest":
            self.writeString("Guest")  # Player Name
            self.writeVint(0)
            DataBase.createAccount(self)
        else:
            self.writeString(self.player.name)  # Player Name
            self.writeVint(1)

        self.writeInt(0)

        self.writeVint(8)

        # Unlocked Brawlers & Resources array
        self.writeVint(len(self.player.card_unlock_id) + 4)  # count

        for unlock_id in self.player.card_unlock_id:
            self.writeVint(23)
            self.writeVint(unlock_id)
            self.writeVint(1)

        self.writeVint(5)  # csv id
        self.writeVint(1)  # resource id
        self.writeVint(self.player.brawl_boxes)  # resource amount

        self.writeVint(5)  # csv id
        self.writeVint(8)  # resource id
        self.writeVint(self.player.gold)  # resource amount

        self.writeVint(5)  # csv id
        self.writeVint(9)  # resource id
        self.writeVint(self.player.big_boxes)  # resource amount

        self.writeVint(5)  # csv id
        self.writeVint(10)  # resource id
        self.writeVint(self.player.star_points)  # resource amount

        # Brawlers Trophies array
        self.writeVint(len(self.player.brawlers_id))  # brawlers count

        for brawler_id in self.player.brawlers_id:
            self.writeScId(16, brawler_id)
            try:
                self.writeVint(self.player.brawlers_trophies[str(brawler_id)])
            except KeyError:
                self.player.brawlers_trophies.update(
                    {f'{brawler_id}': self.player.brawler_trophies_for_rank})
                DataBase.replaceValue(self, 'brawlersTrophies',
                                      self.player.brawlers_trophies)
                self.writeVint(self.player.brawlers_trophies[str(brawler_id)])

        # Brawlers Trophies for Rank array
        self.writeVint(len(self.player.brawlers_id))  # brawlers count

        for brawler_id in self.player.brawlers_id:
            self.writeScId(16, brawler_id)
            try:
                self.writeVint(self.player.brawlers_trophies[str(brawler_id)])
            except KeyError:
                self.player.brawlers_trophies.update(
                    {f'{brawler_id}': self.player.brawler_trophies_for_rank})
                DataBase.replaceValue(self, 'brawlersTrophies',
                                      self.player.brawlers_trophies)
                self.writeVint(self.player.brawlers_trophies[str(brawler_id)])

        self.writeVint(0)

        # Brawlers Upgrade Poitns array
        self.writeVint(len(self.player.brawlers_id))  # brawlers count

        for brawler_id in self.player.brawlers_id:
            self.writeScId(16, brawler_id)
            self.writeVint(self.player.brawler_upgrade_points)

        # Brawlers Power Level array
        self.writeVint(len(self.player.brawlers_id))  # brawlers count

        for brawler_id in self.player.brawlers_id:
            self.writeScId(16, brawler_id)
            self.writeVint(self.player.brawler_power_level)

        # Gadgets and Star Powers array
        self.writeVint(len(self.player.card_skills_id))  # count

        for skill_id in self.player.card_skills_id:
            self.writeVint(23)
            self.writeVint(skill_id)
            self.writeVint(1)

        # "New" Brawlers array
        self.writeVint(len(self.player.brawlers_id))  # brawlers count

        for brawler_id in self.player.brawlers_id:
            self.writeScId(16, brawler_id)
            self.writeVint(2)

        self.writeVint(self.player.gems)  # Player Gems
        self.writeVint(self.player.gems)
        self.writeVint(1)
        self.writeVint(0)
        self.writeVint(0)
        self.writeVint(0)
        self.writeVint(0)
        self.writeVint(0)
        self.writeVint(0)
        self.writeVint(0)
        self.writeVint(2)
        self.writeVint(1585502369)
コード例 #4
0
    def encode(self):
        DataBase.loadAccount(self)

        self.writeVint(2020007)
        self.writeVint(75158)  # Timestamp

        self.writeVint(self.player.trophies)  # Player Trophies
        self.writeVint(self.player.trophies)  # Player Max Reached Trophies

        self.writeVint(122)
        self.writeVint(99)  # Trophy Road Reward

        self.writeVint(1262469)  # Starting Level (exp points)

        self.writeScId(28, self.player.profileIcon)  # Player Icon ID
        self.writeScId(43, self.player.namecolor)  # Player Name Color ID

        self.writeVint(9)  # count

        for i in range(9):
            self.writeVint(i)

        self.writeVint(3)
        self.writeVint(29)

        self.writeVint(14)
        self.writeVint(29)

        self.writeVint(self.player.skinID)  # skinID
        self.writeVint(29)

        self.writeVint(0)

        # Unlocked Skins array
        self.writeVint(len(self.player.SkinsCount))

        for skin_id in self.player.SkinsCount:
            self.writeScId(29, skin_id)

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

        self.writeBoolean(False)  # "token limit reached message" if true

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

        self.writeVint(248791)  # Season End Timer

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

        self.writeVint(200)
        self.writeVint(200)

        self.writeVint(5)

        for i in [93, 206, 456, 1001, 2264]:
            self.writeVint(i)

        self.writeVint(8)

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

        self.writeVint(0)  # array

        self.writeVint(0)  # array

        self.writeVint(100)  # Available Tokens
        self.writeVint(99999)  # Time till Bonus Tokens (seconds)

        self.writeBoolean(True)  # Tickets enabled
        self.writeVint(0)
        self.writeVint(self.player.tickets)  # Tickets value
        self.writeVint(-21)

        self.writeScId(16, self.player.brawlerID)  # Selected Brawler

        self.writeString("RO")  # Location
        self.writeString("26.165")  # Supported Content Creator

        self.writeVint(-133169153)

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

        self.writeVint(2019053)

        self.writeVint(100)
        self.writeVint(10)

        self.writeVint(30)  # Shop Big Box price
        self.writeVint(3)

        self.writeVint(80)  # Shop Mega Box price
        self.writeVint(10)

        self.writeVint(50)  # Shop Token Doubler price
        self.writeVint(1000)  # Shop Token Doubler amount

        self.writeVint(550)
        self.writeVint(0)
        self.writeVint(999900)

        self.writeVint(6)  # count

        for i in range(6):
            self.writeVint(i)

        self.writeVint(15)  # count

        for i in range(15):
            self.writeVint(i)

        totalSlots = 10
        mapsList = [7, 32, 17, 0, 24, 202, 97, 167, 174]
        self.writeVint(totalSlots - 1)  # map slots count

        for i in range(1, totalSlots):

            self.writeVint(-133000102)
            self.writeVint(i)
            self.writeVint(0)
            self.writeVint(75992)  # Timer
            self.writeVint(10)

            self.writeScId(15, int(mapsList[i - 1]))  # Game Mode Slot Map ID

            self.writeVint(2)  # [3 = Nothing, 2 = Star Token, 1 = New Event]

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

        # Shop
        self.writeVint(0)

        self.writeVint(8)
        for i in [20, 35, 75, 140, 290, 480, 800, 1250]:
            self.writeVint(i)

        self.writeVint(8)
        for i in [1, 2, 3, 4, 5, 10, 15, 20]:
            self.writeVint(i)

        self.writeVint(3)
        for i in [10, 30, 80]:  # Tickets price
            self.writeVint(i)

        self.writeVint(3)
        for i in [6, 20, 60]:  # Tickets amount
            self.writeVint(i)

        self.writeVint(4)
        for i in [20, 50, 140, 280]:  # Gold price
            self.writeVint(i)

        self.writeVint(4)
        for i in [150, 400, 1200, 2600]:  # Gold amount
            self.writeVint(i)

        self.writeVint(2)

        self.writeVint(999)  # Max tokens
        self.writeVint(20)  # Plus tokens

        self.writeVint(8640)
        self.writeVint(10)
        self.writeVint(5)

        self.writeVint(6)

        self.writeVint(50)
        self.writeVint(604800)

        self.writeBoolean(True)

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

        self.writeInt(0)
        self.writeInt(1)

        self.writeVint(0)
        self.writeVint(-1)

        self.writeBoolean(False)

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

        self.writeVint(0)  # High Id
        self.writeVint(1)  # Low Id

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

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

        if self.player.name is None:

            self.writeString("Guest")  # player name
            self.writeVint(0)
            DataBase.createAccount(self)  # create new account

        else:
            self.writeString(self.player.name)  # player name
            self.writeVint(1)

        self.writeVint(1207959551)

        # Unlocked Brawlers & Resources array
        self.writeVint(len(self.player.CardUnlockID) + 4)  # count

        for unlock_id in self.player.CardUnlockID:
            self.writeVint(23)
            self.writeVint(unlock_id)
            self.writeVint(1)

        for resource in self.player.Resources:
            self.writeVint(5)  # csv id
            self.writeVint(
                self.player.Resources[resource]['id'])  # resource id
            self.writeVint(
                self.player.Resources[resource]['amount'])  # resource amount

        # Brawlers Trophies array
        self.writeVint(len(self.player.BrawlersCount))  # brawlers count

        for brawler_id in self.player.BrawlersCount:
            self.writeScId(16, brawler_id)
            self.writeVint(self.player.BrawlersTrophies[str(brawler_id)])

        # Brawlers Trophies for Rank array
        self.writeVint(len(self.player.BrawlersCount))  # brawlers count

        for brawler_id in self.player.BrawlersCount:
            self.writeScId(16, brawler_id)
            self.writeVint(self.player.BrawlersTrophies[str(brawler_id)])

        self.writeVint(0)

        # Brawlers Upgrade Poitns array
        self.writeVint(len(self.player.BrawlersCount))  # brawlers count

        for brawler_id in self.player.BrawlersCount:
            self.writeScId(16, brawler_id)
            self.writeVint(self.player.brawler_upgrade_points)

        # Brawlers Power Level array
        self.writeVint(len(self.player.BrawlersCount))  # brawlers count

        for brawler_id in self.player.BrawlersCount:
            self.writeScId(16, brawler_id)
            self.writeVint(self.player.brawler_power_level)

        # Gadgets and Star Powers array
        self.writeVint(len(self.player.CardSkillsID))  # count

        for skill_id in self.player.CardSkillsID:
            self.writeVint(23)
            self.writeVint(skill_id)
            self.writeVint(1)

        # "new" Brawler Tag array
        self.writeVint(len(self.player.BrawlersCount))  # brawlers count

        for brawler_id in self.player.BrawlersCount:
            self.writeScId(16, brawler_id)
            self.writeVint(2)

        self.writeVint(self.player.gems)  # Player Gems
        self.writeVint(0)
        self.writeVint(99)
        self.writeVint(100)
        self.writeVint(0)
        self.writeVint(0)
        self.writeVint(0)
        self.writeVint(0)
        self.writeVint(0)
        self.writeVint(0)
        self.writeVint(0)
        self.writeVint(2)
        self.writeVint(1589967120)