Example #1
0
def viewsettings() -> Response:
    frontend = IIDXFrontend(g.data, g.config, g.cache)
    userid = g.userID
    djinfo = frontend.get_all_player_info([userid])[userid]
    if not djinfo:
        abort(404)
    versions = sorted(
        [version for (game, version, name) in frontend.all_games()],
        reverse=True,
    )
    return render_react(
        'IIDX Game Settings',
        'iidx/settings.react.js',
        {
            'player': djinfo,
            'versions':
            {version: name
             for (game, version, name) in frontend.all_games()},
            'qpros': frontend.get_all_items(versions),
        },
        {
            'updateqpro': url_for('iidx_pages.updateqpro'),
            'updateflags': url_for('iidx_pages.updateflags'),
            'updatesettings': url_for('iidx_pages.updatesettings'),
            'updatename': url_for('iidx_pages.updatename'),
            'updateprefecture': url_for('iidx_pages.updateprefecture'),
            'leavearcade': url_for('iidx_pages.leavearcade'),
        },
    )
Example #2
0
def viewevents() -> Response:
    iidx = IIDXFrontend(g.data, g.config, g.cache)
    jubeat = JubeatFrontend(g.data, g.config, g.cache)
    pnm = PopnMusicFrontend(g.data, g.config, g.cache)
    return render_react(
        'Events',
        'admin/events.react.js',
        {
            'events': [format_event(event) for event in g.data.local.network.get_events(limit=100)],
            'users': {user.id: user.username for user in g.data.local.user.get_all_users()},
            'arcades': {arcade.id: arcade.name for arcade in g.data.local.machine.get_all_arcades()},
            'iidxsongs': iidx.get_all_songs(),
            'jubeatsongs': jubeat.get_all_songs(),
            'pnmsongs': pnm.get_all_songs(),
            'iidxversions': {version: name for (game, version, name) in iidx.all_games()},
            'jubeatversions': {version: name for (game, version, name) in jubeat.all_games()},
            'pnmversions': {version: name for (game, version, name) in pnm.all_games()},
        },
        {
            'refresh': url_for('admin_pages.listevents', since=-1),
            'backfill': url_for('admin_pages.backfillevents', until=-1),
            'viewuser': url_for('admin_pages.viewuser', userid=-1),
            'jubeatsong': url_for('jubeat_pages.viewtopscores', musicid=-1) if g.config.get('support', {}).get(GameConstants.JUBEAT, False) else None,
            'iidxsong': url_for('iidx_pages.viewtopscores', musicid=-1) if g.config.get('support', {}).get(GameConstants.IIDX, False) else None,
            'pnmsong': url_for('popn_pages.viewtopscores', musicid=-1) if g.config.get('support', {}).get(GameConstants.POPN_MUSIC, False) else None,
        },
    )
Example #3
0
def viewscores(userid: UserID) -> Response:
    frontend = IIDXFrontend(g.data, g.config, g.cache)
    djinfo = frontend.get_latest_player_info([userid]).get(userid)
    if djinfo is None:
        abort(404)

    scores = frontend.get_scores(userid, limit=100)
    if len(scores) > 10:
        scores = frontend.round_to_ten(scores)

    return render_react(
        f'dj {djinfo["name"]}\'s IIDX Scores',
        'iidx/scores.react.js',
        {
            'attempts': scores,
            'songs': frontend.get_all_songs(),
            'players': {},
            'versions':
            {version: name
             for (game, version, name) in frontend.all_games()},
            'showdjnames': False,
            'shownewrecords': True,
        },
        {
            'refresh': url_for('iidx_pages.listscores', userid=userid),
            'player': url_for('iidx_pages.viewplayer', userid=-1),
            'individual_score': url_for('iidx_pages.viewtopscores',
                                        musicid=-1),
        },
    )
Example #4
0
def viewplayer(userid: UserID) -> Response:
    frontend = IIDXFrontend(g.data, g.config, g.cache)
    djinfo = frontend.get_all_player_info([userid])[userid]
    if not djinfo:
        abort(404)
    latest_version = sorted(djinfo.keys(), reverse=True)[0]

    for version in djinfo:
        sp_rival = g.data.local.user.get_link(GameConstants.IIDX, version,
                                              g.userID, 'sp_rival', userid)
        dp_rival = g.data.local.user.get_link(GameConstants.IIDX, version,
                                              g.userID, 'dp_rival', userid)
        djinfo[version]['sp_rival'] = sp_rival is not None
        djinfo[version]['dp_rival'] = dp_rival is not None

    return render_react(
        f'dj {djinfo[latest_version]["name"]}\'s IIDX Profile',
        'iidx/player.react.js',
        {
            'playerid': userid,
            'own_profile': userid == g.userID,
            'player': djinfo,
            'versions':
            {version: name
             for (game, version, name) in frontend.all_games()},
        },
        {
            'refresh': url_for('iidx_pages.listplayer', userid=userid),
            'records': url_for('iidx_pages.viewrecords', userid=userid),
            'scores': url_for('iidx_pages.viewscores', userid=userid),
            'addrival': url_for('iidx_pages.addrival'),
            'removerival': url_for('iidx_pages.removerival'),
        },
    )
Example #5
0
def viewnetworkscores() -> Response:
    # Only load the last 100 results for the initial fetch, so we can render faster
    frontend = IIDXFrontend(g.data, g.config, g.cache)
    network_scores = frontend.get_network_scores(limit=100)
    if len(network_scores['attempts']) > 10:
        network_scores['attempts'] = frontend.round_to_ten(
            network_scores['attempts'])

    return render_react(
        'Global IIDX Scores',
        'iidx/scores.react.js',
        {
            'attempts': network_scores['attempts'],
            'songs': frontend.get_all_songs(),
            'players': network_scores['players'],
            'versions':
            {version: name
             for (game, version, name) in frontend.all_games()},
            'showdjnames': True,
            'shownewrecords': False,
        },
        {
            'refresh': url_for('iidx_pages.listnetworkscores'),
            'player': url_for('iidx_pages.viewplayer', userid=-1),
            'individual_score': url_for('iidx_pages.viewtopscores',
                                        musicid=-1),
        },
    )
Example #6
0
def viewrecords(userid: UserID) -> Response:
    frontend = IIDXFrontend(g.data, g.config, g.cache)
    djinfo = frontend.get_latest_player_info([userid]).get(userid)
    if djinfo is None:
        abort(404)

    return render_react(
        f'dj {djinfo["name"]}\'s IIDX Records',
        'iidx/records.react.js',
        {
            'records': frontend.get_records(userid),
            'songs': frontend.get_all_songs(),
            'players': {},
            'versions':
            {version: name
             for (game, version, name) in frontend.all_games()},
            'showdjnames': False,
            'showpersonalsort': True,
            'filterempty': True,
        },
        {
            'refresh': url_for('iidx_pages.listrecords', userid=userid),
            'player': url_for('iidx_pages.viewplayer', userid=-1),
            'individual_score': url_for('iidx_pages.viewtopscores',
                                        musicid=-1),
        },
    )
Example #7
0
def viewnetworkrecords() -> Response:
    frontend = IIDXFrontend(g.data, g.config, g.cache)
    network_records = frontend.get_network_records()

    return render_react(
        'Global IIDX Records',
        'iidx/records.react.js',
        {
            'records': network_records['records'],
            'songs': frontend.get_all_songs(),
            'players': network_records['players'],
            'versions':
            {version: name
             for (game, version, name) in frontend.all_games()},
            'showdjnames': True,
            'showpersonalsort': False,
            'filterempty': False,
        },
        {
            'refresh': url_for('iidx_pages.listnetworkrecords'),
            'player': url_for('iidx_pages.viewplayer', userid=-1),
            'individual_score': url_for('iidx_pages.viewtopscores',
                                        musicid=-1),
        },
    )
Example #8
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 #9
0
def viewrivals() -> Response:
    frontend = IIDXFrontend(g.data, g.config, g.cache)
    rivals, djinfo = frontend.get_rivals(g.userID)

    return render_react(
        'IIDX Rivals',
        'iidx/rivals.react.js',
        {
            'userid': str(g.userID),
            'rivals': rivals,
            'players': djinfo,
            'versions': {version: name for (game, version, name) in frontend.all_games()},
        },
        {
            'refresh': url_for('iidx_pages.listrivals'),
            'search': url_for('iidx_pages.searchrivals'),
            'player': url_for('iidx_pages.viewplayer', userid=-1),
            'addrival': url_for('iidx_pages.addrival'),
            'removerival': url_for('iidx_pages.removerival'),
        },
    )