Repository navigation
Expand file tree
/
Copy pathpyDOOM.py
More file actions
242 lines (202 loc) · 8.42 KB
/
Copy pathpyDOOM.py
File metadata and controls
242 lines (202 loc) · 8.42 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
import random
from rich.progress import Progress
import time
with Progress() as progress:
task = progress.add_task("[blue]Processing...", total=100)
for step in range(100):
time.sleep(0.05) # Simulate work
progress.update(task, advance=1)
# Difficulty Class
class Difficulty:
def __init__(self, name, enemy_damage, player_hp):
self.name = name
self.enemy_damage = enemy_damage
self.player_hp = player_hp
# Define Difficulty Levels
easy = Difficulty("I'm too young to die", enemy_damage=10, player_hp=100)
normal = Difficulty("Bring it on!", enemy_damage=20, player_hp=100)
hard = Difficulty("pure-Violence", enemy_damage=35, player_hp=100)
ultrakill=Difficulty("Ultra-kill must die", enemy_damage=40,player_hp=120)
# Weapon Class
class Weapon:
def __init__(self, name, damage):
self.name = name
self.damage = damage
class RangedWeapon(Weapon):
def __init__(self, name, damage, ammo):
super().__init__(name, damage)
self.ammo = ammo
def attack(self):
if self.ammo > 0:
self.ammo -= 1
print(f"{self.name} fired! Ammo left: {self.ammo}")
return self.damage
else:
print("Out of ammo!")
return 0
def reload(self, amount):
self.ammo += amount
print(f"{self.name} reloaded! Ammo: {self.ammo}")
#Chainsaw class
class Chainsaw(Weapon):
def __init__(self, name, damage, hp_gain):
super().__init__(name, damage)
self.hp_gain = hp_gain
def attack(self, player):
print(f"{self.name} slashes! Deals {self.damage} damage.")
player.hp += self.hp_gain
print(f"{player.name} regained {self.hp_gain} HP! Total HP: {player.hp}")
return self.damage
#ThunderPunch class
class ThunderPunch(Weapon):
def __init__(self, name, damage, cooldown=2):
super().__init__(name, damage)
self.cooldown = cooldown
self.current_cooldown = 0
self.base_damage = damage
def attack(self, player):
if self.current_cooldown > 0:
print("Thunder Punch is on cooldown!")
return 0
if random.randint(1, 10) == 1: # 10% chance critical hit
print("Critical hit! Massive damage and HP restored!")
damage_dealt = 80
hp_gain = 70
else:
damage_dealt = self.base_damage
hp_gain = 30
player.hp += hp_gain
print(f"{player.name} regained {hp_gain} HP! Total HP: {player.hp}")
self.current_cooldown = self.cooldown
return damage_dealt
def reduce_cooldown(self):
if self.current_cooldown > 0:
self.current_cooldown -= 1
# Player Class
class Player:
def __init__(self, name, difficulty, weapon1, weapon2, melee):
self.name = name
self.hp = difficulty.player_hp
self.armor = 50
self.weapons = [weapon1, weapon2]
self.melee = melee
self.current_weapon = 0
self.difficulty = difficulty
def attack(self, enemy):
weapon = self.weapons[self.current_weapon]
if isinstance(weapon, Chainsaw):
damage_dealt = weapon.attack(self)
else:
damage_dealt = weapon.attack()
if damage_dealt > 0:
enemy.take_damage(damage_dealt)
if enemy.hp <= 0:
self.reload_on_kill()
def punch(self, enemy):
damage_dealt = self.melee.attack(self)
if damage_dealt > 0:
enemy.take_damage(damage_dealt)
if enemy.hp <= 0:
self.reload_on_kill()
def switch_weapon(self):
self.current_weapon = (self.current_weapon + 1) % len(self.weapons)
print(f"Switched to {self.weapons[self.current_weapon].name}")
def reduce_cooldowns(self):
self.melee.reduce_cooldown()
def take_damage(self, amount):
if self.armor > 0:
absorbed = min(self.armor, amount)
self.armor -= absorbed
amount -= absorbed
print(f"{self.name}'s armor absorbed {absorbed} damage!")
self.hp -= amount
print(f"{self.name} took {amount} damage! HP: {self.hp}")
#Gains ammo on kills and gets extra heal points on chainsaw kills
def reload_on_kill(self):
weapon = self.weapons[self.current_weapon]
if isinstance(weapon, RangedWeapon):
ammo_gained = random.randint(1, 5)
weapon.reload(ammo_gained)
print(f"You looted {ammo_gained} ammo!")
elif isinstance(weapon, Chainsaw):
self.hp += 10
print(f"Chainsaw kill! {self.name} gained 10 extra HP! HP: {self.hp}")
# Enemy Class
class Enemy:
def __init__(self, name, hp, damage):
self.name = name
self.hp = hp
self.damage = damage
def take_damage(self, amount):
self.hp -= amount
print(f"{self.name} took {amount} damage! HP left: {self.hp}")
def attack(self, player):
player.take_damage(self.damage)
# Boss Class (Stronger Enemies)
class Boss(Enemy):
def __init__(self, name, hp, damage):
super().__init__(name, hp, damage)
# Function to create new enemies (normal and boss)
def create_enemy(round_number, difficulty):
if round_number % 3 == 0: # Every 3 rounds, spawn a boss
return Boss(f"Cyberdemon (Round {round_number})", hp=200 + (round_number * 20), damage=difficulty.enemy_damage + (round_number * 3))
else:
return Enemy(f"Imp (Round {round_number})", hp=100 + (round_number * 10), damage=difficulty.enemy_damage + (round_number * 2))
# Create weapons
pistol = RangedWeapon("Pistol", damage=30, ammo=10)
shotgun = RangedWeapon("Super-Shotgun", damage=45, ammo=5)
chainsaw = Chainsaw("Chainsaw", damage=32, hp_gain=45)
thunder_punch = ThunderPunch("Thunder Punch", damage=39, cooldown=1)
valkyrie = RangedWeapon("Valkyrie", damage=75, ammo=4)
iginite = RangedWeapon("Iginite", damage=50, ammo=6)
def main():
loading_bar()
# Get User Input for choosing the skill level
difficulty_input = input("Choose skill level:\n I'm too young to die\n Bring it on!\n pure-Violence\n Ultrakill must die\n").lower()
if "young" in difficulty_input:
chosen_difficulty = easy
elif "bring" in difficulty_input:
chosen_difficulty = normal
elif "pure" in difficulty_input:
chosen_difficulty = hard
elif "ultra" in difficulty_input:
chosen_difficulty=ultrakill
else:
print("Invalid choice, defaulting to Normal mode.")
chosen_difficulty = normal
# Create Player
player = Player("Alice", chosen_difficulty, pistol, chainsaw, thunder_punch)
print(f"\nStarting game on {player.difficulty.name} mode with a {player.weapons[player.current_weapon].name}!\n")
# Game Loop (Endless Mode with Boss Fights)
round_number = 1
while player.hp > 0:
enemy = create_enemy(round_number, chosen_difficulty)
print(f"\nA {enemy.name} has appeared! HP: {enemy.hp}, Damage: {enemy.damage}\n")
while enemy.hp > 0 and player.hp > 0:
action = input("Do you want to attack, punch, switch weapon, or wait? (attack/punch/switch/wait): ").lower()
if action == "attack":
player.attack(enemy)
if enemy.hp > 0:
enemy.attack(player)
elif action == "punch":
player.punch(enemy)
if enemy.hp > 0:
enemy.attack(player)
elif action == "switch":
player.switch_weapon()
else:
print("You waited...")
player.reduce_cooldowns()
if player.hp <= 0:
print("\nGame Over! You fought bravely but couldn't survive.")
break
elif enemy.hp <= 0:
print(f"\nYou defeated {enemy.name}!")
round_number += 1
if isinstance(enemy, Boss):
if len(player.weapons) < 4:
new_weapon = random.choice([shotgun, valkyrie, iginite])
player.weapons.append(new_weapon)
print(f"{new_weapon.name} has been added to your inventory!")
if __name__ == "__main__":
main()