def get_gambit(membershipType, membershipId, characterId): user = User.query.filter_by( bungieMembershipId=g.user.bungieMembershipId).first() my_api = BungieApi(user) get_profile_res = my_api.get_profile(membershipType, membershipId) activity = my_api.get_activity_history(membershipType, membershipId, characterId, mode=63, count=30) return jsonify(activity)
def get_raid(membershipType, membershipId, characterId): """ Endpoint to get raid data from Bungie.net. Modes: Raid: 4 """ mode = int(request.args.get('game_mode', 4)) user = User.query.filter_by( bungieMembershipId=g.user.bungieMembershipId).first() my_api = BungieApi(user) activity = my_api.get_activity_history(membershipType, membershipId, characterId, mode=mode, count=30) return jsonify(activity)
def get_pvp(membershipType, membershipId, characterId): """ Endpoint to get PvP data from Bungie.net. Modes: 10 : "Control", 12 : "Clash", 15 : "CrimsonDoubles", 19 : "IronBanner", 25 : "AllMayhem", 31 : "Supremacy", 37 : "Survival", 38 : "Countdown", 39 : "TrialsOfTheNine", 48 : "Rumble", 50 : "Doubles", 59 : "Showdown", 60 : "Lockdown", 61 : "Scorched", #??? 65 : "Breakthrough", 67 : "Salvage", 80 : "Elimination", 84 : "TrialsOfOsiris", """ mode = int(request.args.get('gameMode', 5)) season = int(request.args.get('season', CURRENT_SEASON)) user = User.query.filter_by( bungieMembershipId=g.user.bungieMembershipId).first() my_api = BungieApi(user) # get_profile_res = my_api.get_profile(membershipType, membershipId) # character_details = get_character_details_json(get_profile_res) activity = my_api.get_activity_history(membershipType, membershipId, characterId, mode=mode, count=30) return jsonify(activity)
def pgcr_list(membershipType, membershipId, characterId): mode_arg = request.args.get('game_mode', 'pvp') game_mode_switch = { 'pvp': 5, 'trials': 84, 'gambit': 63, 'raid': 4, 'nightfall': 46, 'dungeon': 82, } game_mode = game_mode_switch[mode_arg] game_count = 10 user = User.query.filter_by( bungieMembershipId=g.user.bungieMembershipId).first() my_api = BungieApi(user) activity = my_api.get_activity_history(membershipType, membershipId, characterId, mode=game_mode, count=game_count) pgcr_list = [] stat_list = [] activities_res = activity["Response"].get("activities", None) if not activities_res: print("\n\n\nNo activities!!!") pgcr_list_res = { "Response": stat_list, "statusCode": 200, "ErrorStatus": "Success", } return jsonify(pgcr_list_res) for a in activity["Response"]["activities"]: pgcr_list.append(a["activityDetails"]["instanceId"]) pgcr_res_list = [] for index, instanceId in enumerate(pgcr_list): pgcr_res = my_api.get_pgcr(instanceId) pgcr_res_list.append(pgcr_res["Response"]) for entry in pgcr_res["Response"]["entries"]: if entry["player"]["destinyUserInfo"][ "membershipId"] == membershipId: try: avg_life = int(entry["values"]["activityDurationSeconds"] ["basic"]["value"] / entry["values"]["deaths"]["basic"]["value"]) except ZeroDivisionError: avg_life = int(666) stats = { "count": index, "instanceId": pgcr_res["Response"]["activityDetails"]["instanceId"], "PGCR": pgcr_res["Response"]["activityDetails"]["instanceId"], "period": pgcr_res["Response"]["period"], "standing": entry["standing"], "activityDurationSeconds": entry["values"]["activityDurationSeconds"]["basic"] ["displayValue"], "averageLifeTime": avg_life, "precisionKills": entry["extended"]["values"]["precisionKills"]["basic"] ["displayValue"], "data": entry, } # Add weapon definition to responses: try: for index, weapons in enumerate( entry["extended"].get("weapons")): definition = get_definition( "DestinyInventoryItemDefinition", str(weapons["referenceId"])) stats["data"]["extended"]["weapons"][index][ "definition"] = definition except: continue stat_list.append(stats) pgcr_list_res = { "Response": stat_list, "statusCode": 200, "ErrorStatus": "Success", } return jsonify(pgcr_list_res)