-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcharacter.py
More file actions
72 lines (60 loc) · 2.24 KB
/
Copy pathcharacter.py
File metadata and controls
72 lines (60 loc) · 2.24 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
import os
# clear screen helper function
def clear_screen():
os.system("cls" if os.name=="nt" else "clear")
# wait for input helper function
def wait():
input("Press any key")
# Player Class
class Player:
def __init__(self, name, hp, attack, defense, money = 0, inventory = None):
self.name = name
self.max_hp = hp
self.hp = hp
self.attack = attack
self.defense = defense
self.money = money
self.inventory = inventory or []
def take_damage(self, amount):
self.hp -= amount
print(f"{self.name} takes {amount} damage! ({self.hp} HP left)")
if self.hp <= 0:
print(f"{self.name} died on the coffee stained floor.")
# Subclass Warrior
class Warrior(Player):
def __init__(self, name="Office Warrior"):
super().__init__(name, hp = 100, attack = 15, defense = 10)
self.special_cooldown = 0
def special_attack(self, enemy):
if self.special_cooldown > 0:
print(f"Special attack not ready yet! (Ready in {self.special_cooldown} rounds.)")
wait()
return False
damage = self.attack + 5
print(f"{self.name} throws an office chair at {enemy.name} causing {damage} damage.")
wait()
enemy.take_damage(damage)
self.special_cooldown = 4
return True
def reduce_cooldown(self):
if self.special_cooldown > 0:
self.special_cooldown -= 1
# Subclass Mage
class Mage(Player):
def __init__(self, name="Mage"):
super().__init__(name, hp = 70, attack = 20, defense = 5)
self.special_cooldown = 0
def special_attack(self, enemy):
if self.special_cooldown > 0:
print(f"Special attack not ready yet! (Ready in {self.special_cooldown} rounds.)")
wait()
return False
damage = self.attack + 5
print(f"{self.name} Throws a scalding hot coffee mug at {enemy.name} causing {damage} damage.")
wait()
enemy.take_damage(damage)
self.special_cooldown = 4
return True
def reduce_cooldown(self):
if self.special_cooldown > 0:
self.special_cooldown -= 1