from untitled import rules, ui def pet(cat): if cat.happiness == 100: print("Your cat is already fully happy! They don't want any more pets.") return original_happiness = cat.happiness print(f"Mash keys to pet {cat.name}, press enter when you're done.") count = 0 last = None print("\rPets: 0", end="", flush=True) while True: if count < 100000: key = ui.getch() if key in ("\r", "\n"): print() break if key != last: count += 1 last = key print(f"\rPets: {count}", end="", flush=True) else: rules.excite(cat, -5) print(f"\n{cat.name} ran away to protect your hands") print( f"You lost 5% happiness due to stressing your cat. Before petting, your cat was {round(original_happiness,1)}% happy. You lost {round(original_happiness-cat.happiness,1)}% happiness. Your cat is now {round(cat.happiness,1)}% happy." ) return add_happiness = 0 if count == 0: print("You didn't pet your cat at all.") return elif count < 50: add_happiness = 5 print(f"You didn't pet your cat enough, {cat.name} wants more pets.") elif count <= 200: add_happiness = 15 print(f"You pet {cat.name} a lot, {cat.name} is happy.") elif count <= 500: add_happiness = 20 print(f"You pet {cat.name} a lot. {cat.name} is very happy.") elif count <= 1000: add_happiness = 20 print(f"You pet {cat.name} an absurd amount of times.") elif count <= 10000: add_happiness = 15 print(f"{cat.name} has had enough pets.") elif count <= 20000: add_happiness = 10 print("What are you even doing at this point?") elif count <= 50000: add_happiness = 5 print("You should probably stop now.") elif count <= 75000: add_happiness = 2 print("Seriously. Stop.") else: add_happiness = 1 print(f"{cat.name} is getting extremely worried about your hands.") rules.excite(cat, add_happiness) print( f"Your cat is now {round(cat.happiness,1)}% percent happy. Before petting, your cat was {round(original_happiness,1)}% happy. You gained {round(cat.happiness-original_happiness,1)}% happiness." )