예제 #1
0
def viewtopscores(musicid: int) -> Response:
    # We just want to find the latest mix that this song exists in
    frontend = ReflecBeatFrontend(g.data, g.config, g.cache)
    name = None
    artist = None
    difficulties = [0, 0, 0, 0]

    for chart in [0, 1, 2, 3]:
        details = g.data.local.music.get_song(GameConstants.REFLEC_BEAT, 0, musicid, chart)
        if details is not None:
            if name is None:
                name = details.name
            if artist is None:
                artist = details.artist
            if difficulties[chart] == 0:
                difficulties[chart] = details.data.get_int('difficulty')

    if name is None:
        # Not a real song!
        abort(404)

    top_scores = frontend.get_top_scores(musicid)

    return render_react(
        'Top Reflec Beat Scores for {} - {}'.format(artist, name),
        'reflec/topscores.react.js',
        {
            'name': name,
            'artist': artist,
            'difficulties': difficulties,
            'players': top_scores['players'],
            'topscores': top_scores['topscores'],
        },
        {
            'refresh': url_for('reflec_pages.listtopscores', musicid=musicid),
            'player': url_for('reflec_pages.viewplayer', userid=-1),
        },
    )
예제 #2
0
def listtopscores(musicid: int) -> Dict[str, Any]:
    frontend = ReflecBeatFrontend(g.data, g.config, g.cache)
    return frontend.get_top_scores(musicid)