def show_subordinates(self, *args): """Lists subordinates by species.""" print_header('SUBORDINATES') print(f' Master: {self.name}\n') for i in self.subordinates_generator(output_mode=True): print(i)
def craft_item(self, args): """ Craft item if have necessary material. In in-game command, if not specify amount, will show recipe than ask for amount. Args: arg str: User input, item to craft and amount. Usage: > craft full potion > craft full potion 10 """ try: item, craft_amount = parse_input(args) except: craft_amount = None item = args item = self.get_object(item, new=True) if item is None: return if item.object_type != 'item': return # 'craft full potion 2', or 'craft full potion' to show recipe then input amount. if craft_amount is None: # Shows recipe. recipe = '' print_header('CRAFTING', 5) print(f" Recipe for [{item.name}]:") for ingredient, amount in item.recipe.items(): recipe += F" {amount}x {ingredient}, " print(f" {recipe[:-2]}") # [:-2] will cuts off trailing comma and space. print(f"\n Inputting 1 will craft {item.quantity_add}. 0 cancel.\n") # Asks for how much to make. note that some items are crafted in batches. try: craft_amount = int(input("Craft > ")) except ValueError: gprint("< Error: need integer input >") return False # Let's player enter 0 to cancel. if craft_amount <= 0: return False # Checks if have all the ingredients. for ingredient_name, ingredient_amount in item.recipe.items(): if self.check_acquired(ingredient_name, ingredient_amount * craft_amount): continue gprint("< Missing Ingredient(s) >") return False # Removes ingredients then adds new crafted item to inventory for ingredient_name, ingredient_amount in item.recipe.items(): self.remove_inventory(ingredient_name, ingredient_amount * craft_amount) self.add_inventory(item, craft_amount) return True
def show_mimics(self, *args): """Lists acquired mimicries by species.""" print_header('MIMICRIES') for mob_rank, mobs in self.acquired_mimicries.items(): print(f' {mob_rank}:') for mob_name, _mob_obj in mobs.items(): print(f' {mob_name}') print("\n Note: Reset mimic with 'mimic reset'.")
def show_inventory(self, *args): """ Prints out inventory items, corresponding category, and capacity. Usage: > inv """ print_header('INVENTORY') if self.inventory_capacity: print(f' Capacity: {self.inventory_capacity:.1f}%\n') for i in self.inventory_generator(printout_mode=True): print(i) print()
def show_nearby(self, *args, force_usage=False): """ Prints out nearby mobs. Args: *args: Catch all. force_usage bool(False): Usually this can only be used through specific in-game [Skills], this can bypass that. """ # Either you have to own [Magic Sense] skill or change the force_usage boolean to use this function. if not force_usage and not self.check_acquired('magic sense'): return print_header('NEARBY', 10) for mob in self.active_mobs: print( f" {mob[1]}x {mob[0].name} (lvl {mob[0].level}) {'(Dead)' if mob[0].status else ''}" )
def show_attributes(self, mob=None, *args): """ Shows acquired attribute. Might include: Mimicking, Location, etc. Usage: .show_attributes() .show_attributes('tempest serpent') > stats > stats tempest serpent """ if mob: mob = self.get_object(mob, item_pool_add=[*self.mimic_generator()], sub_pool=True) if not mob: mob = self # If no specified mob, shows player's stats. if not mob.object_type == 'character': return print_header('ATTRIBUTES', 10) print(f" Name: [{(mob.name + ' ' + mob.family_name).strip()}]") print(f" Level: {mob.level}") if mob.current_location: print(f" Location: {mob.current_location}") if mob.titles: print(f" Titles: {', '.join(mob.titles)}") print() # Print out skills organized in corresponding category (Unique Skill, Extra Skill, etc). for i in mob.attributes_generator(printout_mode=True): print(i) # Shows only if using mimic and if getting stats on thyself. if self.current_mimic and self.check_if_player(): print(f"\n Mimicking: [{self.current_mimic.name}]\n") for i in self.current_mimic.attributes_generator( printout_mode=True): print(i) print()
def show_reputations(self, *args): """Shows player's reputation (standing) with factions/characters.""" print_header('REPUTATION') for k, v in self.reputations.items(): print(f" {k}: {v}")