Exemple #1
0
def game(region, summoner_name):
    # check that our summoner exists
    try:
        summoner = rw.get_summoner(name=summoner_name, region=region)
    except LoLException:
        return render_template('error.html')
    # check that a current game exists
    try:
        current_game = rw.get_current_game(summoner['id'], platform_id=ct.abbrev_platforms[region], region=region)
    except LoLException:
        # return not found page
        return render_template('game.html', current_game=None, summoner=summoner, region=region)
    # make team lists
    current_game['teams'] = {}
    current_game['teams']['blueTeam'] = []
    current_game['teams']['redTeam'] = []
    # set up the streak info at top of page for this player
    summoner['streak_info'] = []
    summoner['streak_info'] = ct.get_streak_info(summoner['id'], region)
    # get banned champ imgs
    for bannedChamp in current_game['bannedChampions']:
        bannedChamp['img'] = ct.get_champion_image_url(bannedChamp['championId'])
    # gather participant information
    for participant in current_game['participants']:
        participant['img'] = ct.get_champion_image_url(participant['championId'])
        participant['spell1Img'] = ct.get_ss_image_url(participant['spell1Id'])
        participant['spell2Img'] = ct.get_ss_image_url(participant['spell2Id'])
        participant['profileIconImg'] = ct.get_profile_image_url(participant['profileIconId'])
        participant['stats'] = ct.get_ranked_stats(participant['summonerId'], region, participant['championId'])
        # TODO: I need a production key, ye God Riot Tuxedo hear my plea
        # get streak info for each participant
        participant['streak_info'] = ct.get_streak_info(participant['summonerId'], region)
        # get badges for each participant
        # TODO: Change summoner['streak_info'] to participant['streak_info'] once production key is acquired
        participant['badges'] = ct.get_badges(participant, participant['streak_info'])
        if participant['teamId'] == 100:
            current_game['teams']['blueTeam'].append(participant)
        else:
            current_game['teams']['redTeam'].append(participant)
    current_game['gameStartTime'] = datetime.datetime.fromtimestamp(
        current_game['gameStartTime'] / 1000.0).time().replace(second=0, microsecond=0)
    return render_template('game.html', current_game=current_game, summoner=summoner,
                           region=region)
Exemple #2
0
 def test_ss_img_url(self):
     # grab smite
     ss_image_url = ct.get_ss_image_url('11')
     self.assertEquals(ss_image_url, 'http://ddragon.leagueoflegends.com/cdn/5.23.1/img/spell/SummonerSmite.png')
Exemple #3
0
    # return not found page
    print('not in game')
# make team lists
current_game['teams'] = {}
current_game['teams']['blueTeam'] = []
current_game['teams']['redTeam'] = []
# set up the streak info at top of page for this player
summoner['streak_info'] = []
summoner['streak_info'] = ct.get_streak_info(summoner['id'], region)
# get banned champ imgs
for bannedChamp in current_game['bannedChampions']:
    bannedChamp['img'] = ct.get_champion_image_url(bannedChamp['championId'])
# gather participant information
for participant in current_game['participants']:
    participant['img'] = ct.get_champion_image_url(participant['championId'])
    participant['spell1Img'] = ct.get_ss_image_url(participant['spell1Id'])
    participant['spell2Img'] = ct.get_ss_image_url(participant['spell2Id'])
    participant['profileIconImg'] = ct.get_profile_image_url(participant['profileIconId'])
    print('getting ranked stats')
    participant['stats'] = ct.get_ranked_stats(participant['summonerId'], region, participant['championId'])
    # get streak info for each participant
    participant['streak_info'] = ct.get_streak_info(participant['summonerId'], region)
    # get badges for each participant
    participant['badges'] = ct.get_badges(participant, participant['streak_info'])
    if participant['teamId'] == 100:
        current_game['teams']['blueTeam'].append(participant)
    else:
        current_game['teams']['redTeam'].append(participant)
current_game['gameStartTime'] = datetime.datetime.fromtimestamp(
    current_game['gameStartTime'] / 1000.0).time().replace(second=0, microsecond=0)
print('we done')