def func(self): "create the new character" session = self.session player = self.account args = self.args if not args: session.msg({"alert": _("You should give the character a name.")}) return name = args["name"] if not name: session.msg({"alert": _("Name should not be empty.")}) return # sanity checks if not (0 < len(name) <= 30): # Nickname's length string = "\n\r Name can max be 30 characters or fewer." session.msg({"alert": string}) return # strip excessive spaces in playername nickname = re.sub(r"\s+", " ", name).strip() charmax = settings.MAX_NR_CHARACTERS if settings.MULTISESSION_MODE > 1 else 1 if player.db._playable_characters and len( player.db._playable_characters) >= charmax: session.msg({ "alert": _("You may only create a maximum of %i characters.") % charmax }) return if utils.search_db_data_type("nickname", name, settings.BASE_PLAYER_CHARACTER_TYPECLASS): # check if this name already exists. session.msg({ "alert": _("{rA character named '{w%s{r' already exists.{n") % name }) return try: create_character(player, name) except Exception as e: # We are in the middle between logged in and -not, so we have # to handle tracebacks ourselves at this point. If we don't, # we won't see any errors at all. session.msg( {"alert": _("There was an error creating the Player: %s" % e)}) logger.log_trace() return session.msg({ "char_created": True, "char_all": player.get_all_characters() })
def func(self): "create the new character" session = self.session player = self.account args = self.args if not args: session.msg({"alert":_("You should give the character a name.")}) return name = args["name"] if not name: session.msg({"alert":_("Name should not be empty.")}) return # sanity checks if not (0 < len(name) <= 30): # Nickname's length string = "\n\r Name can max be 30 characters or fewer." session.msg({"alert":string}) return # strip excessive spaces in playername nickname = re.sub(r"\s+", " ", name).strip() charmax = settings.MAX_NR_CHARACTERS if settings.MULTISESSION_MODE > 1 else 1 if player.db._playable_characters and len(player.db._playable_characters) >= charmax: session.msg({"alert":_("You may only create a maximum of %i characters.") % charmax}) return if utils.search_db_data_type("nickname", name, settings.BASE_PLAYER_CHARACTER_TYPECLASS): # check if this name already exists. session.msg({"alert":_("{rA character named '{w%s{r' already exists.{n") % name}) return try: create_character(player, name) except Exception, e: # We are in the middle between logged in and -not, so we have # to handle tracebacks ourselves at this point. If we don't, # we won't see any errors at all. session.msg({"alert":_("There was an error creating the Player: %s" % e)}) logger.log_trace() return