Ejemplo n.º 1
0
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)))
Ejemplo n.º 2
0
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")
Ejemplo n.º 3
0
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])
Ejemplo n.º 4
0
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:
        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")
Ejemplo n.º 5
0
def list_yard_items(data):
    """Display list of items placed in yard."""
    if len(data["yard"]) > 0:
        things = [(item["name"], item["occupant"]) for item in data["yard"]]
        for thing in things:
            cat = "no one"
            if thing[1]:
                try:
                    cat = thing[1][0]["name"]
                except:
                    pass
            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)