2008-12-15 05:55:04 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
This module defines the database models for all in-game objects, that
|
2012-03-30 23:47:22 +02:00
|
|
|
is, all objects that has an actual existence in-game.
|
2010-08-29 18:46:58 +00:00
|
|
|
|
|
|
|
|
Each database object is 'decorated' with a 'typeclass', a normal
|
|
|
|
|
python class that implements all the various logics needed by the game
|
|
|
|
|
in question. Objects created of this class transparently communicate
|
|
|
|
|
with its related database object for storing all attributes. The
|
|
|
|
|
admin should usually not have to deal directly with this database
|
|
|
|
|
object layer.
|
|
|
|
|
|
|
|
|
|
Attributes are separate objects that store values persistently onto
|
|
|
|
|
the database object. Like everything else, they can be accessed
|
|
|
|
|
transparently through the decorating TypeClass.
|
2008-12-15 05:55:04 +00:00
|
|
|
"""
|
2011-02-27 22:27:56 +00:00
|
|
|
|
2011-06-26 14:35:02 +00:00
|
|
|
import traceback
|
2006-11-20 18:54:10 +00:00
|
|
|
from django.db import models
|
2008-12-15 05:55:04 +00:00
|
|
|
from django.conf import settings
|
2010-08-29 18:46:58 +00:00
|
|
|
|
2013-11-14 19:31:17 +01:00
|
|
|
from src.typeclasses.models import (TypedObject, TagHandler, NickHandler,
|
|
|
|
|
AliasHandler, AttributeHandler)
|
2010-08-29 18:46:58 +00:00
|
|
|
from src.objects.manager import ObjectManager
|
2013-05-11 23:22:02 +02:00
|
|
|
from src.players.models import PlayerDB
|
2011-03-20 19:45:56 +00:00
|
|
|
from src.commands.cmdsethandler import CmdSetHandler
|
2011-04-23 11:54:08 +00:00
|
|
|
from src.commands import cmdhandler
|
2011-03-20 19:45:56 +00:00
|
|
|
from src.scripts.scripthandler import ScriptHandler
|
2010-08-29 18:46:58 +00:00
|
|
|
from src.utils import logger
|
2013-11-14 19:31:17 +01:00
|
|
|
from src.utils.utils import make_iter, to_str, to_unicode, variable_from_module
|
2009-05-02 19:02:36 +00:00
|
|
|
|
2012-06-14 08:56:57 +02:00
|
|
|
from django.utils.translation import ugettext as _
|
|
|
|
|
|
2013-07-12 14:44:49 +02:00
|
|
|
#__all__ = ("ObjectDB", )
|
2012-03-31 15:09:22 +02:00
|
|
|
|
2013-02-18 20:08:05 +01:00
|
|
|
_ScriptDB = None
|
2012-04-22 12:23:42 +02:00
|
|
|
_AT_SEARCH_RESULT = variable_from_module(*settings.SEARCH_AT_RESULT.rsplit('.', 1))
|
2013-09-22 11:39:24 +02:00
|
|
|
_SESSIONS = None
|
2010-08-29 18:46:58 +00:00
|
|
|
|
2012-03-31 13:06:29 +02:00
|
|
|
_GA = object.__getattribute__
|
|
|
|
|
_SA = object.__setattr__
|
|
|
|
|
_DA = object.__delattr__
|
2012-02-25 23:56:31 +01:00
|
|
|
|
2012-09-17 15:31:50 +02:00
|
|
|
_ME = _("me")
|
|
|
|
|
_SELF = _("self")
|
|
|
|
|
_HERE = _("here")
|
|
|
|
|
|
2013-11-14 19:31:17 +01:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
#------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# ObjectDB
|
|
|
|
|
#
|
|
|
|
|
#------------------------------------------------------------
|
2009-01-18 04:54:05 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
class ObjectDB(TypedObject):
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
All objects in the game use the ObjectDB model to store
|
|
|
|
|
data in the database. This is handled transparently through
|
|
|
|
|
the typeclass system.
|
|
|
|
|
|
|
|
|
|
Note that the base objectdb is very simple, with
|
|
|
|
|
few defined fields. Use attributes to extend your
|
2012-03-30 23:47:22 +02:00
|
|
|
type class with new database-stored variables.
|
2010-08-29 18:46:58 +00:00
|
|
|
|
|
|
|
|
The TypedObject supplies the following (inherited) properties:
|
|
|
|
|
key - main name
|
|
|
|
|
name - alias for key
|
|
|
|
|
typeclass_path - the path to the decorating typeclass
|
|
|
|
|
typeclass - auto-linked typeclass
|
|
|
|
|
date_created - time stamp of object creation
|
2012-03-30 23:47:22 +02:00
|
|
|
permissions - perm strings
|
2011-03-15 16:08:32 +00:00
|
|
|
locks - lock definitions (handler)
|
2012-03-30 23:47:22 +02:00
|
|
|
dbref - #id of object
|
2010-08-29 18:46:58 +00:00
|
|
|
db - persistent attribute storage
|
2012-03-30 23:47:22 +02:00
|
|
|
ndb - non-persistent attribute storage
|
2010-08-29 18:46:58 +00:00
|
|
|
|
|
|
|
|
The ObjectDB adds the following properties:
|
2013-04-09 15:59:21 +02:00
|
|
|
player - optional connected player (always together with sessid)
|
|
|
|
|
sessid - optional connection session id (always together with player)
|
2010-08-29 18:46:58 +00:00
|
|
|
location - in-game location of object
|
2011-03-15 16:08:32 +00:00
|
|
|
home - safety location for object (handler)
|
|
|
|
|
|
|
|
|
|
scripts - scripts assigned to object (handler from typeclass)
|
|
|
|
|
cmdset - active cmdset on object (handler from typeclass)
|
|
|
|
|
aliases - aliases for this object (property)
|
2012-03-30 23:47:22 +02:00
|
|
|
nicks - nicknames for *other* things in Evennia (handler)
|
2010-08-29 18:46:58 +00:00
|
|
|
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
|
2011-03-15 16:08:32 +00:00
|
|
|
exits - exits from this object
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2009-09-27 16:36:03 +00:00
|
|
|
|
2009-10-14 18:15:15 +00:00
|
|
|
#
|
2010-08-29 18:46:58 +00:00
|
|
|
# ObjectDB Database model setup
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# inherited fields (from TypedObject):
|
2012-03-30 23:47:22 +02:00
|
|
|
# db_key (also 'name' works), db_typeclass_path, db_date_created,
|
2010-08-29 18:46:58 +00:00
|
|
|
# db_permissions
|
|
|
|
|
#
|
2013-11-14 19:31:17 +01:00
|
|
|
# These databse fields (including the inherited ones) should normally be
|
|
|
|
|
# managed by their corresponding wrapper properties, named same as the
|
|
|
|
|
# field, but without the db_* prefix (e.g. the db_key field is set with
|
|
|
|
|
# self.key instead). The wrappers are created at the metaclass level and
|
2013-06-05 18:47:41 +02:00
|
|
|
# will automatically save and cache the data more efficiently.
|
2010-08-29 18:46:58 +00:00
|
|
|
|
|
|
|
|
# If this is a character object, the player is connected here.
|
2012-03-30 23:47:22 +02:00
|
|
|
db_player = models.ForeignKey("players.PlayerDB", blank=True, null=True, verbose_name='player',
|
|
|
|
|
help_text='a Player connected to this object, if any.')
|
2013-02-01 22:03:55 +01:00
|
|
|
# the session id associated with this player, if any
|
|
|
|
|
db_sessid = models.IntegerField(null=True, verbose_name="session id",
|
2013-02-02 22:41:56 +01:00
|
|
|
help_text="unique session id of connected Player, if any.")
|
2010-08-29 18:46:58 +00:00
|
|
|
# The location in the game world. Since this one is likely
|
|
|
|
|
# to change often, we set this with the 'location' property
|
2012-03-30 23:47:22 +02:00
|
|
|
# to transparently handle Typeclassing.
|
2013-11-14 19:31:17 +01:00
|
|
|
db_location = models.ForeignKey('self', related_name="locations_set", db_index=True,
|
2011-10-02 01:21:03 +02:00
|
|
|
blank=True, null=True, verbose_name='game location')
|
2010-08-29 18:46:58 +00:00
|
|
|
# a safety location, this usually don't change much.
|
|
|
|
|
db_home = models.ForeignKey('self', related_name="homes_set",
|
2011-10-02 01:21:03 +02:00
|
|
|
blank=True, null=True, verbose_name='home location')
|
2011-04-08 23:10:04 +00:00
|
|
|
# destination of this object - primarily used by exits.
|
2012-02-06 13:18:25 +01:00
|
|
|
db_destination = models.ForeignKey('self', related_name="destinations_set", db_index=True,
|
2011-10-02 01:21:03 +02:00
|
|
|
blank=True, null=True, verbose_name='destination',
|
|
|
|
|
help_text='a destination, used only by exit objects.')
|
2011-03-20 19:45:56 +00:00
|
|
|
# database storage of persistant cmdsets.
|
2011-10-02 22:37:07 +02:00
|
|
|
db_cmdset_storage = models.CharField('cmdset', max_length=255, null=True, blank=True,
|
|
|
|
|
help_text="optional python path to a cmdset class.")
|
2013-04-13 15:15:02 +02:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
# Database manager
|
|
|
|
|
objects = ObjectManager()
|
2009-10-14 18:15:15 +00:00
|
|
|
|
2013-07-11 15:59:03 +02:00
|
|
|
# caches for quick lookups of typeclass loading.
|
|
|
|
|
_typeclass_paths = settings.OBJECT_TYPECLASS_PATHS
|
|
|
|
|
_default_typeclass_path = settings.BASE_OBJECT_TYPECLASS or "src.objects.objects.Object"
|
2011-03-20 19:45:56 +00:00
|
|
|
|
2013-07-11 15:59:03 +02:00
|
|
|
# Add the object-specific handlers
|
2011-03-15 16:08:32 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
|
"Parent must be initialized first."
|
2012-03-30 23:47:22 +02:00
|
|
|
TypedObject.__init__(self, *args, **kwargs)
|
|
|
|
|
# handlers
|
2012-09-20 23:18:52 +02:00
|
|
|
_SA(self, "cmdset", CmdSetHandler(self))
|
|
|
|
|
_GA(self, "cmdset").update(init_mode=True)
|
|
|
|
|
_SA(self, "scripts", ScriptHandler(self))
|
2013-08-24 21:23:43 +02:00
|
|
|
_SA(self, "attributes", AttributeHandler(self))
|
2013-12-23 13:38:40 -06:00
|
|
|
_SA(self, "tags", TagHandler(self, category_prefix="object"))
|
|
|
|
|
_SA(self, "aliases", AliasHandler(self, category_prefix="object"))
|
2013-08-24 21:23:43 +02:00
|
|
|
_SA(self, "nicks", NickHandler(self))
|
2013-07-12 22:08:15 +02:00
|
|
|
# make sure to sync the contents cache when initializing
|
2013-10-21 21:17:32 +02:00
|
|
|
#_GA(self, "contents_update")()
|
|
|
|
|
|
|
|
|
|
def _at_db_player_presave(self):
|
2013-09-23 22:08:14 +02:00
|
|
|
"""
|
2013-10-21 21:17:32 +02:00
|
|
|
This hook is called automatically just before the player field is saved.
|
2013-09-23 22:08:14 +02:00
|
|
|
"""
|
2013-09-23 23:10:23 +02:00
|
|
|
# we need to re-cache this for superusers to bypass.
|
|
|
|
|
self.locks.cache_lock_bypass(self)
|
2011-04-08 23:10:04 +00:00
|
|
|
|
2013-09-23 23:10:23 +02:00
|
|
|
# cmdset_storage property. We use a custom wrapper to manage this. This also
|
|
|
|
|
# seems very sensitive to caching, so leaving it be for now. /Griatch
|
2011-03-20 19:45:56 +00:00
|
|
|
#@property
|
2012-03-31 15:09:22 +02:00
|
|
|
def __cmdset_storage_get(self):
|
2013-11-14 19:31:17 +01:00
|
|
|
"""
|
|
|
|
|
Getter. Allows for value = self.name.
|
|
|
|
|
Returns a list of cmdset_storage.
|
|
|
|
|
"""
|
2013-09-23 23:10:23 +02:00
|
|
|
storage = _GA(self, "db_cmdset_storage")
|
|
|
|
|
# we need to check so storage is not None
|
2013-11-14 19:31:17 +01:00
|
|
|
return [path.strip() for path in storage.split(',')] if storage else []
|
2011-03-20 19:45:56 +00:00
|
|
|
#@cmdset_storage.setter
|
2012-03-31 15:09:22 +02:00
|
|
|
def __cmdset_storage_set(self, value):
|
2013-11-14 19:31:17 +01:00
|
|
|
"""
|
|
|
|
|
Setter. Allows for self.name = value.
|
|
|
|
|
Stores as a comma-separated string.
|
|
|
|
|
"""
|
2013-09-23 23:10:23 +02:00
|
|
|
_SA(self, "db_cmdset_storage", ",".join(str(val).strip() for val in make_iter(value)))
|
2012-09-20 23:18:52 +02:00
|
|
|
_GA(self, "save")()
|
2011-03-20 19:45:56 +00:00
|
|
|
#@cmdset_storage.deleter
|
2012-03-31 15:09:22 +02:00
|
|
|
def __cmdset_storage_del(self):
|
2011-03-20 19:45:56 +00:00
|
|
|
"Deleter. Allows for del self.name"
|
2013-09-23 23:10:23 +02:00
|
|
|
_SA(self, "db_cmdset_storage", None)
|
2012-09-20 23:18:52 +02:00
|
|
|
_GA(self, "save")()
|
2012-03-31 15:09:22 +02:00
|
|
|
cmdset_storage = property(__cmdset_storage_get, __cmdset_storage_set, __cmdset_storage_del)
|
2011-03-20 19:45:56 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
class Meta:
|
|
|
|
|
"Define Django meta options"
|
|
|
|
|
verbose_name = "Object"
|
|
|
|
|
verbose_name_plural = "Objects"
|
Implemented locks.
The main command to use is @lock, which accept three types of locks at the moment, and three types of keys:
Locks: DefaultLock, UseLock, EnterLock
Keys: ObjectIDs, Groups, Permissions
This offers the most useful functionality - stopping people from picking up things, blocking exits and stopping
anyone from using an object.
If the attributes lock_msg, use_lock_msg and enter_lock_msg are defined on the locked object, these will be used
as error messages instead of a standard one (so "the door is locked" instead of "you cannot traverse that exit").
Behind the scenes, there is a new module, src/locks.py that defines Keys and Locks. A Locks object is a collection
of Lock types. This is stored in the LOCKS attribute on objects. Each Lock contains a set of Keys that might be
of mixed type and which the player must match in order to pass the lock.
/Griatch
2009-10-05 20:04:15 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
#
|
|
|
|
|
# ObjectDB class access methods/properties
|
2012-03-30 23:47:22 +02:00
|
|
|
#
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
#@property
|
2012-03-31 15:09:22 +02:00
|
|
|
def __sessions_get(self):
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
Retrieve sessions connected to this object.
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2012-03-30 23:47:22 +02:00
|
|
|
# if the player is not connected, this will simply be an empty list.
|
2013-04-10 22:33:32 +02:00
|
|
|
if _GA(self, "db_player"):
|
|
|
|
|
return _GA(_GA(self, "db_player"), "get_all_sessions")()
|
2010-08-29 18:46:58 +00:00
|
|
|
return []
|
2012-03-31 15:09:22 +02:00
|
|
|
sessions = property(__sessions_get)
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
|
2012-03-30 23:47:22 +02:00
|
|
|
#@property
|
2012-03-31 15:09:22 +02:00
|
|
|
def __has_player_get(self):
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
Convenience function for checking if an active player is
|
|
|
|
|
currently connected to this object
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2012-09-20 00:47:28 +02:00
|
|
|
return any(_GA(self, "sessions"))
|
2012-03-31 15:09:22 +02:00
|
|
|
has_player = property(__has_player_get)
|
|
|
|
|
is_player = property(__has_player_get)
|
2011-06-26 14:35:02 +00:00
|
|
|
|
2013-05-12 20:24:00 +02:00
|
|
|
#@property
|
|
|
|
|
def __is_superuser_get(self):
|
|
|
|
|
"Check if user has a player, and if so, if it is a superuser."
|
2013-05-14 13:55:03 +02:00
|
|
|
return (_GA(self, "db_player") and _GA(_GA(self, "db_player"), "is_superuser")
|
2013-08-25 16:41:18 +02:00
|
|
|
and not _GA(_GA(self, "db_player"), "attributes").get("_quell"))
|
2013-05-12 20:24:00 +02:00
|
|
|
is_superuser = property(__is_superuser_get)
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
|
2012-08-19 18:48:29 +02:00
|
|
|
# contents
|
|
|
|
|
|
2011-05-01 18:04:15 +00:00
|
|
|
def contents_get(self, exclude=None):
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
Returns the contents of this object, i.e. all
|
|
|
|
|
objects that has this object set as its location.
|
2012-03-31 15:09:22 +02:00
|
|
|
This should be publically available.
|
2012-08-19 18:48:29 +02:00
|
|
|
|
|
|
|
|
exclude is one or more objects to not return
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2013-10-20 14:27:19 +02:00
|
|
|
if exclude:
|
2013-10-21 21:17:32 +02:00
|
|
|
return ObjectDB.objects.get_contents(self, excludeobj=exclude)
|
|
|
|
|
return ObjectDB.objects.get_contents(self)
|
2010-08-29 18:46:58 +00:00
|
|
|
contents = property(contents_get)
|
2009-01-15 16:24:52 +00:00
|
|
|
|
2011-02-14 17:18:31 +00:00
|
|
|
#@property
|
2012-03-31 15:09:22 +02:00
|
|
|
def __exits_get(self):
|
2011-02-14 17:18:31 +00:00
|
|
|
"""
|
|
|
|
|
Returns all exits from this object, i.e. all objects
|
2011-04-08 23:10:04 +00:00
|
|
|
at this location having the property destination != None.
|
2011-02-14 17:18:31 +00:00
|
|
|
"""
|
2012-09-20 23:18:52 +02:00
|
|
|
return [exi for exi in _GA(self, "contents")
|
2011-04-08 23:10:04 +00:00
|
|
|
if exi.destination]
|
2012-03-31 15:09:22 +02:00
|
|
|
exits = property(__exits_get)
|
2011-03-15 16:08:32 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
#
|
|
|
|
|
# Main Search method
|
|
|
|
|
#
|
2012-03-30 23:47:22 +02:00
|
|
|
|
2013-05-14 21:17:29 +02:00
|
|
|
def search(self, searchdata,
|
2010-08-29 18:46:58 +00:00
|
|
|
global_search=False,
|
2013-11-14 19:31:17 +01:00
|
|
|
use_nicks=True, # should this default to off?
|
2013-04-20 16:14:12 +02:00
|
|
|
typeclass=None,
|
|
|
|
|
location=None,
|
2010-08-29 18:46:58 +00:00
|
|
|
attribute_name=None,
|
2013-04-20 16:14:12 +02:00
|
|
|
quiet=False,
|
|
|
|
|
exact=False):
|
2009-05-02 19:02:36 +00:00
|
|
|
"""
|
2013-04-20 16:14:12 +02:00
|
|
|
Returns the typeclass of an Object matching a search string/condition
|
|
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
Perform a standard object search in the database, handling
|
2013-04-20 16:14:12 +02:00
|
|
|
multiple results and lack thereof gracefully. By default, only
|
|
|
|
|
objects in self's current location or inventory is searched.
|
2013-05-11 20:01:19 +02:00
|
|
|
Note: to find Players, use eg. ev.player_search.
|
2013-04-20 16:14:12 +02:00
|
|
|
|
|
|
|
|
Inputs:
|
|
|
|
|
|
2013-11-14 19:31:17 +01:00
|
|
|
searchdata (str or obj): Primary search criterion. Will be matched
|
|
|
|
|
against object.key (with object.aliases second) unless
|
|
|
|
|
the keyword attribute_name specifies otherwise.
|
|
|
|
|
Special strings:
|
|
|
|
|
#<num> - search by unique dbref. This is always
|
|
|
|
|
a global search.
|
2013-04-20 16:14:12 +02:00
|
|
|
me,self - self-reference to this object
|
2013-11-14 19:31:17 +01:00
|
|
|
<num>-<string> - can be used to differentiate
|
|
|
|
|
between multiple same-named matches
|
|
|
|
|
global_search (bool): Search all objects globally. This is overruled
|
|
|
|
|
by "location" keyword.
|
|
|
|
|
use_nicks (bool): Use nickname-replace (nicktype "object") on the
|
|
|
|
|
search string
|
|
|
|
|
typeclass (str or Typeclass, or list of either): Limit search only
|
|
|
|
|
to Objects with this typeclass. May be a list of typeclasses
|
|
|
|
|
for a broader search.
|
|
|
|
|
location (Object): Specify a location to search, if different from the
|
|
|
|
|
self's given location plus its contents. This can also
|
|
|
|
|
be a list of locations.
|
|
|
|
|
attribute_name (str): Define which property to search. If set, no
|
|
|
|
|
key+alias search will be performed. This can be used to
|
|
|
|
|
search database fields (db_ will be automatically
|
|
|
|
|
appended), and if that fails, it will try to return
|
|
|
|
|
objects having Attributes with this name and value
|
|
|
|
|
equal to searchdata. A special use is to search for
|
|
|
|
|
"key" here if you want to do a key-search without
|
|
|
|
|
including aliases.
|
|
|
|
|
quiet (bool) - don't display default error messages - return multiple
|
|
|
|
|
matches as a list and no matches as None. If not
|
|
|
|
|
set (default), will echo error messages and return None.
|
|
|
|
|
exact (bool) - if unset (default) - prefers to match to beginning of
|
|
|
|
|
string rather than not matching at all. If set, requires
|
|
|
|
|
exact mathing of entire string.
|
2013-04-20 16:14:12 +02:00
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
quiet=False (default):
|
|
|
|
|
no match or multimatch:
|
2013-11-14 19:31:17 +01:00
|
|
|
auto-echoes errors to self.msg, then returns None
|
|
|
|
|
(results are handled by settings.SEARCH_AT_RESULT
|
|
|
|
|
and settings.SEARCH_AT_MULTIMATCH_INPUT)
|
2013-04-20 16:14:12 +02:00
|
|
|
match:
|
|
|
|
|
a unique object match
|
|
|
|
|
quiet=True:
|
|
|
|
|
no match or multimatch:
|
|
|
|
|
returns None or list of multi-matches
|
|
|
|
|
match:
|
|
|
|
|
a unique object match
|
|
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
"""
|
2013-05-14 21:17:29 +02:00
|
|
|
is_string = isinstance(searchdata, basestring)
|
|
|
|
|
|
2012-09-17 15:31:50 +02:00
|
|
|
# handle some common self-references:
|
2013-05-14 21:17:29 +02:00
|
|
|
if searchdata == _HERE:
|
2012-09-17 15:31:50 +02:00
|
|
|
return self.location
|
2013-05-14 21:17:29 +02:00
|
|
|
if searchdata in (_ME, _SELF):
|
2013-06-29 14:14:00 -05:00
|
|
|
return self.typeclass
|
2012-09-17 15:31:50 +02:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
if use_nicks:
|
2013-07-12 14:44:49 +02:00
|
|
|
# get all valid nicks to search
|
2013-10-21 22:51:16 +02:00
|
|
|
nicks = self.nicks.all(category="object")
|
2012-10-14 17:24:30 +02:00
|
|
|
if self.has_player:
|
2013-10-21 22:51:16 +02:00
|
|
|
pnicks = self.nicks.all(category="player")
|
2013-07-12 14:44:49 +02:00
|
|
|
nicks = nicks + pnicks
|
2012-10-14 17:24:30 +02:00
|
|
|
for nick in nicks:
|
2013-07-12 20:21:52 +02:00
|
|
|
if searchdata == nick.db_key:
|
2013-10-21 22:51:16 +02:00
|
|
|
searchdata = nick.strvalue
|
2012-10-14 17:24:30 +02:00
|
|
|
break
|
2010-08-29 18:46:58 +00:00
|
|
|
|
2012-09-17 15:31:50 +02:00
|
|
|
candidates=None
|
2013-11-14 19:31:17 +01:00
|
|
|
if(global_search or (is_string and searchdata.startswith("#") and
|
|
|
|
|
len(searchdata) > 1 and searchdata[1:].isdigit())):
|
|
|
|
|
# only allow exact matching if searching the entire database
|
|
|
|
|
# or unique #dbrefs
|
2012-09-17 15:31:50 +02:00
|
|
|
exact = True
|
2012-09-21 08:36:59 +02:00
|
|
|
elif location:
|
|
|
|
|
# location(s) were given
|
|
|
|
|
candidates = []
|
|
|
|
|
for obj in make_iter(location):
|
|
|
|
|
candidates.extend([o.dbobj for o in obj.contents])
|
2011-04-23 11:54:08 +00:00
|
|
|
else:
|
2013-11-14 19:31:17 +01:00
|
|
|
# local search. Candidates are self.contents, self.location
|
|
|
|
|
# and self.location.contents
|
2012-09-21 08:36:59 +02:00
|
|
|
location = self.location
|
2012-09-17 15:31:50 +02:00
|
|
|
candidates = self.contents
|
|
|
|
|
if location:
|
|
|
|
|
candidates = candidates + [location] + location.contents
|
|
|
|
|
else:
|
2013-11-14 19:31:17 +01:00
|
|
|
# normally we are included in location.contents
|
|
|
|
|
candidates.append(self)
|
2012-09-17 15:31:50 +02:00
|
|
|
# db manager expects database objects
|
|
|
|
|
candidates = [obj.dbobj for obj in candidates]
|
|
|
|
|
|
2013-05-14 21:17:29 +02:00
|
|
|
results = ObjectDB.objects.object_search(searchdata,
|
2012-09-17 15:31:50 +02:00
|
|
|
attribute_name=attribute_name,
|
2013-05-11 23:22:02 +02:00
|
|
|
typeclass=typeclass,
|
2012-09-17 15:31:50 +02:00
|
|
|
candidates=candidates,
|
|
|
|
|
exact=exact)
|
2013-05-11 20:01:19 +02:00
|
|
|
if quiet:
|
2012-09-18 21:48:41 +02:00
|
|
|
return results
|
2013-05-14 21:17:29 +02:00
|
|
|
return _AT_SEARCH_RESULT(self, searchdata, results, global_search)
|
2012-09-17 15:31:50 +02:00
|
|
|
|
2013-05-14 21:17:29 +02:00
|
|
|
def search_player(self, searchdata, quiet=False):
|
2013-05-11 23:22:02 +02:00
|
|
|
"""
|
|
|
|
|
Simple wrapper of the player search also handling me, self
|
|
|
|
|
"""
|
2013-05-14 21:17:29 +02:00
|
|
|
if searchdata in (_ME, _SELF) and _GA(self, "db_player"):
|
2013-05-11 23:22:02 +02:00
|
|
|
return _GA(self, "db_player")
|
2013-05-14 21:17:29 +02:00
|
|
|
results = PlayerDB.objects.player_search(searchdata)
|
2013-05-11 23:22:02 +02:00
|
|
|
if quiet:
|
|
|
|
|
return results
|
2013-05-14 21:17:29 +02:00
|
|
|
return _AT_SEARCH_RESULT(self, searchdata, results, True)
|
2009-08-16 01:18:58 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
#
|
|
|
|
|
# Execution/action methods
|
|
|
|
|
#
|
2012-03-30 23:47:22 +02:00
|
|
|
|
2013-02-02 22:41:56 +01:00
|
|
|
def execute_cmd(self, raw_string, sessid=None):
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2013-11-14 19:31:17 +01:00
|
|
|
Do something as this object. This method is a copy of the execute_
|
|
|
|
|
cmd method on the session. This is never called normally, it's only
|
|
|
|
|
used when wanting specifically to let an object be the caller of a
|
|
|
|
|
command. It makes use of nicks of eventual connected players as well.
|
2012-03-24 18:25:32 +01:00
|
|
|
|
2012-03-30 23:47:22 +02:00
|
|
|
Argument:
|
2012-03-24 18:25:32 +01:00
|
|
|
raw_string (string) - raw command input
|
2013-11-12 20:11:36 +01:00
|
|
|
sessid (int) - optional session id to return results to
|
2012-03-24 18:25:32 +01:00
|
|
|
|
|
|
|
|
Returns Deferred - this is an asynchronous Twisted object that will
|
2013-11-14 19:31:17 +01:00
|
|
|
not fire until the command has actually finished executing. To
|
|
|
|
|
overload 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.
|
|
|
|
|
|
|
|
|
|
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.
|
2012-03-30 23:47:22 +02:00
|
|
|
"""
|
2011-02-27 22:27:56 +00:00
|
|
|
# nick replacement - we require full-word matching.
|
2012-03-30 23:47:22 +02:00
|
|
|
|
|
|
|
|
# do text encoding conversion
|
2011-04-21 16:45:18 +00:00
|
|
|
raw_string = to_unicode(raw_string)
|
|
|
|
|
|
2011-02-27 22:27:56 +00:00
|
|
|
raw_list = raw_string.split(None)
|
2013-11-14 19:31:17 +01:00
|
|
|
raw_list = [" ".join(raw_list[:i + 1]) for i in range(len(raw_list))
|
|
|
|
|
if raw_list[:i + 1]]
|
2013-07-12 14:44:49 +02:00
|
|
|
# fetch the nick data efficiently
|
2013-08-24 21:42:48 +02:00
|
|
|
nicks = self.db_attributes.filter(db_category__in=("nick_inputline", "nick_channel"))
|
2012-10-14 17:24:30 +02:00
|
|
|
if self.has_player:
|
2013-11-12 20:11:36 +01:00
|
|
|
# attach player nicks as well, but after the object-level nicks
|
2013-11-12 20:23:44 +01:00
|
|
|
nicks = list(nicks) + list(self.player.db_attributes.filter(db_category__in=("nick_inputline", "nick_channel")))
|
2012-10-14 17:24:30 +02:00
|
|
|
for nick in nicks:
|
2013-07-12 14:44:49 +02:00
|
|
|
if nick.db_key in raw_list:
|
2013-08-24 21:42:48 +02:00
|
|
|
raw_string = raw_string.replace(nick.db_key, nick.db_strvalue, 1)
|
2012-03-30 23:47:22 +02:00
|
|
|
break
|
2013-09-08 00:14:06 +02:00
|
|
|
return cmdhandler.cmdhandler(_GA(self, "typeclass"), raw_string, callertype="object", sessid=sessid)
|
2009-11-01 15:12:38 +00:00
|
|
|
|
2013-09-21 17:33:48 +02:00
|
|
|
def msg(self, text=None, from_obj=None, sessid=0, **kwargs):
|
2009-11-01 15:12:38 +00:00
|
|
|
"""
|
2013-02-02 22:41:56 +01:00
|
|
|
Emits something to a session attached to the object.
|
2012-03-30 23:47:22 +02:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
message (str): The message to send
|
|
|
|
|
from_obj (obj): object that is sending.
|
2010-12-07 02:34:59 +00:00
|
|
|
data (object): an optional data object that may or may not
|
2012-03-30 23:47:22 +02:00
|
|
|
be used by the protocol.
|
2013-02-17 18:48:48 +01:00
|
|
|
sessid (int): sessid to relay to, if any.
|
2013-02-17 20:21:23 +01:00
|
|
|
If set to 0 (default), use either from_obj.sessid (if set) or self.sessid automatically
|
2013-02-17 18:48:48 +01:00
|
|
|
If None, echo to all connected sessions
|
2010-08-29 18:46:58 +00:00
|
|
|
"""
|
2013-09-22 11:39:24 +02:00
|
|
|
global _SESSIONS
|
|
|
|
|
if not _SESSIONS:
|
|
|
|
|
from src.server.sessionhandler import SESSIONS as _SESSIONS
|
|
|
|
|
|
2013-09-22 16:29:02 +02:00
|
|
|
text = to_str(text, force_string=True) if text else ""
|
2013-09-22 11:39:24 +02:00
|
|
|
|
2013-09-21 17:33:48 +02:00
|
|
|
if "data" in kwargs:
|
2013-09-22 11:39:24 +02:00
|
|
|
# deprecation warning
|
2013-09-21 17:33:48 +02:00
|
|
|
logger.log_depmsg("ObjectDB.msg(): 'data'-dict keyword is deprecated. Use **kwargs instead.")
|
|
|
|
|
data = kwargs.pop("data")
|
|
|
|
|
if isinstance(data, dict):
|
|
|
|
|
kwargs.update(data)
|
|
|
|
|
|
2013-09-22 11:39:24 +02:00
|
|
|
if from_obj:
|
|
|
|
|
# call hook
|
|
|
|
|
try:
|
|
|
|
|
_GA(from_obj, "at_msg_send")(text=text, to_obj=self, **kwargs)
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
session = _SESSIONS.session_from_sessid(sessid if sessid else _GA(self, "sessid"))
|
|
|
|
|
if session:
|
|
|
|
|
session.msg(text=text, **kwargs)
|
2009-11-22 21:18:55 +00:00
|
|
|
|
2013-09-21 17:33:48 +02:00
|
|
|
def msg_contents(self, message, exclude=None, from_obj=None, **kwargs):
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
Emits something to all objects inside an object.
|
2009-01-18 02:40:57 +00:00
|
|
|
|
2013-11-14 19:31:17 +01:00
|
|
|
exclude is a list of objects not to send to. See self.msg() for
|
|
|
|
|
more info.
|
2009-01-18 02:40:57 +00:00
|
|
|
"""
|
2012-09-20 23:18:52 +02:00
|
|
|
contents = _GA(self, "contents")
|
2010-08-29 18:46:58 +00:00
|
|
|
if exclude:
|
2012-02-26 01:10:20 +01:00
|
|
|
exclude = make_iter(exclude)
|
2013-09-22 16:29:02 +02:00
|
|
|
contents = [obj for obj in contents if obj not in exclude]
|
2010-08-29 18:46:58 +00:00
|
|
|
for obj in contents:
|
2013-09-21 17:33:48 +02:00
|
|
|
obj.msg(message, from_obj=from_obj, **kwargs)
|
2012-03-30 23:47:22 +02:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
def move_to(self, destination, quiet=False,
|
2012-10-23 22:31:51 +02:00
|
|
|
emit_to_obj=None, use_destination=True, to_none=False):
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
Moves this object to a new location.
|
2012-03-24 18:25:32 +01:00
|
|
|
|
|
|
|
|
Moves this object to a new location. Note that if <destination> is an
|
|
|
|
|
exit object (i.e. it has "destination"!=None), the move_to will
|
|
|
|
|
happen to this destination and -not- into the exit object itself, unless
|
2013-11-14 19:31:17 +01:00
|
|
|
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.
|
2012-03-30 23:47:22 +02:00
|
|
|
|
2011-02-14 17:18:31 +00:00
|
|
|
destination: (Object) Reference to the object to move to. This
|
2011-04-08 23:10:04 +00:00
|
|
|
can also be an exit object, in which case the destination
|
2012-03-30 23:47:22 +02:00
|
|
|
property is used as destination.
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
quiet: (bool) If true, don't emit left/arrived messages.
|
2010-08-29 18:46:58 +00:00
|
|
|
emit_to_obj: (Object) object to receive error messages
|
2013-11-14 19:31:17 +01:00
|
|
|
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.
|
|
|
|
|
to_none - allow destination to be None. Note that no hooks are run when
|
|
|
|
|
moving to a None location. If you want to run hooks,
|
|
|
|
|
run them manually (and make sure they can manage None
|
|
|
|
|
locations).
|
|
|
|
|
|
|
|
|
|
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.
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2011-06-26 14:35:02 +00:00
|
|
|
def logerr(string=""):
|
|
|
|
|
trc = traceback.format_exc()
|
|
|
|
|
errstring = "%s%s" % (trc, string)
|
|
|
|
|
logger.log_trace()
|
2012-09-20 23:18:52 +02:00
|
|
|
_GA(self, "msg")(errstring)
|
2011-06-26 14:35:02 +00:00
|
|
|
|
2012-06-14 08:56:57 +02:00
|
|
|
errtxt = _("Couldn't perform move ('%s'). Contact an admin.")
|
2010-08-29 18:46:58 +00:00
|
|
|
if not emit_to_obj:
|
|
|
|
|
emit_to_obj = self
|
|
|
|
|
|
|
|
|
|
if not destination:
|
2012-10-23 22:31:51 +02:00
|
|
|
if to_none:
|
|
|
|
|
# immediately move to None. There can be no hooks called since
|
|
|
|
|
# there is no destination to call them with.
|
|
|
|
|
self.location = None
|
|
|
|
|
return True
|
2012-06-14 08:56:57 +02:00
|
|
|
emit_to_obj.msg(_("The destination doesn't exist."))
|
2012-03-30 23:47:22 +02:00
|
|
|
return
|
2012-04-15 22:04:15 +02:00
|
|
|
if destination.destination and use_destination:
|
2011-02-14 17:18:31 +00:00
|
|
|
# traverse exits
|
2011-04-08 23:10:04 +00:00
|
|
|
destination = destination.destination
|
2009-12-20 20:51:26 +00:00
|
|
|
|
2009-10-24 03:49:14 +00:00
|
|
|
# Before the move, call eventual pre-commands.
|
2009-12-20 20:51:26 +00:00
|
|
|
try:
|
2010-08-29 18:46:58 +00:00
|
|
|
if not self.at_before_move(destination):
|
2009-12-20 20:51:26 +00:00
|
|
|
return
|
2010-08-29 18:46:58 +00:00
|
|
|
except Exception:
|
2011-06-26 14:35:02 +00:00
|
|
|
logerr(errtxt % "at_before_move()")
|
|
|
|
|
#emit_to_obj.msg(errtxt % "at_before_move()")
|
|
|
|
|
#logger.log_trace()
|
2010-08-29 18:46:58 +00:00
|
|
|
return False
|
2012-03-30 23:47:22 +02:00
|
|
|
|
|
|
|
|
# Save the old location
|
2012-09-20 23:18:52 +02:00
|
|
|
source_location = _GA(self, "location")
|
2010-08-29 18:46:58 +00:00
|
|
|
if not source_location:
|
|
|
|
|
# there was some error in placing this room.
|
|
|
|
|
# we have to set one or we won't be able to continue
|
2012-09-20 23:18:52 +02:00
|
|
|
if _GA(self, "home"):
|
|
|
|
|
source_location = _GA(self, "home")
|
2010-08-29 18:46:58 +00:00
|
|
|
else:
|
2011-08-06 19:39:06 +00:00
|
|
|
default_home = ObjectDB.objects.get_id(settings.CHARACTER_DEFAULT_HOME)
|
2010-08-29 18:46:58 +00:00
|
|
|
source_location = default_home
|
|
|
|
|
|
|
|
|
|
# Call hook on source location
|
|
|
|
|
try:
|
|
|
|
|
source_location.at_object_leave(self, destination)
|
|
|
|
|
except Exception:
|
2011-06-26 14:35:02 +00:00
|
|
|
logerr(errtxt % "at_object_leave()")
|
|
|
|
|
#emit_to_obj.msg(errtxt % "at_object_leave()")
|
|
|
|
|
#logger.log_trace()
|
2010-08-29 18:46:58 +00:00
|
|
|
return False
|
2012-03-30 23:47:22 +02:00
|
|
|
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
if not quiet:
|
2009-09-19 15:18:42 +00:00
|
|
|
#tell the old room we are leaving
|
2009-12-20 20:51:26 +00:00
|
|
|
try:
|
2012-03-30 23:47:22 +02:00
|
|
|
self.announce_move_from(destination)
|
2010-08-29 18:46:58 +00:00
|
|
|
except Exception:
|
2012-03-30 23:47:22 +02:00
|
|
|
logerr(errtxt % "at_announce_move()")
|
2011-06-26 14:35:02 +00:00
|
|
|
#emit_to_obj.msg(errtxt % "at_announce_move()" )
|
|
|
|
|
#logger.log_trace()
|
2012-03-30 23:47:22 +02:00
|
|
|
return False
|
2011-04-24 11:26:51 +00:00
|
|
|
|
2009-10-24 03:49:14 +00:00
|
|
|
# Perform move
|
2010-08-29 18:46:58 +00:00
|
|
|
try:
|
2013-07-13 15:39:16 +02:00
|
|
|
#print "move_to location:", destination
|
2012-09-20 23:18:52 +02:00
|
|
|
_SA(self, "location", destination)
|
2010-08-29 18:46:58 +00:00
|
|
|
except Exception:
|
|
|
|
|
emit_to_obj.msg(errtxt % "location change")
|
|
|
|
|
logger.log_trace()
|
2012-03-30 23:47:22 +02:00
|
|
|
return False
|
|
|
|
|
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
if not quiet:
|
2012-03-30 23:47:22 +02:00
|
|
|
# Tell the new room we are there.
|
2009-12-20 20:51:26 +00:00
|
|
|
try:
|
2010-08-29 18:46:58 +00:00
|
|
|
self.announce_move_to(source_location)
|
|
|
|
|
except Exception:
|
2011-06-26 14:35:02 +00:00
|
|
|
logerr(errtxt % "announce_move_to()")
|
|
|
|
|
#emit_to_obj.msg(errtxt % "announce_move_to()")
|
|
|
|
|
#logger.log_trace()
|
2012-03-30 23:47:22 +02:00
|
|
|
return False
|
|
|
|
|
|
2011-06-26 14:35:02 +00:00
|
|
|
# Perform eventual extra commands on the receiving location
|
|
|
|
|
# (the object has already arrived at this point)
|
|
|
|
|
try:
|
|
|
|
|
destination.at_object_receive(self, source_location)
|
|
|
|
|
except Exception:
|
|
|
|
|
logerr(errtxt % "at_object_receive()")
|
|
|
|
|
#emit_to_obj.msg(errtxt % "at_object_receive()")
|
|
|
|
|
#logger.log_trace()
|
2012-03-30 23:47:22 +02:00
|
|
|
return False
|
2011-06-26 14:35:02 +00:00
|
|
|
|
2009-10-24 03:49:14 +00:00
|
|
|
# Execute eventual extra commands on this object after moving it
|
2010-08-29 18:46:58 +00:00
|
|
|
# (usually calling 'look')
|
2009-12-20 20:51:26 +00:00
|
|
|
try:
|
2010-08-29 18:46:58 +00:00
|
|
|
self.at_after_move(source_location)
|
|
|
|
|
except Exception:
|
2011-06-26 14:35:02 +00:00
|
|
|
logerr(errtxt % "at_after_move")
|
|
|
|
|
#emit_to_obj.msg(errtxt % "at_after_move()")
|
|
|
|
|
#logger.log_trace()
|
2012-03-30 23:47:22 +02:00
|
|
|
return False
|
|
|
|
|
return True
|
2009-08-16 01:18:58 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
#
|
2012-03-30 23:47:22 +02:00
|
|
|
# Object Swap, Delete and Cleanup methods
|
|
|
|
|
#
|
|
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
def clear_exits(self):
|
2009-12-03 00:41:53 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
Destroys all of the exits and any exits pointing to this
|
|
|
|
|
object as a destination.
|
2009-12-03 00:41:53 +00:00
|
|
|
"""
|
2011-09-03 10:22:19 +00:00
|
|
|
for out_exit in [exi for exi in ObjectDB.objects.get_contents(self) if exi.db_destination]:
|
2010-08-29 18:46:58 +00:00
|
|
|
out_exit.delete()
|
2011-04-08 23:10:04 +00:00
|
|
|
for in_exit in ObjectDB.objects.filter(db_destination=self):
|
2010-08-29 18:46:58 +00:00
|
|
|
in_exit.delete()
|
2009-12-03 00:41:53 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
def clear_contents(self):
|
2009-12-03 00:41:53 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
Moves all objects (players/things) to their home
|
2012-03-30 23:47:22 +02:00
|
|
|
location or to default home.
|
2009-12-03 00:41:53 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
# Gather up everything that thinks this is its location.
|
|
|
|
|
objs = ObjectDB.objects.filter(db_location=self)
|
2012-10-14 16:24:21 +02:00
|
|
|
default_home_id = int(settings.CHARACTER_DEFAULT_HOME.lstrip("#"))
|
2010-08-29 18:46:58 +00:00
|
|
|
try:
|
|
|
|
|
default_home = ObjectDB.objects.get(id=default_home_id)
|
2012-09-20 23:18:52 +02:00
|
|
|
if default_home.dbid == _GA(self, "dbid"):
|
2011-11-05 21:19:57 +01:00
|
|
|
# we are deleting default home!
|
2012-03-30 23:47:22 +02:00
|
|
|
default_home = None
|
2010-08-29 18:46:58 +00:00
|
|
|
except Exception:
|
2012-06-14 08:56:57 +02:00
|
|
|
string = _("Could not find default home '(#%d)'.")
|
2010-08-29 18:46:58 +00:00
|
|
|
logger.log_errmsg(string % default_home_id)
|
2012-03-30 23:47:22 +02:00
|
|
|
default_home = None
|
2010-08-29 18:46:58 +00:00
|
|
|
|
2012-03-30 23:47:22 +02:00
|
|
|
for obj in objs:
|
|
|
|
|
home = obj.home
|
2010-08-29 18:46:58 +00:00
|
|
|
# Obviously, we can't send it back to here.
|
2012-09-20 23:18:52 +02:00
|
|
|
if not home or (home and home.dbid == _GA(self, "dbid")):
|
2012-03-30 23:47:22 +02:00
|
|
|
obj.home = default_home
|
|
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
# If for some reason it's still None...
|
2011-11-05 21:19:57 +01:00
|
|
|
if not obj.home:
|
2010-08-29 18:46:58 +00:00
|
|
|
string = "Missing default home, '%s(#%d)' "
|
|
|
|
|
string += "now has a null location."
|
2012-03-30 23:47:22 +02:00
|
|
|
obj.location = None
|
2012-06-14 08:56:57 +02:00
|
|
|
obj.msg(_("Something went wrong! You are dumped into nowhere. Contact an admin."))
|
2012-04-26 17:47:25 +02:00
|
|
|
logger.log_errmsg(string % (obj.name, obj.dbid))
|
2012-03-30 23:47:22 +02:00
|
|
|
return
|
|
|
|
|
|
2011-11-05 21:19:57 +01:00
|
|
|
if obj.has_player:
|
2012-03-30 23:47:22 +02:00
|
|
|
if home:
|
2010-08-29 18:46:58 +00:00
|
|
|
string = "Your current location has ceased to exist,"
|
|
|
|
|
string += " moving you to %s(#%d)."
|
2012-06-14 08:56:57 +02:00
|
|
|
obj.msg(_(string) % (home.name, home.dbid))
|
2010-08-29 18:46:58 +00:00
|
|
|
else:
|
|
|
|
|
# Famous last words: The player should never see this.
|
|
|
|
|
string = "This place should not exist ... contact an admin."
|
2012-06-14 08:56:57 +02:00
|
|
|
obj.msg(_(string))
|
2010-08-29 18:46:58 +00:00
|
|
|
obj.move_to(home)
|
2009-05-01 15:34:43 +00:00
|
|
|
|
2011-05-01 18:04:15 +00:00
|
|
|
def copy(self, new_key=None):
|
2012-03-30 23:47:22 +02:00
|
|
|
"""
|
2013-11-14 19:31:17 +01:00
|
|
|
Makes an identical copy of this object. If you want to customize the
|
|
|
|
|
copy by changing some settings, use ObjectDB.object.copy_object()
|
|
|
|
|
directly.
|
2012-03-24 18:25:32 +01:00
|
|
|
|
2013-11-14 19:31:17 +01:00
|
|
|
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.
|
2012-03-30 23:47:22 +02:00
|
|
|
Returns: Object (copy of this one)
|
2011-05-01 18:04:15 +00:00
|
|
|
"""
|
2012-09-11 23:47:29 +02:00
|
|
|
def find_clone_key():
|
|
|
|
|
"""
|
|
|
|
|
Append 01, 02 etc to obj.key. Checks next higher number in the
|
|
|
|
|
same location, then adds the next number available
|
|
|
|
|
|
|
|
|
|
returns the new clone name on the form keyXX
|
|
|
|
|
"""
|
2012-09-20 23:18:52 +02:00
|
|
|
key = _GA(self, "key")
|
2012-09-11 23:47:29 +02:00
|
|
|
num = 1
|
2012-10-14 16:31:22 +02:00
|
|
|
for obj in (obj for obj in self.location.contents
|
2013-11-14 19:31:17 +01:00
|
|
|
if obj.key.startswith(key) and
|
|
|
|
|
obj.key.lstrip(key).isdigit()):
|
2012-09-11 23:47:29 +02:00
|
|
|
num += 1
|
2012-10-14 16:31:22 +02:00
|
|
|
return "%s%03i" % (key, num)
|
|
|
|
|
new_key = new_key or find_clone_key()
|
2011-05-01 18:04:15 +00:00
|
|
|
return ObjectDB.objects.copy_object(self, new_key=new_key)
|
|
|
|
|
|
2011-09-03 10:22:19 +00:00
|
|
|
delete_iter = 0
|
2012-03-30 23:47:22 +02:00
|
|
|
def delete(self):
|
2009-10-14 18:15:15 +00:00
|
|
|
"""
|
2012-03-30 23:47:22 +02:00
|
|
|
Deletes this object.
|
2010-08-29 18:46:58 +00:00
|
|
|
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.
|
2009-05-01 15:34:43 +00:00
|
|
|
"""
|
2013-02-18 20:08:05 +01:00
|
|
|
global _ScriptDB
|
|
|
|
|
if not _ScriptDB:
|
|
|
|
|
from src.scripts.models import ScriptDB as _ScriptDB
|
|
|
|
|
|
2012-09-20 23:18:52 +02:00
|
|
|
if _GA(self, "delete_iter") > 0:
|
2011-09-03 10:22:19 +00:00
|
|
|
# make sure to only call delete once on this object
|
|
|
|
|
# (avoid recursive loops)
|
|
|
|
|
return False
|
2011-08-06 18:15:04 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
if not self.at_object_delete():
|
|
|
|
|
# this is an extra pre-check
|
|
|
|
|
# run before deletion mechanism
|
2012-03-30 23:47:22 +02:00
|
|
|
# is kicked into gear.
|
2012-09-20 23:18:52 +02:00
|
|
|
_SA(self, "delete_iter", 0)
|
2009-10-20 22:21:01 +00:00
|
|
|
return False
|
2009-05-01 15:34:43 +00:00
|
|
|
|
2011-09-03 10:22:19 +00:00
|
|
|
self.delete_iter += 1
|
|
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
# See if we need to kick the player off.
|
2011-04-23 11:54:08 +00:00
|
|
|
|
2012-09-20 23:18:52 +02:00
|
|
|
for session in _GA(self, "sessions"):
|
|
|
|
|
session.msg(_("Your character %s has been destroyed.") % _GA(self, "key"))
|
2012-03-30 23:47:22 +02:00
|
|
|
# no need to disconnect, Player just jumps to OOC mode.
|
2011-04-23 11:54:08 +00:00
|
|
|
# sever the connection (important!)
|
2012-09-20 23:18:52 +02:00
|
|
|
if _GA(self, 'player'):
|
|
|
|
|
_SA(_GA(self, "player"), "character", None)
|
|
|
|
|
_SA(self, "player", None)
|
2011-08-11 21:16:35 +00:00
|
|
|
|
2013-02-18 20:08:05 +01:00
|
|
|
for script in _ScriptDB.objects.get_all_scripts_on_obj(self):
|
2011-08-11 21:16:35 +00:00
|
|
|
script.stop()
|
2013-02-18 20:08:05 +01:00
|
|
|
#for script in _GA(self, "scripts").all():
|
|
|
|
|
# script.stop()
|
2012-03-30 23:47:22 +02:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
# if self.player:
|
2012-03-30 23:47:22 +02:00
|
|
|
# self.player.user.is_active = False
|
2011-11-05 21:19:57 +01:00
|
|
|
# self.player.user.save(
|
2010-08-29 18:46:58 +00:00
|
|
|
|
|
|
|
|
# Destroy any exits to and from this room, if any
|
2012-09-20 23:18:52 +02:00
|
|
|
_GA(self, "clear_exits")()
|
2010-08-29 18:46:58 +00:00
|
|
|
# Clear out any non-exit objects located within the object
|
2012-09-20 23:18:52 +02:00
|
|
|
_GA(self, "clear_contents")()
|
2013-11-14 19:31:17 +01:00
|
|
|
#old_loc = _GA(self, "location")
|
2010-08-29 18:46:58 +00:00
|
|
|
# Perform the deletion of the object
|
|
|
|
|
super(ObjectDB, self).delete()
|
2012-11-01 11:20:07 +01:00
|
|
|
# clear object's old location's content cache of this object
|
2013-10-21 21:17:32 +02:00
|
|
|
#if old_loc:
|
|
|
|
|
# _GA(old_loc.dbobj, "contents_update")()
|
2012-03-30 23:47:22 +02:00
|
|
|
return True
|