From ea4c30a0b1f30a3bd0a09be2be5c8ff400321f06 Mon Sep 17 00:00:00 2001 From: Griatch Date: Tue, 9 Apr 2013 22:44:05 +0200 Subject: [PATCH] Added a convenience property player.character that will return the (puppeted) Object if in MULTISESSION_MODE 0 or 1, all puppeted Objects for MULTISESSION_MODE=2. Note that this is not quite the same as the old player.character - it will only return a character if that character is actually puppeted (the old scheme returned it also if the Player was offline). --- src/commands/default/muxcommand.py | 4 ++-- src/players/models.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/commands/default/muxcommand.py b/src/commands/default/muxcommand.py index 29a8906a98..c75cbf2a17 100644 --- a/src/commands/default/muxcommand.py +++ b/src/commands/default/muxcommand.py @@ -187,8 +187,8 @@ class MuxCommandOOC(MuxCommand): # caller is an Object/Character self.character = self.caller self.caller = self.caller.player - elif hasattr(self.caller, "character"): + elif utils.inherits_from(self.caller, "src.players.players.Player"): # caller was already a Player - self.character = self.caller.get_character(sessid=self.sessid) + self.character = self.caller.get_puppet(self.sessid) else: self.character = None diff --git a/src/players/models.py b/src/players/models.py index 1a77f7f750..b5b156a13d 100644 --- a/src/players/models.py +++ b/src/players/models.py @@ -484,6 +484,18 @@ class PlayerDB(TypedObject): return puppets return [puppet.typeclass for puppet in puppets] + def __get_single_puppet(self): + """ + This is a legacy convenience link for users of + MULTISESSION_MODE 0 or 1. It will return + only the first puppet. For mode 2, this returns + a list of all characters. + """ + puppets = self.get_all_puppets() + if _MULTISESSION_MODE in (0, 1): + return puppets and puppets[0] or None + return puppets + character = property(__get_single_puppet) # utility methods