示例#1
0
def addrival() -> Dict[str, Any]:
    frontend = ReflecBeatFrontend(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.REFLEC_BEAT, version, other_userid)
    if profile is None:
        raise Exception('Unable to find profile for rival!')

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

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

    return {
        'rivals': rivals,
        'players': playerinfo,
    }
示例#2
0
def viewrivals() -> Response:
    frontend = ReflecBeatFrontend(g.data, g.config, g.cache)
    rivals, playerinfo = frontend.get_rivals(g.userID)

    # Reflec Beat 1 has no rivals support
    for no_rivals_support in NO_RIVAL_SUPPORT:
        if no_rivals_support in rivals:
            del rivals[no_rivals_support]

    return render_react(
        'Reflec Beat Rivals',
        'reflec/rivals.react.js',
        {
            'userid': str(g.userID),
            'rivals': rivals,
            'players': playerinfo,
            'versions': {version: name for (game, version, name) in frontend.all_games() if version not in NO_RIVAL_SUPPORT},
        },
        {
            'refresh': url_for('reflec_pages.listrivals'),
            'search': url_for('reflec_pages.searchrivals'),
            'player': url_for('reflec_pages.viewplayer', userid=-1),
            'addrival': url_for('reflec_pages.addrival'),
            'removerival': url_for('reflec_pages.removerival'),
        },
    )
示例#3
0
def listrivals() -> Dict[str, Any]:
    frontend = ReflecBeatFrontend(g.data, g.config, g.cache)
    rivals, playerinfo = frontend.get_rivals(g.userID)

    # Reflec Beat 1 has no rivals support
    for no_rivals_support in NO_RIVAL_SUPPORT:
        if no_rivals_support in rivals:
            del rivals[no_rivals_support]

    return {
        'rivals': rivals,
        'players': playerinfo,
    }
示例#4
0
def removerival() -> Dict[str, Any]:
    frontend = ReflecBeatFrontend(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.REFLEC_BEAT,
        version,
        userid,
        'rival',
        other_userid,
    )

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

    return {
        'rivals': rivals,
        'players': playerinfo,
    }