Skip to content

Commit

Permalink
contrib/chargen.py code cleaning, update markup
Browse files Browse the repository at this point in the history
Also remove commented code and redundant code
  • Loading branch information
BlauFeuer committed Feb 17, 2017
1 parent b1be4ad commit 9b391fb
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions evennia/contrib/chargen.py
Expand Up @@ -37,6 +37,7 @@

CHARACTER_TYPECLASS = settings.BASE_CHARACTER_TYPECLASS


class CmdOOCLook(default_cmds.CmdLook):
"""
ooc look
Expand Down Expand Up @@ -96,26 +97,25 @@ def func(self):
return

# not inspecting a character. Show the OOC info.
charobjs = []
charnames = []
if self.caller.db._character_dbrefs:
dbrefs = self.caller.db._character_dbrefs
charobjs = [managers.objects.get_id(dbref) for dbref in dbrefs]
charnames = [charobj.key for charobj in charobjs if charobj]
if charnames:
charlist = "The following Character(s) are available:\n\n"
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\r".join(["|w %s|n" % charname for charname in charnames])
charlist += "\n\n Use |w@ic <character name>|n to switch to that Character."
else:
charlist = "You have no Characters."
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.
You need to have a Character in order to interact with the world.
%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)
self.caller.msg(string)

Expand Down Expand Up @@ -160,13 +160,13 @@ def func(self):
charname = self.args.strip()
old_char = managers.objects.get_objs_with_key_and_typeclass(charname, CHARACTER_TYPECLASS)
if old_char:
self.caller.msg("Character {c%s{n already exists." % charname)
self.caller.msg("Character |c%s|n already exists." % charname)
return
# create the character

new_character = create_object(CHARACTER_TYPECLASS, key=charname)
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
# 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)" %
Expand All @@ -179,15 +179,14 @@ def func(self):
else:
avail_chars = [new_character.id]
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):
"""
Extends the default OOC cmdset.
"""
def at_cmdset_creation(self):
"Install everything from the default set, then overload"
#super(OOCCmdSetCharGen, self).at_cmdset_creation()
"""Install everything from the default set, then overload"""
self.add(CmdOOCLook())
self.add(CmdOOCCharacterCreate())

0 comments on commit 9b391fb

Please sign in to comment.