Skip to content

Commit ae4937f

Browse files
committed
Read stats once, tweak printout
1 parent eda6f2c commit ae4937f

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

src/pet/cli.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@ def main():
2727
init_stats(stats_path, name)
2828

2929
stats = read_stats(stats_path)
30-
update_time_stats(stats, stats_path)
31-
stats = read_stats(stats_path)
32-
update_health_stats(stats, stats_path)
33-
stats = read_stats(stats_path)
30+
stats = update_time_stats(stats, stats_path)
31+
stats = update_health_stats(stats, stats_path)
3432

3533
if stats["HEALTH"] <= 0:
36-
print("🪫 Uh-oh, your pet's health is low!")
34+
print("🪫 Uh-oh, your pet's health is low! Try 🍣 Feed.")
3735

3836
action = inquirer.select(
3937
message="What would you like to do?",
@@ -57,10 +55,8 @@ def main():
5755
if stats["HEALTH"] == 10:
5856
print(f"🤢 {stats['NAME']} is full (health = 10).")
5957
else:
60-
feed_pet(stats, stats_path)
61-
print(
62-
f"😋 {stats['NAME']} ate the food (health = stats['HEALTH'] + 1)."
63-
)
58+
stats = feed_pet(stats, stats_path)
59+
print(f"😋 {stats['NAME']} ate the food (health now {stats['HEALTH']}/10).")
6460

6561
if "Quit" in action:
6662
print(f"👋 Goodbye {stats['NAME']}!")

0 commit comments

Comments
 (0)