Change default at_pre_puppet for characters

No longer move character "back onto the grid" when not in None location.
This allows for Character objects to be moved while unpuppeted and remain
where placed when puppeted again.

Also updates markup in code within this module.
This commit is contained in:
BlauFeuer 2017-02-01 17:59:16 -05:00 committed by Griatch
parent 3e6e773939
commit 1ed5a0b4a6

View file

@ -1347,18 +1347,18 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
if con.destination: if con.destination:
exits.append(key) exits.append(key)
elif con.has_player: elif con.has_player:
users.append("{c%s{n" % key) users.append("|c%s|n" % key)
else: else:
things.append(key) things.append(key)
# get description, build string # get description, build string
string = "{c%s{n\n" % self.get_display_name(looker) string = "|c%s|n\n" % self.get_display_name(looker)
desc = self.db.desc desc = self.db.desc
if desc: if desc:
string += "%s" % desc string += "%s" % desc
if exits: if exits:
string += "\n{wExits:{n " + ", ".join(exits) string += "\n|wExits:|n " + ", ".join(exits)
if users or things: if users or things:
string += "\n{wYou see:{n " + ", ".join(users + things) string += "\n|wYou see:|n " + ", ".join(users + things)
return string return string
def at_look(self, target): def at_look(self, target):
@ -1486,26 +1486,19 @@ class DefaultCharacter(DefaultObject):
def at_pre_puppet(self, player, session=None): def at_pre_puppet(self, player, session=None):
""" """
This implementation recovers the character again after having been "stoved Return the character from storage in None location in `at_post_unpuppet`.
away" to the `None` location in `at_post_unpuppet`.
Args: Args:
player (Player): This is the connecting player. player (Player): This is the connecting player.
session (Session): Session controlling the connection. session (Session): Session controlling the connection.
""" """
if self.db.prelogout_location: if self.location is None: # Make sure character's location is never None before being puppeted.
# try to recover # Return to last location (or home, which should always exist).
self.location = self.db.prelogout_location self.location = self.db.prelogout_location if self.db.prelogout_location else self.home
if self.location is None: if self.location: # If the character is verified to be somewhere,
# make sure location is never None (home should always exist) self.db.prelogout_location = self.location # save location again to be sure
self.location = self.home self.location.at_object_receive(self, self.location) # and trigger the location's reception hook.
if self.location:
# save location again to be sure
self.db.prelogout_location = self.location
self.location.at_object_receive(self, self.location)
else: else:
player.msg("{r%s has no location and no home is set.{n" % self, session=session) player.msg("|r%s has no location and no home is set.|n" % self, session=session) # Note to set home.
def at_post_puppet(self): def at_post_puppet(self):
""" """
@ -1519,7 +1512,7 @@ class DefaultCharacter(DefaultObject):
puppeting this Object. puppeting this Object.
""" """
self.msg("\nYou become {c%s{n.\n" % self.name) self.msg("\nYou become |c%s|n.\n" % self.name)
self.msg(self.at_look(self.location)) self.msg(self.at_look(self.location))
def message(obj, from_obj): def message(obj, from_obj):