-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathThe Unwanted mission
More file actions
93 lines (83 loc) · 3.4 KB
/
The Unwanted mission
File metadata and controls
93 lines (83 loc) · 3.4 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
import random
# Initial player setup
player_inventory = {
"Rifle": {"bullets": 10},
"First Aid Kit": 1
}
player_health = 100
# Helper functions
def show_inventory():
print("\nYour Inventory:")
for item, details in player_inventory.items():
if isinstance(details, dict):
print(f"- {item}: {details}")
else:
print(f"- {item}: {details}")
print(f"Health: {player_health}")
def battle(monster_name, monster_health):
global player_health
print(f"\nBattle Start! A {monster_name} appears with {monster_health} HP!")
while monster_health > 0:
print(f"\n{monster_name} HP: {monster_health}")
print("Choose an action:")
print("1. Attack with Rifle")
print("2. Use First Aid Kit")
choice = input("Enter 1 or 2: ")
if choice == "1" and player_inventory["Rifle"]["bullets"] > 0:
damage = random.randint(5, 15)
monster_health -= damage
player_inventory["Rifle"]["bullets"] -= 1
print(f"You deal {damage} damage! Bullets left: {player_inventory['Rifle']['bullets']}")
elif choice == "2" and player_inventory["First Aid Kit"] > 0:
player_health = min(100, player_health + 20)
player_inventory["First Aid Kit"] -= 1
print("You used a First Aid Kit. Health restored to", player_health)
else:
print("Invalid choice or out of resources.")
if monster_health > 0:
monster_damage = random.randint(10, 20)
player_health -= monster_damage
print(f"The {monster_name} attacks and deals {monster_damage} damage! Your health: {player_health}")
if player_health <= 0:
print("You've been defeated!")
return False
print(f"The {monster_name} has been defeated!")
return True
# Game start
print("Welcome to The Unwanted Mission!")
print("You stand in your house just outside the city, ready to face monsters.")
show_inventory()
# Game decision loop
while True:
print("\nChoose your action:")
print("1. Go to the warehouse to find more supplies.")
print("2. Head into the city to find allies.")
print("3. Move deeper into the city to encounter monsters.")
action = input("Enter 1, 2, or 3: ")
if action == "1":
print("\nYou find additional supplies at the warehouse!")
player_inventory["Shotgun"] = {"shells": 5}
player_inventory["Armor Vest"] = 1
show_inventory()
elif action == "2":
print("\nYou meet a teammate who gives you some extra bullets!")
player_inventory["Rifle"]["bullets"] += 5
show_inventory()
elif action == "3":
print("\nYou move deeper into the city and encounter a monster!")
if not battle("Level 1 Monster", 30):
print("Game Over")
break
else:
print("Invalid action, try again.")
if player_health <= 0:
print("Game Over. You were defeated.")
break
# Final monster encounter after gathering resources
if action == "3" and "Shotgun" in player_inventory:
print("\nYou've reached the final level: The Big Monster appears!")
if battle("Big Monster", 100):
print("Congratulations! You have defeated the Big Monster and completed The Unwanted Mission!")
else:
print("Game Over. The Big Monster was too powerful.")
break