def list_owned_items(data): """Display a list of owned items.""" owned_items = [item["name"] for item in data["items"].values() if "owned" in item["attributes"]] if len(owned_items) == 0: printer.warn(data["prefix"], "You don't own any items, better go buy some in the shop~!") else: printer.yard(data["prefix"], "You currently own a {0}".format(", and a ".join(owned_items)))
def cat_activities(data): """Display cat activities.""" yard_items = [(obj, obj["occupant"]) for obj in data["yard"] if obj["occupied"]] for item in yard_items: cats = item[1] for cat in cats: printer.yard(data["prefix"], "{0} is playing with a {1}".format(cat, item[0]['name']))
def cat_activities(data): """Display cat activities.""" yard_items = [(obj, obj["occupant"]) for obj in data["yard"] if obj["occupied"]] for item in yard_items: cats = item[1] for cat in cats: printer.yard( data["prefix"], "{0} is playing with a {1}".format(cat, item[0]['name']))
def offer_replace(data, item): """Replace an existing item in yard.""" yard_items = [toy["name"] for toy in data["yard"]] printer.yard(data["prefix"], "Currently in your yard you have: a {0}".format(", and a".join(yard_items))) data["completer"].set_actions(yard_items) inp = input("{.YARD}{}{.ENDC} Would you like to replace any of the items in your yard? Which one? ".format(printer.PColors, data["prefix"], printer.PColors)) if inp in yard_items: remove_from_yard(data, inp) try_to_place(data, item) else: printer.warn(data["prefix"], "Sorry I don't see that item in your yard")
def list_yard_items(data): """Display list of items placed in yard.""" if len(data["yard"]) > 0: items = [item for item in data["yard"]] for item in items: cats = "no one" if item["occupied"]: cats = ", and ".join([cat["name"] for cat in item["occupant"]]) printer.yard(data["prefix"], "Your yard currently has a {0} in it, occupied by {1}".format(item["name"], cats)) # TODO: add cat descriptions else: printer.warn(data["prefix"], "You currently have nothing in your yard, how sad") check_food(data)
def list_owned_items(data): """Display a list of owned items.""" owned_items = [ item["name"] for item in data["items"].values() if "owned" in item["attributes"] ] if len(owned_items) == 0: printer.warn( data["prefix"], "You don't own any items, better go buy some in the shop~!") else: printer.yard( data["prefix"], "You currently own a {0}".format(", and a ".join(owned_items)))
def offer_replace(data, item): """Replace an existing item in yard.""" yard_items = [toy["name"] for toy in data["yard"]] printer.yard( data["prefix"], "Currently in your yard you have: a {0}".format( ", and a".join(yard_items))) inp = input( "{.YARD}{}{.ENDC} Would you like to replace any of the items in your yard? Which one? " .format(printer.PColors, data["prefix"], printer.PColors)) if inp in yard_items: remove_from_yard(data, inp) try_to_place(data, item) else: printer.warn(data["prefix"], "Sorry I don't see that item in your yard")
def cats(data): """Allow you to look at the cats in your yard""" cats_in_yard = [] [cats_in_yard.extend(obj["occupant"]) for obj in data["yard"] if obj["occupied"]] cat_names = [cat for cat in cats_in_yard] data["completer"].set_actions(cat_names) printer.yard(data["prefix"], "These are the cats in your yard:") for cat in cat_names: printer.yard(data["prefix"],cat) inp = input("{.YARD}{}{.ENDC} Which cat would you like to look at? ".format( printer.PColors, data["prefix"], printer.PColors)) if inp in cat_names: desc_cat(data, [cat for cat in data["cats"] if cat == inp][0]) else: printer.warn(data["prefix"], "I'm sorry that cat isn't in your yard!")
def food(data): """Display food placement options.""" check_food(data) placable_items = {} for idx, item in enumerate(data["owned_food"]): if item["name"] not in placable_items.keys(): placable_items[item["name"]] = [1, idx] else: placable_items[item["name"]][0] += 1 printer.yard(data["prefix"], "Here's what you can place:") for key in placable_items.keys(): printer.yard(data["prefix"], "A {0} ({1})".format(key, placable_items[key][0])) data["completer"].set_actions(placable_items.keys()) to_place = input("{.YARD}{}{.ENDC} Which would you like to place? (hit ENTER if none) ".format(printer.PColors, data["prefix"], printer.PColors)) if to_place in placable_items.keys(): put_food_in_yard(data, placable_items[to_place][1])
def list_yard_items(data): """Display list of items placed in yard.""" if len(data["yard"]) > 0: items = [item for item in data["yard"]] for item in items: cats = "no one" if item["occupied"]: cats = ", and ".join([cat["name"] for cat in item["occupant"]]) printer.yard( data["prefix"], "Your yard currently has a {0} in it, occupied by {1}".format( thing[0], cat)) # TODO: add cat descriptions else: printer.warn(data["prefix"], "You currently have nothing in your yard, how sad") check_food(data)
def place(data): """Place item in yard.""" items_list = [item for item in data["items"].values() if "owned" in item["attributes"] and not item["in_yard"]] # TODO: this is ultra gross placable_items = {} for item in items_list: #deliniate placable items from things like food if item["size"] < 6: placable_items[item["name"]] = item data["completer"].set_actions(placable_items.keys()) printer.yard(data["prefix"], "Here are the items that you can put in your yard: {0}".format(", ".join(placable_items.keys()))) inp = input("{.YARD}{}{.ENDC} Which item would you like to place? ".format( printer.PColors, data["prefix"], printer.PColors)) if inp in placable_items.keys(): try_to_place(data, placable_items[inp]) else: printer.warn(data["prefix"], "I'm sorry I didn't recognize that item")
def food(data): """Display food placement options.""" check_food(data) placable_items = {} for idx, item in enumerate(data["owned_food"]): if item["name"] not in placable_items.keys(): placable_items[item["name"]] = [1, idx] else: placable_items[item["name"]][0] += 1 printer.yard(data["prefix"], "Here's what you can place:") for key in placable_items.keys(): printer.yard(data["prefix"], "A {0} ({1})".format(key, placable_items[key][0])) to_place = input( "{.YARD}{}{.ENDC} Which would you like to place? (hit ENTER if none) ". format(printer.PColors, data["prefix"], printer.PColors)) if to_place in placable_items.keys(): put_food_in_yard(data, placable_items[to_place][1])
def cats(data): """Allow you to look at the cats in your yard""" cats_in_yard = [] [ cats_in_yard.extend(obj["occupant"]) for obj in data["yard"] if obj["occupied"] ] cat_names = [cat for cat in cats_in_yard] data["completer"].set_actions(cat_names) printer.yard(data["prefix"], "These are the cats in your yard:") for cat in cat_names: printer.yard(data["prefix"], cat) inp = input( "{.YARD}{}{.ENDC} Which cat would you like to look at? ".format( printer.PColors, data["prefix"], printer.PColors)) if inp in cat_names: desc_cat(data, [cat for cat in data["cats"] if cat == inp][0]) else: printer.warn(data["prefix"], "I'm sorry that cat isn't in your yard!")
def place(data): """Place item in yard.""" items_list = [ item for item in data["items"].values() if "owned" in item["attributes"] and not item["in_yard"] ] # TODO: this is ultra gross placable_items = {} for item in items_list: #deliniate placable items from things like food if item["size"] < 6: placable_items[item["name"]] = item printer.yard( data["prefix"], "Here are the items that you can put in your yard: {0}".format( ", ".join(placable_items.keys()))) inp = input("{.YARD}{}{.ENDC} Which item would you like to place? ".format( printer.PColors, data["prefix"], printer.PColors)) if inp in placable_items.keys(): try_to_place(data, placable_items[inp]) else: printer.warn(data["prefix"], "I'm sorry I didn't recognize that item")
def desc_cat(data, cat): printer.yard(data["prefix"], data["cats"][cat]["desc"])