def drink(self, caller): # TODO: Make this use a more generic def consume """Response to drinking the object.""" if not self.locks.check_lockstring(caller, 'holds()'): msg = "You are not holding %s." % self.get_display_name( caller.sessions) caller.msg(msg) return False finish = '' if self.traits.health.actual: self.traits.health.current -= 1 if self.traits.health.actual < 1: finish = ', finishing it' # self.location = None # Leaves empty container. else: finish = ', finishing it' self.location = None caller.location.msg_contents('{caller} takes a drink of {drink}%s.' % finish, from_obj=caller, mapping=dict(char=caller, drink=self)) def drink_callback(caller, prompt, user_input): """"Response to input given after drink potion""" msg = "%s begins to have an effect on %s, transforming into species %s." %\ (self.get_display_name(caller.sessions), caller.get_display_name(caller.sessions), user_input) caller.location.msg_contents(msg) caller.db.species = user_input[0:20].strip() get_input( caller, "Species? (Type your species setting now, and then [enter]) ", drink_callback) return True
def drink(self, caller): # TODO: Make this use a more generic def consume """Response to drinking the object.""" if not self.locks.check_lockstring(caller, 'holds()'): msg = "You are not holding %s." % self.get_display_name(caller.sessions) caller.msg(msg) return False finish = '' if self.traits.health.actual: self.traits.health.current -= 1 if self.traits.health.actual < 1: finish = ', finishing it' # self.location = None # Leaves empty container. else: finish = ', finishing it' self.location = None caller.location.msg_contents('{caller} takes a drink of {drink}%s.' % finish, from_obj=caller, mapping=dict(char=caller, drink=self)) def drink_callback(caller, prompt, user_input): """"Response to input given after drink potion""" msg = "%s begins to have an effect on %s, transforming into species %s." %\ (self.get_display_name(caller.sessions), caller.get_display_name(caller.sessions), user_input) caller.location.msg_contents(msg) caller.db.species = user_input[0:20].strip() get_input(caller, "Species? (Type your species setting now, and then [enter]) ", drink_callback) return True
def drink(self, caller): # TODO: Make this use a more generic def consume """Response to drinking the object.""" if not self.locks.check_lockstring(caller, 'holds()'): msg = "You are not holding %s." % self.full_name(caller.sessions) caller.msg(msg) return False finish = '' if self.attributes.has('health'): self.db.health -= 1 if self.db.health < 1: finish = ', finishing it' # self.location = None # Leaves empty container. else: finish = ', finishing it' self.location = None msg = "%s takes a drink of %s%s." % (caller.full_name(caller.sessions), self.full_name(caller.sessions), finish) caller.location.msg_contents(msg) def drink_callback(caller, prompt, user_input): """"Response to input given after drink potion""" msg = "%s begins to have an effect on %s, transforming into species %s." % (self.full_name(caller.sessions), caller.full_name(caller.sessions), user_input) caller.location.msg_contents(msg) caller.db.species = user_input[0:20].strip() get_input(caller, "Species? (Type your species setting now, and then [enter]) ", drink_callback)
def func(self): caller = self.caller args = self.args.strip() leader = caller.db.party_leader if not args: if not leader: caller.msg("Ты и так не состоишь в группе.") return leader_search = caller.search(leader, global_search=True,nofound_string="Такого лидера нет.") if not leader_search: return leader_search.db.party.remove(caller.key) caller.db.party_leader = None caller.msg("Ты вышел из группы лидера %s." % leader_search.key) leader_search.msg("Из твой группы вышел %s" % caller.key) return leader_to_follow = caller.search(args, location=caller.location, global_search=True,nofound_string="Такого игрока нет.") if not leader_to_follow: return if not leader_to_follow.has_player: caller.msg("Игрок %s не в сети. Ты пока не можешь присоединиться к нему." % leader_to_follow.key) return get_input(leader_to_follow, "Игрок %s хочет к вам присоединиться, ты согласен? (Да/Нет)" % caller.key, self.yesno) caller.msg("Ты подал запрос на вступление в группу. Жди пока %s ответит." % leader_to_follow.key)
def drink(self, caller): # TODO: Make this use a more generic def consume """Response to drinking the object.""" if not self.locks.check_lockstring(caller, 'holds()'): msg = "You are not holding %s." % self.full_name(caller.sessions) caller.msg(msg) return False finish = '' if self.attributes.has('health'): self.db.health -= 1 if self.db.health < 1: finish = ', finishing it' # self.location = None # Leaves empty container. else: finish = ', finishing it' self.location = None msg = "%s takes a drink of %s%s." % (caller.full_name( caller.sessions), self.full_name(caller.sessions), finish) caller.location.msg_contents(msg) def drink_callback(caller, prompt, user_input): """"Response to input given after drink potion""" msg = "%s begins to have an effect on %s, transforming into species %s." % ( self.full_name(caller.sessions), caller.full_name(caller.sessions), user_input) caller.location.msg_contents(msg) caller.db.species = user_input[0:20].strip() get_input( caller, "Species? (Type your species setting now, and then [enter]) ", drink_callback)
def func(self): """Add the description.""" char = self.character here = None if char is None else char.location opt = self.switches target = here if 'room' in opt else char if not here and 'room' in opt: self.caller.msg( "You cannot edit the location's description while |y@OOC|n and outside the room." " Switch to |y@IC|n first.") return if not target.access(char, 'edit'): self.caller.msg("You don't have permission to edit {}.".format( target.get_display_name(char))) return self.target = target if 'edit' in opt: self.edit_handler() return if not self.args: if 'brief' in opt: self.caller.msg( "You must supply a brief description (65 characters or less) to describe yourself." ) return def desc_callback(caller, prompt, user_input): """"Response to input given after description is set""" if not user_input.strip(): self.caller.msg( '|yNo description given - |wcurrent description unchanged.' ) return msg = "{}'s appearance begins to change." contents = caller.location.contents for obj in contents: obj.msg(msg.format(target.get_display_name(obj))) if 'side' in opt: caller.db.desc_side = user_input.strip() elif 'room' in opt: target.db.desc = user_input.strip() else: caller.db.desc = user_input.strip() get_input( char, "Type a description for {} now, and then |g[enter]|n: ".format( target.get_display_name(char)), desc_callback) return if 'brief' in opt: self.caller.db.desc_brief = self.args[0:65].strip() self.caller.msg("Your brief description has been saved: %s" % self.caller.db.desc_brief) return if 'side' in opt: char.db.desc_side = self.args else: target.db.desc = self.args char.msg('You successfully described {}.'.format( target.get_display_name(char)))
def func(self): """delete the character""" account = self.account if not self.args: self.msg("Utilisation : supprimer <nom du personnage>") return # use the playable_characters list to search match = [ char for char in utils.make_iter(account.db._playable_characters) if char.key.lower() == self.args.lower() ] if not match: self.msg("Aucun personnage ne corresponds.") return elif len(match) > 1: self.msg("Annulation - Vous avez deux personnages du même nom. " "Demandez à un administrateur de supprimer le bon.") return else: # one match from evennia.utils.evmenu import get_input def _callback(caller, callback_prompt, result): if result.lower() == "oui": # only take action delobj = caller.ndb._char_to_delete key = delobj.key caller.db._playable_characters = [ pc for pc in caller.db._playable_characters if pc != delobj ] delobj.delete() self.msg(f"Le personnage '{key}' a été supprimé de " f"manière permanente.") logger.log_sec( "Character Deleted: %s (Caller: %s, IP: %s)." % (key, account, self.session.address)) else: self.msg("La suppression de personnage à été annulée.") del caller.ndb._char_to_delete match = match[0] account.ndb._char_to_delete = match # Return if caller has no permission to delete this if not match.access(account, "delete"): self.msg( "Vous n'avez pas la permission de supprimer ce personnage." ) return prompt = ( f"|rCeci va supprimer de manière permanente '{match.key}'. " f"Ce personnage ne pourra pas être récupéré.\n" f"|nContinuer oui/[non]?") get_input(account, prompt, _callback)
def MailTo(self, caller, prompt, user_input): target = search.search_object(user_input, typeclass="typeclasses.characters.Character") if len(target) == 0: caller.msg("SYSTEM: That didn't match a player. Confirm the player's name and try again.") elif len(target) > 1: caller.msg("SYSTEM: That matched several players. Maybe try an alias?") else: caller.ndb.mailtarget = target[0] get_input(self.caller, "SYSTEM: What is the subject of this mail?", self.MailSubject) return True
def func(self): """delete the character""" account = self.account if not self.args: self.msg("Usage: chardelete <charactername>") return # use the playable_characters list to search match = [ char for char in utils.make_iter(account.db._playable_characters) if char.key.lower() == self.args.lower() ] if not match: self.msg("You have no such character to delete.") return elif len(match) > 1: self.msg( "Aborting - there are two characters with the same name. Ask an admin to delete the right one." ) return else: # one match from evennia.utils.evmenu import get_input def _callback(caller, callback_prompt, result): if result.lower() == "yes": # only take action delobj = caller.ndb._char_to_delete key = delobj.key caller.db._playable_characters = [ pc for pc in caller.db._playable_characters if pc != delobj ] delobj.delete() self.msg("Character '%s' was permanently deleted." % key) logger.log_sec( "Character Deleted: %s (Caller: %s, IP: %s)." % (key, account, self.session.address)) else: self.msg("Deletion was aborted.") del caller.ndb._char_to_delete match = match[0] account.ndb._char_to_delete = match # Return if caller has no permission to delete this if not match.access(account, "delete"): self.msg( "You do not have permission to delete this character.") return prompt = ( "|rThis will permanently destroy '%s'. This cannot be undone.|n Continue yes/[no]?" ) get_input(account, prompt % match.key, _callback)
def addMorph(caller, prompt, result): args = result.strip() args = args[:12] # Do we already have this key used? if args in caller.db.morph.keys(): sysemit(caller, "The morph name '{}' already in use!".format(args)) return else: caller.ndb.mname = args evmenu.get_input(caller, "Enter a short description for this form (32 chars or less):", descMorph) return True
def func(self): """Allow account or character to submit short and/or long suggestions.""" char = self.character here = char.location or 'the Void' account = self.account args = self.args.strip() where = self.obj def suggest_callback(caller, prompt, user_input): """"Response to input given after suggestion submitted""" if len(user_input.strip()) < 1: here.msg_contents( "%s%s|n discards the full suggestion intended for %s%s|n." % (char.STYLE, char.key, where.STYLE, where.key)) account.msg( "Long suggestion discarded. Only the topic or short suggestion was given to %s." % where.get_display_name(account)) return # Abort the suggestion. here.msg_contents("%s%s|n pops a suggestion into %s%s|n." % (char.STYLE, char.key, where.STYLE, where.key)) # List structure to allow multiple suggestions to be saved. (By account and character name) answer = [ account.get_display_name(account), char.get_display_name(account), user_input[0:355].strip() ] if where.db.suggestions: suggestions = list(where.db.suggestions) where.db.suggestions = suggestions + answer else: where.db.suggestions = answer topic = args[0:80].strip() if topic: topic_answer = [ account.get_display_name(account), char.get_display_name(account), topic ] if where.db.suggestions: suggestions1 = list(where.db.suggestions) where.db.suggestions = suggestions1 + topic_answer else: where.db.suggestions = topic_answer msg = '%s%s|n begins writing a suggestion for %s%s|n regarding "|w%s|n".' %\ (char.STYLE, char.key, where.STYLE, where.key, topic) else: msg = "%s%s|n begins writing a suggestion for %s%s|n regarding no specific topic." % \ (char.STYLE, char.key, where.STYLE, where.key) here.msg_contents(msg) get_input( char, "|wSuggestion?|n (Type your suggestion now (300 characters or less)," " and then |g[enter]|n) ", suggest_callback)
def func(self): caller = self.caller args = self.args.strip().lower() race = caller.db.race if race in ALL_RACES: get_input( caller, "You have already selected your race, do you wish to change it? (Yes/No)?", self.choice) else: apply_race(caller, args)
def func(self): caller = self.caller args = self.args.strip() switch = next(iter(self.switches or []), None) #Initialize the character's db attribute if it isn't there. if not caller.db.morph: caller.db.morph = {} # Handle switches. These are all passed onto other functions. if switch == "add": evmenu.get_input(caller, "Enter a one word label for this morph (12 Chars or less).", addMorph) return elif switch == "del": if args in caller.db.morph.keys(): del caller.db.morph[args] sysemit(caller, "Morph {} deleted.".format(args)) return else: sysemit(caller, "No morph by the name {} found to delete.".format(args)) return elif switch is not None: sysemit(caller, "Switch {} not understood.".format(switch)) return # Now to morph or not to morph? if args: if args in caller.db.morph.keys(): # We're morphing. Unpack. attr_dict = caller.db.morph[args] for attr in attr_dict.keys(): setattr(caller.db, attr, attr_dict[attr]) del caller.db.mdesc sysemit(caller, "Morphed to {}.".format(args)) return else: # Not a valid morph. sysemit(caller, "Morph '{}' not found.".format(args)) return else: caller.msg(header("Morph")) table = evtable.EvTable("|gKey:|n", "|cDescription:|n", width=74, align="l", valign="t", border="none") table.reformat_column(0, width=14) for name in caller.db.morph.keys(): unpack = caller.db.morph[name] table.add_row("|G" + name + "|n", "|C" + unpack.get("mdesc", "none") + "|n") caller.msg(table) caller.msg(footer()) return
def func(self): """Add the description.""" char = self.character if 'edit' in self.switches: self.edit_handler() return if not self.args: if 'brief' in self.switches: self.caller.msg( "You must supply a brief description (65 characters or less) to describe yourself." ) return def desc_callback(caller, prompt, user_input): """"Response to input given after description is set""" if not user_input.strip(): self.caller.msg( '|yNo description given - |wcurrent description unchanged.' ) return msg = "%s's appearance begins to change." % self.character.get_display_name( caller.sessions) contents = caller.location.contents for obj in contents: obj.msg(msg) if 'side' in self.switches: caller.db.desc_side = user_input.strip() else: caller.db.desc = user_input.strip() get_input(char, "Type your description now, and then |g[enter]|n: ", desc_callback) return if 'brief' in self.switches: self.caller.db.desc_brief = self.args[0:65].strip() self.caller.msg("Your brief description has been saved: %s" % self.caller.db.desc_brief) return if 'side' in self.switches: char.db.desc_side = self.args else: char.db.desc = self.args char.msg('You successfully set your description.')
def func(self): "delete the character" player = self.player if not self.args: self.msg("Usage: @chardelete <charactername>") return # use the playable_characters list to search match = [ char for char in utils.make_iter(player.db._playable_characters) if char.key.lower() == self.args.lower() ] if not match: self.msg("You have no such character to delete.") return elif len(match) > 1: self.msg( "Aborting - there are two characters with the same name. Ask an admin to delete the right one." ) return else: # one match from evennia.utils.evmenu import get_input def _callback(caller, prompt, result): if result.lower() == "yes": # only take action delobj = caller.ndb._char_to_delete key = delobj.key caller.db._playable_characters = [ char for char in caller.db._playable_characters if char != delobj ] delobj.delete() caller.msg("Character '%s' was permanently deleted." % key) else: caller.msg("Deletion was aborted.") del caller.ndb._char_to_delete match = match[0] player.ndb._char_to_delete = match prompt = "|rThis will permanently destroy '%s'. This cannot be undone.|n Continue yes/[no]?" get_input(player, prompt % match.key, _callback)
def func(self): """Allow account or character to submit short and/or long suggestions.""" char = self.character here = char.location or 'the Void' account = self.account args = self.args.strip() where = self.obj def suggest_callback(caller, prompt, user_input): """"Response to input given after suggestion submitted""" if len(user_input.strip()) < 1: here.msg_contents("%s%s|n discards the full suggestion intended for %s%s|n." % (char.STYLE, char.key, where.STYLE, where.key)) account.msg("Long suggestion discarded. Only the topic or short suggestion was given to %s." % where.get_display_name(account)) return # Abort the suggestion. here.msg_contents("%s%s|n pops a suggestion into %s%s|n." % (char.STYLE, char.key, where.STYLE, where.key)) # List structure to allow multiple suggestions to be saved. (By account and character name) answer = [account.get_display_name(account), char.get_display_name(account), user_input[0:355].strip()] if where.db.suggestions: suggestions = list(where.db.suggestions) where.db.suggestions = suggestions + answer else: where.db.suggestions = answer topic = args[0:80].strip() if topic: topic_answer = [account.get_display_name(account), char.get_display_name(account), topic] if where.db.suggestions: suggestions1 = list(where.db.suggestions) where.db.suggestions = suggestions1 + topic_answer else: where.db.suggestions = topic_answer msg = '%s%s|n begins writing a suggestion for %s%s|n regarding "|w%s|n".' %\ (char.STYLE, char.key, where.STYLE, where.key, topic) else: msg = "%s%s|n begins writing a suggestion for %s%s|n regarding no specific topic." % \ (char.STYLE, char.key, where.STYLE, where.key) here.msg_contents(msg) get_input(char, "|wSuggestion?|n (Type your suggestion now (300 characters or less)," " and then |g[enter]|n) ", suggest_callback)
def func(self): if not self.args: get_input(self.caller, "SYSTEM: Who are you sending mail to?", self.MailTo) else: target = search.search_object(self.args.split('/')[0], typeclass="typeclasses.characters.Character") title = self.args.split('/')[1].split('=')[0] message = self.args.split('/')[1].split('=',1)[1] if len(target) == 0: caller.msg("SYSTEM: That didn't match a player. Confirm the player's name and try again.") elif len(target) > 1: caller.msg("SYSTEM: That matched several players. Maybe try an alias?") else: target = target[0] temp = [ self.caller.key, title, message, datetime.now() ] target.db.mailsystem.append(temp) self.caller.msg("Sent your mail to {0}".format(target.key)) msg = "{0}/{1}: New mail from {2} about {3}.".format(temp[3].month, temp[3].day, self.caller.key, temp[1]) target.db.notifications.append(msg) if target.has_player: target.msg("SYSTEM: You have pending notifications.")
def func(self): """delete the character""" account = self.account if not self.args: self.msg("Usage: @chardelete <charactername>") return # use the playable_characters list to search match = [char for char in utils.make_iter(account.db._playable_characters) if char.key.lower() == self.args.lower()] if not match: self.msg("You have no such character to delete.") return elif len(match) > 1: self.msg("Aborting - there are two characters with the same name. Ask an admin to delete the right one.") return else: # one match from evennia.utils.evmenu import get_input def _callback(caller, callback_prompt, result): if result.lower() == "yes": # only take action delobj = caller.ndb._char_to_delete key = delobj.key caller.db._playable_characters = [pc for pc in caller.db._playable_characters if pc != delobj] delobj.delete() self.msg("Character '%s' was permanently deleted." % key) else: self.msg("Deletion was aborted.") del caller.ndb._char_to_delete match = match[0] account.ndb._char_to_delete = match prompt = "|rThis will permanently destroy '%s'. This cannot be undone.|n Continue yes/[no]?" get_input(account, prompt % match.key, _callback)
def func(self): """Add the description.""" char = self.character if 'edit' in self.switches: self.edit_handler() return if not self.args: if 'brief' in self.switches: self.caller.msg("You must supply a brief description (65 characters or less) to describe yourself.") return def desc_callback(caller, prompt, user_input): """"Response to input given after description is set""" if not user_input.strip(): self.caller.msg('|yNo description given - |wcurrent description unchanged.') return msg = "%s's appearance begins to change." % self.character.get_display_name(caller.sessions) contents = caller.location.contents for obj in contents: obj.msg(msg) if 'side' in self.switches: caller.db.desc_side = user_input.strip() else: caller.db.desc = user_input.strip() get_input(char, "Type your description now, and then |g[enter]|n: ", desc_callback) return if 'brief' in self.switches: self.caller.db.desc_brief = self.args[0:65].strip() self.caller.msg("Your brief description has been saved: %s" % self.caller.db.desc_brief) return if 'side' in self.switches: char.db.desc_side = self.args else: char.db.desc = self.args char.msg('You successfully set your description.')