Example #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)
Example #2
0
def gameHasEnded(actualWord, guessedWord, attemptsRemaining):
    if guessedWord == actualWord:
        return printer.success("You WON! :D")
    elif attemptsRemaining <= 0:
        printer.failure("You Lost :(")
        return printer.information('Word was ' + actualWord)
    return False
Example #3
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
Example #4
0
def repport(tests, index):
    errors = 0
    ok = 0
    missing = 0
    for line in tests:
        if line[index] == 0:
            errors += 1
        elif line[index] == 1:
            ok += 1
        elif line[index] == 3:
            missing += 1
    print "Repport:\n"
    print "- {:>12} Methods not yet implemented".format(info(missing))
    print "- {:>12} Methods failing".format(danger(errors))
    print "- {:>12} Methods doing ok".format(success(ok))
    print
Example #5
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"]))
Example #6
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"]))