Beispiel #1
0
    def write_to_clan_chat(self, text: str) -> bool:
        data = '{"msg":"'+str(text)+'","id":"'+str(self.id)+'"}';
        j = make_request('clan/write', data=data)

        if j:
            return True#r.get('success', False)
        else:
            return False
Beispiel #2
0
    def _get_user(self, user_id: str) -> dict:
        data = '{"playerId":"'+user_id+'","id":"'+self.id+'"}'
        j = make_request('profiles/details', data=data)

        if j:
            return j.get('player', None)
        else:
            return None
Beispiel #3
0
    def ranked_battle(self, enemy_id: str) -> bool:
        data = '{"enemyId":"'+str(enemy_id)+'","groupId":"'+str(self.group_id)+'","id":"'+str(self.id)+'"}'
        j = make_request('battle/ranked', data=data)

        if j:
            return True
        else:
            return False
Beispiel #4
0
    def get_more_info(self):
        data = '{"chat":false,"id":"' + self.owner_id + '"}'
        j = make_request('clan', data)

        if j:
            return j['clan']
        else:
            return None
Beispiel #5
0
    def search_clans(self) -> list:
        data = '{"id":"'+str(self.id)+'"}'
        j = make_request('clans/search', data=data)

        if j:
            for i in j['clans']:
                yield duels_api.Clan(i['_id'], self.id, self.log)
        else:
            return []
Beispiel #6
0
    def get_me(self):
        data = '{"clanId":"' + str(self.id) + '","id":"' + str(
            self.owner_id) + '"}'
        j = make_request('clan/info', data)

        if j:
            return j
        else:
            return None
Beispiel #7
0
    def claim_reward(self, claim_id: str) -> bool:
        data = '{"containerId":"'+str(claim_id)+'","id":"'+str(self.id)+'"}'
        j = make_request('queue/claim', data=data)

        if j:
            self.log.debug("{} Claimed reward".format(self.id))
            return True
        else:
            self.log.debug("{} Cant claimed reward".format(self.id))
            return False
Beispiel #8
0
    def equip(self) -> bool:
        data = '{"partId":"'+str(self.id)+'","id":"'+str(self.owner_id)+'"}'
        j = make_request('inventory/equip', data)

        if j:
            self.log.debug("{} Equiped item".format(self.id))
            return True
        else:
            self.log.debug("{} Can`t equip".format(self.id))
            return False
Beispiel #9
0
    def join_clan(self, clan_id: str) -> bool:
        data = '{"clanId":"'+str(clan_id)+'","id":"'+str(self.id)+'"}'
        j = make_request('clans/join', data=data)

        if j:
            self.log.debug("{} Join clan {}".format(self.name, clan_id))
            return True
        else:
            self.log.debug("{} Cant join clan {}".format(self.name, clan_id))
            return False
Beispiel #10
0
    def dissasemble(self) -> bool:
        data = '{"partId":"'+str(self.id)+'","id":"'+str(self.owner_id)+'"}'
        j = make_request('inventory/disassemble', data)

        if j:
            self.log.debug("{} Dissasemble item".format(self.id))
            return True
        else:
            self.log.debug("{} Can`t dissasemble".format(self.id))
            return False
Beispiel #11
0
    def leave_clan(self) -> bool:
        data = '{"id":"'+self.id+'"}'
        j = make_request('clan/leave', data=data)

        if j:
            self.log.debug("{} Leave clan".format(self.name))
            return True
        else:
            self.log.debug("{} Cant leave clan".format(self.name))
            return False
Beispiel #12
0
    def get_defeated_clan_opponent(self) -> int:
        data = '{"chat":false,"id":"'+self.id+'"}'
        j = make_request('clan', data=data)

        if j:
            j = j['clan']['war'].get('war', None)
            if j is not None:
                return j['defeatedOpponents']
            else:
                return 10
        else:
            return -1
Beispiel #13
0
    def clan_battle(self) -> int:
        if self.get_defeated_clan_opponent()<10:
            self.log.debug("clan battle {}".format(self.name))
            data = '{"id":"'+str(self.id)+'"}'
            j = make_request('clan/war/battle', data=data)

            if j:
                return j['battle']['result']
            else:
                return -1
        else:
            return -2
Beispiel #14
0
    def get_ranked_claim_id(self) -> str:
        data = '{"id":"'+str(self.id)+'"}'
        j = make_request('ranking/group', data=data)

        if j:
            j = j.get('_q')
            if j is not None:
                return j[0]['_id']
            else:
                return None
        else:
            return None
Beispiel #15
0
    def edit_description(self,
                         clan_name: str = '',
                         description: str = '') -> bool:
        data = '{"name":"' + (
            clan_name.encode('utf-8').decode('latin-1')
            if clan_name != '' else self.name.encode('utf-8').decode('latin-1')
        ) + '","countryInfo":"UA","description":"' + (
            description.encode('utf-8').decode('latin-1') if description != ''
            else self.description.encode('utf-8').decode('latin-1')
        ) + '","badge":{"backInfo":"ClanBadgeBackground001","backColor":"F04E0D","iconInfo":"ClanBadgeIcon009","iconColor":"FFFFFF"},"id":"' + str(
            self.owner_id) + '"}'
        j = make_request('clan/edit', data)

        return True if j.get('error', True) is True else False
Beispiel #16
0
    def claim_reward_group(self) -> int:
        claim_id = self.get_ranked_claim_id()
        if claim_id is not None:
            data = '{"containerId":"'+str(claim_id)+'","id":"'+str(self.id)+'"}'
            j = make_request('queue/claim', data=data)

            if j:
                self.log.debug("Claim reward {} - keys: {}".format(self.name, j['_u']['Key@Value']))
                return j['_u']['Key@Value']
            else:
                return -1
        else:
            self.log.debug("Cant get reward for ranked battle {}".format(self.name))
            return -2
Beispiel #17
0
    def get_special_crate(self) -> list:
        data = '{"info":"SpecialCrate1","id":"'+str(self.id)+'"}'
        j = make_request('crates/buy', data=data)

        if j:
            self.log.debug("{} Special crate".format(self.id))
            if self.claim_reward(j['_q'][0]['_id']):
                for i in j['_q'][0]['steps'][0]['crate']['rewards']:
                    item = i['reward']
                    yield Item(item['__id'], self.id, item['__type'], item['rarity'], item['stat']['info'], item['stat']['value'])
            else:
                return []
        else:
            return []
Beispiel #18
0
    def set_ranked_group_info(self) -> bool:
        data = '{"id":"'+self.id+'"}'
        j = make_request('ranking/group', data=data)

        if j:
            try:
                self.group_id = j['group']['_id']
                self.group_players = [i['pid'] for i in j['group']['members'] if i.get("pid") is not None]
                self.group_players.remove(self.id)
            except Exception as e:
                print(self)
                print(j)
                print(e)

            return True
        else:
            return False
Beispiel #19
0
    def _create_user(self) -> bool:
        data = '{"ids":["'+str(uuid4())+'"],"appBundle":"com.deemedyainc.duels","appVersion":"0.6.6","platform":"Android"}'
        j = make_request('general/login', data=data)

        return j['profile']['_id']