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)
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"]))
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"]))
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)
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
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
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"]))
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"]))