Beispiel #1
0
def try_to_place(data, item):
    """Attempt item placement in yard."""
    if sum([toy["size"] for toy in data["yard"]]) + item["size"] < data["space"]:
        data["yard"].append(item)
        item["in_yard"] = True
        printer.success(data["prefix"], "Nice! Your yard now consists of a {0}".format(", and a ".join([toy["name"] for toy in data["yard"]])))
    else:
        printer.warn(data["prefix"], "Oops that won't fit in your yard! Would you like to remove an item?")
        offer_replace(data, item)
Beispiel #2
0
def put_food_in_yard(data, arr_idx):
    """Place food in yard."""
    food = data["owned_food"].pop(arr_idx)
    data["food"] = food["name"]
    data["food_remaining"] = food["size"]
    printer.success(
        data["prefix"],
        "Sweet! Your yard now has a {0} set out, and {1} of food remaining".
        format(data["food"], data["food_remaining"]))
Beispiel #3
0
def check_food(data):
    """Check food in yard."""
    if data["food_remaining"] == 0:
        printer.warn(
            data["prefix"],
            "Your yard currently doesn't have any food in it! No cats will come if there's no food!"
        )
    else:
        printer.success(
            data["prefix"],
            "Your yard currently has a {0} in it with {1} time remaining".
            format(data["food"], data["food_remaining"]))
Beispiel #4
0
def try_to_place(data, item):
    """Attempt item placement in yard."""
    if sum([toy["size"]
            for toy in data["yard"]]) + item["size"] < data["space"]:
        data["yard"].append(item)
        item["in_yard"] = True
        printer.success(
            data["prefix"], "Nice! Your yard now consists of a {0}".format(
                ", and a ".join([toy["name"] for toy in data["yard"]])))
    else:
        printer.warn(
            data["prefix"],
            "Oops that won't fit in your yard! Would you like to remove an item?"
        )
        offer_replace(data, item)
Beispiel #5
0
def try_to_buy(data, item_name):
    """Attempt to buy an item."""
    item = data["items"][item_name]
    currency = item["currency"] + "_fish"
    money = data[currency]
    cost = item["cost"]
    if money < cost:
        printer.fail(
            data["prefix"], "Sorry but you don't have enough money for that!")
        return
    else:
        data[currency] = data[currency] - cost
        if item["size"] < 6:
            data["items"][item_name]["attributes"] = ["owned"]
        else:
            data["owned_food"].append(item.copy())
        printer.success(data["prefix"], "Ah! A splendid choice!")
        return
Beispiel #6
0
def try_to_buy(data, item_name):
    """Attempt to buy an item."""
    item = data["items"][item_name]
    currency = item["currency"] + "_fish"
    money = data[currency]
    cost = item["cost"]
    if money < cost:
        printer.fail(data["prefix"],
                     "Sorry but you don't have enough money for that!")
        return
    else:
        data[currency] = data[currency] - cost
        if item["size"] < 6:
            data["items"][item_name]["attributes"] = ["owned"]
        else:
            data["owned_food"].append(item.copy())
        printer.success(data["prefix"], "Ah! A splendid choice!")
        return
Beispiel #7
0
def put_food_in_yard(data, arr_idx):
    """Place food in yard."""
    food = data["owned_food"].pop(arr_idx)
    data["food"] = food["name"]
    data["food_remaining"] = food["size"]
    printer.success(data["prefix"], "Sweet! Your yard now has a {0} set out, and {1} of food remaining".format(data["food"], data["food_remaining"]))
Beispiel #8
0
def check_food(data):
    """Check food in yard."""
    if data["food_remaining"] == 0:
        printer.warn(data["prefix"], "Your yard currently doesn't have any food in it! No cats will come if there's no food!")
    else:
        printer.success(data["prefix"], "Your yard currently has a {0} in it with {1} time remaining".format(data["food"], data["food_remaining"]))