diff --git a/src/commands/default/general.py b/src/commands/default/general.py index 3714b22053..a26925bead 100644 --- a/src/commands/default/general.py +++ b/src/commands/default/general.py @@ -735,9 +735,11 @@ class CmdOOCLook(MuxCommandOOC, CmdLook): "Hook method for when an argument is given." # caller is assumed to be a player object here. caller = self.caller - looktarget = caller.get_character(key=self.args) + key = self.args.lower() + chars = dict((utils.to_str(char.key.lower()), char) for char in caller.db._playable_characters) + looktarget = chars.get(key) if looktarget: - caller.msg(looktarget.return_appearance()) + caller.msg(looktarget.return_appearance(caller)) else: caller.msg("No such character.") return @@ -748,24 +750,22 @@ class CmdOOCLook(MuxCommandOOC, CmdLook): player = self.caller sessid = self.sessid # get all our characters - characters = player.get_all_characters() # get all characters + characters = player.db._playable_characters string = "You are logged in as {g%s{n." % player.key string += " Use {w@ic {n to enter the game." - string += "\n\nAvailable character%s:" % (len(characters) > 1 and "s" or "") - for char in characters: - csessid = char.sessid - if csessid: - # character is already puppeted - if csessid == sessid: - # this should not happen. - string += "\n - {r%s{n (sessid not properly cleared! Contact an admin!)" % char.key - elif player.get_session(csessid): - string += "\n - {G%s{n (played by you in another session)" + if characters: + string += "\n\nAvailable character%s:" % (len(characters) > 1 and "s" or "") + for char in characters: + csessid = char.sessid + if csessid: + # character is already puppeted + if player.get_session(csessid): + string += "\n - {G%s{n (played by you in another session)" + else: + string += "\n - {R%s{n (played by someone else)" % char.key else: - string += "\n - {R%s{n (played by someone else)" % char.key - else: - # character is "free to puppet" - string += "\n - %s" % char.key + # character is "free to puppet" + string += "\n - %s" % char.key player.msg(string) def func(self): @@ -802,10 +802,7 @@ class CmdCharCreate(MuxCommandOOC): return key = self.lhs desc = self.rhs - if not player.db._created_chars: - lockstring = "attrread:perm(Admins);attredit:perm(Admins);attrcreate:perm(Admins)" - player.set_attribute("_created_chars", [], lockstring=lockstring) - if len(player.db._created_chars) >= self.MAX_NR_CHARACTERS: + if player.db._playeable_characters and len(player.db._playable_characters) >= self.MAX_NR_CHARACTERS: player.msg("You may only create a maximum of %i characters." % self.MAX_NR_CHARACTERS) return # create the character @@ -817,7 +814,7 @@ class CmdCharCreate(MuxCommandOOC): new_character = create.create_object(typeclass, key=key, location=default_home, home=default_home, permissions=permissions) - player.db._created_chars.append(new_character) + player.db._playable_characters.append(new_character) if desc: new_character.db.desc = desc player.msg("Created new character %s." % new_character.key) diff --git a/src/commands/default/system.py b/src/commands/default/system.py index 8cb1aa3835..412b721755 100644 --- a/src/commands/default/system.py +++ b/src/commands/default/system.py @@ -156,7 +156,7 @@ class CmdPy(MuxCommand): 'ev':ev, 'inherits_from':utils.inherits_from} - caller.msg(">>> %s" % pycode, data={"raw":True}) + caller.msg(">>> %s" % pycode, data={"raw":True}, sessid=self.sessid) mode = "eval" try: @@ -185,7 +185,7 @@ class CmdPy(MuxCommand): ret = "\n".join("{n<<< %s" % line for line in errlist if line) if ret != None: - caller.msg(ret) + caller.msg(ret, sessid=self.sessid) # helper function. Kept outside so it can be imported and run # by other commands. diff --git a/src/commands/default/unloggedin.py b/src/commands/default/unloggedin.py index 1d0c1bfd23..e9a3d09df4 100644 --- a/src/commands/default/unloggedin.py +++ b/src/commands/default/unloggedin.py @@ -161,15 +161,19 @@ class CmdUnconnectedCreate(MuxCommand): permissions = settings.PERMISSION_PLAYER_DEFAULT try: - new_character = create.create_player(playername, None, password, - permissions=permissions, - character_typeclass=typeclass, - character_location=default_home, - character_home=default_home) + new_player = create.create_player(playername, None, password, + permissions=permissions) + + # create character to go with player + new_character = create_object(character_typeclass, key=name, + location=default_home, home=default_home, + permissions=permissions) + # set list + new_player.db._playable_characters.append(new_character) + except Exception: - session.msg("There was an error creating the default Character/Player:\n%s\n If this problem persists, contact an admin.") + session.msg("There was an error creating the default Player/Character:\n%s\n If this problem persists, contact an admin.") return - new_player = new_character.player # This needs to be called so the engine knows this player is logging in for the first time. # (so it knows to call the right hooks during login later) diff --git a/src/players/player.py b/src/players/player.py index 58b2899990..84977cfb57 100644 --- a/src/players/player.py +++ b/src/players/player.py @@ -246,8 +246,9 @@ class Player(TypeClass): to store attributes all players should have, like configuration values etc. """ - pass - + # set an attribute holding the characters this player has + lockstring = "attrread:perm(Admins);attredit:perm(Admins);attrcreate:perm(Admins)" + self.set_attribute("_playable_characters", [], lockstring=lockstring) def at_init(self): """ diff --git a/src/server/initial_setup.py b/src/server/initial_setup.py index 8df3d3686b..98ef0c9d37 100644 --- a/src/server/initial_setup.py +++ b/src/server/initial_setup.py @@ -52,10 +52,8 @@ def create_objects(): # exists. Also, all properties (name, email, password, is_superuser) # is inherited from the user so we don't specify it again here. - god_character = create.create_player(god_user.username, None, None, - user=god_user, - create_character=True, - character_typeclass=character_typeclass) + god_player = create.create_player(god_user.username, None, None, user=god_user) + god_character = create.create_object(character_typeclass, key=god_user.username) god_character.id = 1 god_character.db.desc = _('This is User #1.') @@ -83,6 +81,8 @@ def create_objects(): god_character.location = limbo_obj if not god_character.home: god_character.home = limbo_obj + # store in list as playable character + god_player.db._playable_characters.append(god_character) def create_channels(): """ diff --git a/src/utils/create.py b/src/utils/create.py index 49cf593b85..45b467c403 100644 --- a/src/utils/create.py +++ b/src/utils/create.py @@ -53,7 +53,7 @@ _GA = object.__getattribute__ # def create_object(typeclass, key=None, location=None, - home=None, player=None, permissions=None, locks=None, + home=None, permissions=None, locks=None, aliases=None, destination=None, report_to=None): """ Create a new in-game object. Any game object is a combination @@ -116,11 +116,6 @@ def create_object(typeclass, key=None, location=None, # from now on we can use the typeclass object # as if it was the database object. - if player: - # link a player and the object together - new_object.player = player - player.obj = new_object - new_object.destination = destination # call the hook method. This is where all at_creation @@ -397,11 +392,8 @@ def create_player(name, email, password, typeclass=None, is_superuser=False, locks=None, permissions=None, - create_character=True, character_typeclass=None, - character_location=None, character_home=None, player_dbobj=None, report_to=None): - """ This creates a new player, handling the creation of the User object and its associated Player object. @@ -510,17 +502,6 @@ def create_player(name, email, password, if locks: new_player.locks.add(locks) - # create *in-game* 'player' object - if create_character: - if not character_typeclass: - character_typeclass = settings.BASE_CHARACTER_TYPECLASS - # creating the object automatically links the player - # and object together by player.obj <-> obj.player - new_character = create_object(character_typeclass, key=name, - location=character_location, home=character_location, - permissions=permissions, - player=new_player, report_to=report_to) - return new_character return new_player except Exception: # a failure in creating the character