Non-working intermediary commit.
This commit is contained in:
parent
261454ff0a
commit
8b5938ddd0
2 changed files with 44 additions and 8 deletions
|
|
@ -176,6 +176,9 @@ class ObjectDB(TypedObject):
|
|||
# If this is a character object, the player is connected here.
|
||||
db_player = models.ForeignKey("players.PlayerDB", blank=True, null=True, verbose_name='player',
|
||||
help_text='a Player connected to this object, if any.')
|
||||
# the session id associated with this player, if any
|
||||
db_sessid = models.IntegerField(null=True, verbose_name="session id",
|
||||
help_text="unique session id of connected Player, if any."
|
||||
# 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.
|
||||
|
|
@ -191,7 +194,6 @@ class ObjectDB(TypedObject):
|
|||
# database storage of persistant cmdsets.
|
||||
db_cmdset_storage = models.CharField('cmdset', max_length=255, null=True, blank=True,
|
||||
help_text="optional python path to a cmdset class.")
|
||||
|
||||
# Database manager
|
||||
objects = ObjectManager()
|
||||
|
||||
|
|
@ -260,6 +262,30 @@ class ObjectDB(TypedObject):
|
|||
del_field_cache(self, "player")
|
||||
player = property(__player_get, __player_set, __player_del)
|
||||
|
||||
# sessid property (wraps db_sessid)
|
||||
#@property
|
||||
def __sessid_get(self):
|
||||
"""
|
||||
Getter. Allows for value = self.sessid. Since sessid
|
||||
is directly related to self.player, we cannot have
|
||||
a sessid without a player being connected (but the
|
||||
opposite could be true).
|
||||
"""
|
||||
if not get_field_cache(self, "player"):
|
||||
del_field_cache(self, "sessid")
|
||||
return get_field_cache(self, "sessid")
|
||||
|
||||
#@player.setter
|
||||
def __sessid_set(self, player):
|
||||
"Setter. Allows for self.player = value"
|
||||
if inherits_from(player, TypeClass):
|
||||
player = player.dbobj
|
||||
set_field_cache(self, "player", player)
|
||||
#@player.deleter
|
||||
def __player_del(self):
|
||||
"Deleter. Allows for del self.player"
|
||||
del_field_cache(self, "player")
|
||||
player = property(__player_get, __player_set, __player_del)
|
||||
# location property (wraps db_location)
|
||||
#@property
|
||||
def __location_get(self):
|
||||
|
|
|
|||
|
|
@ -387,7 +387,7 @@ class PlayerDB(TypedObject):
|
|||
for sess in _GA(self, 'get_sessions'):
|
||||
sess.msg(outgoing_string, data)
|
||||
|
||||
def inmsg(self, ingoing_string, data, session):
|
||||
def inmsg(self, ingoing_string, data, sessid):
|
||||
"""
|
||||
This is the reverse of msg - used by sessions to relay
|
||||
messages/data back into the game. It is normally not called
|
||||
|
|
@ -395,16 +395,21 @@ class PlayerDB(TypedObject):
|
|||
|
||||
ingoing_string - text string (i.e. command string)
|
||||
data - dictionary of optional data
|
||||
sessid - session sending this data
|
||||
session - session sending this data
|
||||
"""
|
||||
character = _GA(self, "get_character")(session.sessid)
|
||||
character = _GA(self, "get_character")(sessid)
|
||||
if character:
|
||||
# execute command on character
|
||||
character.execute_cmd(ingoing_string)
|
||||
_GA(character, "execute_cmd")(ingoing_string)
|
||||
else:
|
||||
# a non-character session; this goes to player directly
|
||||
self.execute_cmd(ingoing_message)
|
||||
_GA(self, "execute_cmd")(ingoing_string)
|
||||
|
||||
def connect_session(self, sessid):
|
||||
"""
|
||||
Connect session to this player to a session through
|
||||
its session id.
|
||||
"""
|
||||
|
||||
def get_sessions(self, sessid=None):
|
||||
"""
|
||||
|
|
@ -436,8 +441,10 @@ class PlayerDB(TypedObject):
|
|||
|
||||
def connect_character(self, character, sessid):
|
||||
"""
|
||||
Use the Player to connect a Character to a session. Note
|
||||
that we don't do any access checks at this point.
|
||||
Use the Player to connect a Character to a session. Note that
|
||||
we don't do any access checks at this point. Note that if the
|
||||
game was fully restarted (including the Portal), this must be
|
||||
used, since sessids will have changed as players reconnect.
|
||||
"""
|
||||
character = character.dbobj
|
||||
character.player = self
|
||||
|
|
@ -456,6 +463,9 @@ class PlayerDB(TypedObject):
|
|||
character.sessid = None
|
||||
self.save()
|
||||
|
||||
def disconnect_all_characters(self):
|
||||
for char in self.db_objs.all():
|
||||
|
||||
def swap_character(self, new_character, delete_old_character=False):
|
||||
"""
|
||||
Swaps character, if possible
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue