boring_adventure.py 1.17 KB
Newer Older
Adam Blank's avatar
Adam Blank committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from termcolor import colored
from utils import choices_to_str

choices = ["sleep", "cheer", "dowork"]
inventory = []

# The `colored` function prints out text in the color provided!
print(colored("Hello! Welcome to a boring adventure!", "green"))
print(colored("You are in a dark room. Choose one of the following:", "blue"))

# done is a "boolean variable" (i.e., either True or False)
# We use it to control when the `while` loop should end!
done = False
while not done:
    # `choices_to_str` is a function we wrote to turn a choices
    # list into a string where each choice is underlined.  If you
    # want to check it out, it's in `utils.py` on the left!
    prompt = choices_to_str(choices)
    action = input(prompt + " >>> ")
    if action == "sleep" and "work" in inventory:
        print(colored("ZZZZ...zzzz", "blue"))
        done = True
    elif action == "sleep":
        print(colored("You still have work to do!", "red"))
    elif action == "dowork":
        inventory.append("work")
        print(colored("You're done with your work now!", "green"))
    elif action == "cheer":
        print("Hip hip hooray!! You're still tired!")
print(colored("The adventure is over!", "green"))