-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrpg.py
More file actions
100 lines (81 loc) · 3.33 KB
/
rpg.py
File metadata and controls
100 lines (81 loc) · 3.33 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
import random
class Warrior:
def __init__(self, character_name, details, health, power):
self.character_name = character_name
self.details = details
self.health = health
self.power = power
def greet(self):
print(f"You selected {self.characterName}")
def alive(self):
if self.health > 0:
print(
f"\n{self.character_name} is alive and has {self.health} health points"
)
return self.health
def attack(self, other_character):
if self.power % 2 == 1:
print("MISSED! Lucky for you!")
else:
random_power = random.randint(1, self.power)
other_character.health -= random_power
print(
f"\n\n{self.character_name} attacks {other_character.character_name} for {random_power} damage"
)
if other_character.health <= 0:
print(f"{other_character.character_name} is DEAD")
print("/////////////////////////////////////////\n")
class Hero(Warrior):
def announce(self, villain):
print(
f" {hero.character_name} says: You will be defeated, {villain.character_name}, by the mighty hand of {self.character_name}!"
)
print("/////////////////////////////////////////\n")
class Villain(Warrior):
def taunt(self, hero):
print(
f"{villain.character_name} says: You are no match for me {hero.character_name}!"
)
print("/////////////////////////////////////////\n")
hero_input = input("Type your Hero name: ")
villain_input = input("Type your Villain name: ")
##########INSTANTIATE VILLAIN AND HERO
villain = Villain(villain_input.upper(), "Needs 1 MILLLLLLION dollars", 25, 10)
hero = Hero(hero_input.upper(), "Shagadellic, BABY!", 25, 10)
while hero.alive() and villain.alive():
print("\n\n\n/////////////////////////////////////////")
print(f"{hero.character_name} HEALTH: {hero.health}")
print(f"{villain.character_name} HEALTH: {villain.health} ")
print("///////////CHOOSE THE NEXT STEP///////////////\n")
print("f: attack villain with hero")
print("a: attack hero with villain")
print("s: you want to give up, so you run away")
print("n: be a pacifist, but still stay")
print("v: have villain taunt hero")
print("h: have hero posture against villain\n")
print("/////////////////////////////////////////\n")
print("TYPE NEW INPUT BELOW")
user_input = input()
if user_input == "f":
hero.attack(villain)
elif user_input == "a":
villain.attack(hero)
elif user_input == "s":
print("I thought you were better than that!")
print("/////////////////////////////////////////\n")
break
elif user_input == "n":
print(f"{hero.character_name} chooses not to fight.")
villain.attack(hero)
print(
f"Can you believe {villain.character_name} still hits {hero.character_name}? HOW RUDE?!?!"
)
print("/////////////////////////////////////////\n")
elif user_input == "v":
villain.taunt(hero)
elif user_input == "h":
hero.announce(villain)
else:
print("!!!!!!Please type a correct command!!!!!!")
print("Options are: 'f', 'a', 's', 'n', 'v', 'h'")
print("/////////////////////////////////////////\n")