def equipment_command(actor, *args, **kwargs): from settings.game import ACTOR_EQUIPMENT_LOCATIONS from utils.ansi import Ansi # FIXME Make this actually look up items. for location in ACTOR_EQUIPMENT_LOCATIONS: list_name = location.get("list_name", location.get("uid")) show_if_empty = location.get("show_if_empty", True) if show_if_empty: output = "" output += Ansi.pad_right(("{{G<{{C{}{{G>".format(list_name)), 14) output += " {xNothing" actor.echo(output)
def pad_right(message, length, symbol=" "): stripped = Ansi.decolorize(message) return message + (symbol * max(0, length - len(stripped)))
def who_command(actor, game, *args, **kwargs): from utils.ansi import Ansi actor.echo("""\ {G The Visible Mortals and Immortals of Waterdeep {g-----------------------------------------------------------------------------\ """) total_count = 0 visible_count = 0 chars = list(game.query_characters()) for other in sorted(chars, key=get_who_level_value, reverse=True): total_count += 1 if not actor.can_see(other): continue visible_count += 1 output = "{x" if other.who_level: output += Ansi.pad_right(other.who_level, 4) elif other.has_role("admin"): output += "{RIMP{x " elif other.has_role("builder"): output += "{GCRE{x " elif other.has_role("immortal"): output += "{GIMM{x " elif other.is_hero(): output += "{BHRO{x " else: output += Ansi.pad_left("{x" + str(other.level) + "{x", 3) + " " if other.who: output += Ansi.pad_right(other.who, 18) + "{x" else: if other.who_gender: output += Ansi.pad_right(other.who_gender, 2) else: output += other.format_who_gender() + " " output += "{x" if other.who_race: output += Ansi.pad_right(other.who_race, 6) else: output += Ansi.pad_right(other.format_who_race(), 6) output += "{x" if other.who_class: output += Ansi.pad_right(other.who_class, 4) else: output += Ansi.pad_right(other.format_who_class(), 4) output += "{x" if other.who_clan: output += Ansi.pad_right(other.who_clan, 6) else: output += Ansi.pad_right(other.format_who_clan(), 6) output += "{x" if other.who_flags: flags_length = 10 if other.has_role("immortal") else 8 output += "[" + Ansi.pad_right(other.who_flags, flags_length, ".") + "{x]" elif other.has_role("immortal"): output += "[..........]" else: output += "[........]" output += "{x " output += other.name if other.title: output += " " + other.title if other.bracket: output += " {x[" + other.bracket + "{x]" faction = other.get_faction() if faction: output += " " + faction.format_who_display() actor.echo(output) highest_count = total_count actor.echo() actor.echo( "{{GPlayers found{{g: {{x{} {{GTotal online{{g: {{W{} {{GMost on today{{g: {{x{}" .format( visible_count, total_count, highest_count, ))
def write(self, message=""): if self.color: message = Ansi.colorize(message) self.output_buffer += message