Rename all instances of Player->Account.

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

View file

@ -1,6 +1,6 @@
"""
This sub-package holds the Scripts system. Scripts are database
entities that can store data both in connection to Objects and Players
entities that can store data both in connection to Objects and Accounts
or globally. They may also have a timer-component to execute various
timed effects.

View file

@ -49,20 +49,20 @@ class ScriptDBManager(TypedObjectManager):
"""
if not obj:
return []
player = _GA(_GA(obj, "__dbclass__"), "__name__") == "PlayerDB"
account = _GA(_GA(obj, "__dbclass__"), "__name__") == "AccountDB"
if key:
dbref = self.dbref(key)
if dbref or dbref == 0:
if player:
return self.filter(db_player=obj, id=dbref)
if account:
return self.filter(db_account=obj, id=dbref)
else:
return self.filter(db_obj=obj, id=dbref)
elif player:
return self.filter(db_player=obj, db_key=key)
elif account:
return self.filter(db_account=obj, db_key=key)
else:
return self.filter(db_obj=obj, db_key=key)
elif player:
return self.filter(db_player=obj)
elif account:
return self.filter(db_account=obj)
else:
return self.filter(db_obj=obj)

View file

@ -15,13 +15,13 @@ cleaning whatever effect they have had on the game object.
Common examples of uses of Scripts:
- Load the default cmdset to the player object's cmdhandler
- Load the default cmdset to the account object's cmdhandler
when logging in.
- Switch to a different state, such as entering a text editor,
start combat or enter a dark room.
- Merge a new cmdset with the default one for changing which
commands are available at a particular time
- Give the player/object a time-limited bonus/effect
- Give the account/object a time-limited bonus/effect
"""
from builtins import object
@ -62,7 +62,7 @@ class ScriptDB(TypedObject):
The ScriptDB adds the following properties:
desc - optional description of script
obj - the object the script is linked to, if any
player - the player the script is linked to (exclusive with obj)
account - the account the script is linked to (exclusive with obj)
interval - how often script should run
start_delay - if the script should start repeating right away
repeats - how many times the script should repeat
@ -122,18 +122,18 @@ class ScriptDB(TypedObject):
def __get_obj(self):
"""
Property wrapper that homogenizes access to either the
db_player or db_obj field, using the same object property
db_account or db_obj field, using the same object property
name.
"""
obj = _GA(self, "db_player")
obj = _GA(self, "db_account")
if not obj:
obj = _GA(self, "db_obj")
return obj
def __set_obj(self, value):
"""
Set player or obj to their right database field. If
Set account or obj to their right database field. If
a dbref is given, assume ObjectDB.
"""
@ -153,8 +153,8 @@ class ScriptDB(TypedObject):
except ObjectDoesNotExist:
# maybe it is just a name that happens to look like a dbid
pass
if value.__class__.__name__ == "PlayerDB":
fname = "db_player"
if value.__class__.__name__ == "AccountDB":
fname = "db_account"
_SA(self, fname, value)
else:
fname = "db_obj"

View file

@ -66,9 +66,9 @@ class ScriptHandler(object):
autostart (bool, optional): Start the script upon adding it.
"""
if self.obj.__dbclass__.__name__ == "PlayerDB":
# we add to a Player, not an Object
script = create.create_script(scriptclass, key=key, player=self.obj,
if self.obj.__dbclass__.__name__ == "AccountDB":
# we add to an Account, not an Object
script = create.create_script(scriptclass, key=key, account=self.obj,
autostart=autostart)
else:
# the normal - adding to an Object