Rename all instances of Player->Account.

This commit is contained in:
Griatch 2017-07-07 23:47:21 +02:00
parent a14e11640b
commit 5590ee2258
94 changed files with 1316 additions and 2327 deletions

View file

@ -6,12 +6,12 @@ Both sides use this same protocol.
The separation works like this:
Portal - (AMP client) handles protocols. It contains a list of connected
sessions in a dictionary for identifying the respective player
sessions in a dictionary for identifying the respective account
connected. If it loses the AMP connection it will automatically
try to reconnect.
Server - (AMP server) Handles all mud operations. The server holds its own list
of sessions tied to player objects. This is synced against the portal
of sessions tied to account objects. This is synced against the portal
at startup and when a session connects/disconnects
"""

View file

@ -24,7 +24,7 @@ def check_errors(settings):
raise DeprecationWarning(deprstring % (
"CMDSET_DEFAULT", "CMDSET_CHARACTER"))
if hasattr(settings, "CMDSET_OOC"):
raise DeprecationWarning(deprstring % ("CMDSET_OOC", "CMDSET_PLAYER"))
raise DeprecationWarning(deprstring % ("CMDSET_OOC", "CMDSET_ACCOUNT"))
if settings.WEBSERVER_ENABLED and not isinstance(settings.WEBSERVER_PORTS[0], tuple):
raise DeprecationWarning(
"settings.WEBSERVER_PORTS must be on the form "
@ -46,8 +46,8 @@ def check_errors(settings):
raise DeprecationWarning(deprstring % "OBJECT_TYPECLASS_PATHS")
if hasattr(settings, "SCRIPT_TYPECLASS_PATHS"):
raise DeprecationWarning(deprstring % "SCRIPT_TYPECLASS_PATHS")
if hasattr(settings, "PLAYER_TYPECLASS_PATHS"):
raise DeprecationWarning(deprstring % "PLAYER_TYPECLASS_PATHS")
if hasattr(settings, "ACCOUNT_TYPECLASS_PATHS"):
raise DeprecationWarning(deprstring % "ACCOUNT_TYPECLASS_PATHS")
if hasattr(settings, "CHANNEL_TYPECLASS_PATHS"):
raise DeprecationWarning(deprstring % "CHANNEL_TYPECLASS_PATHS")
if hasattr(settings, "SEARCH_MULTIMATCH_SEPARATOR"):

View file

@ -132,15 +132,15 @@ ERROR_NO_GAMEDIR = \
WARNING_MOVING_SUPERUSER = \
"""
WARNING: Evennia expects a Player superuser with id=1. No such
Player was found. However, another superuser ('{other_key}',
WARNING: Evennia expects an Account superuser with id=1. No such
Account was found. However, another superuser ('{other_key}',
id={other_id}) was found in the database. If you just created this
superuser and still see this text it is probably due to the
database being flushed recently - in this case the database's
internal auto-counter might just start from some value higher than
one.
We will fix this by assigning the id 1 to Player '{other_key}'.
We will fix this by assigning the id 1 to Account '{other_key}'.
Please confirm this is acceptable before continuing.
"""
@ -182,7 +182,7 @@ RECREATED_SETTINGS = \
Note that if you were using an existing database, the password
salt of this new settings file will be different from the old one.
This means that any existing players may not be able to log in to
This means that any existing accounts may not be able to log in to
their accounts with their old passwords.
"""
@ -270,7 +270,7 @@ HELP_ENTRY = \
adding new protocols or are debugging Evennia itself.
Reload with (5) to update the server with your changes without
disconnecting any players.
disconnecting any accounts.
Note: Reload and stop are sometimes poorly supported in Windows. If you
have issues, log into the game to stop or restart the server instead.
@ -581,11 +581,11 @@ def create_game_directory(dirname):
def create_superuser():
"""
Create the superuser player
Create the superuser account
"""
print(
"\nCreate a superuser below. The superuser is Player #1, the 'owner' "
"\nCreate a superuser below. The superuser is Account #1, the 'owner' "
"account of the server.\n")
django.core.management.call_command("createsuperuser", interactive=True)
@ -602,20 +602,20 @@ def check_database():
tables = connection.introspection.get_table_list(connection.cursor())
if not tables or not isinstance(tables[0], basestring): # django 1.8+
tables = [tableinfo.name for tableinfo in tables]
if tables and u'players_playerdb' in tables:
if tables and u'accounts_accountdb' in tables:
# database exists and seems set up. Initialize evennia.
evennia._init()
# Try to get Player#1
from evennia.players.models import PlayerDB
# Try to get Account#1
from evennia.accounts.models import AccountDB
try:
PlayerDB.objects.get(id=1)
AccountDB.objects.get(id=1)
except django.db.utils.OperationalError as e:
print(ERROR_DATABASE.format(traceback=e))
sys.exit()
except PlayerDB.DoesNotExist:
except AccountDB.DoesNotExist:
# no superuser yet. We need to create it.
other_superuser = PlayerDB.objects.filter(is_superuser=True)
other_superuser = AccountDB.objects.filter(is_superuser=True)
if other_superuser:
# Another superuser was found, but not with id=1. This may
# happen if using flush (the auto-id starts at a higher
@ -811,10 +811,10 @@ def error_check_python_modules():
print("Warning: CMDSET_UNLOGGED failed to load!")
if not cmdsethandler.import_cmdset(settings.CMDSET_CHARACTER, None):
print("Warning: CMDSET_CHARACTER failed to load")
if not cmdsethandler.import_cmdset(settings.CMDSET_PLAYER, None):
print("Warning: CMDSET_PLAYER failed to load")
if not cmdsethandler.import_cmdset(settings.CMDSET_ACCOUNT, None):
print("Warning: CMDSET_ACCOUNT failed to load")
# typeclasses
_imp(settings.BASE_PLAYER_TYPECLASS)
_imp(settings.BASE_ACCOUNT_TYPECLASS)
_imp(settings.BASE_OBJECT_TYPECLASS)
_imp(settings.BASE_CHARACTER_TYPECLASS)
_imp(settings.BASE_ROOM_TYPECLASS)
@ -945,10 +945,10 @@ def run_dummyrunner(number_of_dummies):
Start an instance of the dummyrunner
Args:
number_of_dummies (int): The number of dummy players to start.
number_of_dummies (int): The number of dummy accounts to start.
Notes:
The dummy players' behavior can be customized by adding a
The dummy accounts' behavior can be customized by adding a
`dummyrunner_settings.py` config file in the game's conf/
directory.
@ -1215,7 +1215,7 @@ def main():
parser.add_argument(
'--dummyrunner', nargs=1, action='store', dest='dummyrunner',
metavar="N",
help="Test a running server by connecting N dummy players to it.")
help="Test a running server by connecting N dummy accounts to it.")
parser.add_argument(
'--settings', nargs=1, action='store', dest='altsettings',
default=None, metavar="filename.py",

View file

@ -10,7 +10,7 @@ from __future__ import print_function
import time
from django.conf import settings
from django.utils.translation import ugettext as _
from evennia.players.models import PlayerDB
from evennia.accounts.models import AccountDB
from evennia.server.models import ServerConfig
from evennia.utils import create, logger
@ -28,7 +28,7 @@ ERROR_NO_SUPERUSER = """
LIMBO_DESC = _("""
Welcome to your new |wEvennia|n-based game! Visit http://www.evennia.com if you need
help, want to contribute, report issues or just join the community.
As Player #1 you can create a demo/tutorial area with |w@batchcommand tutorial_world.build|n.
As Account #1 you can create a demo/tutorial area with |w@batchcommand tutorial_world.build|n.
""")
@ -36,55 +36,55 @@ WARNING_POSTGRESQL_FIX = """
PostgreSQL-psycopg2 compatibility fix:
The in-game channels {chan1}, {chan2} and {chan3} were created,
but the superuser was not yet connected to them. Please use in
game commands to connect Player #1 to those channels when first
game commands to connect Account #1 to those channels when first
logging in.
"""
def get_god_player():
def get_god_account():
"""
Creates the god user and don't take no for an answer.
"""
try:
god_player = PlayerDB.objects.get(id=1)
except PlayerDB.DoesNotExist:
raise PlayerDB.DoesNotExist(ERROR_NO_SUPERUSER)
return god_player
god_account = AccountDB.objects.get(id=1)
except AccountDB.DoesNotExist:
raise AccountDB.DoesNotExist(ERROR_NO_SUPERUSER)
return god_account
def create_objects():
"""
Creates the #1 player and Limbo room.
Creates the #1 account and Limbo room.
"""
logger.log_info("Creating objects (Player #1 and Limbo room) ...")
logger.log_info("Creating objects (Account #1 and Limbo room) ...")
# Set the initial User's account object's username on the #1 object.
# This object is pure django and only holds name, email and password.
god_player = get_god_player()
god_account = get_god_account()
# Create a Player 'user profile' object to hold eventual
# mud-specific settings for the PlayerDB object.
player_typeclass = settings.BASE_PLAYER_TYPECLASS
# Create an Account 'user profile' object to hold eventual
# mud-specific settings for the AccountDB object.
account_typeclass = settings.BASE_ACCOUNT_TYPECLASS
# run all creation hooks on god_player (we must do so manually
# run all creation hooks on god_account (we must do so manually
# since the manage.py command does not)
god_player.swap_typeclass(player_typeclass, clean_attributes=True)
god_player.basetype_setup()
god_player.at_player_creation()
god_player.locks.add("examine:perm(Developer);edit:false();delete:false();boot:false();msg:all()")
god_account.swap_typeclass(account_typeclass, clean_attributes=True)
god_account.basetype_setup()
god_account.at_account_creation()
god_account.locks.add("examine:perm(Developer);edit:false();delete:false();boot:false();msg:all()")
# this is necessary for quelling to work correctly.
god_player.permissions.add("Developer")
god_account.permissions.add("Developer")
# Limbo is the default "nowhere" starting room
# Create the in-game god-character for player #1 and set
# Create the in-game god-character for account #1 and set
# it to exist in Limbo.
character_typeclass = settings.BASE_CHARACTER_TYPECLASS
god_character = create.create_object(character_typeclass,
key=god_player.username,
key=god_account.username,
nohome=True)
god_character.id = 1
@ -93,13 +93,13 @@ def create_objects():
god_character.locks.add("examine:perm(Developer);edit:false();delete:false();boot:false();msg:all();puppet:false()")
god_character.permissions.add("Developer")
god_player.attributes.add("_first_login", True)
god_player.attributes.add("_last_puppet", god_character)
god_account.attributes.add("_first_login", True)
god_account.attributes.add("_last_puppet", god_character)
try:
god_player.db._playable_characters.append(god_character)
god_account.db._playable_characters.append(god_character)
except AttributeError:
god_player.db_playable_characters = [god_character]
god_account.db_playable_characters = [god_character]
room_typeclass = settings.BASE_ROOM_TYPECLASS
limbo_obj = create.create_object(room_typeclass, _('Limbo'), nohome=True)
@ -123,7 +123,7 @@ def create_channels():
"""
logger.log_info("Creating default channels ...")
goduser = get_god_player()
goduser = get_god_account()
for channeldict in settings.DEFAULT_CHANNELS:
channel = create.create_channel(**channeldict)
channel.connect(goduser)

View file

@ -23,7 +23,7 @@ from future.utils import viewkeys
import importlib
from django.conf import settings
from evennia.commands.cmdhandler import cmdhandler
from evennia.players.models import PlayerDB
from evennia.accounts.models import AccountDB
from evennia.utils.logger import log_err
from evennia.utils.utils import to_str, to_unicode
@ -67,15 +67,15 @@ def text(session, *args, **kwargs):
if txt.strip() in _IDLE_COMMAND:
session.update_session_counters(idle=True)
return
if session.player:
if session.account:
# nick replacement
puppet = session.puppet
if puppet:
txt = puppet.nicks.nickreplace(txt,
categories=("inputline", "channel"), include_player=True)
categories=("inputline", "channel"), include_account=True)
else:
txt = session.player.nicks.nickreplace(txt,
categories=("inputline", "channel"), include_player=False)
txt = session.account.nicks.nickreplace(txt,
categories=("inputline", "channel"), include_account=False)
kwargs.pop("options", None)
cmdhandler(session, txt, callertype="session", session=session, **kwargs)
session.update_session_counters()
@ -105,7 +105,7 @@ def bot_data_in(session, *args, **kwargs):
return
kwargs.pop("options", None)
# Trigger the execute_cmd method of the corresponding bot.
session.player.execute_cmd(session=session, txt=txt, **kwargs)
session.account.execute_cmd(session=session, txt=txt, **kwargs)
session.update_session_counters()
@ -153,10 +153,10 @@ def browser_sessid(session, *args, **kwargs):
uid = browsersession.get("logged_in", None)
if uid:
try:
player = PlayerDB.objects.get(pk=uid)
account = AccountDB.objects.get(pk=uid)
except Exception:
return
session.sessionhandler.login(session, player)
session.sessionhandler.login(session, account)
@ -288,15 +288,15 @@ def login(session, *args, **kwargs):
in. This will also automatically throttle too quick attempts.
Kwargs:
name (str): Player name
name (str): Account name
password (str): Plain-text password
"""
if not session.logged_in and "name" in kwargs and "password" in kwargs:
from evennia.commands.default.unloggedin import create_normal_player
player = create_normal_player(session, kwargs["name"], kwargs["password"])
if player:
session.sessionhandler.login(session, player)
from evennia.commands.default.unloggedin import create_normal_account
account = create_normal_account(session, kwargs["name"], kwargs["password"])
if account:
session.sessionhandler.login(session, account)
_gettable = {
"name": lambda obj: obj.key,
@ -308,7 +308,7 @@ _gettable = {
def get_value(session, *args, **kwargs):
"""
Return the value of a given attribute or db_property on the
session's current player or character.
session's current account or character.
Kwargs:
name (str): Name of info value to return. Only names
@ -317,7 +317,7 @@ def get_value(session, *args, **kwargs):
"""
name = kwargs.get("name", "")
obj = session.puppet or session.player
obj = session.puppet or session.account
if name in _gettable:
session.msg(get_value={"name": name, "value": _gettable[name](obj)})
@ -428,7 +428,7 @@ def unmonitor(session, *args, **kwargs):
def _on_webclient_options_change(**kwargs):
"""
Called when the webclient options stored on the player changes.
Called when the webclient options stored on the account changes.
Inform the interested clients of this change.
"""
session = kwargs["session"]
@ -452,15 +452,15 @@ def webclient_options(session, *args, **kwargs):
that changes.
If kwargs is not empty, the key/values stored in there will be persisted
to the player object.
to the account object.
Kwargs:
<option name>: an option to save
"""
player = session.player
account = session.account
clientoptions = settings.WEBCLIENT_OPTIONS.copy()
storedoptions = player.db._saved_webclient_options or {}
storedoptions = account.db._saved_webclient_options or {}
clientoptions.update(storedoptions)
# The webclient adds a cmdid to every kwargs, but we don't need it.
@ -476,13 +476,13 @@ def webclient_options(session, *args, **kwargs):
# Create a monitor. If a monitor already exists then it will replace
# the previous one since it would use the same idstring
from evennia.scripts.monitorhandler import MONITOR_HANDLER
MONITOR_HANDLER.add(player, "_saved_webclient_options",
MONITOR_HANDLER.add(account, "_saved_webclient_options",
_on_webclient_options_change,
idstring=session.sessid, persistent=False,
session=session)
else:
# kwargs provided: persist them to the player object
# kwargs provided: persist them to the account object
for key, value in kwargs.iteritems():
clientoptions[key] = value
player.db._saved_webclient_options = clientoptions
account.db._saved_webclient_options = clientoptions

View file

@ -45,7 +45,7 @@ from twisted.python import components
from django.conf import settings
from evennia.server import session
from evennia.players.models import PlayerDB
from evennia.accounts.models import AccountDB
from evennia.utils import ansi
from evennia.utils.utils import to_str
@ -61,21 +61,21 @@ CTRL_L = '\x0c'
class SshProtocol(Manhole, session.Session):
"""
Each player connecting over ssh gets this protocol assigned to
them. All communication between game and player goes through
Each account connecting over ssh gets this protocol assigned to
them. All communication between game and account goes through
here.
"""
def __init__(self, starttuple):
"""
For setting up the player. If player is not None then we'll
For setting up the account. If account is not None then we'll
login automatically.
Args:
starttuple (tuple): A (player, factory) tuple.
starttuple (tuple): A (account, factory) tuple.
"""
self.authenticated_player = starttuple[0]
self.authenticated_account = starttuple[0]
# obs must not be called self.factory, that gets overwritten!
self.cfactory = starttuple[1]
@ -101,9 +101,9 @@ class SshProtocol(Manhole, session.Session):
self.init_session("ssh", client_address, self.cfactory.sessionhandler)
# since we might have authenticated already, we might set this here.
if self.authenticated_player:
if self.authenticated_account:
self.logged_in = True
self.uid = self.authenticated_player.user.id
self.uid = self.authenticated_account.user.id
self.sessionhandler.connect(self)
def connectionMade(self):
@ -313,10 +313,10 @@ class ExtraInfoAuthServer(SSHUserAuthServer):
self._ebPassword)
class PlayerDBPasswordChecker(object):
class AccountDBPasswordChecker(object):
"""
Checks the django db for the correct credentials for
username/password otherwise it returns the player or None which is
username/password otherwise it returns the account or None which is
useful for the Realm.
"""
@ -331,7 +331,7 @@ class PlayerDBPasswordChecker(object):
"""
self.factory = factory
super(PlayerDBPasswordChecker, self).__init__()
super(AccountDBPasswordChecker, self).__init__()
def requestAvatarId(self, c):
"""
@ -341,10 +341,10 @@ class PlayerDBPasswordChecker(object):
up = credentials.IUsernamePassword(c, None)
username = up.username
password = up.password
player = PlayerDB.objects.get_player_from_name(username)
account = AccountDB.objects.get_account_from_name(username)
res = (None, self.factory)
if player and player.check_password(password):
res = (player, self.factory)
if account and account.check_password(password):
res = (account, self.factory)
return defer.succeed(res)
@ -462,6 +462,6 @@ def makeFactory(configdict):
factory.services = factory.services.copy()
factory.services['ssh-userauth'] = ExtraInfoAuthServer
factory.portal.registerChecker(PlayerDBPasswordChecker(factory))
factory.portal.registerChecker(AccountDBPasswordChecker(factory))
return factory

View file

@ -15,7 +15,7 @@ full step-by-step setup help.
Basically (for testing default Evennia):
- Use an empty/testing database.
- set PERMISSION_PLAYER_DEFAULT = "Builder"
- set PERMISSION_ACCOUNT_DEFAULT = "Builder"
- start server, eventually with profiling active
- launch this client runner
@ -65,7 +65,7 @@ TIMESTEP = DUMMYRUNNER_SETTINGS.TIMESTEP
# chance of a client performing an action, per timestep. This helps to
# spread out usage randomly, like it would be in reality.
CHANCE_OF_ACTION = DUMMYRUNNER_SETTINGS.CHANCE_OF_ACTION
# spread out the login action separately, having many players create accounts
# spread out the login action separately, having many accounts create accounts
# and connect simultaneously is generally unlikely.
CHANCE_OF_LOGIN = DUMMYRUNNER_SETTINGS.CHANCE_OF_LOGIN
# Port to use, if not specified on command line
@ -79,7 +79,7 @@ NLOGGED_IN = 0
INFO_STARTING = \
"""
Dummyrunner starting using {N} dummy player(s). If you don't see
Dummyrunner starting using {N} dummy account(s). If you don't see
any connection messages, make sure that the Evennia server is
running.
@ -95,7 +95,7 @@ ERROR_NO_MIXIN = \
from evennia.server.profiling.settings_mixin import *
This will change the settings in the following way:
- change PERMISSION_PLAYER_DEFAULT to 'Developer' to allow clients
- change PERMISSION_ACCOUNT_DEFAULT to 'Developer' to allow clients
to test all commands
- change PASSWORD_HASHERS to use a faster (but less safe) algorithm
when creating large numbers of accounts at the same time
@ -106,7 +106,7 @@ ERROR_NO_MIXIN = \
error completely.
Warning: Don't run dummyrunner on a production database! It will
create a lot of spammy objects and player accounts!
create a lot of spammy objects and account accounts!
"""
@ -121,7 +121,7 @@ HELPTEXT = """
DO NOT RUN THIS ON A PRODUCTION SERVER! USE A CLEAN/TESTING DATABASE!
This stand-alone program launches dummy telnet clients against a
running Evennia server. The idea is to mimic real players logging in
running Evennia server. The idea is to mimic real accounts logging in
and repeatedly doing resource-heavy commands so as to stress test the
game. It uses the default command set to log in and issue commands, so
if that was customized, some of the functionality will not be tested
@ -136,9 +136,9 @@ Setup:
`evennia migrate`)
2) in server/conf/settings.py, add
PERMISSION_PLAYER_DEFAULT="Builder"
PERMISSION_ACCOUNT_DEFAULT="Builder"
This is so that the dummy players can test building operations.
This is so that the dummy accounts can test building operations.
You can also customize the dummyrunner by modifying a setting
file specified by DUMMYRUNNER_SETTINGS_MODULE
@ -160,12 +160,12 @@ Setup:
Notes:
The dummyrunner tends to create a lot of players all at once, which is
The dummyrunner tends to create a lot of accounts all at once, which is
a very heavy operation. This is not a realistic use-case - what you want
to test is performance during run. A large
number of clients here may lock up the client until all have been
created. It may be better to connect multiple dummyrunners instead of
starting one single one with a lot of players. Exactly what this number
starting one single one with a lot of accounts. Exactly what this number
is depends on your computer power. So start with 10-20 clients and increase
until you see the initial login slows things too much.
@ -223,7 +223,7 @@ def makeiter(obj):
class DummyClient(telnet.StatefulTelnetProtocol):
"""
Handles connection to a running Evennia server,
mimicking a real player by sending commands on
mimicking a real account by sending commands on
a timer.
"""

View file

@ -2,7 +2,7 @@
Settings and actions for the dummyrunner
This module defines dummyrunner settings and sets up
the actions available to dummy players.
the actions available to dummy accounts.
The settings are global variables:
@ -18,7 +18,7 @@ ACTIONS is a tuple
where the first entry is the function to call on first connect, with a
chance of occurring given by CHANCE_OF_LOGIN. This function is usually
responsible for logging in the player. The second entry is always
responsible for logging in the account. The second entry is always
called when the dummyrunner disconnects from the server and should
thus issue a logout command. The other entries are tuples (chance,
func). They are picked randomly, their commonality based on the
@ -61,7 +61,7 @@ TIMESTEP = 2
CHANCE_OF_ACTION = 0.5
# Chance of a currently unlogged-in dummy performing its login
# action every tick. This emulates not all players logging in
# action every tick. This emulates not all accounts logging in
# at exactly the same time.
CHANCE_OF_LOGIN = 1.0
@ -234,7 +234,7 @@ def c_moves_s(client):
# (0.1, c_creates_obj),
# #(0.01, c_creates_button),
# (0.2, c_moves))
## "passive player" definition
## "passive account" definition
#ACTIONS = ( c_login,
# c_logout,
# (0.7, c_looks),
@ -244,11 +244,11 @@ def c_moves_s(client):
# #(0.1, c_creates_obj),
# #(0.1, c_creates_button),
# #(0.4, c_moves))
# "inactive player" definition
# "inactive account" definition
#ACTIONS = (c_login_nodig,
# c_logout,
# (1.0, c_idles))
## "normal player" definition
## "normal account" definition
ACTIONS = ( c_login,
c_logout,
(0.01, c_digs),

View file

@ -62,7 +62,7 @@ if __name__ == "__main__":
fig = pp.figure()
ax1 = fig.add_subplot(111)
ax1.set_title("1000 bots (normal players with light building)")
ax1.set_title("1000 bots (normal accounts with light building)")
ax1.set_xlabel("Time (mins)")
ax1.set_ylabel("Memory usage (MB)")
ax1.plot(secs, rmem, "r", label="RMEM", lw=2)

View file

@ -12,10 +12,10 @@ servers!
# the mixin is present
DUMMYRUNNER_MIXIN = True
# a faster password hasher suitable for multiple simultaneous
# player creations. The default one is safer but deliberately
# account creations. The default one is safer but deliberately
# very slow to make cracking harder.
PASSWORD_HASHERS = (
'django.contrib.auth.hashers.MD5PasswordHasher',
)
# make dummy clients able to test all commands
PERMISSION_PLAYER_DEFAULT = "Developer"
PERMISSION_ACCOUNT_DEFAULT = "Developer"

View file

@ -27,7 +27,7 @@ evennia._init()
from django.db import connection
from django.conf import settings
from evennia.players.models import PlayerDB
from evennia.accounts.models import AccountDB
from evennia.scripts.models import ScriptDB
from evennia.server.models import ServerConfig
from evennia.server import initial_setup
@ -214,8 +214,8 @@ class Evennia(object):
already existing objects.
"""
# setting names
settings_names = ("CMDSET_CHARACTER", "CMDSET_PLAYER",
"BASE_PLAYER_TYPECLASS", "BASE_OBJECT_TYPECLASS",
settings_names = ("CMDSET_CHARACTER", "CMDSET_ACCOUNT",
"BASE_ACCOUNT_TYPECLASS", "BASE_OBJECT_TYPECLASS",
"BASE_CHARACTER_TYPECLASS", "BASE_ROOM_TYPECLASS",
"BASE_EXIT_TYPECLASS", "BASE_SCRIPT_TYPECLASS",
"BASE_CHANNEL_TYPECLASS")
@ -228,16 +228,16 @@ class Evennia(object):
# run the update
from evennia.objects.models import ObjectDB
from evennia.comms.models import ChannelDB
#from evennia.players.models import PlayerDB
#from evennia.accounts.models import AccountDB
for i, prev, curr in ((i, tup[0], tup[1]) for i, tup in enumerate(settings_compare) if i in mismatches):
# update the database
print(" %s:\n '%s' changed to '%s'. Updating unchanged entries in database ..." % (settings_names[i], prev, curr))
if i == 0:
ObjectDB.objects.filter(db_cmdset_storage__exact=prev).update(db_cmdset_storage=curr)
if i == 1:
PlayerDB.objects.filter(db_cmdset_storage__exact=prev).update(db_cmdset_storage=curr)
AccountDB.objects.filter(db_cmdset_storage__exact=prev).update(db_cmdset_storage=curr)
if i == 2:
PlayerDB.objects.filter(db_typeclass_path__exact=prev).update(db_typeclass_path=curr)
AccountDB.objects.filter(db_typeclass_path__exact=prev).update(db_typeclass_path=curr)
if i in (3, 4, 5, 6):
ObjectDB.objects.filter(db_typeclass_path__exact=prev).update(db_typeclass_path=curr)
if i == 7:
@ -247,7 +247,7 @@ class Evennia(object):
# store the new default and clean caches
ServerConfig.objects.conf(settings_names[i], curr)
ObjectDB.flush_instance_cache()
PlayerDB.flush_instance_cache()
AccountDB.flush_instance_cache()
ScriptDB.flush_instance_cache()
ChannelDB.flush_instance_cache()
# if this is the first start we might not have a "previous"
@ -283,13 +283,13 @@ class Evennia(object):
Called every server start
"""
from evennia.objects.models import ObjectDB
#from evennia.players.models import PlayerDB
#from evennia.accounts.models import AccountDB
#update eventual changed defaults
self.update_defaults()
[o.at_init() for o in ObjectDB.get_all_cached_instances()]
[p.at_init() for p in PlayerDB.get_all_cached_instances()]
[p.at_init() for p in AccountDB.get_all_cached_instances()]
mode = self.getset_restart_mode()
@ -356,7 +356,7 @@ class Evennia(object):
mode = self.getset_restart_mode(mode)
from evennia.objects.models import ObjectDB
#from evennia.players.models import PlayerDB
#from evennia.accounts.models import AccountDB
from evennia.server.models import ServerConfig
from evennia.utils import gametime as _GAMETIME_MODULE
@ -364,7 +364,7 @@ class Evennia(object):
# call restart hooks
ServerConfig.objects.conf("server_restart_mode", "reload")
yield [o.at_server_reload() for o in ObjectDB.get_all_cached_instances()]
yield [p.at_server_reload() for p in PlayerDB.get_all_cached_instances()]
yield [p.at_server_reload() for p in AccountDB.get_all_cached_instances()]
yield [(s.pause(manual_pause=False), s.at_server_reload()) for s in ScriptDB.get_all_cached_instances() if s.is_active]
yield self.sessions.all_sessions_portal_sync()
self.at_server_reload_stop()
@ -375,14 +375,14 @@ class Evennia(object):
if mode == 'reset':
# like shutdown but don't unset the is_connected flag and don't disconnect sessions
yield [o.at_server_shutdown() for o in ObjectDB.get_all_cached_instances()]
yield [p.at_server_shutdown() for p in PlayerDB.get_all_cached_instances()]
yield [p.at_server_shutdown() for p in AccountDB.get_all_cached_instances()]
if self.amp_protocol:
yield self.sessions.all_sessions_portal_sync()
else: # shutdown
yield [_SA(p, "is_connected", False) for p in PlayerDB.get_all_cached_instances()]
yield [_SA(p, "is_connected", False) for p in AccountDB.get_all_cached_instances()]
yield [o.at_server_shutdown() for o in ObjectDB.get_all_cached_instances()]
yield [(p.unpuppet_all(), p.at_server_shutdown())
for p in PlayerDB.get_all_cached_instances()]
for p in AccountDB.get_all_cached_instances()]
yield ObjectDB.objects.clear_all_sessids()
yield [(s.pause(manual_pause=False), s.at_server_shutdown()) for s in ScriptDB.get_all_cached_instances()]
ServerConfig.objects.conf("server_restart_mode", "reset")
@ -482,7 +482,7 @@ class Evennia(object):
script.stop()
if GUEST_ENABLED:
for guest in PlayerDB.objects.all().filter(db_typeclass_path=settings.BASE_GUEST_TYPECLASS):
for guest in AccountDB.objects.all().filter(db_typeclass_path=settings.BASE_GUEST_TYPECLASS):
for character in guest.db._playable_characters:
if character: character.delete()
guest.delete()

View file

@ -152,18 +152,18 @@ class NAttributeHandler(object):
class ServerSession(Session):
"""
This class represents a player's session and is a template for
This class represents an account's session and is a template for
individual protocols to communicate with Evennia.
Each player gets a session assigned to them whenever they connect
to the game server. All communication between game and player goes
Each account gets a session assigned to them whenever they connect
to the game server. All communication between game and account goes
through their session.
"""
def __init__(self):
"""Initiate to avoid AttributeErrors down the line"""
self.puppet = None
self.player = None
self.account = None
self.cmdset_storage_string = ""
self.cmdset = CmdSetHandler(self, True)
@ -178,7 +178,7 @@ class ServerSession(Session):
"""
This is called whenever a session has been resynced with the
portal. At this point all relevant attributes have already
been set and self.player been assigned (if applicable).
been set and self.account been assigned (if applicable).
Since this is often called after a server restart we need to
set up the session as it was.
@ -201,23 +201,23 @@ class ServerSession(Session):
# hooks, echoes or access checks.
obj = _ObjectDB.objects.get(id=self.puid)
obj.sessions.add(self)
obj.player = self.player
obj.account = self.account
self.puid = obj.id
self.puppet = obj
# obj.scripts.validate()
obj.locks.cache_lock_bypass(obj)
def at_login(self, player):
def at_login(self, account):
"""
Hook called by sessionhandler when the session becomes authenticated.
Args:
player (Player): The player associated with the session.
account (Account): The account associated with the session.
"""
self.player = player
self.uid = self.player.id
self.uname = self.player.username
self.account = account
self.uid = self.account.id
self.uname = self.account.username
self.logged_in = True
self.conn_time = time.time()
self.puid = None
@ -230,12 +230,12 @@ class ServerSession(Session):
# can also see we are logged in.
csession = ClientSessionStore(session_key=self.csessid)
if not csession.get("logged_in"):
csession["logged_in"] = player.id
csession["logged_in"] = account.id
csession.save()
# Update account's last login time.
self.player.last_login = timezone.now()
self.player.save()
self.account.last_login = timezone.now()
self.account.save()
# add the session-level cmdset
self.cmdset = CmdSetHandler(self, True)
@ -246,34 +246,34 @@ class ServerSession(Session):
"""
if self.logged_in:
player = self.player
account = self.account
if self.puppet:
player.unpuppet_object(self)
uaccount = player
account.unpuppet_object(self)
uaccount = account
uaccount.last_login = timezone.now()
uaccount.save()
# calling player hook
player.at_disconnect()
# calling account hook
account.at_disconnect()
self.logged_in = False
if not self.sessionhandler.sessions_from_player(player):
# no more sessions connected to this player
player.is_connected = False
# this may be used to e.g. delete player after disconnection etc
player.at_post_disconnect()
if not self.sessionhandler.sessions_from_account(account):
# no more sessions connected to this account
account.is_connected = False
# this may be used to e.g. delete account after disconnection etc
account.at_post_disconnect()
# remove any webclient settings monitors associated with this
# session
MONITOR_HANDLER.remove(player, "_saved_webclient_options",
MONITOR_HANDLER.remove(account, "_saved_webclient_options",
self.sessid)
def get_player(self):
def get_account(self):
"""
Get the player associated with this session
Get the account associated with this session
Returns:
player (Player): The associated Player.
account (Account): The associated Account.
"""
return self.logged_in and self.player
return self.logged_in and self.account
def get_puppet(self):
"""
@ -286,17 +286,17 @@ class ServerSession(Session):
return self.logged_in and self.puppet
get_character = get_puppet
def get_puppet_or_player(self):
def get_puppet_or_account(self):
"""
Get puppet or player.
Get puppet or account.
Returns:
controller (Object or Player): The puppet if one exists,
otherwise return the player.
controller (Object or Account): The puppet if one exists,
otherwise return the account.
"""
if self.logged_in:
return self.puppet if self.puppet else self.player
return self.puppet if self.puppet else self.account
return None
def log(self, message, channel=True):
@ -343,7 +343,7 @@ class ServerSession(Session):
if not idle:
# Increment the user's command counter.
self.cmd_total += 1
# Player-visible idle time, not used in idle timeout calcs.
# Account-visible idle time, not used in idle timeout calcs.
self.cmd_last_visible = self.cmd_last
def update_flags(self, **kwargs):
@ -395,7 +395,7 @@ class ServerSession(Session):
def msg(self, text=None, **kwargs):
"""
Wrapper to mimic msg() functionality of Objects and Players.
Wrapper to mimic msg() functionality of Objects and Accounts.
Args:
text (str): String input.
@ -449,8 +449,8 @@ class ServerSession(Session):
"""
symbol = ""
if self.logged_in and hasattr(self, "player") and self.player:
symbol = "(#%s)" % self.player.id
if self.logged_in and hasattr(self, "account") and self.account:
symbol = "(#%s)" % self.account.id
try:
if hasattr(self.address, '__iter__'):
address = ":".join([str(part) for part in self.address])

View file

@ -25,7 +25,7 @@ class Session(object):
respective hook methods should be connected to the methods unique
for the respective protocol so that there is a unified interface
to Evennia.
2. A Server session. This is the same for all connected players,
2. A Server session. This is the same for all connected accounts,
regardless of how they connect.
The Portal and Server have their own respective sessionhandlers. These
@ -123,11 +123,11 @@ class Session(object):
def at_sync(self):
"""
Called after a session has been fully synced (including
secondary operations such as setting self.player based
secondary operations such as setting self.account based
on uid etc).
"""
self.protocol_flags.update(self.player.attributs.get("_saved_protocol_flags"), {})
self.protocol_flags.update(self.account.attributs.get("_saved_protocol_flags"), {})
# access hooks

View file

@ -33,7 +33,7 @@ except ImportError:
_INLINEFUNC_ENABLED = settings.INLINEFUNC_ENABLED
# delayed imports
_PlayerDB = None
_AccountDB = None
_ServerSession = None
_ServerConfig = None
_ScriptDB = None
@ -77,20 +77,20 @@ def delayed_import():
Helper method for delayed import of all needed entities.
"""
global _ServerSession, _PlayerDB, _ServerConfig, _ScriptDB
global _ServerSession, _AccountDB, _ServerConfig, _ScriptDB
if not _ServerSession:
# we allow optional arbitrary serversession class for overloading
modulename, classname = settings.SERVER_SESSION_CLASS.rsplit(".", 1)
_ServerSession = variable_from_module(modulename, classname)
if not _PlayerDB:
from evennia.players.models import PlayerDB as _PlayerDB
if not _AccountDB:
from evennia.accounts.models import AccountDB as _AccountDB
if not _ServerConfig:
from evennia.server.models import ServerConfig as _ServerConfig
if not _ScriptDB:
from evennia.scripts.models import ScriptDB as _ScriptDB
# including once to avoid warnings in Python syntax checkers
assert(_ServerSession)
assert(_PlayerDB)
assert(_AccountDB)
assert(_ServerConfig)
assert(_ScriptDB)
@ -249,7 +249,7 @@ class ServerSessionHandler(SessionHandler):
A session register with the handler in two steps, first by
registering itself with the connect() method. This indicates an
non-authenticated session. Whenever the session is authenticated
the session together with the related player is sent to the login()
the session together with the related account is sent to the login()
method.
"""
@ -277,7 +277,7 @@ class ServerSessionHandler(SessionHandler):
"""
delayed_import()
global _ServerSession, _PlayerDB, _ScriptDB
global _ServerSession, _AccountDB, _ScriptDB
sess = _ServerSession()
sess.sessionhandler = self
@ -291,10 +291,10 @@ class ServerSessionHandler(SessionHandler):
# Session is already logged in. This can happen in the
# case of auto-authenticating protocols like SSH or
# webclient's session sharing
player = _PlayerDB.objects.get_player_from_uid(sess.uid)
if player:
# this will set player.is_connected too
self.login(sess, player, force=True)
account = _AccountDB.objects.get_account_from_uid(sess.uid)
if account:
# this will set account.is_connected too
self.login(sess, account, force=True)
return
else:
sess.logged_in = False
@ -336,7 +336,7 @@ class ServerSessionHandler(SessionHandler):
"""
delayed_import()
global _ServerSession, _PlayerDB, _ServerConfig, _ScriptDB
global _ServerSession, _AccountDB, _ServerConfig, _ScriptDB
for sess in self.values():
# we delete the old session to make sure to catch eventual
@ -348,7 +348,7 @@ class ServerSessionHandler(SessionHandler):
sess.sessionhandler = self
sess.load_sync_data(sessdict)
if sess.uid:
sess.player = _PlayerDB.objects.get_player_from_uid(sess.uid)
sess.account = _AccountDB.objects.get_account_from_uid(sess.uid)
self[sessid] = sess
sess.at_sync()
@ -403,7 +403,7 @@ class ServerSessionHandler(SessionHandler):
"network:"irc.freenode.net", "port": 6667})
Notes:
The new session will use the supplied player-bot uid to
The new session will use the supplied account-bot uid to
initiate an already logged-in connection. The Portal will
treat this as a normal connection and henceforth so will
the Server.
@ -420,15 +420,15 @@ class ServerSessionHandler(SessionHandler):
self.server.amp_protocol.send_AdminServer2Portal(DUMMYSESSION,
operation=SSHUTD)
def login(self, session, player, force=False, testmode=False):
def login(self, session, account, force=False, testmode=False):
"""
Log in the previously unloggedin session and the player we by
Log in the previously unloggedin session and the account we by
now should know is connected to it. After this point we assume
the session to be logged in one way or another.
Args:
session (Session): The Session to authenticate.
player (Player): The Player identified as associated with this Session.
account (Account): The Account identified as associated with this Session.
force (bool): Login also if the session thinks it's already logged in
(this can happen for auto-authenticating protocols)
testmode (bool, optional): This is used by unittesting for
@ -440,28 +440,28 @@ class ServerSessionHandler(SessionHandler):
# don't log in a session that is already logged in.
return
player.is_connected = True
account.is_connected = True
# sets up and assigns all properties on the session
session.at_login(player)
session.at_login(account)
# player init
player.at_init()
# account init
account.at_init()
# Check if this is the first time the *player* logs in
if player.db.FIRST_LOGIN:
player.at_first_login()
del player.db.FIRST_LOGIN
# Check if this is the first time the *account* logs in
if account.db.FIRST_LOGIN:
account.at_first_login()
del account.db.FIRST_LOGIN
player.at_pre_login()
account.at_pre_login()
if _MULTISESSION_MODE == 0:
# disconnect all previous sessions.
self.disconnect_duplicate_sessions(session)
nsess = len(self.sessions_from_player(player))
string = "Logged in: {player} {address} ({nsessions} session(s) total)"
string = string.format(player=player,address=session.address, nsessions=nsess)
nsess = len(self.sessions_from_account(account))
string = "Logged in: {account} {address} ({nsessions} session(s) total)"
string = string.format(account=account,address=session.address, nsessions=nsess)
session.log(string)
session.logged_in = True
# sync the portal to the session
@ -469,7 +469,7 @@ class ServerSessionHandler(SessionHandler):
self.server.amp_protocol.send_AdminServer2Portal(session,
operation=SLOGIN,
sessiondata={"logged_in": True})
player.at_post_login(session=session)
account.at_post_login(session=session)
def disconnect(self, session, reason="", sync_portal=True):
"""
@ -488,11 +488,11 @@ class ServerSessionHandler(SessionHandler):
if not session:
return
if hasattr(session, "player") and session.player:
if hasattr(session, "account") and session.account:
# only log accounts logging off
nsess = len(self.sessions_from_player(session.player)) - 1
string = "Logged out: {player} {address} ({nsessions} sessions(s) remaining)"
string = string.format(player=session.player, address=session.address, nsessions=nsess)
nsess = len(self.sessions_from_account(session.account)) - 1
string = "Logged out: {account} {address} ({nsessions} sessions(s) remaining)"
string = string.format(account=session.account, address=session.address, nsessions=nsess)
session.log(string)
session.at_disconnect()
@ -575,28 +575,28 @@ class ServerSessionHandler(SessionHandler):
and (tcurr - session.cmd_last) > _IDLE_TIMEOUT):
self.disconnect(session, reason=reason)
def player_count(self):
def account_count(self):
"""
Get the number of connected players (not sessions since a
player may have more than one session depending on settings).
Only logged-in players are counted here.
Get the number of connected accounts (not sessions since a
account may have more than one session depending on settings).
Only logged-in accounts are counted here.
Returns:
nplayer (int): Number of connected players
naccount (int): Number of connected accounts
"""
return len(set(session.uid for session in self.values() if session.logged_in))
def all_connected_players(self):
def all_connected_accounts(self):
"""
Get a unique list of connected and logged-in Players.
Get a unique list of connected and logged-in Accounts.
Returns:
players (list): All conected Players (which may be fewer than the
accounts (list): All conected Accounts (which may be fewer than the
amount of Sessions due to multi-playing).
"""
return list(set(session.player for session in self.values() if session.logged_in and session.player))
return list(set(session.account for session in self.values() if session.logged_in and session.account))
def session_from_sessid(self, sessid):
"""
@ -614,13 +614,13 @@ class ServerSessionHandler(SessionHandler):
return [self.get(sid) for sid in sessid if sid in self]
return self.get(sessid)
def session_from_player(self, player, sessid):
def session_from_account(self, account, sessid):
"""
Given a player and a session id, return the actual session
Given an account and a session id, return the actual session
object.
Args:
player (Player): The Player to get the Session from.
account (Account): The Account to get the Session from.
sessid (int or list): Session id(s).
Returns:
@ -628,21 +628,21 @@ class ServerSessionHandler(SessionHandler):
"""
sessions = [self[sid] for sid in make_iter(sessid)
if sid in self and self[sid].logged_in and player.uid == self[sid].uid]
if sid in self and self[sid].logged_in and account.uid == self[sid].uid]
return sessions[0] if len(sessions) == 1 else sessions
def sessions_from_player(self, player):
def sessions_from_account(self, account):
"""
Given a player, return all matching sessions.
Given an account, return all matching sessions.
Args:
player (Player): Player to get sessions from.
account (Account): Account to get sessions from.
Returns:
sessions (list): All Sessions associated with this player.
sessions (list): All Sessions associated with this account.
"""
uid = player.uid
uid = account.uid
return [session for session in self.values() if session.logged_in and session.uid == uid]
def sessions_from_puppet(self, puppet):