Example #1
0
def viewtopscores(musicid: int) -> Response:
    # We just want to find the latest mix that this song exists in
    frontend = IIDXFrontend(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]
    notecounts = [0, 0, 0, 0, 0, 0]

    for version in versions:
        for omniadd in [0, 10000]:
            for chart in [0, 1, 2, 3, 4, 5]:
                details = g.data.local.music.get_song(GameConstants.IIDX,
                                                      version + omniadd,
                                                      musicid, chart)
                if details is not None:
                    name = details.name
                    artist = details.artist
                    genre = details.genre
                    difficulties[chart] = details.data.get_int(
                        'difficulty', 13)
                    notecounts[chart] = details.data.get_int('notecount', 5730)

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

    top_scores = frontend.get_top_scores(musicid)

    return render_react(
        f'Top IIDX Scores for {artist} - {name}',
        'iidx/topscores.react.js',
        {
            'name': name,
            'artist': artist,
            'genre': genre,
            'difficulties': difficulties,
            'notecounts': notecounts,
            'players': top_scores['players'],
            'topscores': top_scores['topscores'],
        },
        {
            'refresh': url_for('iidx_pages.listtopscores', musicid=musicid),
            'player': url_for('iidx_pages.viewplayer', userid=-1),
        },
    )
Example #2
0
def listtopscores(musicid: int) -> Dict[str, Any]:
    frontend = IIDXFrontend(g.data, g.config, g.cache)
    return frontend.get_top_scores(musicid)