mirror of
https://github.com/evennia/evennia.git
synced 2026-04-05 23:47:16 +02:00
Some cleanup and changing to conform to PEP8 standard.
This commit is contained in:
parent
364b156456
commit
3819c97b06
3 changed files with 32 additions and 32 deletions
|
|
@ -73,21 +73,21 @@ class CmdUnconnectedConnect(MuxCommand):
|
|||
if playername == None:
|
||||
session.msg("All guest accounts are in use. Please try again later.")
|
||||
return
|
||||
|
||||
|
||||
password = "%016x" % getrandbits(64)
|
||||
home = ObjectDB.objects.get_id(settings.GUEST_HOME)
|
||||
permissions = settings.PERMISSION_GUEST_DEFAULT
|
||||
typeclass = settings.BASE_CHARACTER_TYPECLASS
|
||||
ptypeclass = settings.BASE_GUEST_TYPECLASS
|
||||
start_location = ObjectDB.objects.get_id(settings.GUEST_START_LOCATION)
|
||||
|
||||
new_player = CreatePlayer(session, playername, password,
|
||||
|
||||
new_player = _create_player(session, playername, password,
|
||||
home, permissions, ptypeclass)
|
||||
if new_player:
|
||||
CreateCharacter(session, new_player, typeclass, start_location,
|
||||
_create_character(session, new_player, typeclass, start_location,
|
||||
home, permissions)
|
||||
session.sessionhandler.login(session, new_player)
|
||||
|
||||
|
||||
except Exception:
|
||||
# We are in the middle between logged in and -not, so we have
|
||||
# to handle tracebacks ourselves at this point. If we don't,
|
||||
|
|
@ -97,7 +97,7 @@ class CmdUnconnectedConnect(MuxCommand):
|
|||
logger.log_errmsg(traceback.format_exc())
|
||||
finally:
|
||||
return
|
||||
|
||||
|
||||
if len(parts) != 2:
|
||||
session.msg("\n\r Usage (without <>): connect <name> <password>")
|
||||
return
|
||||
|
|
@ -217,11 +217,11 @@ class CmdUnconnectedCreate(MuxCommand):
|
|||
default_home = ObjectDB.objects.get_id(settings.DEFAULT_HOME)
|
||||
permissions = settings.PERMISSION_PLAYER_DEFAULT
|
||||
typeclass = settings.BASE_CHARACTER_TYPECLASS
|
||||
new_player = CreatePlayer(session, playername, password, default_home, permissions)
|
||||
new_player = _create_player(session, playername, password, default_home, permissions)
|
||||
start_location = ObjectDB.objects.get_id(settings.START_LOCATION)
|
||||
if new_player:
|
||||
if MULTISESSION_MODE < 2:
|
||||
CreateCharacter(session, new_player, typeclass, start_location,
|
||||
_create_character(session, new_player, typeclass, start_location,
|
||||
default_home, permissions)
|
||||
# tell the caller everything went well.
|
||||
string = "A new account '%s' was created. Welcome!"
|
||||
|
|
@ -230,7 +230,7 @@ class CmdUnconnectedCreate(MuxCommand):
|
|||
else:
|
||||
string += "\n\nYou can now log with the command 'connect %s <your password>'."
|
||||
session.msg(string % (playername, playername))
|
||||
|
||||
|
||||
except Exception:
|
||||
# We are in the middle between logged in and -not, so we have
|
||||
# to handle tracebacks ourselves at this point. If we don't,
|
||||
|
|
@ -334,10 +334,10 @@ You can use the {wlook{n command if you want to see the connect screen again.
|
|||
self.caller.msg(string)
|
||||
|
||||
|
||||
def CreatePlayer(session, playername, password,
|
||||
def _create_player(session, playername, password,
|
||||
default_home, permissions, typeclass=None):
|
||||
"""
|
||||
Creates a player of the specified typeclass.
|
||||
Helper function, creates a player of the specified typeclass.
|
||||
"""
|
||||
try:
|
||||
new_player = create.create_player(playername, None, password,
|
||||
|
|
@ -363,10 +363,10 @@ def CreatePlayer(session, playername, password,
|
|||
return new_player
|
||||
|
||||
|
||||
def CreateCharacter(session, new_player, typeclass, start_location, home, permissions):
|
||||
def _create_character(session, new_player, typeclass, start_location, home, permissions):
|
||||
"""
|
||||
Creates a character based on a player's name. This is meant for Guest and
|
||||
MULTISESSION_MODE <2 situations.
|
||||
Helper function, creates a character based on a player's name.
|
||||
This is meant for Guest and MULTISESSION_MODE < 2 situations.
|
||||
"""
|
||||
try:
|
||||
if not start_location:
|
||||
|
|
@ -376,11 +376,11 @@ def CreateCharacter(session, new_player, typeclass, start_location, home, permis
|
|||
permissions=permissions)
|
||||
# set playable character list
|
||||
new_player.db._playable_characters.append(new_character)
|
||||
|
||||
|
||||
# allow only the character itself and the player to puppet this character (and Immortals).
|
||||
new_character.locks.add("puppet:id(%i) or pid(%i) or perm(Immortals) or pperm(Immortals)" %
|
||||
(new_character.id, new_player.id))
|
||||
|
||||
|
||||
# If no description is set, set a default description
|
||||
if not new_character.db.desc:
|
||||
new_character.db.desc = "This is a Player."
|
||||
|
|
@ -390,4 +390,4 @@ def CreateCharacter(session, new_player, typeclass, start_location, home, permis
|
|||
session.msg("There was an error creating the Character:\n%s\n If this problem persists, contact an admin." % e)
|
||||
logger.log_trace()
|
||||
return False
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -356,9 +356,9 @@ class Evennia(object):
|
|||
# flag to avoid loops.
|
||||
self.shutdown_complete = True
|
||||
reactor.callLater(0, reactor.stop)
|
||||
|
||||
|
||||
# server start/stop hooks
|
||||
|
||||
|
||||
def at_server_start(self):
|
||||
"""
|
||||
This is called every time the server starts up, regardless of
|
||||
|
|
@ -366,8 +366,8 @@ class Evennia(object):
|
|||
"""
|
||||
if SERVER_STARTSTOP_MODULE:
|
||||
SERVER_STARTSTOP_MODULE.at_server_start()
|
||||
|
||||
|
||||
|
||||
|
||||
def at_server_stop(self):
|
||||
"""
|
||||
This is called just before a server is shut down, regardless
|
||||
|
|
@ -375,24 +375,24 @@ class Evennia(object):
|
|||
"""
|
||||
if SERVER_STARTSTOP_MODULE:
|
||||
SERVER_STARTSTOP_MODULE.at_server_stop()
|
||||
|
||||
|
||||
|
||||
|
||||
def at_server_reload_start(self):
|
||||
"""
|
||||
This is called only when server starts back up after a reload.
|
||||
"""
|
||||
if SERVER_STARTSTOP_MODULE:
|
||||
SERVER_STARTSTOP_MODULE.at_server_reload_start()
|
||||
|
||||
|
||||
|
||||
|
||||
def at_server_reload_stop(self):
|
||||
"""
|
||||
This is called only time the server stops before a reload.
|
||||
"""
|
||||
if SERVER_STARTSTOP_MODULE:
|
||||
SERVER_STARTSTOP_MODULE.at_server_reload_stop()
|
||||
|
||||
|
||||
|
||||
|
||||
def at_server_cold_start(self):
|
||||
"""
|
||||
This is called only when the server starts "cold", i.e. after a
|
||||
|
|
@ -405,7 +405,7 @@ class Evennia(object):
|
|||
guest.delete()
|
||||
if SERVER_STARTSTOP_MODULE:
|
||||
SERVER_STARTSTOP_MODULE.at_server_cold_start()
|
||||
|
||||
|
||||
def at_server_cold_stop(self):
|
||||
"""
|
||||
This is called only when the server goes down due to a shutdown or reset.
|
||||
|
|
|
|||
|
|
@ -306,14 +306,14 @@ BASE_SCRIPT_TYPECLASS = "src.scripts.scripts.DoNothing"
|
|||
# fallback if an object's normal home location is deleted. Default
|
||||
# is Limbo (#2).
|
||||
DEFAULT_HOME = "#2"
|
||||
# This enables guest logins.
|
||||
GUEST_ENABLED = True
|
||||
# The default home location used for guests.
|
||||
GUEST_HOME = "#2"
|
||||
# The start position for new characters. Default is Limbo (#2).
|
||||
# MULTISESSION_MODE = 0, 1 - used by default unloggedin create command
|
||||
# MULTISESSION_MODE = 2 - used by default character_create command
|
||||
START_LOCATION = "#2"
|
||||
# This enables guest logins.
|
||||
GUEST_ENABLED = True
|
||||
# The default home location used for guests.
|
||||
GUEST_HOME = "#2"
|
||||
# The start position used for guest characters.
|
||||
GUEST_START_LOCATION = "#2"
|
||||
# The naming convention for guest players/characters. The size of this list
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue