-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.py
101 lines (87 loc) · 3.26 KB
/
game.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
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
from consoleRPG import *
import random
me = Hero("me")
boss = BadGuy("MegaBad",hp=200,strength=50,defense=50,level=20)
def fight_bad_guy(hero,bad_guy):
while hero.hp > 0 and bad_guy.hp > 0:
print("Your stats:")
print("HP: " + str(hero.hp))
print("Magic: " + str(hero.magic))
print("What do you want to do?")
print("1) attack")
print("2) attack with aid of magic")
print("3) defend")
answer = input(">>> ")
if answer == "1":
damage = hero.attack(bad_guy)
print("You attacked " + bad_guy.name + " and did " + str(damage) + " damage")
elif answer == "2":
if hero.magic > 0:
damage = hero.attack(bad_guy,True)
print("You attacked " + bad_guy.name + "with magic and did " + str(damage) + " damage")
else:
hero.magic = 0
damage = hero.attack(bad_guy)
print("You don't have any magic!")
print("You attacked " + bad_guy.name + " and did " + str(damage) + " damage")
elif answer == "3":
print("Your defense is temporarily increased")
hero.defense = hero.defense + 0.25 * hero.defense
else:
print("That's not an option!")
damage = bad_guy.attack(me)
print(bad_guy.name + " attacked and did "+ str(damage) + " damage to you.")
if answer == 3:
hero.defense = 0.8*hero.defense
if bad_guy.hp <= 0:
if bad_guy.level > hero.level:
hero.gain_experience((bad_guy.level-hero.level)*100)
elif bad_guy.level == hero.level:
hero.gain_experience(50)
else:
hero.gain_experience(50/(hero.level - bad_guy.level))
return True
elif hero.hp <= 0:
print(bad_guy.name + " killed you. You Lose.")
return False
elif hero.hp <= 0 and bad_guy.hp <= 0:
print("Good news: You killed " + bad_guy.name + ". Bad News: You died too. Sucks to be you")
return False
def adventure():
adventuring = True
while adventuring:
print("What would you like to do today?")
print("1) find a bad guy to fight")
print("2) look for magical treasures")
answer = input(">>> ")
chance = random.random()
if answer == "1":
if chance <= 0.75:
baddy = BadGuy("monster")
return fight_bad_guy(me,baddy)
else:
print("You weren't able to find any bad guys")
return True
elif answer == "2":
if chance <= 0.25:
pass
print("""
Kill teh monsters so dat you don't die from da BOSS!
""")
alive = True
day = 1
BOSS_DOOMSDAY = 100
while alive and day < BOSS_DOOMSDAY:
print("What would you like to do today?")
print("1) Go out adventuring")
print("2) Stay home an study the magic tome")
print("3) Rest/Heal from wounds")
print("4) Meditate to rejuvenate magic")
print("5) Go face the evil bad guy now (and most likely die)")
answer = input(">>> ")
if answer == "1":
alive = adventure()
elif answer == "2":
pass
else:
print("That's not an option")