コード例 #1
0
ファイル: endpoints.py プロジェクト: vangar/bemaniutils
def viewrivals() -> Response:
    frontend = SoundVoltexFrontend(g.data, g.config, g.cache)
    rivals, playerinfo = frontend.get_rivals(g.userID)

    # There were no rivals in SDVX 1 or 2.
    if VersionConstants.SDVX_BOOTH in rivals:
        del rivals[VersionConstants.SDVX_BOOTH]
    if VersionConstants.SDVX_INFINITE_INFECTION in rivals:
        del rivals[VersionConstants.SDVX_INFINITE_INFECTION]

    return render_react(
        'SDVX Rivals',
        'sdvx/rivals.react.js',
        {
            'userid': str(g.userID),
            'rivals': rivals,
            'players': playerinfo,
            'versions': {version: name for (game, version, name) in frontend.all_games()},
        },
        {
            'refresh': url_for('sdvx_pages.listrivals'),
            'search': url_for('sdvx_pages.searchrivals'),
            'player': url_for('sdvx_pages.viewplayer', userid=-1),
            'addrival': url_for('sdvx_pages.addrival'),
            'removerival': url_for('sdvx_pages.removerival'),
        },
    )
コード例 #2
0
ファイル: endpoints.py プロジェクト: vangar/bemaniutils
def listplayer(userid: UserID) -> Dict[str, Any]:
    frontend = SoundVoltexFrontend(g.data, g.config, g.cache)
    info = frontend.get_all_player_info([userid])[userid]

    return {
        'player': info,
    }
コード例 #3
0
ファイル: cache.py プロジェクト: vangar/bemaniutils
 def preload(cls, data: Data, config: Dict[str, Any]) -> None:
     cache = Cache(app, config={
         'CACHE_TYPE': 'filesystem',
         'CACHE_DIR': config['cache_dir'],
     })
     frontend = SoundVoltexFrontend(data, config, cache)
     frontend.get_all_songs(force_db_load=True)
コード例 #4
0
ファイル: endpoints.py プロジェクト: vangar/bemaniutils
def addrival() -> Dict[str, Any]:
    frontend = SoundVoltexFrontend(g.data, g.config, g.cache)
    version = int(request.get_json()['version'])
    other_userid = UserID(int(request.get_json()['userid']))
    userid = g.userID

    # Add this rival link
    profile = g.data.remote.user.get_profile(GameConstants.SDVX, version, other_userid)
    if profile is None:
        raise Exception('Unable to find profile for rival!')

    g.data.local.user.put_link(
        GameConstants.SDVX,
        version,
        userid,
        'rival',
        other_userid,
        {},
    )

    # Now return updated rival info
    rivals, playerinfo = frontend.get_rivals(userid)

    return {
        'rivals': rivals,
        'players': playerinfo,
    }
コード例 #5
0
ファイル: endpoints.py プロジェクト: yungsun09/bemaniutils
def viewnetworkscores() -> Response:
    # Only load the last 100 results for the initial fetch, so we can render faster
    frontend = SoundVoltexFrontend(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 SDVX Scores',
        'sdvx/scores.react.js',
        {
            'attempts': network_scores['attempts'],
            'songs': frontend.get_all_songs(),
            'players': network_scores['players'],
            'shownames': True,
            'shownewrecords': False,
        },
        {
            'refresh': url_for('sdvx_pages.listnetworkscores'),
            'player': url_for('sdvx_pages.viewplayer', userid=-1),
            'individual_score': url_for('sdvx_pages.viewtopscores',
                                        musicid=-1),
        },
    )
コード例 #6
0
ファイル: endpoints.py プロジェクト: yungsun09/bemaniutils
def viewnetworkrecords() -> Response:
    frontend = SoundVoltexFrontend(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 SDVX Records',
        'sdvx/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('sdvx_pages.listnetworkrecords'),
            'player': url_for('sdvx_pages.viewplayer', userid=-1),
            'individual_score': url_for('sdvx_pages.viewtopscores',
                                        musicid=-1),
        },
    )
コード例 #7
0
ファイル: endpoints.py プロジェクト: wolskiCN/bemaniutils
def listrivals() -> Dict[str, Any]:
    frontend = SoundVoltexFrontend(g.data, g.config, g.cache)
    rivals, playerinfo = frontend.get_rivals(g.userID)

    return {
        'rivals': rivals,
        'players': playerinfo,
    }
コード例 #8
0
ファイル: endpoints.py プロジェクト: yungsun09/bemaniutils
def viewplayers() -> Response:
    frontend = SoundVoltexFrontend(g.data, g.config, g.cache)
    return render_react(
        'All SDVX Players',
        'sdvx/allplayers.react.js',
        {'players': frontend.get_all_players()},
        {
            'refresh': url_for('sdvx_pages.listplayers'),
            'player': url_for('sdvx_pages.viewplayer', userid=-1),
        },
    )
コード例 #9
0
ファイル: endpoints.py プロジェクト: vangar/bemaniutils
def listrivals() -> Dict[str, Any]:
    frontend = SoundVoltexFrontend(g.data, g.config, g.cache)
    rivals, playerinfo = frontend.get_rivals(g.userID)

    # There were no rivals in SDVX 1 or 2.
    if VersionConstants.SDVX_BOOTH in rivals:
        del rivals[VersionConstants.SDVX_BOOTH]
    if VersionConstants.SDVX_INFINITE_INFECTION in rivals:
        del rivals[VersionConstants.SDVX_INFINITE_INFECTION]

    return {
        'rivals': rivals,
        'players': playerinfo,
    }
コード例 #10
0
ファイル: endpoints.py プロジェクト: vangar/bemaniutils
def viewsettings() -> Response:
    frontend = SoundVoltexFrontend(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(
        'SDVX Game Settings',
        'sdvx/settings.react.js',
        {
            'player': info,
            'versions': {version: name for (game, version, name) in frontend.all_games()},
        },
        {
            'updatename': url_for('sdvx_pages.updatename'),
        },
    )
コード例 #11
0
ファイル: endpoints.py プロジェクト: vangar/bemaniutils
def searchrivals() -> Dict[str, Any]:
    frontend = SoundVoltexFrontend(g.data, g.config, g.cache)
    version = int(request.get_json()['version'])
    name = request.get_json()['term']

    # Try to treat the term as an extid
    extid = ID.parse_extid(name)

    matches = set()
    profiles = g.data.remote.user.get_all_profiles(GameConstants.SDVX, version)
    for (userid, profile) in profiles:
        if profile.get_int('extid') == extid or profile.get_str('name').lower() == name.lower():
            matches.add(userid)

    playerinfo = frontend.get_all_player_info(list(matches), allow_remote=True)
    return {
        'results': playerinfo,
    }
コード例 #12
0
ファイル: endpoints.py プロジェクト: yungsun09/bemaniutils
def viewtopscores(musicid: int) -> Response:
    # We just want to find the latest mix that this song exists in
    frontend = SoundVoltexFrontend(g.data, g.config, g.cache)
    versions = sorted(
        [version for (game, version, name) in frontend.all_games()],
        reverse=True,
    )
    name = None
    artist = None
    difficulties = [0, 0, 0, 0, 0]

    for version in versions:
        for chart in [0, 1, 2, 3, 4]:
            details = g.data.local.music.get_song(GameConstants.SDVX, version,
                                                  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(
        f'Top SDVX Scores for {artist} - {name}',
        'sdvx/topscores.react.js',
        {
            'name': name,
            'artist': artist,
            'difficulties': difficulties,
            'players': top_scores['players'],
            'topscores': top_scores['topscores'],
        },
        {
            'refresh': url_for('sdvx_pages.listtopscores', musicid=musicid),
            'player': url_for('sdvx_pages.viewplayer', userid=-1),
        },
    )
コード例 #13
0
ファイル: endpoints.py プロジェクト: vangar/bemaniutils
def viewscores(userid: UserID) -> Response:
    frontend = SoundVoltexFrontend(g.data, g.config, g.cache)
    info = frontend.get_latest_player_info([userid]).get(userid)
    if info 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'{info["name"]}\'s SDVX Scores',
        'sdvx/scores.react.js',
        {
            'attempts': scores,
            'songs': frontend.get_all_songs(),
            'players': {},
            'shownames': False,
            'shownewrecords': True,
        },
        {
            'refresh': url_for('sdvx_pages.listscores', userid=userid),
            'player': url_for('sdvx_pages.viewplayer', userid=-1),
            'individual_score': url_for('sdvx_pages.viewtopscores', musicid=-1),
        },
    )
コード例 #14
0
ファイル: endpoints.py プロジェクト: vangar/bemaniutils
def viewrecords(userid: UserID) -> Response:
    frontend = SoundVoltexFrontend(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()}

    return render_react(
        f'{info["name"]}\'s SDVX Records',
        'sdvx/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('sdvx_pages.listrecords', userid=userid),
            'player': url_for('sdvx_pages.viewplayer', userid=-1),
            'individual_score': url_for('sdvx_pages.viewtopscores', musicid=-1),
        },
    )
コード例 #15
0
ファイル: endpoints.py プロジェクト: vangar/bemaniutils
def viewplayer(userid: UserID) -> Response:
    frontend = SoundVoltexFrontend(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 SDVX Profile',
        'sdvx/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('sdvx_pages.listplayer', userid=userid),
            'records': url_for('sdvx_pages.viewrecords', userid=userid),
            'scores': url_for('sdvx_pages.viewscores', userid=userid),
        },
    )
コード例 #16
0
ファイル: endpoints.py プロジェクト: vangar/bemaniutils
def removerival() -> Dict[str, Any]:
    frontend = SoundVoltexFrontend(g.data, g.config, g.cache)
    version = int(request.get_json()['version'])
    other_userid = UserID(int(request.get_json()['userid']))
    userid = g.userID

    # Remove this rival link
    g.data.local.user.destroy_link(
        GameConstants.SDVX,
        version,
        userid,
        'rival',
        other_userid,
    )

    # Now return updated rival info
    rivals, playerinfo = frontend.get_rivals(userid)

    return {
        'rivals': rivals,
        'players': playerinfo,
    }
コード例 #17
0
ファイル: endpoints.py プロジェクト: vangar/bemaniutils
def listscores(userid: UserID) -> Dict[str, Any]:
    frontend = SoundVoltexFrontend(g.data, g.config, g.cache)
    return {
        'attempts': frontend.get_scores(userid),
        'players': {},
    }
コード例 #18
0
ファイル: endpoints.py プロジェクト: vangar/bemaniutils
def listrecords(userid: UserID) -> Dict[str, Any]:
    frontend = SoundVoltexFrontend(g.data, g.config, g.cache)
    return {
        'records': frontend.get_records(userid),
        'players': {},
    }
コード例 #19
0
ファイル: endpoints.py プロジェクト: vangar/bemaniutils
def listnetworkscores() -> Dict[str, Any]:
    frontend = SoundVoltexFrontend(g.data, g.config, g.cache)
    return frontend.get_network_scores()
コード例 #20
0
ファイル: endpoints.py プロジェクト: vangar/bemaniutils
def listtopscores(musicid: int) -> Dict[str, Any]:
    frontend = SoundVoltexFrontend(g.data, g.config, g.cache)
    return frontend.get_top_scores(musicid)
コード例 #21
0
ファイル: endpoints.py プロジェクト: vangar/bemaniutils
def listplayers() -> Dict[str, Any]:
    frontend = SoundVoltexFrontend(g.data, g.config, g.cache)
    return {
        'players': frontend.get_all_players(),
    }