def get_profile(self, player, user=None): if not player or len(player) > 15 or len(player.split()) != 1: return {'error': 'name not matched'} force = False if player.endswith('!'): player = player[:-1] force = True profile = ScannerPg().get_profile(player) if profile and not force: if util.TimeCl(profile['update']).daydiff() < 3: return profile profile = Scanner().get_player_profile(player, user) if profile.get('error'): return profile if not profile.get('ap') or profile.get('error'): ScannerPg().insert_error_profile(player) return { 'error': 'Player profile not found, banned or renamed', 'playername': player } ScannerPg().insert_profile(ProfileScannerModel(profile).profile) return ProfileScannerModel(profile).profile
def get_user(self): result = self.data.get('result') entity = result.get('playerEntity')[2] agent_name = result.get('nickname') xsrf = result.get('xsrfToken') faction = entity.get('controllingTeam').get('team') agent_id = result.get('playerEntity')[0] ScannerPg().update_agent_info(agent_name, agent_id, xsrf, faction)
def __init__(self, data, current): agent_id = data.get('agent_id') hm = InventoryModel(data, current) self.render = hm.to_render_json( ScannerPg().get_agent_inventory(agent_id))
def __init__(self, data, current): agent_id = data.get('agent_id') hm = AccountModel(data, current) self.render = hm.to_render_json(ScannerPg().hide_achievements( agent_id, current.get('email')))
def __init__(self, data, current): agent_name = data.get('agent_name') hm = AccountModel(data, current) self.render = hm.to_render_json(ScannerPg().remove_account( agent_name, current.get('email')))
def __init__(self, data, current): hm = AccountModel(data, current) self.render = hm.to_render_json(ScannerPg().get_user_accounts( current.get('email')))
def get_inventory(self): for i in self.headers: if i == 'Cookie': cookie = self.headers[i] elif i == 'X-XsrfToken': xsrf = self.headers[i] ScannerPg().update_agent_cookies(cookie, xsrf) inventory = self.data.get('gameBasket').get('inventory') agent_id = '' if inventory: resourceWithLevels = collections.OrderedDict() resource = collections.OrderedDict() modResource = collections.OrderedDict() portalkeys = [] for i in inventory: if agent_id == '': agent_id = i[2].get('inInventory').get('playerId') rw = i[2].get('resourceWithLevels') r = i[2].get('resource') rm = i[2].get('modResource') capsule = i[2].get('container') if rw: item = '{}_{}'.format(rw['level'], rw['resourceType']) if item not in resourceWithLevels: resourceWithLevels[item] = 1 else: counter = resourceWithLevels[item] resourceWithLevels[item] = counter + 1 elif r: if r.get('resourceType') == 'PORTAL_LINK_KEY': portalKey = i[2].get('portalCoupler') lat, lng = portalKey.get('portalLocation').split(',') late6 = int('0x{}'.format(lat[1:]), 16) lnge6 = int('0x{}'.format(lng[1:]), 16) portalKey.update({'portalLocation': [late6, lnge6]}) portalkeys.append(portalKey) elif r.get('resourceType') == 'FLIP_CARD': item = '{}_{}'.format(r['resourceType'], i[2]['flipCard']['flipCardType']) if item not in resource: resource[item] = 1 else: counter = resource[item] resource[item] = counter + 1 else: item = '{}_{}'.format(r['resourceType'], r['resourceRarity']) if capsule: if item not in resource: resource[item] = 1 else: counter = resource[item] resource[item] = counter + 1 for items in capsule.get('stackableItems'): az = items.get('exampleGameEntity')[2] res = az.get('resource') resw = az.get('resourceWithLevels') resm = az.get('modResource') if res: if res.get('resourceType' ) == 'PORTAL_LINK_KEY': portalKey = az.get('portalCoupler') lat, lng = portalKey.get( 'portalLocation').split(',') late6 = int('0x{}'.format(lat[1:]), 16) lnge6 = int('0x{}'.format(lng[1:]), 16) portalKey.update( {'portalLocation': [late6, lnge6]}) portalkeys.append(portalKey) elif res.get( 'resourceType') == 'FLIP_CARD': item = '{}_{}'.format( res['resourceType'], az['flipCard']['flipCardType']) count = capsule.get('currentCount') if item not in resource: resource[item] = count else: counter = resource[item] resource[item] = counter + count else: item = '{}_{}'.format( res['resourceType'], res['resourceRarity']) count = capsule.get('currentCount') if item not in resource: resource[item] = count else: counter = resource[item] resource[item] = counter + count elif resw: item = '{}_{}'.format( resw['level'], resw['resourceType']) count = capsule.get('currentCount') if item not in resourceWithLevels: resourceWithLevels[item] = count else: counter = resourceWithLevels[item] resourceWithLevels[ item] = counter + count elif resm: item = '{}_{}'.format( resm['resourceType'], resm['rarity']) count = capsule.get('currentCount') if item not in modResource: modResource[item] = count else: counter = modResource[item] modResource[item] = counter + count else: if item not in resource: resource[item] = 1 else: counter = resource[item] resource[item] = counter + 1 elif rm: item = '{}_{}'.format(rm['resourceType'], rm['rarity']) if item not in modResource: modResource[item] = 1 else: counter = modResource[item] modResource[item] = counter + 1 itogo = { 'resourceWithLevels': resourceWithLevels, 'resource': resource, 'modResource': modResource, 'portalKeys': portalkeys } ScannerPg().update_agent_inventory(itogo, agent_id)