def process(self):
        self.player.brawlers_skins[str(self.player.homeBrawler)] = self.skinID
        self.player.starpower = Cards.get_spg_by_brawler_id(self, self.player.homeBrawler, 4)
        self.player.gadget    = Cards.get_spg_by_brawler_id(self, self.player.homeBrawler, 5)

        self.player.updateAccount('Starpower', self.player.starpower)
        self.player.updateAccount('Gadget', self.player.gadget)
        self.player.updateAccount('HomeSkins', self.player.brawlers_skins)
        self.player.updateAccount('HomeBrawler', self.player.homeBrawler)
Beispiel #2
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)
Beispiel #3
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()
    def process(self, db):
        self.player.home_brawler = Characters.get_brawler_by_skin_id(
            self, self.skinID)
        db.update_player_account(self.player.token, 'HomeBrawler',
                                 self.player.home_brawler)

        self.player.selected_skins[str(self.player.home_brawler)] = self.skinID
        db.update_player_account(self.player.token, 'SelectedSkins',
                                 self.player.selected_skins)

        self.player.starpower = Cards.get_spg_by_brawler_id(
            self, self.player.home_brawler, 4)
        db.update_player_account(self.player.token, 'StarPower',
                                 self.player.starpower)

        self.player.gadget = Cards.get_spg_by_brawler_id(
            self, self.player.home_brawler, 5)
        db.update_player_account(self.player.token, 'Gadget',
                                 self.player.gadget)
    def process(self):
        if self.scID[0] == 29:
            self.player.homeBrawler = Characters.get_brawler_by_skin_id(
                self, self.scID[1])
            self.player.starpower = Cards.get_spg_by_brawler_id(
                self, self.player.homeBrawler, 4)
            self.player.gadget = Cards.get_spg_by_brawler_id(
                self, self.player.homeBrawler, 5)

        elif self.scID[0] == 23:
            type = Cards.check_spg_id(self, self.scID[1])
            if type == '4':
                self.player.starpower = self.scID[1]
            elif type == '5':
                self.player.gadget = self.scID[1]

        self.player.updateAccount('Starpower', self.player.starpower)
        self.player.updateAccount('Gadget', self.player.gadget)
        self.player.updateAccount('HomeBrawler', self.player.homeBrawler)

        TeamMessage(self.client, self.player).send()
    def process(self, db):
        if self.data_ref[0] == 29:
            self.player.home_brawler = Characters.get_brawler_by_skin_id(
                self, self.data_ref[1])
            self.player.home_skin = self.data_ref[1]
            self.player.starpower = Cards.get_spg_by_brawler_id(
                self, self.player.home_brawler, 4)
            self.player.gadget = Cards.get_spg_by_brawler_id(
                self, self.player.home_brawler, 5)

        elif self.data_ref[0] == 23:
            type = Cards.check_spg_id(self, self.data_ref[1])
            if type == '4':
                self.player.starpower = self.data_ref[1]
            elif type == '5':
                self.player.gadget = self.data_ref[1]

            db.update_player_account(self.player.token, 'StarPower',
                                     self.player.starpower)
            db.update_player_account(self.player.token, 'Gadget',
                                     self.player.gadget)

        TeamMessage(self.client, self.player).send()
Beispiel #7
0
class Players:
    config = open('config.json', 'r')
    content = config.read()
    settings = json.loads(content)

    # Player data
    high_id = 0
    low_id = 0
    token = "None"
    IsFacebookLinked = 0
    FacebookID = "None"
    FacebookToken = "None"
    box_id = 0
    map_id = 7
    slot_index = 0
    room_id = 0
    brawler_id = 0
    skin_id = 0

    # Socket
    ClientDict = {}

    # Brawler data
    skins_id = Skins.get_skins_id()
    brawlers_id = Characters.get_brawlers_id()
    card_skills_id = Cards.get_spg_id()
    card_unlock_id = Cards.get_brawler_unlock()

    # General player (Brawler, Currency, etc..)
    UnlockType = settings['UnlockedBrawlersOption']
    BrawlersDict = json.loads(json.dumps(settings['UnlockedBrawler'][0]))
    BrawlersUnlockedState = {}

    if UnlockType == "All":
        for i in brawlers_id:
            BrawlersUnlockedState[str(i)] = 1
    elif UnlockType == "SpecifiedOnly":
        index = 0
        for brawlers_name in BrawlersDict:
            BrawlersUnlockedState[str(index)] = BrawlersDict[brawlers_name]
            if index == 34:
                index += 3
            elif index == 32:
                index += 2
            else:
                index += 1
    elif UnlockType == "StarterOnly":
        starter = [0, 1, 2, 3, 7, 8, 9, 14, 22, 27, 30]
        for i in brawlers_id:
            if i in starter:
                BrawlersUnlockedState[str(i)] = 1
            else:
                BrawlersUnlockedState[str(i)] = 0

    brawler_power_level = settings['BrawlerPowerLevel']
    brawler_trophies_for_rank = settings['BrawlerTrophiesForRank']
    brawler_trophies = settings['BrawlerTrophies']
    brawler_upgrade_points = settings['BrawlerUpgradePoints']
    brawlers_spg_unlock = {}  # For starpower and gadget
    gadget = 255
    starpower = 76

    brawlers_trophies = {}
    for id in brawlers_id:
        brawlers_trophies.update({f'{id}': brawler_trophies_for_rank})

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

    name = "Guest"
    player_experience = 0
    profile_icon = 0
    name_color = 0
    do_not_distrub = 0
    brawl_boxes = settings['BrawlBoxTokens']
    big_boxes = settings['BigBoxTokens']
    star_points = settings['Starpoints']
    highest_trophies = 0
    trophies = settings['Trophies']
    solo_wins = 0
    duo_wins = 0
    ThreeVSThree_wins = 0
    gems = settings['Gems']
    gold = settings['Gold']
    tickets = settings['Tickets']
    tokensdoubler = 0
    player_tokens = 0

    # Alliances
    club_high_id = 0
    club_low_id = 0
    club_role = 0

    # Message stuff...
    update_url = settings['UpdateUrl']
    patch_url = settings['PatchUrl']
    patch_sha = Fingerprint.loadFinger("GameAssets/fingerprint.json")
    maintenance_time = 0

    err_code = 7
    maintenance = False
    patch = False

    if settings['Patch']:
        error_code = 7
        patch = True

    if settings['Maintenance']:
        err_code = 10
        maintenance = True
        maintenance_time = settings['MaintenanceTime']

    # Chat data
    message_tick = 0
    bot_message_tick = 0

    brawlers_trophies_in_rank = {
        '0': brawler_trophies_for_rank,
        '1': brawler_trophies_for_rank,
        '2': brawler_trophies_for_rank,
        '3': brawler_trophies_for_rank,
        '4': brawler_trophies_for_rank,
        '5': brawler_trophies_for_rank,
        '6': brawler_trophies_for_rank,
        '7': brawler_trophies_for_rank,
        '8': brawler_trophies_for_rank,
        '9': brawler_trophies_for_rank,
        '10': brawler_trophies_for_rank,
        '11': brawler_trophies_for_rank,
        '12': brawler_trophies_for_rank,
        '13': brawler_trophies_for_rank,
        '14': brawler_trophies_for_rank,
        '15': brawler_trophies_for_rank,
        '16': brawler_trophies_for_rank,
        '17': brawler_trophies_for_rank,
        '18': brawler_trophies_for_rank,
        '19': brawler_trophies_for_rank,
        '20': brawler_trophies_for_rank,
        '21': brawler_trophies_for_rank,
        '22': brawler_trophies_for_rank,
        '23': brawler_trophies_for_rank,
        '24': brawler_trophies_for_rank,
        '25': brawler_trophies_for_rank,
        '26': brawler_trophies_for_rank,
        '27': brawler_trophies_for_rank,
        '28': brawler_trophies_for_rank,
        '29': brawler_trophies_for_rank,
        '30': brawler_trophies_for_rank,
        '31': brawler_trophies_for_rank,
        '32': brawler_trophies_for_rank,
        '34': brawler_trophies_for_rank,
        '37': brawler_trophies_for_rank
    }

    brawlers_upgradium = {
        '0': brawler_upgrade_points,
        '1': brawler_upgrade_points,
        '2': brawler_upgrade_points,
        '3': brawler_upgrade_points,
        '4': brawler_upgrade_points,
        '5': brawler_upgrade_points,
        '6': brawler_upgrade_points,
        '7': brawler_upgrade_points,
        '8': brawler_upgrade_points,
        '9': brawler_upgrade_points,
        '10': brawler_upgrade_points,
        '11': brawler_upgrade_points,
        '12': brawler_upgrade_points,
        '13': brawler_upgrade_points,
        '14': brawler_upgrade_points,
        '15': brawler_upgrade_points,
        '16': brawler_upgrade_points,
        '17': brawler_upgrade_points,
        '18': brawler_upgrade_points,
        '19': brawler_upgrade_points,
        '20': brawler_upgrade_points,
        '21': brawler_upgrade_points,
        '22': brawler_upgrade_points,
        '23': brawler_upgrade_points,
        '24': brawler_upgrade_points,
        '25': brawler_upgrade_points,
        '26': brawler_upgrade_points,
        '27': brawler_upgrade_points,
        '28': brawler_upgrade_points,
        '29': brawler_upgrade_points,
        '30': brawler_upgrade_points,
        '31': brawler_upgrade_points,
        '32': brawler_upgrade_points,
        '34': brawler_upgrade_points,
        '37': brawler_upgrade_points
    }

    Brawler_level = {
        '0': brawler_power_level,
        '1': brawler_power_level,
        '2': brawler_power_level,
        '3': brawler_power_level,
        '4': brawler_power_level,
        '5': brawler_power_level,
        '6': brawler_power_level,
        '7': brawler_power_level,
        '8': brawler_power_level,
        '9': brawler_power_level,
        '10': brawler_power_level,
        '11': brawler_power_level,
        '12': brawler_power_level,
        '13': brawler_power_level,
        '14': brawler_power_level,
        '15': brawler_power_level,
        '16': brawler_power_level,
        '17': brawler_power_level,
        '18': brawler_power_level,
        '19': brawler_power_level,
        '20': brawler_power_level,
        '21': brawler_power_level,
        '22': brawler_power_level,
        '23': brawler_power_level,
        '24': brawler_power_level,
        '25': brawler_power_level,
        '26': brawler_power_level,
        '27': brawler_power_level,
        '28': brawler_power_level,
        '29': brawler_power_level,
        '30': brawler_power_level,
        '31': brawler_power_level,
        '32': brawler_power_level,
        '34': brawler_power_level,
        '37': brawler_power_level
    }

    # Friendly game (Teams, info, result)
    battle_result = 0
    game_type = 0
    use_gadget = 1
    rank = 0
    team = 0
    isReady = 0

    bot1 = 0
    bot1_n = None
    bot2 = 0
    bot2_n = None
    bot3 = 0
    bot3_n = None
    bot4 = 0
    bot4_n = None
    bot5 = 0
    bot5_n = None

    def CreateNewBrawlersList():
        Players.BrawlersUnlockedState = {}
        for id in Players.brawlers_id:
            if id == 0:
                Players.BrawlersUnlockedState[str(id)] = 1
            else:
                Players.BrawlersUnlockedState[str(id)] = 0
        return Players.BrawlersUnlockedState

    def __init__(self, device):
        self.device = device
Beispiel #8
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
Beispiel #9
0
class Players:

    try:
        config = open('config.json', 'r')
        content = config.read()
    except FileNotFoundError:
        print("Creating config.json...")
        Config.create_config()
        config = open('config.json', 'r')
        content = config.read()

    settings = json.loads(content)

    HighID = 0
    LowID = 0
    Token = None
    boxID = 0
    mapID = 7
    roomID = 0
    brawlerID = 0
    skinID = 0

    SkinsCount = Skins.get_skins_id()
    BrawlersCount = Characters.get_brawlers_id()
    CardSkillsID = Cards.get_spg_id()
    CardUnlockID = Cards.get_brawler_unlock()

    brawler_power_level = settings['BrawlerPowerLevel']
    brawler_trophies_for_rank = settings['BrawlerTrophiesForRank']
    brawler_trophies = settings['BrawlerTrophies']
    brawler_upgrade_points = settings['BrawlerUpgradePoints']
    trophies = settings['Trophies']
    gems = settings['Gems']
    gold = settings['Gold']
    tickets = settings['Tickets']
    name = None
    profileIcon = 0
    brawlBoxes = settings['BrawlBoxTokens']
    bigBoxes = settings['BigBoxTokens']
    starPoints = settings['Starpoints']

    Resources = {
        'brawlbox': {
            'id': 1,
            'amount': brawlBoxes
        },
        'gold': {
            'id': 8,
            'amount': gold
        },
        'bigbox': {
            'id': 9,
            'amount': bigBoxes
        },
        'starpoints': {
            'id': 10,
            'amount': starPoints
        },
    }

    updateUrl = settings['UpdateUrl']
    patchUrl = settings['PatchUrl']
    patch_sha = Fingerprint.loadFinger("GameAssets/fingerprint.json")

    err_code = 7
    maintenance = False
    patch = False

    patching = settings['Patch']

    if patching:
        error_code = 7
        patch = True

    if settings['Maintenance']:
        err_code = 10
        maintenance = True

    messageTick = 0
    botMessageTick = 0

    shellySkin = 0
    nitaSkin = 0
    coltSkin = 0
    bullSkin = 0
    jessieSkin = 0
    brockSkin = 0
    dynamikeSkin = 0
    boSkin = 0
    elprimoSkin = 0
    barleySkin = 0
    pocoSkin = 0
    ricoSkin = 0
    darrylSkin = 0
    pennySkin = 0
    piperSkin = 0
    pamSkin = 0
    frankSkin = 0
    mortisSkin = 0
    taraSkin = 0
    spikeSkin = 0
    crowSkin = 0
    geneSkin = 0
    tickSkin = 0
    leonSkin = 0
    rosaSkin = 0
    carlSkin = 0
    bibiSkin = 0
    bitSkin = 0
    sandySkin = 0
    beaSkin = 0
    emzSkin = 0
    mrpSkin = 0
    maxSkin = 0
    jackySkin = 0
    galeSkin = 0
    naniSkin = 0
    sproutSkin = 0
    gadget = 255
    starpower = 76
    namecolor = 12
    GameType = 0
    Rank = 0
    Team = 0
    Bot1 = 0
    Bot1N = None
    Bot2 = 0
    Bot2N = None
    Bot3 = 0
    Bot3N = None
    Bot4 = 0
    Bot4N = None
    Bot5 = 0
    Bot5N = None
    useGadget = 1
    DoNotDistrub = 0

    def __init__(self, device):
        self.device = device
Beispiel #10
0
class Players:
    try:
        config = open('config.json', 'r')
        content = config.read()
    except FileNotFoundError:
        print("Creating config.json...")
        Config.create_config()
        config = open('config.json', 'r')
        content = config.read()

    settings = json.loads(content)

    # Player data
    high_id = 0
    low_id = 0
    token = None
    box_id = 0
    map_id = 7
    room_id = 0
    brawler_id = 0
    skin_id = 0

    # Brawler data
    skins_id = Skins.get_skins_id()
    brawlers_id = Characters.get_brawlers_id()
    card_skills_id = Cards.get_spg_id()
    card_unlock_id = Cards.get_brawler_unlock()
    brawler_power_level = settings['BrawlerPowerLevel']
    brawler_trophies_for_rank = settings['BrawlerTrophiesForRank']
    brawler_trophies = settings['BrawlerTrophies']
    brawler_upgrade_points = settings['BrawlerUpgradePoints']
    gadget = 255
    starpower = 76

    brawlers_trophies = {}
    for id in brawlers_id:
        brawlers_trophies.update({f'{id}': brawler_trophies_for_rank})

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

    # Player info
    name = "Guest"
    profile_icon = 0
    name_color = 0
    do_not_distrub = 0
    brawl_boxes = settings['BrawlBoxTokens']
    big_boxes = settings['BigBoxTokens']
    star_points = settings['Starpoints']
    trophies = settings['Trophies']
    gems = settings['Gems']
    gold = settings['Gold']
    tickets = settings['Tickets']

    # Server config
    update_url = settings['UpdateUrl']
    patch_url = settings['PatchUrl']
    patch_sha = Fingerprint.loadFinger("GameAssets/fingerprint.json")

    err_code = 7
    maintenance = False
    patch = False

    patching = settings['Patch']

    if patching:
        error_code = 7
        patch = True

    if settings['Maintenance']:
        err_code = 10
        maintenance = True

    # Chat data
    message_tick = 0
    bot_message_tick = 0

    # Friendly game data & info
    battle_result = 0
    game_type = 0
    use_gadget = 1
    rank = 0
    team = 0

    bot1 = 0
    bot1_n = None
    bot2 = 0
    bot2_n = None
    bot3 = 0
    bot3_n = None
    bot4 = 0
    bot4_n = None
    bot5 = 0
    bot5_n = None

    def __init__(self, device):
        self.device = device
    def encode(self):

        self.writeVInt(0)
        self.writeVInt(0)

        for x in range(3):
            self.writeLogicLong(self.player.ID)

        if self.player.name == "Guest" and not self.player.name_set:
            self.writeString("Guest")
            self.writeVInt(0)
        else:
            self.writeString(self.player.name)
            self.writeVInt(1)

        self.writeInt(0)

        self.writeVInt(8)  # Commodity Array

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

        # Unlocked Brawlers & Resources array
        self.writeVInt(
            len(self.player.resources) + len(self.player.brawlers_card_id))

        for x in self.player.brawlers_card_id:
            self.writeDataReference(23, x)
            self.writeVInt(1)

        for resource in self.player.resources:
            self.writeDataReference(5, resource['ID'])
            self.writeVInt(resource['Amount'])

        self.writeVInt(len(self.player.brawlers_id))
        for x in self.player.brawlers_id:
            self.writeDataReference(16, x)
            self.writeVInt(self.player.brawlers_trophies[str(x)])

        self.writeVInt(len(self.player.brawlers_id))
        for x in self.player.brawlers_id:
            self.writeDataReference(16, x)
            self.writeVInt(self.player.brawlers_high_trophies[str(x)])

        self.writeVInt(0)
        for x in range(0):
            self.writeDataReference(16, x)
            self.writeVInt(0)

        self.writeVInt(len(self.player.brawlers_unlocked))
        for x in self.player.brawlers_unlocked:
            self.writeDataReference(16, x)
            self.writeVInt(self.player.brawlers_powerpoints[str(x)])

        self.writeVInt(len(self.player.brawlers_id))
        for x in self.player.brawlers_id:
            self.writeDataReference(16, x)
            self.writeVInt(self.player.brawlers_level[str(x)])

        self.writeVInt(len(self.player.brawlers_spg))
        for x in self.player.brawlers_spg:
            self.writeDataReference(23, x)
            self.writeVInt(1)

        self.writeVInt(0)  # New Brawlers Array
        for x in range(0):
            self.writeDataReference(16, x)
            self.writeVInt(0)

        self.writeVInt(self.player.gems)  # Player Gems
        self.writeVInt(self.player.gems)  # Player Free Gems

        self.writeVInt(0)
        self.writeVInt(0)
        self.writeVInt(0)
        self.writeVInt(0)
        self.writeVInt(0)
        self.writeVInt(0)
        self.writeVInt(0)
        self.writeVInt(0)
        self.writeVInt(0)

        self.writeVInt(2)  # Tutorial State
Beispiel #12
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)
    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.highest_trophies)  # Player Max Reached Trophies

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

        self.writeVint(
            99999
        )  # Player exp set to high number because of the name and bot battle level restriction

        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)  # "token limit reached message" if true
        self.writeVint(1)
        self.writeBoolean(True)

        self.writeVint(self.player.tokensdoubler)  # Token doubler ammount
        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)
        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("Classic Brawl")  # 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(8):
            self.writeVint(i)

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

        for map in EventSlots.maps:

            self.writeVint(EventSlots.maps.index(map) + 1)
            self.writeVint(EventSlots.maps.index(map) + 1)
            self.writeVint(map['Ended'])  # IsActive | 0 = Active, 1 = Disabled
            self.writeVint(EventSlots.Timer)  # Timer

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

            self.writeVint(map['Status'])

            self.writeString()
            self.writeVint(0)
            self.writeVint(0)  # Powerplay game played
            self.writeVint(0)  # Powerplay game left maximum

            if map['Modifier'] > 0:
                self.writeBoolean(True)  # Gamemodifier boolean
                self.writeVint(1)  # ModifierID
            else:
                self.writeBoolean(False)

            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)  # array
        self.writeVint(200)  # 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)  # Box boolean

        self.writeVint(0)  # array

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

        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(self.player.high_id)  # High Id
        self.writeVint(self.player.low_id)  # 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

        index = 0
        for unlock_id in self.player.card_unlock_id:
            self.writeVint(23)
            self.writeVint(unlock_id)
            try:
                self.writeVint(self.player.BrawlersUnlockedState[str(index)])
            except:
                self.writeVint(1)

            if index == 34:
                index += 3
            elif index == 32:
                index += 2
            else:
                index += 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)
            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)
            self.writeVint(
                self.player.brawlers_trophies_in_rank[str(brawler_id)])

        self.writeVint(0)  # array

        # Brawlers Upgrade Points 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.brawlers_upgradium[str(brawler_id)])

        # 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_level[str(brawler_id)])

        # Gadgets and Star Powers array
        spgList = []
        for id, level in self.player.Brawler_level.items():
            if level == 8:
                spg = Cards.get_unlocked_spg(self, int(id))
                for i in range(len(spg)):
                    spgList.append(spg[i])
        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)
            if skill_id in spgList:
                self.writeVint(1)
            else:
                self.writeVint(0)

        # "new" Brawler Tag array
        self.writeVint(0)  # brawlers count

        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(0)
        self.writeVint(2)
        self.writeVint(1585502369)