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
|
|
|
|
|
is, all objects that has an actual existence in-game.
|
|
|
|
|
|
|
|
|
|
Each database object is 'decorated' with a 'typeclass', a normal
|
|
|
|
|
python class that implements all the various logics needed by the game
|
|
|
|
|
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
|
|
|
|
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
|
2011-04-23 11:54:08 +00:00
|
|
|
from django.contrib.contenttypes.models import ContentType
|
2010-08-29 18:46:58 +00:00
|
|
|
|
2010-10-30 18:42:37 +00:00
|
|
|
from src.utils.idmapper.models import SharedMemoryModel
|
2011-04-23 11:54:08 +00:00
|
|
|
from src.typeclasses.models import Attribute, TypedObject, TypeNick, TypeNickHandler
|
2010-08-29 18:46:58 +00:00
|
|
|
from src.typeclasses.typeclass import TypeClass
|
|
|
|
|
from src.objects.manager import ObjectManager
|
2011-04-23 11:54:08 +00:00
|
|
|
from src.players.models import PlayerDB
|
2011-04-12 21:43:57 +00:00
|
|
|
from src.server.models import ServerConfig
|
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
|
2011-04-23 11:54:08 +00:00
|
|
|
from src.utils.utils import is_iter, to_unicode, to_str, mod_import
|
2009-05-02 19:02:36 +00:00
|
|
|
|
2011-04-23 11:54:08 +00:00
|
|
|
#PlayerDB = ContentType.objects.get(app_label="players", model="playerdb").model_class()
|
2006-11-20 18:54:10 +00:00
|
|
|
|
2011-04-23 11:54:08 +00:00
|
|
|
FULL_PERSISTENCE = settings.FULL_PERSISTENCE
|
|
|
|
|
AT_SEARCH_RESULT = mod_import(*settings.SEARCH_AT_RESULT.rsplit('.', 1))
|
2010-08-29 18:46:58 +00:00
|
|
|
|
|
|
|
|
#------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# ObjAttribute
|
|
|
|
|
#
|
|
|
|
|
#------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
class ObjAttribute(Attribute):
|
|
|
|
|
"Attributes for ObjectDB objects."
|
|
|
|
|
db_obj = models.ForeignKey("ObjectDB")
|
2009-11-25 19:27:32 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
class Meta:
|
|
|
|
|
"Define Django meta options"
|
|
|
|
|
verbose_name = "Object Attribute"
|
|
|
|
|
verbose_name_plural = "Object Attributes"
|
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-10-30 18:42:37 +00:00
|
|
|
#------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Alias
|
|
|
|
|
#
|
|
|
|
|
#------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
class Alias(SharedMemoryModel):
|
|
|
|
|
"""
|
|
|
|
|
This model holds a range of alternate names for an object.
|
|
|
|
|
These are intrinsic properties of the object. The split
|
|
|
|
|
is so as to allow for effective global searches also by
|
|
|
|
|
alias.
|
|
|
|
|
"""
|
|
|
|
|
db_key = models.CharField(max_length=255)
|
|
|
|
|
db_obj = models.ForeignKey("ObjectDB")
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
"Define Django meta options"
|
|
|
|
|
verbose_name = "Object alias"
|
|
|
|
|
verbose_name_plural = "Object aliases"
|
2011-03-15 16:08:32 +00:00
|
|
|
def __unicode__(self):
|
|
|
|
|
return u"%s" % self.db_key
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return str(self.db_key)
|
|
|
|
|
|
|
|
|
|
|
2010-10-30 18:42:37 +00:00
|
|
|
|
2011-02-27 22:27:56 +00:00
|
|
|
#------------------------------------------------------------
|
|
|
|
|
#
|
2011-04-23 11:54:08 +00:00
|
|
|
# Object Nicks
|
2011-02-27 22:27:56 +00:00
|
|
|
#
|
|
|
|
|
#------------------------------------------------------------
|
|
|
|
|
|
2011-04-23 11:54:08 +00:00
|
|
|
class ObjectNick(TypeNick):
|
2011-02-27 22:27:56 +00:00
|
|
|
"""
|
2011-04-23 11:54:08 +00:00
|
|
|
|
2011-02-27 22:27:56 +00:00
|
|
|
The default nick types used by Evennia are:
|
|
|
|
|
inputline (default) - match against all input
|
|
|
|
|
player - match against player searches
|
|
|
|
|
obj - match against object searches
|
|
|
|
|
channel - used to store own names for channels
|
|
|
|
|
"""
|
|
|
|
|
db_obj = models.ForeignKey("ObjectDB")
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
"Define Django meta options"
|
2011-04-23 11:54:08 +00:00
|
|
|
verbose_name = "Nickname for Objects"
|
|
|
|
|
verbose_name_plural = "Nicknames Objects"
|
2011-02-27 22:27:56 +00:00
|
|
|
unique_together = ("db_nick", "db_type", "db_obj")
|
|
|
|
|
|
2011-04-23 11:54:08 +00:00
|
|
|
class ObjectNickHandler(TypeNickHandler):
|
2011-03-15 16:08:32 +00:00
|
|
|
"""
|
|
|
|
|
Handles nick access and setting. Accessed through ObjectDB.nicks
|
|
|
|
|
"""
|
2011-04-23 11:54:08 +00:00
|
|
|
NickClass = ObjectNick
|
2011-03-15 16:08:32 +00: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
|
|
|
|
|
type class with new database-stored variables.
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
permissions - perm strings
|
2011-03-15 16:08:32 +00:00
|
|
|
locks - lock definitions (handler)
|
|
|
|
|
dbref - #id of object
|
2010-08-29 18:46:58 +00:00
|
|
|
db - persistent attribute storage
|
|
|
|
|
ndb - non-persistent attribute storage
|
|
|
|
|
|
|
|
|
|
The ObjectDB adds the following properties:
|
|
|
|
|
player - optional connected player
|
|
|
|
|
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)
|
|
|
|
|
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):
|
|
|
|
|
# db_key (also 'name' works), db_typeclass_path, db_date_created,
|
|
|
|
|
# db_permissions
|
|
|
|
|
#
|
|
|
|
|
# These databse fields (including the inherited ones) are all set
|
|
|
|
|
# using their corresponding properties, named same as the field,
|
|
|
|
|
# but withtout the db_* prefix.
|
|
|
|
|
|
|
|
|
|
# If this is a character object, the player is connected here.
|
|
|
|
|
db_player = models.ForeignKey("players.PlayerDB", blank=True, null=True)
|
|
|
|
|
# The location in the game world. Since this one is likely
|
|
|
|
|
# to change often, we set this with the 'location' property
|
|
|
|
|
# to transparently handle Typeclassing.
|
|
|
|
|
db_location = models.ForeignKey('self', related_name="locations_set",
|
|
|
|
|
blank=True, null=True)
|
|
|
|
|
# a safety location, this usually don't change much.
|
|
|
|
|
db_home = models.ForeignKey('self', related_name="homes_set",
|
|
|
|
|
blank=True, null=True)
|
2011-04-08 23:10:04 +00:00
|
|
|
# destination of this object - primarily used by exits.
|
|
|
|
|
db_destination = models.ForeignKey('self', related_name="destinations_set",
|
|
|
|
|
blank=True, null=True)
|
2011-03-20 19:45:56 +00:00
|
|
|
# database storage of persistant cmdsets.
|
|
|
|
|
db_cmdset_storage = models.TextField(null=True)
|
2009-10-21 18:42:52 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
# Database manager
|
|
|
|
|
objects = ObjectManager()
|
2009-10-14 18:15:15 +00:00
|
|
|
|
2011-03-15 16:08:32 +00:00
|
|
|
# Add the object-specific handlers
|
2011-03-20 19:45:56 +00:00
|
|
|
|
2011-03-15 16:08:32 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
|
"Parent must be initialized first."
|
|
|
|
|
TypedObject.__init__(self, *args, **kwargs)
|
2011-03-20 19:45:56 +00:00
|
|
|
# handlers
|
|
|
|
|
self.cmdset = CmdSetHandler(self)
|
|
|
|
|
self.cmdset.update(init_mode=True)
|
|
|
|
|
self.scripts = ScriptHandler(self)
|
|
|
|
|
self.scripts.validate(init_mode=True)
|
2011-04-23 11:54:08 +00:00
|
|
|
self.nicks = ObjectNickHandler(self)
|
2011-03-20 19:45:56 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
# Wrapper properties to easily set database fields. These are
|
|
|
|
|
# @property decorators that allows to access these fields using
|
|
|
|
|
# normal python operations (without having to remember to save()
|
|
|
|
|
# etc). So e.g. a property 'attr' has a get/set/del decorator
|
|
|
|
|
# defined that allows the user to do self.attr = value,
|
|
|
|
|
# value = self.attr and del self.attr respectively (where self
|
|
|
|
|
# is the object in question).
|
|
|
|
|
|
|
|
|
|
# aliases property (wraps (db_aliases)
|
|
|
|
|
#@property
|
|
|
|
|
def aliases_get(self):
|
|
|
|
|
"Getter. Allows for value = self.aliases"
|
2011-03-14 08:41:47 +00:00
|
|
|
return list(Alias.objects.filter(db_obj=self).values_list("db_key", flat=True))
|
2010-08-29 18:46:58 +00:00
|
|
|
#@aliases.setter
|
|
|
|
|
def aliases_set(self, aliases):
|
2010-10-30 18:42:37 +00:00
|
|
|
"Setter. Allows for self.aliases = value"
|
2010-08-29 18:46:58 +00:00
|
|
|
if not is_iter(aliases):
|
2010-10-30 18:42:37 +00:00
|
|
|
aliases = [aliases]
|
|
|
|
|
for alias in aliases:
|
|
|
|
|
new_alias = Alias(db_key=alias, db_obj=self)
|
|
|
|
|
new_alias.save()
|
2010-08-29 18:46:58 +00:00
|
|
|
#@aliases.deleter
|
|
|
|
|
def aliases_del(self):
|
|
|
|
|
"Deleter. Allows for del self.aliases"
|
2010-10-30 18:42:37 +00:00
|
|
|
for alias in Alias.objects.filter(db_obj=self):
|
|
|
|
|
alias.delete()
|
2010-08-29 18:46:58 +00:00
|
|
|
aliases = property(aliases_get, aliases_set, aliases_del)
|
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
|
|
|
# player property (wraps db_player)
|
|
|
|
|
#@property
|
|
|
|
|
def player_get(self):
|
2009-01-15 16:24:52 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
Getter. Allows for value = self.player.
|
|
|
|
|
We have to be careful here since Player is also
|
|
|
|
|
a TypedObject, so as to not create a loop.
|
2009-01-15 16:24:52 +00:00
|
|
|
"""
|
2009-03-26 14:03:41 +00:00
|
|
|
try:
|
2010-08-29 18:46:58 +00:00
|
|
|
return object.__getattribute__(self, 'db_player')
|
|
|
|
|
except AttributeError:
|
|
|
|
|
return None
|
|
|
|
|
#@player.setter
|
|
|
|
|
def player_set(self, player):
|
|
|
|
|
"Setter. Allows for self.player = value"
|
|
|
|
|
if isinstance(player, TypeClass):
|
|
|
|
|
player = player.dbobj
|
|
|
|
|
self.db_player = player
|
|
|
|
|
self.save()
|
|
|
|
|
#@player.deleter
|
|
|
|
|
def player_del(self):
|
|
|
|
|
"Deleter. Allows for del self.player"
|
|
|
|
|
self.db_player = None
|
|
|
|
|
self.save()
|
|
|
|
|
player = property(player_get, player_set, player_del)
|
|
|
|
|
|
|
|
|
|
# location property (wraps db_location)
|
|
|
|
|
#@property
|
|
|
|
|
def location_get(self):
|
|
|
|
|
"Getter. Allows for value = self.location."
|
|
|
|
|
loc = self.db_location
|
|
|
|
|
if loc:
|
|
|
|
|
return loc.typeclass(loc)
|
|
|
|
|
return None
|
|
|
|
|
#@location.setter
|
|
|
|
|
def location_set(self, location):
|
|
|
|
|
"Setter. Allows for self.location = location"
|
2009-01-15 16:24:52 +00:00
|
|
|
try:
|
2010-08-29 18:46:58 +00:00
|
|
|
if location == None or type(location) == ObjectDB:
|
|
|
|
|
# location is None or a valid object
|
|
|
|
|
loc = location
|
|
|
|
|
elif ObjectDB.objects.dbref(location):
|
|
|
|
|
# location is a dbref; search
|
2011-04-23 11:54:08 +00:00
|
|
|
loc = ObjectDB.objects.dbref_search(ocation)
|
2010-08-29 18:46:58 +00:00
|
|
|
if loc and hasattr(loc,'dbobj'):
|
|
|
|
|
loc = loc.dbobj
|
|
|
|
|
else:
|
|
|
|
|
loc = location.dbobj
|
|
|
|
|
else:
|
|
|
|
|
loc = location.dbobj
|
|
|
|
|
self.db_location = loc
|
|
|
|
|
self.save()
|
|
|
|
|
except Exception:
|
|
|
|
|
string = "Cannot set location: "
|
|
|
|
|
string += "%s is not a valid location."
|
|
|
|
|
self.msg(string % location)
|
|
|
|
|
logger.log_trace(string)
|
|
|
|
|
raise
|
|
|
|
|
#@location.deleter
|
|
|
|
|
def location_del(self):
|
|
|
|
|
"Deleter. Allows for del self.location"
|
|
|
|
|
self.db_location = None
|
2011-04-08 23:10:04 +00:00
|
|
|
self.save()
|
2010-08-29 18:46:58 +00:00
|
|
|
location = property(location_get, location_set, location_del)
|
|
|
|
|
|
|
|
|
|
# home property (wraps db_home)
|
|
|
|
|
#@property
|
|
|
|
|
def home_get(self):
|
|
|
|
|
"Getter. Allows for value = self.home"
|
|
|
|
|
home = self.db_home
|
|
|
|
|
if home:
|
|
|
|
|
return home.typeclass(home)
|
|
|
|
|
return None
|
|
|
|
|
#@home.setter
|
|
|
|
|
def home_set(self, home):
|
|
|
|
|
"Setter. Allows for self.home = value"
|
2009-01-15 16:24:52 +00:00
|
|
|
try:
|
2010-08-29 18:46:58 +00:00
|
|
|
if home == None or type(home) == ObjectDB:
|
|
|
|
|
hom = home
|
|
|
|
|
elif ObjectDB.objects.dbref(home):
|
|
|
|
|
hom = ObjectDB.objects.dbref_search(home)
|
|
|
|
|
if hom and hasattr(hom,'dbobj'):
|
|
|
|
|
hom = hom.dbobj
|
|
|
|
|
else:
|
|
|
|
|
hom = home.dbobj
|
|
|
|
|
else:
|
|
|
|
|
hom = home.dbobj
|
|
|
|
|
if home:
|
|
|
|
|
self.db_home = hom
|
|
|
|
|
except Exception:
|
|
|
|
|
string = "Cannot set home: "
|
|
|
|
|
string += "%s is not a valid home."
|
|
|
|
|
self.msg(string % home)
|
|
|
|
|
logger.log_trace(string)
|
|
|
|
|
raise
|
|
|
|
|
self.save()
|
|
|
|
|
#@home.deleter
|
|
|
|
|
def home_del(self):
|
|
|
|
|
"Deleter. Allows for del self.home."
|
|
|
|
|
self.db_home = None
|
2011-04-08 23:10:04 +00:00
|
|
|
self.save()
|
2010-08-29 18:46:58 +00:00
|
|
|
home = property(home_get, home_set, home_del)
|
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-04-08 23:10:04 +00:00
|
|
|
# destination property (wraps db_destination)
|
|
|
|
|
#@property
|
|
|
|
|
def destination_get(self):
|
|
|
|
|
"Getter. Allows for value = self.destination."
|
|
|
|
|
dest = self.db_destination
|
|
|
|
|
if dest:
|
|
|
|
|
return dest.typeclass(dest)
|
|
|
|
|
return None
|
|
|
|
|
#@destination.setter
|
|
|
|
|
def destination_set(self, destination):
|
|
|
|
|
"Setter. Allows for self.destination = destination"
|
|
|
|
|
try:
|
|
|
|
|
if destination == None or type(destination) == ObjectDB:
|
|
|
|
|
# destination is None or a valid object
|
|
|
|
|
dest = destination
|
|
|
|
|
elif ObjectDB.objects.dbref(destination):
|
|
|
|
|
# destination is a dbref; search
|
|
|
|
|
dest = ObjectDB.objects.dbref_search(destination)
|
|
|
|
|
if dest and hasattr(dest,'dbobj'):
|
|
|
|
|
dest = dest.dbobj
|
|
|
|
|
else:
|
|
|
|
|
dest = destination.dbobj
|
|
|
|
|
else:
|
|
|
|
|
dest = destination.dbobj
|
|
|
|
|
self.db_destination = dest
|
|
|
|
|
self.save()
|
|
|
|
|
except Exception:
|
|
|
|
|
string = "Cannot set destination: "
|
|
|
|
|
string += "%s is not a valid destination."
|
|
|
|
|
self.msg(string % destination)
|
|
|
|
|
logger.log_trace(string)
|
|
|
|
|
raise
|
|
|
|
|
#@destination.deleter
|
|
|
|
|
def destination_del(self):
|
|
|
|
|
"Deleter. Allows for del self.destination"
|
|
|
|
|
self.db_destination = None
|
|
|
|
|
self.save()
|
|
|
|
|
destination = property(destination_get, destination_set, destination_del)
|
|
|
|
|
|
2011-03-15 16:08:32 +00:00
|
|
|
#@property for consistent aliases access throughout Evennia
|
|
|
|
|
#@aliases.setter
|
|
|
|
|
def aliases_set(self, aliases):
|
|
|
|
|
"Adds an alias to object"
|
|
|
|
|
if not is_iter(aliases):
|
|
|
|
|
aliases = [aliases]
|
|
|
|
|
for alias in aliases:
|
|
|
|
|
query = Alias.objects.filter(db_obj=self, db_key__iexact=alias)
|
|
|
|
|
if query.count():
|
|
|
|
|
continue
|
|
|
|
|
new_alias = Alias(db_key=alias, db_obj=self)
|
|
|
|
|
new_alias.save()
|
|
|
|
|
#@aliases.getter
|
|
|
|
|
def aliases_get(self):
|
|
|
|
|
"Return a list of all aliases defined on this object."
|
|
|
|
|
return list(Alias.objects.filter(db_obj=self).values_list("db_key", flat=True))
|
|
|
|
|
#@aliases.deleter
|
|
|
|
|
def aliases_del(self):
|
|
|
|
|
"Removes aliases from object"
|
|
|
|
|
query = Alias.objects.filter(db_obj=self)
|
|
|
|
|
if query:
|
|
|
|
|
query.delete()
|
|
|
|
|
aliases = property(aliases_get, aliases_set, aliases_del)
|
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
|
|
|
|
2011-03-20 19:45:56 +00:00
|
|
|
# cmdset_storage property
|
|
|
|
|
#@property
|
|
|
|
|
def cmdset_storage_get(self):
|
|
|
|
|
"Getter. Allows for value = self.name. Returns a list of cmdset_storage."
|
|
|
|
|
if self.db_cmdset_storage:
|
|
|
|
|
return [path.strip() for path in self.db_cmdset_storage.split(',')]
|
|
|
|
|
return []
|
|
|
|
|
#@cmdset_storage.setter
|
|
|
|
|
def cmdset_storage_set(self, value):
|
|
|
|
|
"Setter. Allows for self.name = value. Stores as a comma-separated string."
|
|
|
|
|
if is_iter(value):
|
|
|
|
|
value = ",".join([str(val).strip() for val in value])
|
|
|
|
|
self.db_cmdset_storage = value
|
|
|
|
|
self.save()
|
|
|
|
|
#@cmdset_storage.deleter
|
|
|
|
|
def cmdset_storage_del(self):
|
|
|
|
|
"Deleter. Allows for del self.name"
|
|
|
|
|
self.db_cmdset_storage = ""
|
|
|
|
|
self.save()
|
|
|
|
|
cmdset_storage = property(cmdset_storage_get, cmdset_storage_set, cmdset_storage_del)
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
#
|
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
|
|
|
# this is required to properly handle attributes
|
|
|
|
|
attribute_model_path = "src.objects.models"
|
|
|
|
|
attribute_model_name = "ObjAttribute"
|
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
|
|
|
# this is used by all typedobjects as a fallback
|
|
|
|
|
try:
|
|
|
|
|
default_typeclass_path = settings.BASE_OBJECT_TYPECLASS
|
|
|
|
|
except Exception:
|
|
|
|
|
default_typeclass_path = "src.objects.objects.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
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
#@property
|
|
|
|
|
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
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
# if the player is not connected, this will simply be an empty list.
|
|
|
|
|
if self.player:
|
|
|
|
|
return self.player.sessions
|
|
|
|
|
return []
|
|
|
|
|
sessions = property(sessions_get)
|
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
|
|
|
|
|
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
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
return any(self.sessions)
|
|
|
|
|
has_player = property(has_player_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
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
#@property
|
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.
|
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-05-01 18:04:15 +00:00
|
|
|
return ObjectDB.objects.get_contents(self, excludeobj=exclude)
|
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
|
|
|
|
|
def exits_get(self):
|
|
|
|
|
"""
|
|
|
|
|
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
|
|
|
"""
|
|
|
|
|
return [exi for exi in self.contents
|
2011-04-08 23:10:04 +00:00
|
|
|
if exi.destination]
|
2011-02-14 17:18:31 +00:00
|
|
|
exits = property(exits_get)
|
2011-03-15 16:08:32 +00:00
|
|
|
|
|
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
#
|
|
|
|
|
# Main Search method
|
|
|
|
|
#
|
2009-11-25 19:27:32 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
def search(self, ostring,
|
|
|
|
|
global_search=False,
|
|
|
|
|
attribute_name=None,
|
2011-02-27 22:55:42 +00:00
|
|
|
use_nicks=False, location=None,
|
2011-04-23 11:54:08 +00:00
|
|
|
ignore_errors=False, player=False):
|
2009-05-02 19:02:36 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
Perform a standard object search in the database, handling
|
|
|
|
|
multiple results and lack thereof gracefully.
|
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
|
|
|
ostring: (str) The string to match object names against.
|
|
|
|
|
Obs - To find a player, append * to the
|
|
|
|
|
start of ostring.
|
2010-10-21 18:58:47 +00:00
|
|
|
global_search: Search all objects, not just the current
|
|
|
|
|
location/inventory
|
2010-08-29 18:46:58 +00:00
|
|
|
attribute_name: (string) Which attribute to match
|
|
|
|
|
(if None, uses default 'name')
|
|
|
|
|
use_nicks : Use nickname replace (off by default)
|
2011-02-27 22:55:42 +00:00
|
|
|
location : If None, use caller's current location
|
2010-08-29 18:46:58 +00:00
|
|
|
ignore_errors : Don't display any error messages even
|
2010-09-12 15:07:12 +00:00
|
|
|
if there are none/multiple matches -
|
|
|
|
|
just return the result as a list.
|
2011-04-23 11:54:08 +00:00
|
|
|
player : Don't search for an Object but a Player.
|
|
|
|
|
This will also find players that don't
|
|
|
|
|
currently have a character.
|
|
|
|
|
|
|
|
|
|
Use *<string> to search for objects controlled by a specific
|
|
|
|
|
player. Note that the object controlled by the player will be
|
|
|
|
|
returned, not the player object itself. This also means that
|
|
|
|
|
this will not find Players without a character. Use the keyword
|
|
|
|
|
player=True to find player objects.
|
|
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
Note - for multiple matches, the engine accepts a number
|
|
|
|
|
linked to the key in order to separate the matches from
|
|
|
|
|
each other without showing the dbref explicitly. Default
|
|
|
|
|
syntax for this is 'N-searchword'. So for example, if there
|
|
|
|
|
are three objects in the room all named 'ball', you could
|
|
|
|
|
address the individual ball as '1-ball', '2-ball', '3-ball'
|
|
|
|
|
etc.
|
|
|
|
|
"""
|
|
|
|
|
if use_nicks:
|
2011-04-23 11:54:08 +00:00
|
|
|
if ostring.startswith('*') or player:
|
2010-08-29 18:46:58 +00:00
|
|
|
# player nick replace
|
2011-04-23 11:54:08 +00:00
|
|
|
ostring = self.nicks.get(ostring.lstrip('*'), nick_type="player")
|
|
|
|
|
if not player:
|
|
|
|
|
ostring = "*%s" % ostring
|
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
|
|
|
else:
|
2010-08-29 18:46:58 +00:00
|
|
|
# object nick replace
|
2011-03-15 16:08:32 +00:00
|
|
|
ostring = self.nicks.get(ostring, nick_type="object")
|
2010-08-29 18:46:58 +00:00
|
|
|
|
2011-04-23 11:54:08 +00:00
|
|
|
if player:
|
|
|
|
|
if ostring in ("me", "self", "*me", "*self"):
|
|
|
|
|
results = [self.player]
|
|
|
|
|
else:
|
|
|
|
|
results = PlayerDB.objects.player_search(ostring.lstrip('*'))
|
|
|
|
|
else:
|
2011-04-24 11:26:51 +00:00
|
|
|
results = ObjectDB.objects.object_search(ostring, caller=self,
|
2011-04-23 11:54:08 +00:00
|
|
|
global_search=global_search,
|
|
|
|
|
attribute_name=attribute_name,
|
|
|
|
|
location=location)
|
2010-09-04 12:18:00 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
if ignore_errors:
|
|
|
|
|
return results
|
2011-04-23 11:54:08 +00:00
|
|
|
# this import is cache after the first call.
|
|
|
|
|
return AT_SEARCH_RESULT(self, ostring, results, global_search)
|
2009-08-16 01:18:58 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
#
|
|
|
|
|
# Execution/action methods
|
|
|
|
|
#
|
2011-03-15 16:08:32 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
def execute_cmd(self, raw_string):
|
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
|
|
|
Do something as this object. This command transparently
|
|
|
|
|
lets its typeclass execute the command.
|
|
|
|
|
raw_string - raw command input coming from the command line.
|
|
|
|
|
"""
|
2011-02-27 22:27:56 +00:00
|
|
|
# nick replacement - we require full-word matching.
|
2011-04-21 16:45:18 +00:00
|
|
|
|
|
|
|
|
# do text encoding conversion
|
|
|
|
|
raw_string = to_unicode(raw_string)
|
|
|
|
|
|
2011-02-27 22:27:56 +00:00
|
|
|
raw_list = raw_string.split(None)
|
|
|
|
|
raw_list = [" ".join(raw_list[:i+1]) for i in range(len(raw_list)) if raw_list[:i+1]]
|
2011-04-23 11:54:08 +00:00
|
|
|
for nick in ObjectNick.objects.filter(db_obj=self, db_type__in=("inputline","channel")):
|
2011-02-27 22:27:56 +00:00
|
|
|
if nick.db_nick in raw_list:
|
|
|
|
|
raw_string = raw_string.replace(nick.db_nick, nick.db_real, 1)
|
|
|
|
|
break
|
2010-08-29 18:46:58 +00:00
|
|
|
cmdhandler.cmdhandler(self.typeclass(self), raw_string)
|
2009-11-01 15:12:38 +00:00
|
|
|
|
2010-12-07 02:34:59 +00:00
|
|
|
def msg(self, message, from_obj=None, data=None):
|
2009-11-01 15:12:38 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
Emits something to any sessions attached to the object.
|
2009-11-01 15:12:38 +00: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
|
|
|
|
|
be used by the protocol.
|
2010-08-29 18:46:58 +00:00
|
|
|
"""
|
|
|
|
|
# This is an important function that must always work.
|
|
|
|
|
# we use a different __getattribute__ to avoid recursive loops.
|
2011-04-23 11:54:08 +00:00
|
|
|
|
2010-10-03 19:11:43 +00:00
|
|
|
if object.__getattribute__(self, 'player'):
|
2011-04-25 20:13:15 +00:00
|
|
|
object.__getattribute__(self, 'player').msg(message, from_obj=from_obj, data=data)
|
2009-11-22 21:18:55 +00:00
|
|
|
|
2010-12-07 02:34:59 +00:00
|
|
|
def emit_to(self, message, from_obj=None, data=None):
|
2010-08-29 18:46:58 +00:00
|
|
|
"Deprecated. Alias for msg"
|
2011-03-15 16:08:32 +00:00
|
|
|
logger.log_depmsg("emit_to() is deprecated. Use msg() instead.")
|
2010-12-07 02:34:59 +00:00
|
|
|
self.msg(message, from_obj, data)
|
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-12-07 02:34:59 +00:00
|
|
|
def msg_contents(self, message, exclude=None, from_obj=None, data=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
|
|
|
Emits something to all objects inside an object.
|
2009-01-18 02:40:57 +00:00
|
|
|
|
2010-12-07 02:34:59 +00: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
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
contents = self.contents
|
|
|
|
|
if exclude:
|
|
|
|
|
if not is_iter(exclude):
|
|
|
|
|
exclude = [exclude]
|
|
|
|
|
contents = [obj for obj in contents
|
|
|
|
|
if (obj not in exclude and obj not in exclude)]
|
|
|
|
|
for obj in contents:
|
2010-12-07 02:34:59 +00:00
|
|
|
obj.msg(message, from_obj=from_obj, data=data)
|
2010-08-29 18:46:58 +00:00
|
|
|
|
2010-12-07 02:34:59 +00:00
|
|
|
def emit_to_contents(self, message, exclude=None, from_obj=None, data=None):
|
2010-08-29 18:46:58 +00:00
|
|
|
"Deprecated. Alias for msg_contents"
|
2011-03-15 16:08:32 +00:00
|
|
|
logger.log_depmsg("emit_to_contents() is deprecated. Use msg_contents() instead.")
|
2010-12-07 02:34:59 +00:00
|
|
|
self.msg_contents(message, exclude=exclude, from_obj=from_obj, data=data)
|
2010-08-29 18:46:58 +00:00
|
|
|
|
|
|
|
|
def move_to(self, destination, quiet=False,
|
|
|
|
|
emit_to_obj=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
|
|
|
Moves this object to a new location.
|
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-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
|
|
|
|
|
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
|
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
|
|
|
errtxt = "Couldn't perform move ('%s'). Contact an admin."
|
|
|
|
|
if not emit_to_obj:
|
|
|
|
|
emit_to_obj = self
|
|
|
|
|
|
|
|
|
|
if not destination:
|
|
|
|
|
emit_to_obj.msg("The destination doesn't exist.")
|
|
|
|
|
return
|
2011-04-08 23:10:04 +00:00
|
|
|
if destination.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:
|
|
|
|
|
emit_to_obj.msg(errtxt % "at_before_move()")
|
|
|
|
|
logger.log_trace()
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
# Save the old location
|
|
|
|
|
source_location = self.location
|
|
|
|
|
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
|
|
|
|
|
if self.home:
|
|
|
|
|
source_location = self.home
|
|
|
|
|
else:
|
2011-04-12 21:43:57 +00:00
|
|
|
default_home_id = ServerConfig.objects.conf("default_home")
|
2010-08-29 18:46:58 +00:00
|
|
|
default_home = ObjectDB.objects.get_id(default_home_id)
|
|
|
|
|
source_location = default_home
|
|
|
|
|
|
|
|
|
|
# Call hook on source location
|
|
|
|
|
try:
|
|
|
|
|
source_location.at_object_leave(self, destination)
|
|
|
|
|
except Exception:
|
|
|
|
|
emit_to_obj.msg(errtxt % "at_object_leave()")
|
|
|
|
|
logger.log_trace()
|
|
|
|
|
return False
|
2009-12-20 20:51:26 +00: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:
|
2010-08-29 18:46:58 +00:00
|
|
|
self.announce_move_from(destination)
|
|
|
|
|
except Exception:
|
|
|
|
|
emit_to_obj.msg(errtxt % "at_announce_move()" )
|
|
|
|
|
logger.log_trace()
|
2011-04-24 11:26:51 +00:00
|
|
|
return False
|
|
|
|
|
|
2009-10-24 03:49:14 +00:00
|
|
|
# Perform move
|
2010-08-29 18:46:58 +00:00
|
|
|
try:
|
|
|
|
|
self.location = destination
|
|
|
|
|
except Exception:
|
|
|
|
|
emit_to_obj.msg(errtxt % "location change")
|
|
|
|
|
logger.log_trace()
|
|
|
|
|
return False
|
2009-09-19 15:18:42 +00: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-10-24 03:49:14 +00: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:
|
|
|
|
|
emit_to_obj.msg(errtxt % "announce_move_to()")
|
|
|
|
|
logger.log_trace()
|
|
|
|
|
return False
|
|
|
|
|
|
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:
|
|
|
|
|
emit_to_obj.msg(errtxt % "at_after_move()")
|
|
|
|
|
logger.log_trace()
|
|
|
|
|
return False
|
|
|
|
|
|
2009-10-25 15:25:15 +00:00
|
|
|
# Perform eventual extra commands on the receiving location
|
2009-12-20 20:51:26 +00:00
|
|
|
try:
|
2010-08-29 18:46:58 +00:00
|
|
|
destination.at_object_receive(self, source_location)
|
|
|
|
|
except Exception:
|
|
|
|
|
emit_to_obj.msg(errtxt % "at_obj_receive()")
|
|
|
|
|
logger.log_trace()
|
|
|
|
|
return False
|
2009-12-20 20:51:26 +00:00
|
|
|
|
2009-08-16 01:18:58 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
#
|
|
|
|
|
# Object Swap, Delete and Cleanup methods
|
|
|
|
|
#
|
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
|
|
|
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-02-14 17:18:31 +00:00
|
|
|
for out_exit in self.exits:
|
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
|
|
|
|
|
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)
|
2011-04-12 21:43:57 +00:00
|
|
|
default_home_id = int(ServerConfig.objects.conf('default_home'))
|
2010-08-29 18:46:58 +00:00
|
|
|
try:
|
|
|
|
|
default_home = ObjectDB.objects.get(id=default_home_id)
|
|
|
|
|
except Exception:
|
|
|
|
|
string = "Could not find default home '(#%d)'."
|
|
|
|
|
logger.log_errmsg(string % default_home_id)
|
|
|
|
|
default_home = None
|
|
|
|
|
|
|
|
|
|
for obj in objs:
|
|
|
|
|
home = obj.home
|
|
|
|
|
# Obviously, we can't send it back to here.
|
|
|
|
|
if home and home.id == self.id:
|
|
|
|
|
home = default_home
|
|
|
|
|
|
|
|
|
|
# If for some reason it's still None...
|
|
|
|
|
if not home:
|
|
|
|
|
string = "Missing default home, '%s(#%d)' "
|
|
|
|
|
string += "now has a null location."
|
|
|
|
|
logger.log_errmsg(string % (obj.name, obj.id))
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if self.has_player:
|
|
|
|
|
if home:
|
|
|
|
|
string = "Your current location has ceased to exist,"
|
|
|
|
|
string += " moving you to %s(#%d)."
|
|
|
|
|
obj.msg(string % (home.name, home.id))
|
|
|
|
|
else:
|
|
|
|
|
# Famous last words: The player should never see this.
|
|
|
|
|
string = "This place should not exist ... contact an admin."
|
|
|
|
|
obj.msg(string)
|
|
|
|
|
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):
|
|
|
|
|
"""
|
|
|
|
|
Makes an identical copy of this object and returns
|
|
|
|
|
it. The copy will be named <key>_copy by default. If you
|
|
|
|
|
want to customize the copy by changing some settings, use
|
|
|
|
|
the manager method copy_object directly.
|
|
|
|
|
"""
|
|
|
|
|
if not new_key:
|
|
|
|
|
new_key = "%s_copy" % self.key
|
|
|
|
|
return ObjectDB.objects.copy_object(self, new_key=new_key)
|
|
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
def delete(self):
|
2009-10-14 18:15:15 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
Deletes this object.
|
|
|
|
|
Before deletion, this method makes sure to move all contained
|
|
|
|
|
objects to their respective home locations, as well as clean
|
|
|
|
|
up all exits to/from the object.
|
2009-05-01 15:34:43 +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
|
|
|
|
|
# is kicked into gear.
|
2009-10-20 22:21:01 +00:00
|
|
|
return False
|
2009-05-01 15:34:43 +00:00
|
|
|
|
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
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
for session in self.sessions:
|
2011-04-23 11:54:08 +00:00
|
|
|
session.msg("Your character %s has been destroyed." % self.name)
|
|
|
|
|
#session.session_disconnect()
|
|
|
|
|
|
|
|
|
|
# sever the connection (important!)
|
|
|
|
|
if object.__getattribute__(self, 'player') and self.player:
|
|
|
|
|
self.player.character = None
|
|
|
|
|
self.player = None
|
2011-04-07 22:10:51 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
# if self.player:
|
|
|
|
|
# self.player.user.is_active = False
|
|
|
|
|
# self.player.user.save()
|
|
|
|
|
|
|
|
|
|
# Destroy any exits to and from this room, if any
|
|
|
|
|
self.clear_exits()
|
|
|
|
|
# Clear out any non-exit objects located within the object
|
|
|
|
|
self.clear_contents()
|
|
|
|
|
# Perform the deletion of the object
|
|
|
|
|
super(ObjectDB, self).delete()
|
|
|
|
|
return True
|