mirror of
https://github.com/evennia/evennia.git
synced 2026-03-26 09:46:32 +01:00
Cleaning some unnecessary whitespace, overall cleanup of various source codes.
This commit is contained in:
parent
d4c97d7df8
commit
c0322c9eae
27 changed files with 1342 additions and 1318 deletions
|
|
@ -1,6 +1,6 @@
|
|||
"""
|
||||
This module defines the database models for all in-game objects, that
|
||||
is, all objects that has an actual existence in-game.
|
||||
is, all objects that has an actual existence in-game.
|
||||
|
||||
Each database object is 'decorated' with a 'typeclass', a normal
|
||||
python class that implements all the various logics needed by the game
|
||||
|
|
@ -66,11 +66,11 @@ class Alias(SharedMemoryModel):
|
|||
This model holds a range of alternate names for an object.
|
||||
These are intrinsic properties of the object. The split
|
||||
is so as to allow for effective global searches also by
|
||||
alias.
|
||||
"""
|
||||
alias.
|
||||
"""
|
||||
db_key = models.CharField('alias', max_length=255, db_index=True)
|
||||
db_obj = models.ForeignKey("ObjectDB", verbose_name='object')
|
||||
|
||||
|
||||
class Meta:
|
||||
"Define Django meta options"
|
||||
verbose_name = "Object alias"
|
||||
|
|
@ -79,8 +79,8 @@ class Alias(SharedMemoryModel):
|
|||
return u"%s" % self.db_key
|
||||
def __str__(self):
|
||||
return str(self.db_key)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------
|
||||
#
|
||||
|
|
@ -90,11 +90,11 @@ class Alias(SharedMemoryModel):
|
|||
|
||||
class ObjectNick(TypeNick):
|
||||
"""
|
||||
|
||||
The default nick types used by Evennia are:
|
||||
|
||||
The default nick types used by Evennia are:
|
||||
inputline (default) - match against all input
|
||||
player - match against player searches
|
||||
obj - match against object searches
|
||||
obj - match against object searches
|
||||
channel - used to store own names for channels
|
||||
"""
|
||||
db_obj = models.ForeignKey("ObjectDB", verbose_name='object')
|
||||
|
|
@ -108,7 +108,7 @@ class ObjectNick(TypeNick):
|
|||
class ObjectNickHandler(TypeNickHandler):
|
||||
"""
|
||||
Handles nick access and setting. Accessed through ObjectDB.nicks
|
||||
"""
|
||||
"""
|
||||
NickClass = ObjectNick
|
||||
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ class ObjectDB(TypedObject):
|
|||
|
||||
Note that the base objectdb is very simple, with
|
||||
few defined fields. Use attributes to extend your
|
||||
type class with new database-stored variables.
|
||||
type class with new database-stored variables.
|
||||
|
||||
The TypedObject supplies the following (inherited) properties:
|
||||
key - main name
|
||||
|
|
@ -134,11 +134,11 @@ class ObjectDB(TypedObject):
|
|||
typeclass_path - the path to the decorating typeclass
|
||||
typeclass - auto-linked typeclass
|
||||
date_created - time stamp of object creation
|
||||
permissions - perm strings
|
||||
permissions - perm strings
|
||||
locks - lock definitions (handler)
|
||||
dbref - #id of object
|
||||
dbref - #id of object
|
||||
db - persistent attribute storage
|
||||
ndb - non-persistent attribute storage
|
||||
ndb - non-persistent attribute storage
|
||||
|
||||
The ObjectDB adds the following properties:
|
||||
player - optional connected player
|
||||
|
|
@ -148,7 +148,7 @@ class ObjectDB(TypedObject):
|
|||
scripts - scripts assigned to object (handler from typeclass)
|
||||
cmdset - active cmdset on object (handler from typeclass)
|
||||
aliases - aliases for this object (property)
|
||||
nicks - nicknames for *other* things in Evennia (handler)
|
||||
nicks - nicknames for *other* things in Evennia (handler)
|
||||
sessions - sessions connected to this object (see also player)
|
||||
has_player - bool if an active player is currently connected
|
||||
contents - other objects having this object as location
|
||||
|
|
@ -160,7 +160,7 @@ class ObjectDB(TypedObject):
|
|||
#
|
||||
#
|
||||
# inherited fields (from TypedObject):
|
||||
# db_key (also 'name' works), db_typeclass_path, db_date_created,
|
||||
# db_key (also 'name' works), db_typeclass_path, db_date_created,
|
||||
# db_permissions
|
||||
#
|
||||
# These databse fields (including the inherited ones) are all set
|
||||
|
|
@ -168,11 +168,11 @@ class ObjectDB(TypedObject):
|
|||
# but withtout the db_* prefix.
|
||||
|
||||
# If this is a character object, the player is connected here.
|
||||
db_player = models.ForeignKey("players.PlayerDB", blank=True, null=True, verbose_name='player',
|
||||
help_text='a Player connected to this object, if any.')
|
||||
db_player = models.ForeignKey("players.PlayerDB", blank=True, null=True, verbose_name='player',
|
||||
help_text='a Player connected to this object, if any.')
|
||||
# The location in the game world. Since this one is likely
|
||||
# to change often, we set this with the 'location' property
|
||||
# to transparently handle Typeclassing.
|
||||
# to transparently handle Typeclassing.
|
||||
db_location = models.ForeignKey('self', related_name="locations_set",db_index=True,
|
||||
blank=True, null=True, verbose_name='game location')
|
||||
# a safety location, this usually don't change much.
|
||||
|
|
@ -193,24 +193,24 @@ class ObjectDB(TypedObject):
|
|||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"Parent must be initialized first."
|
||||
TypedObject.__init__(self, *args, **kwargs)
|
||||
# handlers
|
||||
TypedObject.__init__(self, *args, **kwargs)
|
||||
# handlers
|
||||
self.cmdset = CmdSetHandler(self)
|
||||
self.cmdset.update(init_mode=True)
|
||||
self.scripts = ScriptHandler(self)
|
||||
self.nicks = ObjectNickHandler(self)
|
||||
self.nicks = ObjectNickHandler(self)
|
||||
# store the attribute class
|
||||
|
||||
|
||||
# Wrapper properties to easily set database fields. These are
|
||||
# @property decorators that allows to access these fields using
|
||||
# normal python operations (without having to remember to save()
|
||||
# etc). So e.g. a property 'attr' has a get/set/del decorator
|
||||
# defined that allows the user to do self.attr = value,
|
||||
# value = self.attr and del self.attr respectively (where self
|
||||
# defined that allows the user to do self.attr = value,
|
||||
# value = self.attr and del self.attr respectively (where self
|
||||
# is the object in question).
|
||||
|
||||
# aliases property (wraps (db_aliases)
|
||||
#@property
|
||||
#@property
|
||||
def aliases_get(self):
|
||||
"Getter. Allows for value = self.aliases"
|
||||
try:
|
||||
|
|
@ -218,10 +218,10 @@ class ObjectDB(TypedObject):
|
|||
except AttributeError:
|
||||
aliases = list(Alias.objects.filter(db_obj=self).values_list("db_key", flat=True))
|
||||
SA(self, "_cached_aliases", aliases)
|
||||
return aliases
|
||||
return aliases
|
||||
#@aliases.setter
|
||||
def aliases_set(self, aliases):
|
||||
"Setter. Allows for self.aliases = value"
|
||||
"Setter. Allows for self.aliases = value"
|
||||
for alias in make_iter(aliases):
|
||||
new_alias = Alias(db_key=alias, db_obj=self)
|
||||
new_alias.save()
|
||||
|
|
@ -258,121 +258,121 @@ class ObjectDB(TypedObject):
|
|||
player = property(player_get, player_set, player_del)
|
||||
|
||||
# location property (wraps db_location)
|
||||
#@property
|
||||
#@property
|
||||
def location_get(self):
|
||||
"Getter. Allows for value = self.location."
|
||||
loc = get_cache(self, "location")
|
||||
if loc:
|
||||
return loc.typeclass
|
||||
return None
|
||||
return None
|
||||
#@location.setter
|
||||
def location_set(self, location):
|
||||
"Setter. Allows for self.location = location"
|
||||
try:
|
||||
if location == None or type(location) == ObjectDB:
|
||||
# location is None or a valid object
|
||||
loc = location
|
||||
loc = location
|
||||
elif ObjectDB.objects.dbref(location):
|
||||
# location is a dbref; search
|
||||
loc = ObjectDB.objects.dbref_search(location)
|
||||
if loc and hasattr(loc,'dbobj'):
|
||||
loc = loc.dbobj
|
||||
else:
|
||||
loc = location.dbobj
|
||||
else:
|
||||
loc = location.dbobj
|
||||
loc = location.dbobj
|
||||
else:
|
||||
loc = location.dbobj
|
||||
set_cache(self, "location", loc)
|
||||
except Exception:
|
||||
string = "Cannot set location: "
|
||||
string += "%s is not a valid location."
|
||||
string += "%s is not a valid location."
|
||||
self.msg(string % location)
|
||||
logger.log_trace(string)
|
||||
raise
|
||||
raise
|
||||
#@location.deleter
|
||||
def location_del(self):
|
||||
"Deleter. Allows for del self.location"
|
||||
self.db_location = None
|
||||
self.db_location = None
|
||||
self.save()
|
||||
del_cache()
|
||||
location = property(location_get, location_set, location_del)
|
||||
|
||||
# home property (wraps db_home)
|
||||
#@property
|
||||
#@property
|
||||
def home_get(self):
|
||||
"Getter. Allows for value = self.home"
|
||||
home = get_cache(self, "home")
|
||||
if home:
|
||||
return home.typeclass
|
||||
return None
|
||||
return None
|
||||
#@home.setter
|
||||
def home_set(self, home):
|
||||
"Setter. Allows for self.home = value"
|
||||
try:
|
||||
if home == None or type(home) == ObjectDB:
|
||||
hom = home
|
||||
hom = home
|
||||
elif ObjectDB.objects.dbref(home):
|
||||
hom = ObjectDB.objects.dbref_search(home)
|
||||
if hom and hasattr(hom,'dbobj'):
|
||||
hom = hom.dbobj
|
||||
else:
|
||||
hom = home.dbobj
|
||||
else:
|
||||
hom = home.dbobj
|
||||
hom = home.dbobj
|
||||
else:
|
||||
hom = home.dbobj
|
||||
set_cache(self, "home", hom)
|
||||
except Exception:
|
||||
string = "Cannot set home: "
|
||||
string += "%s is not a valid home."
|
||||
string += "%s is not a valid home."
|
||||
self.msg(string % home)
|
||||
logger.log_trace(string)
|
||||
#raise
|
||||
#raise
|
||||
#@home.deleter
|
||||
def home_del(self):
|
||||
"Deleter. Allows for del self.home."
|
||||
self.db_home = None
|
||||
self.db_home = None
|
||||
self.save()
|
||||
del_cache(self, "home")
|
||||
home = property(home_get, home_set, home_del)
|
||||
|
||||
# destination property (wraps db_destination)
|
||||
#@property
|
||||
#@property
|
||||
def destination_get(self):
|
||||
"Getter. Allows for value = self.destination."
|
||||
dest = get_cache(self, "destination")
|
||||
if dest:
|
||||
return dest.typeclass
|
||||
return None
|
||||
return None
|
||||
#@destination.setter
|
||||
def destination_set(self, destination):
|
||||
"Setter. Allows for self.destination = destination"
|
||||
try:
|
||||
if destination == None or type(destination) == ObjectDB:
|
||||
# destination is None or a valid object
|
||||
dest = destination
|
||||
dest = destination
|
||||
elif ObjectDB.objects.dbref(destination):
|
||||
# destination is a dbref; search
|
||||
dest = ObjectDB.objects.dbref_search(destination)
|
||||
if dest and hasattr(dest,'dbobj'):
|
||||
dest = dest.dbobj
|
||||
else:
|
||||
dest = destination.dbobj
|
||||
else:
|
||||
dest = destination.dbobj
|
||||
dest = destination.dbobj
|
||||
else:
|
||||
dest = destination.dbobj
|
||||
set_cache(self, "destination", dest)
|
||||
except Exception:
|
||||
string = "Cannot set destination: "
|
||||
string += "%s is not a valid destination."
|
||||
string += "%s is not a valid destination."
|
||||
self.msg(string % destination)
|
||||
logger.log_trace(string)
|
||||
raise
|
||||
raise
|
||||
#@destination.deleter
|
||||
def destination_del(self):
|
||||
"Deleter. Allows for del self.destination"
|
||||
self.db_destination = None
|
||||
self.db_destination = None
|
||||
self.save()
|
||||
del_cache(self, "destination")
|
||||
destination = property(destination_get, destination_set, destination_del)
|
||||
|
||||
# cmdset_storage property.
|
||||
# cmdset_storage property.
|
||||
# This seems very sensitive to caching, so leaving it be for now. /Griatch
|
||||
#@property
|
||||
def cmdset_storage_get(self):
|
||||
|
|
@ -385,7 +385,7 @@ class ObjectDB(TypedObject):
|
|||
"Setter. Allows for self.name = value. Stores as a comma-separated string."
|
||||
value = ",".join(str(val).strip() for val in make_iter(value))
|
||||
self.db_cmdset_storage = value
|
||||
self.save()
|
||||
self.save()
|
||||
#@cmdset_storage.deleter
|
||||
def cmdset_storage_del(self):
|
||||
"Deleter. Allows for del self.name"
|
||||
|
|
@ -400,12 +400,12 @@ class ObjectDB(TypedObject):
|
|||
|
||||
#
|
||||
# ObjectDB class access methods/properties
|
||||
#
|
||||
#
|
||||
|
||||
# this is required to properly handle attributes and typeclass loading.
|
||||
#attribute_model_path = "src.objects.models"
|
||||
#attribute_model_name = "ObjAttribute"
|
||||
typeclass_paths = settings.OBJECT_TYPECLASS_PATHS
|
||||
typeclass_paths = settings.OBJECT_TYPECLASS_PATHS
|
||||
attribute_class = ObjAttribute
|
||||
db_model_name = "objectdb" # used by attributes to safely store objects
|
||||
|
||||
|
|
@ -420,13 +420,13 @@ class ObjectDB(TypedObject):
|
|||
"""
|
||||
Retrieve sessions connected to this object.
|
||||
"""
|
||||
# if the player is not connected, this will simply be an empty list.
|
||||
# if the player is not connected, this will simply be an empty list.
|
||||
if self.player:
|
||||
return self.player.sessions
|
||||
return []
|
||||
sessions = property(sessions_get)
|
||||
|
||||
#@property
|
||||
#@property
|
||||
def has_player_get(self):
|
||||
"""
|
||||
Convenience function for checking if an active player is
|
||||
|
|
@ -436,13 +436,13 @@ class ObjectDB(TypedObject):
|
|||
has_player = property(has_player_get)
|
||||
is_player = property(has_player_get)
|
||||
|
||||
#@property
|
||||
#@property
|
||||
def is_superuser_get(self):
|
||||
"Check if user has a player, and if so, if it is a superuser."
|
||||
return any(self.sessions) and self.player.is_superuser
|
||||
is_superuser = property(is_superuser_get)
|
||||
|
||||
#@property
|
||||
#@property
|
||||
def contents_get(self, exclude=None):
|
||||
"""
|
||||
Returns the contents of this object, i.e. all
|
||||
|
|
@ -461,11 +461,11 @@ class ObjectDB(TypedObject):
|
|||
if exi.destination]
|
||||
exits = property(exits_get)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Main Search method
|
||||
#
|
||||
|
||||
|
||||
def search(self, ostring,
|
||||
global_search=False,
|
||||
attribute_name=None,
|
||||
|
|
@ -474,49 +474,49 @@ class ObjectDB(TypedObject):
|
|||
"""
|
||||
Perform a standard object search in the database, handling
|
||||
multiple results and lack thereof gracefully.
|
||||
|
||||
|
||||
ostring: (str) The string to match object names against.
|
||||
Obs - To find a player, append * to the
|
||||
start of ostring.
|
||||
start of ostring.
|
||||
global_search: Search all objects, not just the current
|
||||
location/inventory
|
||||
attribute_name: (string) Which attribute to match
|
||||
(if None, uses default 'name')
|
||||
use_nicks : Use nickname replace (off by default)
|
||||
use_nicks : Use nickname replace (off by default)
|
||||
location : If None, use caller's current location
|
||||
ignore_errors : Don't display any error messages even
|
||||
if there are none/multiple matches -
|
||||
just return the result as a list.
|
||||
player : Don't search for an Object but a Player.
|
||||
if there are none/multiple matches -
|
||||
just return the result as a list.
|
||||
player : Don't search for an Object but a Player.
|
||||
This will also find players that don't
|
||||
currently have a character.
|
||||
|
||||
Returns - a unique Object/Player match or None. All error
|
||||
messages are handled by system-commands and the parser-handlers
|
||||
specified in settings.
|
||||
specified in settings.
|
||||
|
||||
Use *<string> to search for objects controlled by a specific
|
||||
player. Note that the object controlled by the player will be
|
||||
returned, not the player object itself. This also means that
|
||||
this will not find Players without a character. Use the keyword
|
||||
player=True to find player objects.
|
||||
|
||||
player=True to find player objects.
|
||||
|
||||
Note - for multiple matches, the engine accepts a number
|
||||
linked to the key in order to separate the matches from
|
||||
each other without showing the dbref explicitly. Default
|
||||
syntax for this is 'N-searchword'. So for example, if there
|
||||
are three objects in the room all named 'ball', you could
|
||||
address the individual ball as '1-ball', '2-ball', '3-ball'
|
||||
etc.
|
||||
etc.
|
||||
"""
|
||||
if use_nicks:
|
||||
if ostring.startswith('*') or player:
|
||||
# player nick replace
|
||||
# player nick replace
|
||||
ostring = self.nicks.get(ostring.lstrip('*'), nick_type="player")
|
||||
if not player:
|
||||
ostring = "*%s" % ostring
|
||||
else:
|
||||
# object nick replace
|
||||
# object nick replace
|
||||
ostring = self.nicks.get(ostring, nick_type="object")
|
||||
|
||||
if player:
|
||||
|
|
@ -525,11 +525,11 @@ class ObjectDB(TypedObject):
|
|||
else:
|
||||
results = PlayerDB.objects.player_search(ostring.lstrip('*'))
|
||||
else:
|
||||
results = ObjectDB.objects.object_search(ostring, caller=self,
|
||||
results = ObjectDB.objects.object_search(ostring, caller=self,
|
||||
global_search=global_search,
|
||||
attribute_name=attribute_name,
|
||||
location=location)
|
||||
|
||||
|
||||
if ignore_errors:
|
||||
return results
|
||||
# this import is cache after the first call.
|
||||
|
|
@ -538,50 +538,50 @@ class ObjectDB(TypedObject):
|
|||
#
|
||||
# Execution/action methods
|
||||
#
|
||||
|
||||
|
||||
def execute_cmd(self, raw_string):
|
||||
"""
|
||||
Do something as this object. This command transparently
|
||||
lets its typeclass execute the command. Evennia also calls
|
||||
this method whenever the player sends a command on the command line.
|
||||
|
||||
Argument:
|
||||
Argument:
|
||||
raw_string (string) - raw command input
|
||||
|
||||
Returns Deferred - this is an asynchronous Twisted object that will
|
||||
not fire until the command has actually finished executing. To overload
|
||||
this one needs to attach callback functions to it, with addCallback(function).
|
||||
this one needs to attach callback functions to it, with addCallback(function).
|
||||
This function will be called with an eventual return value from the command
|
||||
execution.
|
||||
execution.
|
||||
|
||||
This return is not used at all by Evennia by default, but might be useful
|
||||
for coders intending to implement some sort of nested command structure.
|
||||
"""
|
||||
for coders intending to implement some sort of nested command structure.
|
||||
"""
|
||||
# nick replacement - we require full-word matching.
|
||||
|
||||
# do text encoding conversion
|
||||
|
||||
# do text encoding conversion
|
||||
raw_string = to_unicode(raw_string)
|
||||
|
||||
raw_list = raw_string.split(None)
|
||||
raw_list = [" ".join(raw_list[:i+1]) for i in range(len(raw_list)) if raw_list[:i+1]]
|
||||
for nick in ObjectNick.objects.filter(db_obj=self, db_type__in=("inputline","channel")):
|
||||
for nick in ObjectNick.objects.filter(db_obj=self, db_type__in=("inputline","channel")):
|
||||
if nick.db_nick in raw_list:
|
||||
raw_string = raw_string.replace(nick.db_nick, nick.db_real, 1)
|
||||
break
|
||||
raw_string = raw_string.replace(nick.db_nick, nick.db_real, 1)
|
||||
break
|
||||
return cmdhandler.cmdhandler(self.typeclass, raw_string)
|
||||
|
||||
def msg(self, message, from_obj=None, data=None):
|
||||
"""
|
||||
Emits something to any sessions attached to the object.
|
||||
|
||||
|
||||
message (str): The message to send
|
||||
from_obj (obj): object that is sending.
|
||||
data (object): an optional data object that may or may not
|
||||
be used by the protocol.
|
||||
be used by the protocol.
|
||||
"""
|
||||
# This is an important function that must always work.
|
||||
# This is an important function that must always work.
|
||||
# we use a different __getattribute__ to avoid recursive loops.
|
||||
|
||||
|
||||
if object.__getattribute__(self, 'player'):
|
||||
object.__getattribute__(self, 'player').msg(message, from_obj=from_obj, data=data)
|
||||
|
||||
|
|
@ -589,7 +589,7 @@ class ObjectDB(TypedObject):
|
|||
"Deprecated. Alias for msg"
|
||||
logger.log_depmsg("emit_to() is deprecated. Use msg() instead.")
|
||||
self.msg(message, from_obj, data)
|
||||
|
||||
|
||||
def msg_contents(self, message, exclude=None, from_obj=None, data=None):
|
||||
"""
|
||||
Emits something to all objects inside an object.
|
||||
|
|
@ -608,7 +608,7 @@ class ObjectDB(TypedObject):
|
|||
"Deprecated. Alias for msg_contents"
|
||||
logger.log_depmsg("emit_to_contents() is deprecated. Use msg_contents() instead.")
|
||||
self.msg_contents(message, exclude=exclude, from_obj=from_obj, data=data)
|
||||
|
||||
|
||||
def move_to(self, destination, quiet=False,
|
||||
emit_to_obj=None, use_destination=True):
|
||||
"""
|
||||
|
|
@ -618,19 +618,19 @@ class ObjectDB(TypedObject):
|
|||
exit object (i.e. it has "destination"!=None), the move_to will
|
||||
happen to this destination and -not- into the exit object itself, unless
|
||||
use_destination=False. Note that no lock checks are done by this function,
|
||||
such things are assumed to have been handled before calling move_to.
|
||||
|
||||
such things are assumed to have been handled before calling move_to.
|
||||
|
||||
destination: (Object) Reference to the object to move to. This
|
||||
can also be an exit object, in which case the destination
|
||||
property is used as destination.
|
||||
property is used as destination.
|
||||
quiet: (bool) If true, don't emit left/arrived messages.
|
||||
emit_to_obj: (Object) object to receive error messages
|
||||
use_destination (bool): Default is for objects to use the "destination" property
|
||||
of destinations as the target to move to. Turning off this
|
||||
keyword allows objects to move "inside" exit objects.
|
||||
keyword allows objects to move "inside" exit objects.
|
||||
|
||||
Returns True/False depending on if there were problems with the move. This method
|
||||
may also return various error messages to the emit_to_obj.
|
||||
may also return various error messages to the emit_to_obj.
|
||||
"""
|
||||
def logerr(string=""):
|
||||
trc = traceback.format_exc()
|
||||
|
|
@ -644,7 +644,7 @@ class ObjectDB(TypedObject):
|
|||
|
||||
if not destination:
|
||||
emit_to_obj.msg("The destination doesn't exist.")
|
||||
return
|
||||
return
|
||||
if destination.destination:
|
||||
# traverse exits
|
||||
destination = destination.destination
|
||||
|
|
@ -658,8 +658,8 @@ class ObjectDB(TypedObject):
|
|||
#emit_to_obj.msg(errtxt % "at_before_move()")
|
||||
#logger.log_trace()
|
||||
return False
|
||||
|
||||
# Save the old location
|
||||
|
||||
# Save the old location
|
||||
source_location = self.location
|
||||
if not source_location:
|
||||
# there was some error in placing this room.
|
||||
|
|
@ -678,16 +678,16 @@ class ObjectDB(TypedObject):
|
|||
#emit_to_obj.msg(errtxt % "at_object_leave()")
|
||||
#logger.log_trace()
|
||||
return False
|
||||
|
||||
|
||||
if not quiet:
|
||||
#tell the old room we are leaving
|
||||
try:
|
||||
self.announce_move_from(destination)
|
||||
self.announce_move_from(destination)
|
||||
except Exception:
|
||||
logerr(errtxt % "at_announce_move()")
|
||||
logerr(errtxt % "at_announce_move()")
|
||||
#emit_to_obj.msg(errtxt % "at_announce_move()" )
|
||||
#logger.log_trace()
|
||||
return False
|
||||
return False
|
||||
|
||||
# Perform move
|
||||
try:
|
||||
|
|
@ -695,18 +695,18 @@ class ObjectDB(TypedObject):
|
|||
except Exception:
|
||||
emit_to_obj.msg(errtxt % "location change")
|
||||
logger.log_trace()
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
if not quiet:
|
||||
# Tell the new room we are there.
|
||||
# Tell the new room we are there.
|
||||
try:
|
||||
self.announce_move_to(source_location)
|
||||
except Exception:
|
||||
logerr(errtxt % "announce_move_to()")
|
||||
#emit_to_obj.msg(errtxt % "announce_move_to()")
|
||||
#logger.log_trace()
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
# Perform eventual extra commands on the receiving location
|
||||
# (the object has already arrived at this point)
|
||||
try:
|
||||
|
|
@ -715,7 +715,7 @@ class ObjectDB(TypedObject):
|
|||
logerr(errtxt % "at_object_receive()")
|
||||
#emit_to_obj.msg(errtxt % "at_object_receive()")
|
||||
#logger.log_trace()
|
||||
return False
|
||||
return False
|
||||
|
||||
# Execute eventual extra commands on this object after moving it
|
||||
# (usually calling 'look')
|
||||
|
|
@ -725,13 +725,13 @@ class ObjectDB(TypedObject):
|
|||
logerr(errtxt % "at_after_move")
|
||||
#emit_to_obj.msg(errtxt % "at_after_move()")
|
||||
#logger.log_trace()
|
||||
return False
|
||||
return True
|
||||
return False
|
||||
return True
|
||||
|
||||
#
|
||||
# Object Swap, Delete and Cleanup methods
|
||||
#
|
||||
|
||||
# Object Swap, Delete and Cleanup methods
|
||||
#
|
||||
|
||||
def clear_exits(self):
|
||||
"""
|
||||
Destroys all of the exits and any exits pointing to this
|
||||
|
|
@ -745,7 +745,7 @@ class ObjectDB(TypedObject):
|
|||
def clear_contents(self):
|
||||
"""
|
||||
Moves all objects (players/things) to their home
|
||||
location or to default home.
|
||||
location or to default home.
|
||||
"""
|
||||
# Gather up everything that thinks this is its location.
|
||||
objs = ObjectDB.objects.filter(db_location=self)
|
||||
|
|
@ -754,29 +754,29 @@ class ObjectDB(TypedObject):
|
|||
default_home = ObjectDB.objects.get(id=default_home_id)
|
||||
if default_home.id == self.id:
|
||||
# we are deleting default home!
|
||||
default_home = None
|
||||
default_home = None
|
||||
except Exception:
|
||||
string = "Could not find default home '(#%d)'."
|
||||
logger.log_errmsg(string % default_home_id)
|
||||
default_home = None
|
||||
default_home = None
|
||||
|
||||
for obj in objs:
|
||||
home = obj.home
|
||||
for obj in objs:
|
||||
home = obj.home
|
||||
# Obviously, we can't send it back to here.
|
||||
if not home or (home and home.id == self.id):
|
||||
obj.home = default_home
|
||||
|
||||
obj.home = default_home
|
||||
|
||||
# If for some reason it's still None...
|
||||
if not obj.home:
|
||||
string = "Missing default home, '%s(#%d)' "
|
||||
string += "now has a null location."
|
||||
obj.location = None
|
||||
obj.location = None
|
||||
obj.msg("Something went wrong! You are dumped into nowhere. Contact an admin.")
|
||||
logger.log_errmsg(string % (obj.name, obj.id))
|
||||
return
|
||||
|
||||
return
|
||||
|
||||
if obj.has_player:
|
||||
if home:
|
||||
if home:
|
||||
string = "Your current location has ceased to exist,"
|
||||
string += " moving you to %s(#%d)."
|
||||
obj.msg(string % (home.name, home.id))
|
||||
|
|
@ -787,22 +787,22 @@ class ObjectDB(TypedObject):
|
|||
obj.move_to(home)
|
||||
|
||||
def copy(self, new_key=None):
|
||||
"""
|
||||
"""
|
||||
Makes an identical copy of this object. If you want to customize the copy by
|
||||
changing some settings, use ObjectDB.object.copy_object() directly.
|
||||
|
||||
new_key (string) - new key/name of copied object. If new_key is not specified, the copy will be named
|
||||
<old_key>_copy by default.
|
||||
Returns: Object (copy of this one)
|
||||
<old_key>_copy by default.
|
||||
Returns: Object (copy of this one)
|
||||
"""
|
||||
if not new_key:
|
||||
new_key = "%s_copy" % self.key
|
||||
return ObjectDB.objects.copy_object(self, new_key=new_key)
|
||||
|
||||
delete_iter = 0
|
||||
def delete(self):
|
||||
def delete(self):
|
||||
"""
|
||||
Deletes this object.
|
||||
Deletes this object.
|
||||
Before deletion, this method makes sure to move all contained
|
||||
objects to their respective home locations, as well as clean
|
||||
up all exits to/from the object.
|
||||
|
|
@ -815,7 +815,7 @@ class ObjectDB(TypedObject):
|
|||
if not self.at_object_delete():
|
||||
# this is an extra pre-check
|
||||
# run before deletion mechanism
|
||||
# is kicked into gear.
|
||||
# is kicked into gear.
|
||||
self.delete_iter == 0
|
||||
return False
|
||||
|
||||
|
|
@ -825,17 +825,17 @@ class ObjectDB(TypedObject):
|
|||
|
||||
for session in self.sessions:
|
||||
session.msg("Your character %s has been destroyed." % self.name)
|
||||
# no need to disconnect, Player just jumps to OOC mode.
|
||||
# no need to disconnect, Player just jumps to OOC mode.
|
||||
# sever the connection (important!)
|
||||
if object.__getattribute__(self, 'player') and self.player:
|
||||
self.player.character = None
|
||||
self.player = None
|
||||
self.player = None
|
||||
|
||||
for script in self.scripts.all():
|
||||
script.stop()
|
||||
|
||||
|
||||
# if self.player:
|
||||
# self.player.user.is_active = False
|
||||
# self.player.user.is_active = False
|
||||
# self.player.user.save(
|
||||
|
||||
# Destroy any exits to and from this room, if any
|
||||
|
|
@ -844,4 +844,4 @@ class ObjectDB(TypedObject):
|
|||
self.clear_contents()
|
||||
# Perform the deletion of the object
|
||||
super(ObjectDB, self).delete()
|
||||
return True
|
||||
return True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue