Exemplo n.º 1
0
def viewtopscores(musicid: int) -> Response:
    # We just want to find the latest mix that this song exists in
    frontend = JubeatFrontend(g.data, g.config, g.cache)
    versions = sorted(
        [version for (game, version, name) in frontend.all_games()],
        reverse=True,
    )
    name = None
    artist = None
    genre = None
    difficulties = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
    found = [False, False, False, False, False, False]

    for version in versions:
        for omniadd in [10000, 0]:
            for chart in [0, 1, 2, 3, 4, 5]:
                details = g.data.local.music.get_song(GameConstants.JUBEAT,
                                                      version + omniadd,
                                                      musicid, chart)
                if details is not None:
                    found[chart] = True
                    print(version + omniadd)
                    name = details.name
                    artist = details.artist
                    genre = details.genre
                    difficulties[chart] = details.data.get_float(
                        'difficulty', 13)
            if False not in found:
                break
        if False not in found:
            break

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

    top_scores = frontend.get_top_scores(musicid)

    return render_react(
        f'Top Jubeat Scores for {artist} - {name}',
        'jubeat/topscores.react.js',
        {
            'name': name,
            'artist': artist,
            'genre': genre,
            'difficulties': difficulties,
            'players': top_scores['players'],
            'topscores': top_scores['topscores'],
        },
        {
            'refresh': url_for('jubeat_pages.listtopscores', musicid=musicid),
            'player': url_for('jubeat_pages.viewplayer', userid=-1),
        },
    )
Exemplo n.º 2
0
def listtopscores(musicid: int) -> Dict[str, Any]:
    frontend = JubeatFrontend(g.data, g.config, g.cache)
    return frontend.get_top_scores(musicid)