mirror of
https://github.com/evennia/evennia.git
synced 2026-04-02 14:07:16 +02:00
Starting the move of typeclass methods off *DB models and onto the typeclasses.
This commit is contained in:
parent
9321573c23
commit
0b5e2b94ff
6 changed files with 21 additions and 21 deletions
|
|
@ -169,8 +169,8 @@ class Channel(ChannelDB):
|
|||
this channel, and sending them a message.
|
||||
"""
|
||||
# get all players connected to this channel and send to them
|
||||
for player in self.dbobj.db_subscriptions.all():
|
||||
player = player.typeclass
|
||||
for player in self.db_subscriptions.all():
|
||||
player = player
|
||||
try:
|
||||
# note our addition of the from_channel keyword here. This could be checked
|
||||
# by a custom player.msg() to treat channel-receives differently.
|
||||
|
|
@ -222,7 +222,7 @@ class Channel(ChannelDB):
|
|||
msgobj = TempMsg()
|
||||
msgobj.header = header
|
||||
msgobj.message = msg
|
||||
msgobj.channels = [self.dbobj] # add this channel
|
||||
msgobj.channels = [self] # add this channel
|
||||
|
||||
if not msgobj.senders:
|
||||
msgobj.senders = senders
|
||||
|
|
|
|||
|
|
@ -121,9 +121,9 @@ class Msg(SharedMemoryModel):
|
|||
#@property
|
||||
def __senders_get(self):
|
||||
"Getter. Allows for value = self.sender"
|
||||
return list(self.db_sender_players.all()) +
|
||||
list(self.db_sender_objects.all()) +
|
||||
self.extra_senders]
|
||||
return list(self.db_sender_players.all()) + \
|
||||
list(self.db_sender_objects.all()) + \
|
||||
self.extra_senders
|
||||
|
||||
#@sender.setter
|
||||
def __senders_set(self, value):
|
||||
|
|
|
|||
|
|
@ -547,7 +547,7 @@ class ObjectDB(TypedObject):
|
|||
except Exception:
|
||||
logger.log_trace()
|
||||
try:
|
||||
if not self.at_msg_receive(text=text, **kwargs)
|
||||
if not self.at_msg_receive(text=text, **kwargs):
|
||||
# if at_msg_receive returns false, we abort message to this object
|
||||
return
|
||||
except Exception:
|
||||
|
|
|
|||
|
|
@ -123,8 +123,8 @@ class Player(PlayerDB):
|
|||
a command on a Character, the character automatically stores and
|
||||
handles the sessid).
|
||||
kwargs - extra data to send through protocol
|
||||
"""
|
||||
self.dbobj.msg(text=text, from_obj=from_obj, sessid=sessid, **kwargs)
|
||||
"""
|
||||
self.msg(text=text, from_obj=from_obj, sessid=sessid, **kwargs)
|
||||
|
||||
def swap_character(self, new_character, delete_old_character=False):
|
||||
"""
|
||||
|
|
@ -135,7 +135,7 @@ class Player(PlayerDB):
|
|||
|
||||
Returns: True/False depending on if swap suceeded or not.
|
||||
"""
|
||||
return self.dbobj.swap_character(new_character, delete_old_character=delete_old_character)
|
||||
return self.swap_character(new_character, delete_old_character=delete_old_character)
|
||||
|
||||
def execute_cmd(self, raw_string, sessid=None, **kwargs):
|
||||
"""
|
||||
|
|
@ -163,7 +163,7 @@ class Player(PlayerDB):
|
|||
be useful for coders intending to implement some sort of nested
|
||||
command structure.
|
||||
"""
|
||||
return self.dbobj.execute_cmd(raw_string, sessid=sessid, **kwargs)
|
||||
return self.execute_cmd(raw_string, sessid=sessid, **kwargs)
|
||||
|
||||
def search(self, searchdata, return_puppet=False, **kwargs):
|
||||
"""
|
||||
|
|
@ -183,7 +183,7 @@ class Player(PlayerDB):
|
|||
# handle wrapping of common terms
|
||||
if searchdata.lower() in ("me", "*me", "self", "*self",):
|
||||
return self
|
||||
return self.dbobj.search(searchdata, return_puppet=return_puppet, **kwargs)
|
||||
return self.search(searchdata, return_puppet=return_puppet, **kwargs)
|
||||
|
||||
def is_typeclass(self, typeclass, exact=False):
|
||||
"""
|
||||
|
|
@ -200,7 +200,7 @@ class Player(PlayerDB):
|
|||
|
||||
Returns: Boolean
|
||||
"""
|
||||
return self.dbobj.is_typeclass(typeclass, exact=exact)
|
||||
return self.is_typeclass(typeclass, exact=exact)
|
||||
|
||||
def swap_typeclass(self, new_typeclass, clean_attributes=False, no_default=True):
|
||||
"""
|
||||
|
|
@ -235,7 +235,7 @@ class Player(PlayerDB):
|
|||
boolean True/False depending on if the swap worked or not.
|
||||
|
||||
"""
|
||||
self.dbobj.swap_typeclass(new_typeclass,
|
||||
self.swap_typeclass(new_typeclass,
|
||||
clean_attributes=clean_attributes, no_default=no_default)
|
||||
|
||||
def access(self, accessing_obj, access_type='read', default=False, **kwargs):
|
||||
|
|
@ -248,7 +248,7 @@ class Player(PlayerDB):
|
|||
default (bool) - what to return if no lock of access_type was found
|
||||
**kwargs - passed to the at_access hook along with the result.
|
||||
"""
|
||||
result = self.dbobj.access(accessing_obj, access_type=access_type, default=default)
|
||||
result = self.access(accessing_obj, access_type=access_type, default=default)
|
||||
self.at_access(result, accessing_obj, access_type, **kwargs)
|
||||
return result
|
||||
|
||||
|
|
@ -261,7 +261,7 @@ class Player(PlayerDB):
|
|||
on the object. (example: 'Builders')
|
||||
Note that this method does -not- call the at_access hook.
|
||||
"""
|
||||
return self.dbobj.check_permstring(permstring)
|
||||
return self.check_permstring(permstring)
|
||||
|
||||
## player hooks
|
||||
|
||||
|
|
|
|||
|
|
@ -115,18 +115,18 @@ class ServerSession(Session):
|
|||
if self.logged_in:
|
||||
sessid = self.sessid
|
||||
player = self.player
|
||||
_GA(player.dbobj, "unpuppet_object")(sessid)
|
||||
uaccount = player.dbobj
|
||||
player.unpuppet_object(sessid)
|
||||
uaccount = player
|
||||
uaccount.last_login = datetime.now()
|
||||
uaccount.save()
|
||||
# calling player hook
|
||||
_GA(player.typeclass, "at_disconnect")()
|
||||
player.at_disconnect()
|
||||
self.logged_in = False
|
||||
if not self.sessionhandler.sessions_from_player(player):
|
||||
# no more sessions connected to this player
|
||||
player.is_connected = False
|
||||
# this may be used to e.g. delete player after disconnection etc
|
||||
_GA(player.typeclass, "at_post_disconnect")()
|
||||
player.at_post_disconnect()
|
||||
|
||||
def get_player(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ def returns_typeclass(method):
|
|||
def func(self, *args, **kwargs):
|
||||
self.__doc__ = method.__doc__
|
||||
query = method(self, *args, **kwargs)
|
||||
return list(query)[0] if query else None
|
||||
return query
|
||||
return update_wrapper(func, method)
|
||||
|
||||
# Managers
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue