contrib/chargen.py code cleaning, update markup

Also remove commented code and redundant code
This commit is contained in:
BlauFeuer 2017-02-16 21:21:20 -05:00 committed by GitHub
parent b1be4ade62
commit 9b391fbe6b

View file

@ -37,6 +37,7 @@ from evennia import default_cmds, managers
CHARACTER_TYPECLASS = settings.BASE_CHARACTER_TYPECLASS CHARACTER_TYPECLASS = settings.BASE_CHARACTER_TYPECLASS
class CmdOOCLook(default_cmds.CmdLook): class CmdOOCLook(default_cmds.CmdLook):
""" """
ooc look ooc look
@ -96,7 +97,6 @@ class CmdOOCLook(default_cmds.CmdLook):
return return
# not inspecting a character. Show the OOC info. # not inspecting a character. Show the OOC info.
charobjs = []
charnames = [] charnames = []
if self.caller.db._character_dbrefs: if self.caller.db._character_dbrefs:
dbrefs = self.caller.db._character_dbrefs dbrefs = self.caller.db._character_dbrefs
@ -104,18 +104,18 @@ class CmdOOCLook(default_cmds.CmdLook):
charnames = [charobj.key for charobj in charobjs if charobj] charnames = [charobj.key for charobj in charobjs if charobj]
if charnames: if charnames:
charlist = "The following Character(s) are available:\n\n" charlist = "The following Character(s) are available:\n\n"
charlist += "\n\r".join(["{w %s{n" % charname for charname in charnames]) charlist += "\n\r".join(["|w %s|n" % charname for charname in charnames])
charlist += "\n\n Use {w@ic <character name>{n to switch to that Character." charlist += "\n\n Use |w@ic <character name>|n to switch to that Character."
else: else:
charlist = "You have no Characters." charlist = "You have no Characters."
string = \ string = \
""" You, %s, are an {wOOC ghost{n without form. The world is hidden """ You, %s, are an |wOOC ghost|n without form. The world is hidden
from you and besides chatting on channels your options are limited. from you and besides chatting on channels your options are limited.
You need to have a Character in order to interact with the world. You need to have a Character in order to interact with the world.
%s %s
Use {wcreate <name>{n to create a new character and {whelp{n for a Use |wcreate <name>|n to create a new character and |whelp|n for a
list of available commands.""" % (self.caller.key, charlist) list of available commands.""" % (self.caller.key, charlist)
self.caller.msg(string) self.caller.msg(string)
@ -160,13 +160,13 @@ class CmdOOCCharacterCreate(Command):
charname = self.args.strip() charname = self.args.strip()
old_char = managers.objects.get_objs_with_key_and_typeclass(charname, CHARACTER_TYPECLASS) old_char = managers.objects.get_objs_with_key_and_typeclass(charname, CHARACTER_TYPECLASS)
if old_char: if old_char:
self.caller.msg("Character {c%s{n already exists." % charname) self.caller.msg("Character |c%s|n already exists." % charname)
return return
# create the character # create the character
new_character = create_object(CHARACTER_TYPECLASS, key=charname) new_character = create_object(CHARACTER_TYPECLASS, key=charname)
if not new_character: if not new_character:
self.caller.msg("{rThe Character couldn't be created. This is a bug. Please contact an admin.") self.caller.msg("|rThe Character couldn't be created. This is a bug. Please contact an admin.")
return return
# make sure to lock the character to only be puppeted by this player # make sure to lock the character to only be puppeted by this player
new_character.locks.add("puppet:id(%i) or pid(%i) or perm(Immortals) or pperm(Immortals)" % new_character.locks.add("puppet:id(%i) or pid(%i) or perm(Immortals) or pperm(Immortals)" %
@ -179,7 +179,7 @@ class CmdOOCCharacterCreate(Command):
else: else:
avail_chars = [new_character.id] avail_chars = [new_character.id]
self.caller.db._character_dbrefs = avail_chars self.caller.db._character_dbrefs = avail_chars
self.caller.msg("{gThe Character {c%s{g was successfully created!" % charname) self.caller.msg("|gThe Character |c%s|g was successfully created!" % charname)
class OOCCmdSetCharGen(default_cmds.PlayerCmdSet): class OOCCmdSetCharGen(default_cmds.PlayerCmdSet):
@ -187,7 +187,6 @@ class OOCCmdSetCharGen(default_cmds.PlayerCmdSet):
Extends the default OOC cmdset. Extends the default OOC cmdset.
""" """
def at_cmdset_creation(self): def at_cmdset_creation(self):
"Install everything from the default set, then overload" """Install everything from the default set, then overload"""
#super(OOCCmdSetCharGen, self).at_cmdset_creation()
self.add(CmdOOCLook()) self.add(CmdOOCLook())
self.add(CmdOOCCharacterCreate()) self.add(CmdOOCCharacterCreate())