当前位置: 首页>>代码示例>>Python>>正文


Python SESSIONS.player_count方法代码示例

本文整理汇总了Python中src.server.sessionhandler.SESSIONS.player_count方法的典型用法代码示例。如果您正苦于以下问题:Python SESSIONS.player_count方法的具体用法?Python SESSIONS.player_count怎么用?Python SESSIONS.player_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在src.server.sessionhandler.SESSIONS的用法示例。


在下文中一共展示了SESSIONS.player_count方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: func

# 需要导入模块: from src.server.sessionhandler import SESSIONS [as 别名]
# 或者: from src.server.sessionhandler.SESSIONS import player_count [as 别名]
    def func(self):
        """
        Get all connected players by polling session.
        """

        caller = self.caller
        session_list = SESSIONS.get_sessions()

        if self.cmdstring == "doing":
            show_session_data = False
        else:
            show_session_data = caller.check_permstring("Immortals") or caller.check_permstring("Wizards")

        if show_session_data:
            table = [["Player Name"], ["On for"], ["Idle"], ["Room"], ["Cmds"], ["Host"]]
        else:
            table = [["Player Name"], ["On for"], ["Idle"]]

        for session in session_list:
            if not session.logged_in:
                continue

            delta_cmd = time.time() - session.cmd_last_visible
            delta_conn = time.time() - session.conn_time
            plr_pobject = session.get_character()
            if not plr_pobject:
                plr_pobject = session.get_player()
                show_session_data = False
                table = [["Player Name"], ["On for"], ["Idle"]]
            if show_session_data:
                table[0].append(plr_pobject.name[:25])
                table[1].append(utils.time_format(delta_conn, 0))
                table[2].append(utils.time_format(delta_cmd, 1))
                table[3].append(plr_pobject.location and plr_pobject.location.id or "None")
                table[4].append(session.cmd_total)
                table[5].append(session.address[0])
            else:
                table[0].append(plr_pobject.name[:25])
                table[1].append(utils.time_format(delta_conn,0))
                table[2].append(utils.time_format(delta_cmd,1))

        stable = []
        for row in table: # prettify values
            stable.append([str(val).strip() for val in row])
        ftable = utils.format_table(stable, 5)
        string = ""
        for ir, row in enumerate(ftable):
            if ir == 0:
                string += "\n" + "{w%s{n" % ("".join(row))
            else:
                string += "\n" + "".join(row)
        nplayers = (SESSIONS.player_count())
        if nplayers == 1:
            string += '\nOne player logged in.'
        else:
            string += '\n%d players logged in.' % nplayers

        caller.msg(string)
开发者ID:abbacode,项目名称:avaloria,代码行数:60,代码来源:general.py

示例2: func

# 需要导入模块: from src.server.sessionhandler import SESSIONS [as 别名]
# 或者: from src.server.sessionhandler.SESSIONS import player_count [as 别名]
    def func(self):
        """
        Get all connected players by polling session.
        """

        player = self.player
        session_list = SESSIONS.get_sessions()

        session_list = sorted(session_list, key=lambda o: o.player.key)

        if self.cmdstring == "doing":
            show_session_data = False
        else:
            show_session_data = player.check_permstring("Immortals") or player.check_permstring("Wizards")

        nplayers = (SESSIONS.player_count())
        if show_session_data:
            # privileged info
            table = prettytable.PrettyTable(["{wPlayer Name",
                                             "{wOn for",
                                             "{wIdle",
                                             "{wPuppeting",
                                             "{wRoom",
                                             "{wCmds",
                                             "{wProtocol",
                                             "{wHost"])
            for session in session_list:
                if not session.logged_in: continue
                delta_cmd = time.time() - session.cmd_last_visible
                delta_conn = time.time() - session.conn_time
                player = session.get_player()
                puppet = session.get_puppet()
                location = puppet.location.key if puppet else "None"
                table.add_row([utils.crop(player.name, width=25),
                               utils.time_format(delta_conn, 0),
                               utils.time_format(delta_cmd, 1),
                               utils.crop(puppet.key if puppet else "None", width=25),
                               utils.crop(location, width=25),
                               session.cmd_total,
                               session.protocol_key,
                               isinstance(session.address, tuple) and session.address[0] or session.address])
        else:
            # unprivileged
            table = prettytable.PrettyTable(["{wPlayer name", "{wOn for", "{wIdle"])
            for session in session_list:
                if not session.logged_in:
                    continue
                delta_cmd = time.time() - session.cmd_last_visible
                delta_conn = time.time() - session.conn_time
                player = session.get_player()
                table.add_row([utils.crop(player.key, width=25),
                               utils.time_format(delta_conn, 0),
                               utils.time_format(delta_cmd, 1)])

        isone = nplayers == 1
        string = "{wPlayers:{n\n%s\n%s unique account%s logged in." % (table, "One" if isone else nplayers, "" if isone else "s")
        self.msg(string)
开发者ID:RetroRodent,项目名称:evennia,代码行数:59,代码来源:player.py

示例3: webclient

# 需要导入模块: from src.server.sessionhandler import SESSIONS [as 别名]
# 或者: from src.server.sessionhandler.SESSIONS import player_count [as 别名]
def webclient(request):
    """
    Webclient page template loading. 
    """    
    # as an example we send the number of connected players to the template
    pagevars = {'num_players_connected': SESSIONS.player_count()}

    context_instance = RequestContext(request)
    return render_to_response('webclient.html', pagevars, context_instance)
开发者ID:Kelketek,项目名称:wintersoasis,代码行数:11,代码来源:views.py

示例4: webclient

# 需要导入模块: from src.server.sessionhandler import SESSIONS [as 别名]
# 或者: from src.server.sessionhandler.SESSIONS import player_count [as 别名]
def webclient(request):
    """
    Webclient page template loading.
    """

    # analyze request to find which port we are on
    if int(request.META["SERVER_PORT"]) == 8000:
        # we relay webclient to the portal port
        print "Called from port 8000!"
        # return redirect("http://localhost:8001/webclient/", permanent=True)

    # as an example we send the number of connected players to the template
    pagevars = {"num_players_connected": SESSIONS.player_count()}

    context_instance = RequestContext(request)
    return render_to_response("webclient.html", pagevars, context_instance)
开发者ID:Aumnren,项目名称:evennia,代码行数:18,代码来源:views.py


注:本文中的src.server.sessionhandler.SESSIONS.player_count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。