本文整理汇总了Python中evennia.server.sessionhandler.SESSIONS.player_count方法的典型用法代码示例。如果您正苦于以下问题:Python SESSIONS.player_count方法的具体用法?Python SESSIONS.player_count怎么用?Python SESSIONS.player_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类evennia.server.sessionhandler.SESSIONS
的用法示例。
在下文中一共展示了SESSIONS.player_count方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: func
# 需要导入模块: from evennia.server.sessionhandler import SESSIONS [as 别名]
# 或者: from evennia.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)
示例2: func
# 需要导入模块: from evennia.server.sessionhandler import SESSIONS [as 别名]
# 或者: from evennia.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(["{wИмя игрока",
"{wВ игре",
"{wIdle",
"{wУправляет",
"{wКомната",
"{wCmds",
"{wПротокол",
"{wХост"])
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 and puppet.location 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(["{wИмя игрока", "{wВ игре", "{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 = "{wИгроков:{n\n%s\n%s уникальных аккаунтов%s залогинено." % (table, "Один" if isone else nplayers, "" if isone else "")
self.msg(string)
示例3: _form_and_send_request
# 需要导入模块: from evennia.server.sessionhandler import SESSIONS [as 别名]
# 或者: from evennia.server.sessionhandler.SESSIONS import player_count [as 别名]
def _form_and_send_request(self):
agent = Agent(reactor, pool=self._conn_pool)
headers = {
'User-Agent': ['Evennia Game Index Client'],
'Content-Type': ['application/x-www-form-urlencoded'],
}
egi_config = self._get_config_dict()
# We are using `or` statements below with dict.get() to avoid sending
# stringified 'None' values to the server.
values = {
# Game listing stuff
'game_name': settings.SERVERNAME,
'game_status': egi_config['game_status'],
'game_website': egi_config.get('game_website') or '',
'short_description': egi_config['short_description'],
'long_description': egi_config.get('long_description') or '',
'listing_contact': egi_config['listing_contact'],
# How to play
'telnet_hostname': egi_config.get('telnet_hostname') or '',
'telnet_port': egi_config.get('telnet_port') or '',
'web_client_url': egi_config.get('web_client_url') or '',
# Game stats
'connected_player_count': SESSIONS.player_count(),
'total_player_count': PlayerDB.objects.num_total_players() or 0,
# System info
'evennia_version': get_evennia_version(),
'python_version': platform.python_version(),
'django_version': django.get_version(),
'server_platform': platform.platform(),
}
data = urllib.urlencode(values)
d = agent.request(
'POST', self.report_url,
headers=Headers(headers),
bodyProducer=StringProducer(data))
d.addCallback(self.handle_egd_response)
return d
示例4: func
# 需要导入模块: from evennia.server.sessionhandler import SESSIONS [as 别名]
# 或者: from evennia.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)
show_session_data = player.check_permstring('Immortals') if 'f' in self.switches else False
nplayers = (SESSIONS.player_count())
if 'f' in self.switches or 'full' in self.switches:
if show_session_data:
# privileged info - who/f by wizard or immortal
table = prettytable.PrettyTable(["|wPlayer Name",
"|wOn for",
"|wIdle",
"|wCharacter",
"|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 info - who/f by player
table = prettytable.PrettyTable(["|wCharacter", "|wOn for", "|wIdle", "|wLocation"])
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
character = session.get_puppet()
location = character.location.key if character and character.location else 'None'
table.add_row([utils.crop(character.key if character else '- Unknown -', width=25),
utils.time_format(delta_conn, 0),
utils.time_format(delta_cmd, 1),
utils.crop(location, width=25)])
else:
if 's' in self.switches or 'species' in self.switches or self.cmdstring == 'ws':
my_character = self.caller.get_puppet(self.session)
if not (my_character and my_character.location):
self.msg("You can't see anyone here.")
return
table = prettytable.PrettyTable(["|wCharacter", "|wOn for", "|wIdle", "|wSpecies"])
for session in session_list:
character = session.get_puppet()
# my_character = self.caller.get_puppet(self.session)
if not session.logged_in or character.location != my_character.location:
continue
delta_cmd = time.time() - session.cmd_last_visible
delta_conn = time.time() - session.conn_time
character = session.get_puppet()
species = character.attributes.get('species', default='- None -')
table.add_row([utils.crop(character.key if character else '- Unknown -', width=25),
utils.time_format(delta_conn, 0),
utils.time_format(delta_cmd, 1),
utils.crop(species, width=25)])
else: # unprivileged info - who
table = prettytable.PrettyTable(["|wCharacter", "|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
character = session.get_puppet()
table.add_row([utils.crop(character.key if character else '- Unknown -', width=25),
utils.time_format(delta_conn, 0),
utils.time_format(delta_cmd, 1)])
isone = nplayers == 1
string = "%s\n%s " % (table, 'A' if isone else nplayers)
string += 'single' if isone else 'unique'
plural = '' if isone else 's'
string += " account%s logged in." % plural
self.msg(string)