Example #1
0
class Player:
    try:
        config = open('config.json', 'r')
        content = config.read()
    except FileNotFoundError:
        Helpers().create_config()
        config = open('config.json', 'r')
        content = config.read()

    settings = json.loads(content)

    skins_id = Skins().get_skins_id()
    brawlers_id = Characters().get_brawlers_id()

    ID = 0
    token = None

    trophies = settings['Trophies']
    tickets = settings['Tickets']
    gems = settings['Gems']
    resources = [{
        'ID': 1,
        'Amount': settings['BrawlBoxTokens']
    }, {
        'ID': 8,
        'Amount': settings['Gold']
    }, {
        'ID': 9,
        'Amount': settings['BigBoxTokens']
    }, {
        'ID': 10,
        'Amount': settings['StarPoints']
    }]
    high_trophies = 999999
    trophy_reward = 300
    exp_points = settings['ExperiencePoints']
    profile_icon = 0
    name_color = 0
    selected_brawler = 0
    region = settings['Region']
    content_creator = "Modern Brawl"
    name_set = False
    name = 'Guest'
    map_id = 0
    use_gadget = True
    starpower = 76
    gadget = 255
    home_brawler = 0
    home_skin = 0
    leaderboard_type = 0
    leaderboard_is_global = False
    bp_activated = False
    token_doubler = 0
    welcome_msg_viewed = False
    theme_id = settings['ThemeID']
    content_creator_codes = settings['ContentCreatorCodes']
    maintenance = settings['Maintenance']
    maintenance_time = settings['SecondsTillMaintenanceOver']
    patch = settings['Patch']
    patch_url = settings['PatchURL']
    patch_sha = Fingerprint.loadFinger("GameAssets/fingerprint.json")
    update_url = settings['UpdateURL']

    delivery_items = {}
    box_rewards = {}

    db = None

    battle_tick = 0

    emotes_id = Emotes().get_emotes_id()

    unlocked_skins = skins_id

    selected_skins = {}
    for id in brawlers_id:
        selected_skins.update({f"{id}": 0})

    brawlers_unlocked = [0, 1]

    brawlers_card_id = []
    for x in brawlers_unlocked:
        brawlers_card_id.append(Cards().get_unlock_by_brawler_id(x))

    brawlers_spg = Cards().get_spg_id()

    def_trophies = 0
    def_high_trophies = 99999

    brawlers_trophies = {}
    for x in brawlers_id:
        brawlers_trophies.update({f'{x}': def_trophies})

    brawlers_high_trophies = {}
    for x in brawlers_id:
        brawlers_high_trophies.update({f'{x}': def_high_trophies})

    def_level = 0

    brawlers_level = {}
    for x in brawlers_id:
        brawlers_level.update({f'{x}': def_level})

    def_pp = 0

    brawlers_powerpoints = {}
    for x in brawlers_id:
        brawlers_powerpoints.update({f'{x}': def_pp})

    club_id = 0
    club_role = 0

    message_tick = 0

    clients = {}

    def __init__(self, device):
        self.device = device
Example #2
0
class Player:
    ID = 0
    token = None

    skinsID = Skins().get_skins_id()
    emotesID = Emotes().get_emotes_id()
    brawlersID = Characters().get_brawlers_id()
    cardsSkillsID = Cards().get_spg_id()
    cardsUnlockID = Cards().get_brawler_unlock()

    brawlers_skins = {}
    for id in brawlersID:
        brawlers_skins.update({f'{id}': 0})

    majorVersion, minorVersion, buildVersion = 28, 189, 1
    resources = []
    gold, tickets, gems, starpoints, trophies = 10000, 500, 9999, 10000, 12000
    homeBrawler, homeSkin, nameColor, thumbnail, roomID, mapID, team = 0, 0, 0, 0, 0, 0, 0
    name, nameSet = '', False
    starpower, gadget = 76, 255
    dnd, useGadget = False, True

    Helpers = Helpers()

    def __init__(self, device):
        self.device = device
        self.Data = None
        self.ID = Player.ID
        self.token = Player.token
        self.Helpers = Helpers()

    def getPlayerAccount(self):
        if self.token:
            self.loadPlayerAccount()
        else:
            if self.ID == 0:
                self.createPlayerAccount()

        Player.name = self.Data['Name']
        Player.nameSet = self.Data['NameSet']
        Player.thumbnail = self.Data['Thumbnail']
        Player.nameColor = self.Data['NameColor']
        Player.trophies = self.Data['Trophies']
        Player.tickets = self.Data['Tickets']
        Player.gems = self.Data['Diamonds']
        Player.resources = self.Data['Resources']
        Player.starpower = self.Data['Starpower']
        Player.gadget = self.Data['Gadget']
        Player.homeBrawler = self.Data['HomeBrawler']
        Player.homeSkin = self.Data['HomeSkin']
        Player.brawlers_skins = self.Data['HomeSkins']

    def loadPlayerAccount(self):
        self.DB = DataBase()
        try:
            self.Data = json.loads(self.DB.getPlayerAccount(self.token)[0][3])
        except IndexError:  # Account not found
            self.createPlayerAccount(token=self.token)

    def createPlayerAccount(self,
                            token=Helpers.randomToken(),
                            id=Helpers.randomID()):
        self.DB = DataBase()

        self.ID = id
        self.token = token

        data = {
            'ID':
            self.ID,
            'Token':
            self.token,
            'Name':
            'Guest',
            'NameSet':
            False,
            'Trophies':
            99999,
            'Tickets':
            8888,
            'Diamonds':
            9999,
            'Score':
            99999,
            'ExpPoints':
            99999,
            'HomeBrawler':
            0,
            'HomeSkin':
            0,
            'Starpower':
            76,
            'Gadget':
            255,
            'Thumbnail':
            0,
            'NameColor':
            0,
            'HomeSkins':
            Player.brawlers_skins,
            'Resources': [{
                'ID': 1,
                'Amount': 10000
            }, {
                'ID': 8,
                'Amount': Player.gold
            }, {
                'ID': 9,
                'Amount': 10000
            }, {
                'ID': 10,
                'Amount': Player.starpoints
            }],
        }

        self.DB.createPlayerAccount(self.token, self.ID, 9999,
                                    json.dumps(data))
        self.Data = json.loads(self.DB.getPlayerAccount(self.token)[0][3])

    def updateAccount(self, var, value):
        self.DB = DataBase()
        self.Data[var] = value
        self.DB.updatePlayerAccount('data', json.dumps(self.Data), self.token)