generated from DigitalCraftsStudents/python-rpg-game
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpg-0.py
65 lines (59 loc) · 1.71 KB
/
rpg-0.py
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
from hero import Hero
from goblin import Goblin
from zombie import Zombie
from medic import Medic
from shadow import Shadow
"""
In this simple RPG game, the hero fights the goblin. He has the options to:
1. fight goblin
2. do nothing - in which case the goblin will attack him anyway
3. flee
"""
def main():
my_hero = Hero()
goblin = Goblin()
zombie = Zombie()
medic = Medic()
shadow = Shadow()
while (goblin.alive() or zombie.alive()) and my_hero.alive():
my_hero.print_status()
print()
print("What do you want to do?")
print("1. fight goblin")
print("2. fight zombie")
print("3. fight medic")
print("4. fight shadow")
print("5. do nothing")
print("6. flee")
print("> ",)
user_input = input()
if user_input == "1":
goblin.print_status()
# my_hero attacks goblin
my_hero.attack(goblin)
if goblin.health > 0:
# Goblin attacks my_hero
goblin.attack(my_hero)
elif user_input == "2":
zombie.print_status()
my_hero.attack(zombie)
zombie.attack(my_hero)
zombie.alive()
elif user_input == "3":
medic.print_status()
my_hero.attack(medic)
medic.attack(my_hero)
medic.alive()
elif user_input == "4":
shadow.print_status()
shadow.attack(my_hero)
my_hero.attack(shadow)
shadow.alive()
elif user_input == "5":
pass
elif user_input == "6":
print("Goodbye.")
break
else:
print("Invalid input %r" % user_input)
main()