-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest1.py
More file actions
183 lines (155 loc) · 5.98 KB
/
Copy pathtest1.py
File metadata and controls
183 lines (155 loc) · 5.98 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import random
def path():
print("You're currently in the asteroid field.")
def mercury(difficulty, player_health):
print("You've landed on Mercury.")
player_health = alien(difficulty, player_health)
return player_health
def venus(resource_level, player_health):
print("You've landed on Venus.")
player_health = resource_gathering(resource_level, player_health)
return player_health
def jupiter(player_health):
print("You've arrived at Jupiter.")
choice = input("Explore a moon (Y/N)? ")
if choice.lower() == 'y':
player_health = moon(player_health)
else:
print("You are heading to Saturn.")
return player_health
def moon(player_health):
print("You are on one of Jupiter's moons.")
player_health = resource_gathering("medium", player_health)
return player_health
def saturn(player_health, difficulty):
print("You've arrived at Saturn.")
player_health = alien(difficulty, player_health)
return player_health
def neptune(player_health):
print("You've arrived at Neptune.")
player_health = finalboss(player_health)
return player_health
def mars(player_health):
print("You've landed on Mars.")
player_health = riddle(player_health)
return player_health
def pluto(player_health):
print("You've reached Pluto.")
player_health = riddle(player_health)
return player_health
def uranus(player_health, difficulty):
print("You've arrived at Uranus.")
player_health = alien(difficulty, player_health)
return player_health
def finalboss(player_health):
print("You face the ultimate challenge: the Cosmic Destroyer!")
player_health = boss_fight(player_health)
return player_health
def resource_gathering(resource_level, player_health):
if resource_level == "high":
health_gain = 30
elif resource_level == "medium":
health_gain = 20
else:
health_gain = 10
player_health += health_gain
print(f"You gained {health_gain} health. Your current health is {player_health}.")
return player_health
def alien(difficulty, player_health):
if difficulty == "easy":
alien_health = 20
alien_damage = 5
elif difficulty == "medium":
alien_health = 30
alien_damage = 10
else:
alien_health = 40
alien_damage = 15
while alien_health > 0 and player_health > 0:
player_action = input("Attack (A) or Defend (D)? ")
if player_action.lower() == 'a':
damage_dealt = random.randint(10, 20)
alien_health -= damage_dealt
print(f"You dealt {damage_dealt} damage. Alien health is now {alien_health}.")
elif player_action.lower() == 'd':
shield_gained = random.randint(5, 10)
print(f"You defended and gained {shield_gained} shield points.")
else:
print("Invalid input.")
if alien_health > 0:
player_health -= alien_damage
print(f"The alien attacks you for {alien_damage} damage. Your health is now {player_health}.")
return player_health
def boss_fight(player_health):
alien_health = 100
alien_damage = 30
while alien_health > 0 and player_health > 0:
player_action = input("Attack (A) or Defend (D)? ")
if player_action.lower() == 'a':
damage_dealt = random.randint(15, 25)
alien_health -= damage_dealt
print(f"You dealt {damage_dealt} damage. Boss health is now {alien_health}.")
elif player_action.lower() == 'd':
shield_gained = random.randint(5, 15)
print(f"You defended and gained {shield_gained} shield points.")
else:
print("Invalid input.")
if alien_health > 0:
player_health -= alien_damage
print(f"The boss attacks you for {alien_damage} damage. Your health is now {player_health}.")
return player_health
def riddle(player_health):
riddles = [
("I speak without a mouth and hear without ears. I have no body, but I can still talk. What am I?", "echo"),
("I'm light as a feather, yet the strongest person can't hold me for five minutes. What am I?", "breath")
]
riddle, answer = random.choice(riddles)
user_answer = input(riddle + "\nYour answer: ").lower()
if user_answer == answer:
print("Correct!")
player_health += 10
else:
print("Incorrect!")
player_health -= 5
print(f"Your current health is {player_health}.")
return player_health
def main():
player_health = 100
resource_level = random.choice(["low", "medium", "high"])
difficulty = random.choice(["easy", "medium", "hard"])
while player_health > 0:
print("\nWhere do you want to go? (Enter a number)")
print("1. Mercury")
print("2. Venus")
print("3. Mars")
print("4. Jupiter")
print("5. Saturn")
print("6. Uranus")
print("7. Neptune")
print("8. Pluto")
print("9. Asteroid Field")
choice = input("> ")
if choice == '1':
player_health = mercury("easy", player_health)
elif choice == '2':
player_health = venus(resource_level, player_health)
elif choice == '3':
player_health = mars(player_health)
elif choice == '4':
player_health = jupiter(player_health)
elif choice == '5':
player_health = saturn(player_health, "medium")
elif choice == '6':
player_health = uranus(player_health, "hard")
elif choice == '7':
player_health = neptune(player_health)
elif choice == '8':
player_health = pluto(player_health)
elif choice == '9':
path()
if player_health <= 0:
print("You died")
break
if player_health > 0:
print("YAY you won!")
main()