Exemplo n.º 1
0
def viewrecords(userid: UserID) -> Response:
    frontend = PopnMusicFrontend(g.data, g.config, g.cache)
    info = frontend.get_latest_player_info([userid]).get(userid)
    if info is None:
        abort(404)
    versions = {
        version: name
        for (game, version, name) in frontend.all_games()
    }
    versions[0] = 'CS and Licenses'

    return render_react(
        '{}\'s Pop\'n Music Records'.format(info['name']),
        'popn/records.react.js',
        {
            'records': frontend.get_records(userid),
            'songs': frontend.get_all_songs(),
            'players': {},
            'versions': versions,
            'shownames': False,
            'showpersonalsort': True,
            'filterempty': True,
        },
        {
            'refresh': url_for('popn_pages.listrecords', userid=userid),
            'player': url_for('popn_pages.viewplayer', userid=-1),
            'individual_score': url_for('popn_pages.viewtopscores',
                                        musicid=-1),
        },
    )
Exemplo n.º 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,
        },
    )
Exemplo n.º 3
0
def viewnetworkrecords() -> Response:
    frontend = PopnMusicFrontend(g.data, g.config, g.cache)
    network_records = frontend.get_network_records()
    versions = {
        version: name
        for (game, version, name) in frontend.all_games()
    }
    versions[0] = 'CS and Licenses'

    return render_react(
        'Global Pop\'n Music Records',
        'popn/records.react.js',
        {
            'records': network_records['records'],
            'songs': frontend.get_all_songs(),
            'players': network_records['players'],
            'versions': versions,
            'shownames': True,
            'showpersonalsort': False,
            'filterempty': False,
        },
        {
            'refresh': url_for('popn_pages.listnetworkrecords'),
            'player': url_for('popn_pages.viewplayer', userid=-1),
            'individual_score': url_for('popn_pages.viewtopscores',
                                        musicid=-1),
        },
    )
Exemplo n.º 4
0
def viewrivals() -> Response:
    frontend = PopnMusicFrontend(g.data, g.config, g.cache)
    rivals, playerinfo = frontend.get_rivals(g.userID)

    # There is no support for Rivals in Tune Street.
    if VersionConstants.POPN_MUSIC_TUNE_STREET in rivals:
        del rivals[VersionConstants.POPN_MUSIC_TUNE_STREET]

    return render_react(
        'Pop\'n Music Rivals',
        'popn/rivals.react.js',
        {
            'userid': str(g.userID),
            'rivals': rivals,
            'max_active_rivals': frontend.max_active_rivals,
            'players': playerinfo,
            'versions':
            {version: name
             for (game, version, name) in frontend.all_games()},
        },
        {
            'refresh': url_for('popn_pages.listrivals'),
            'search': url_for('popn_pages.searchrivals'),
            'player': url_for('popn_pages.viewplayer', userid=-1),
            'addrival': url_for('popn_pages.addrival'),
            'removerival': url_for('popn_pages.removerival'),
        },
    )
Exemplo n.º 5
0
def viewtopscores(musicid: int) -> Response:
    # We just want to find the latest mix that this song exists in
    frontend = PopnMusicFrontend(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]

    for version in versions:
        for omniadd in [0, 10000]:
            for chart in [0, 1, 2, 3]:
                details = g.data.local.music.get_song(GameConstants.POPN_MUSIC,
                                                      version + omniadd,
                                                      musicid, chart)
                if details is not None:
                    if name is None:
                        name = details.name
                    if artist is None:
                        artist = details.artist
                    if genre is None:
                        genre = details.genre
                    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(
        f'Top Pop\'n Music Scores for {artist} - {name}',
        'popn/topscores.react.js',
        {
            'name': name,
            'artist': artist,
            'genre': genre,
            'difficulties': difficulties,
            'players': top_scores['players'],
            'topscores': top_scores['topscores'],
        },
        {
            'refresh': url_for('popn_pages.listtopscores', musicid=musicid),
            'player': url_for('popn_pages.viewplayer', userid=-1),
        },
    )
Exemplo n.º 6
0
def viewsettings() -> Response:
    frontend = PopnMusicFrontend(g.data, g.config, g.cache)
    userid = g.userID
    info = frontend.get_all_player_info([userid])[userid]
    if not info:
        abort(404)

    return render_react(
        'Pop\'n Music Game Settings',
        'popn/settings.react.js',
        {
            'player': info,
            'versions': {version: name for (game, version, name) in frontend.all_games()},
        },
        {
            'updatename': url_for('popn_pages.updatename'),
        },
    )
Exemplo n.º 7
0
def viewplayer(userid: UserID) -> Response:
    frontend = PopnMusicFrontend(g.data, g.config, g.cache)
    info = frontend.get_all_player_info([userid])[userid]
    if not info:
        abort(404)
    latest_version = sorted(info.keys(), reverse=True)[0]

    return render_react(
        f'{info[latest_version]["name"]}\'s Pop\'n Music Profile',
        'popn/player.react.js',
        {
            'playerid': userid,
            'own_profile': userid == g.userID,
            'player': info,
            'versions': {version: name for (game, version, name) in frontend.all_games()},
        },
        {
            'refresh': url_for('popn_pages.listplayer', userid=userid),
            'records': url_for('popn_pages.viewrecords', userid=userid),
            'scores': url_for('popn_pages.viewscores', userid=userid),
        },
    )