Fixed initial_setup and set up the _playable_characters attribute on all players, for handling multi-accounts. Still some issues with how the character's permissions is accessed.

This commit is contained in:
Griatch 2013-02-03 20:04:40 +01:00
parent 70b8f074f1
commit b82a75d816
6 changed files with 40 additions and 57 deletions

View file

@ -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 <character>{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)

View file

@ -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.

View file

@ -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)