Continued work on multi-char-per-account. Added a new default login point. Still need to add sessid to commands.

This commit is contained in:
Griatch 2013-02-02 15:55:42 +01:00
parent b50266623e
commit 231af4a351
5 changed files with 120 additions and 50 deletions

View file

@ -649,7 +649,12 @@ class CmdAccess(MuxCommand):
string += "\nPlayer {c%s{n: %s" % (caller.player.key, pperms)
caller.msg(string)
#------------------------------------------------------------
# OOC commands
#------------------------------------------------------------
class CmdOOCLook(MuxCommandOOC, CmdLook):
"""
@ -658,28 +663,67 @@ class CmdOOCLook(MuxCommandOOC, CmdLook):
Usage:
look
This is an OOC version of the look command. Since a
Player doesn't have an in-game existence, there is no
concept of location or "self". If we are controlling
a character, pass control over to normal look.
Look in the ooc state.
"""
#This is an OOC version of the look command. Since a
#Player doesn't have an in-game existence, there is no
#concept of location or "self". If we are controlling
#a character, pass control over to normal look.
key = "look"
aliases = ["l", "ls"]
locks = "cmd:all()"
help_category = "General"
def look_target(self):
"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)
if looktarget:
caller.msg(looktarget.return_appearance())
else:
caller.msg("No such character.")
return
def no_look_target(self):
"Hook method for default look without a specified target"
# caller is always a player at this point.
player = self.caller
sessid = self.sessid
# get all our characters
characters = player.get_all_characters() # get all 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:" % (characters.count() > 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)"
else:
string += "\n - {R%s{n (played by someone else)" % char.key
else:
# character is "free to puppet"
string += "\n - %s" % char.key
player.msg(string)
def func(self):
"implement the ooc look command"
if not self.character:
string = "You are out-of-character (OOC). "
string += "Use {w@ic{n to get back to the game, {whelp{n for more info."
self.caller.msg(string)
else:
self.caller = self.character # we have to put this back for normal look to work.
if utils.inherits_from(self.caller, "src.objects.objects.Object"):
# An object of some type is calling. Use default look instead.
super(CmdOOCLook, self).func()
elif self.args:
self.look_target()
else:
self.no_look_target()
class CmdIC(MuxCommandOOC):
"""