Adding a new API system to Evennia. This centralizes all access of the evennia driver through a single module "ev". Importing ev one should be able to access (and also importantly, easily explore) Evennia's API much easier. This API goes a long way to "flatten" the structure so that one doesn't need to remember how to find some method in a deeply nested subdirectory.
As part of this work, I have also written full listings of all available properties on Typeclassed objects (including those inherited in various ways). Should hopefully make things easier to find. One can of course still import things directly from src/ as before. But this is a first step towards removing the "base" objects in game/gamesrc and instead making those accessible through the core API.
This commit is contained in:
parent
7a2cdd3842
commit
0d01462077
24 changed files with 519 additions and 93 deletions
|
|
@ -0,0 +1,12 @@
|
|||
"""
|
||||
Makes it easier to import by grouping all relevant things already at this level.
|
||||
|
||||
You can henceforth import most things directly from src.player
|
||||
Also, the initiated object manager is available as src.players.manager.
|
||||
|
||||
"""
|
||||
|
||||
from src.players.player import *
|
||||
from src.players.models import PlayerDB
|
||||
|
||||
manager = PlayerDB.objects
|
||||
|
|
@ -18,33 +18,73 @@ class Player(TypeClass):
|
|||
"""
|
||||
Base typeclass for all Players.
|
||||
"""
|
||||
def __init__(self, dbobj):
|
||||
"""
|
||||
This is the base Typeclass for all Players. Players represent
|
||||
the person playing the game and tracks account info, password
|
||||
etc. They are OOC entities without presence in-game. A Player
|
||||
can connect to a Character Object in order to "enter" the
|
||||
game.
|
||||
|
||||
## available properties
|
||||
Player Typeclass API:
|
||||
|
||||
# key (string) - name of player
|
||||
# name (string)- wrapper for user.username
|
||||
# aliases (list of strings) - aliases to the object. Will be saved to database as AliasDB entries but returned as strings.
|
||||
# dbref (int, read-only) - unique #id-number. Also "id" can be used.
|
||||
# dbobj (Player, read-only) - link to database model. dbobj.typeclass points back to this class
|
||||
# typeclass (Player, read-only) - this links back to this class as an identified only. Use self.swap_typeclass() to switch.
|
||||
# date_created (string) - time stamp of object creation
|
||||
# permissions (list of strings) - list of permission strings
|
||||
* Available properties (only available on initiated typeclass objects)
|
||||
|
||||
# user (User, read-only) - django User authorization object
|
||||
# obj (Object) - game object controlled by player. 'character' can also be used.
|
||||
# sessions (list of Sessions) - sessions connected to this player
|
||||
# is_superuser (bool, read-only) - if the connected user is a superuser
|
||||
key (string) - name of player
|
||||
name (string)- wrapper for user.username
|
||||
aliases (list of strings) - aliases to the object. Will be saved to database as AliasDB entries but returned as strings.
|
||||
dbref (int, read-only) - unique #id-number. Also "id" can be used.
|
||||
dbobj (Player, read-only) - link to database model. dbobj.typeclass points back to this class
|
||||
typeclass (Player, read-only) - this links back to this class as an identified only. Use self.swap_typeclass() to switch.
|
||||
date_created (string) - time stamp of object creation
|
||||
permissions (list of strings) - list of permission strings
|
||||
|
||||
user (User, read-only) - django User authorization object
|
||||
obj (Object) - game object controlled by player. 'character' can also be used.
|
||||
sessions (list of Sessions) - sessions connected to this player
|
||||
is_superuser (bool, read-only) - if the connected user is a superuser
|
||||
|
||||
* Handlers
|
||||
|
||||
locks - lock-handler: use locks.add() to add new lock strings
|
||||
db - attribute-handler: store/retrieve database attributes on this self.db.myattr=val, val=self.db.myattr
|
||||
ndb - non-persistent attribute handler: same as db but does not create a database entry when storing data
|
||||
scripts - script-handler. Add new scripts to object with scripts.add()
|
||||
cmdset - cmdset-handler. Use cmdset.add() to add new cmdsets to object
|
||||
nicks - nick-handler. New nicks with nicks.add().
|
||||
|
||||
## Handlers
|
||||
* Helper methods
|
||||
|
||||
msg(outgoing_string, from_obj=None, data=None)
|
||||
swap_character(new_character, delete_old_character=False)
|
||||
execute_cmd(raw_string)
|
||||
search(ostring, global_search=False, attribute_name=None, use_nicks=False, location=None, ignore_errors=False, player=False)
|
||||
is_typeclass(typeclass, exact=False)
|
||||
swap_typeclass(new_typeclass, clean_attributes=False, no_default=True)
|
||||
access(accessing_obj, access_type='read', default=False)
|
||||
check_permstring(permstring)
|
||||
|
||||
* Hook methods
|
||||
|
||||
basetype_setup()
|
||||
at_player_creation()
|
||||
|
||||
- note that the following hooks are also found on Objects and are
|
||||
usually handled on the character level:
|
||||
|
||||
at_init()
|
||||
at_cmdset_get()
|
||||
at_first_login()
|
||||
at_post_login()
|
||||
at_disconnect()
|
||||
at_message_receive()
|
||||
at_message_send()
|
||||
at_server_reload()
|
||||
at_server_shutdown()
|
||||
|
||||
"""
|
||||
super(Player, self).__init__(dbobj)
|
||||
|
||||
# locks - lock-handler: use locks.add() to add new lock strings
|
||||
# db - attribute-handler: store/retrieve database attributes on this self.db.myattr=val, val=self.db.myattr
|
||||
# ndb - non-persistent attribute handler: same as db but does not create a database entry when storing data
|
||||
# scripts - script-handler. Add new scripts to object with scripts.add()
|
||||
# cmdset - cmdset-handler. Use cmdset.add() to add new cmdsets to object
|
||||
# nicks - nick-handler. New nicks with nicks.add().
|
||||
|
||||
|
||||
## methods inherited from database model
|
||||
|
||||
def msg(self, outgoing_string, from_obj=None, data=None):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue