Skip to content

Commit 2153646

Browse files
authored
good 🎲
1 parent 5dfd419 commit 2153646

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

‎Number/fortune.py‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import random
2+
import time
3+
4+
FORTUNES = [
5+
"This is your lucky day — you are going to win the lottery!",
6+
"The sun is going to shine during your holidays!",
7+
"Congratulations! You bought a flashy car with your lottery money!",
8+
"Congratulations! You also bought a mansion with your money!",
9+
"Oh nooooo! You are bankrupt — you spent too much money on the economy. What do you do now?"
10+
]
11+
12+
RARE_FORTUNES = [
13+
"The universe bends in your favour. This message appears once in a lifetime.",
14+
"You are chosen. Great power (and great responsibility) awaits you.",
15+
"Time slows. A decision you make soon will change everything."
16+
]
17+
18+
def get_fortune(previous=None):
19+
roll = random.randint(1, 100) # every 1 in 100 rolls
20+
21+
# 1% chance to get a 1
22+
if roll == 1:
23+
return random.choice(RARE_FORTUNES), True
24+
25+
# Normal fortune
26+
fortune = random.choice(FORTUNES)
27+
while fortune == previous:
28+
fortune = random.choice(FORTUNES)
29+
30+
return fortune, False
31+
32+
def main():
33+
print("Welcome to TheM1ddleM1n fortune teller v2")
34+
35+
count = 0
36+
last_fortune = None
37+
38+
while True:
39+
choice = input("\nWould you like your fortune read? (press y for yes, and q for quit): ").strip().lower()
40+
41+
if choice in ("q", ""):
42+
break
43+
if choice != "y":
44+
print("Invalid input.")
45+
continue
46+
47+
print("\nConsulting the ghostly spirits...")
48+
time.sleep(2.5)
49+
50+
fortune, rare = get_fortune(last_fortune)
51+
52+
if rare:
53+
print("\nA RARE FORTUNE HAS BEEN UNLOCKED!!!")
54+
else:
55+
last_fortune = fortune
56+
57+
print(f"\n{fortune}")
58+
count += 1
59+
60+
print(f"You had {count} fortune(s) read.")
61+
print(f"--------------------------")
62+
print(f"Goodbye!")
63+
64+
if __name__ == "__main__":
65+
main()

0 commit comments

Comments
 (0)