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)
Exemplo n.º 2
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):
        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()
Exemplo n.º 5
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
Exemplo n.º 6
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
Exemplo n.º 7
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
Exemplo n.º 8
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
Exemplo n.º 9
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)