- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.py
More file actions
Latest commit
101 lines (87 loc) · 3.26 KB
/
Copy pathgame.py
File metadata and controls
101 lines (87 loc) · 3.26 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
fromconsoleRPGimport*
importrandom
me=Hero("me")
boss=BadGuy("MegaBad",hp=200,strength=50,defense=50,level=20)
deffight_bad_guy(hero,bad_guy):
whilehero.hp>0andbad_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(">>> ")
ifanswer=="1":
damage=hero.attack(bad_guy)
print("You attacked "+bad_guy.name+" and did "+str(damage) +" damage")
elifanswer=="2":
ifhero.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")
elifanswer=="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.")
ifanswer==3:
hero.defense=0.8*hero.defense
ifbad_guy.hp<=0:
ifbad_guy.level>hero.level:
hero.gain_experience((bad_guy.level-hero.level)*100)
elifbad_guy.level==hero.level:
hero.gain_experience(50)
else:
hero.gain_experience(50/(hero.level-bad_guy.level))
returnTrue
elifhero.hp<=0:
print(bad_guy.name+" killed you. You Lose.")
returnFalse
elifhero.hp<=0andbad_guy.hp<=0:
print("Good news: You killed "+bad_guy.name+". Bad News: You died too. Sucks to be you")
returnFalse
defadventure():
adventuring=True
whileadventuring:
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()
ifanswer=="1":
ifchance<=0.75:
baddy=BadGuy("monster")
returnfight_bad_guy(me,baddy)
else:
print("You weren't able to find any bad guys")
returnTrue
elifanswer=="2":
ifchance<=0.25:
pass
print("""
Kill teh monsters so dat you don't die from da BOSS!
""")
alive=True
day=1
BOSS_DOOMSDAY=100
whilealiveandday<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(">>> ")
ifanswer=="1":
alive=adventure()
elifanswer=="2":
pass
else:
print("That's not an option")