-
Notifications
You must be signed in to change notification settings - Fork 0
/
endboss.py
74 lines (61 loc) · 2.53 KB
/
endboss.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
import bosslist as Bosslist
from bosslist import ByteBoss,HipsterBoss
import random, time,sys
from random import uniform
from stringhandler import Stringhandler
class Endboss(object):
def __init__(self):
self.handler = Stringhandler()
self.bossList = []
self.byteBoss = Bosslist.ByteBoss()
self.hipsterBoss = Bosslist.HipsterBoss()
self.boss = None
def randomBoss(self,player):
self.bossList.append(self.byteBoss)
self.bossList.append(self.hipsterBoss)
# self.bossList.append("")
# self.bossList.append("")
self.boss = random.choice(self.bossList)
return self.boss
def kill(self):
self.boss.killed = True
def takeDamage(self,damage,player):
self.boss.hp -= damage
def getHP(self):
return self.boss.hp
def calcDamage(self):
damage = self.boss.strength + random.randint(0,3)
return damage
def attackFromPlayer(self,player):
damage = player.getStrength()+random.randint(0,3)
if (self.boss.hp - damage <= 0):
self.kill()
player.facesBoss = False
player.victory = True
if isinstance(self.boss,ByteBoss):
return self.handler.strBoss("bDie",player,damage)
elif isinstance(self.boss,HipsterBoss):
return self.handler.strBoss("hDie",player,damage)
else:
return "Error 404: Boss not found"
else:
self.takeDamage(damage,player)
if isinstance(self.boss,ByteBoss):
print self.handler.strBoss("bHit",player,damage)+"\n"+self.handler.strMonsterDamage("returnHP",self.boss,damage,player)
return "\n"+self.attack(player)
elif isinstance(self.boss,HipsterBoss):
print self.handler.strBoss("hHit",player,damage)+"\n"+self.handler.strMonsterDamage("returnHP",self.boss,damage,player)+"\n"
return self.attack(player)
def attack(self,player):
damage = self.calcDamage()
if isinstance(self.boss,ByteBoss):
return player.takeDamage(damage,self.boss)
elif isinstance(self.boss,HipsterBoss):
return player.takeDamage(damage,self.boss)
def spawn(self,player):
player.facesBoss = True
damage = self.calcDamage()
if isinstance(self.boss,ByteBoss):
return self.handler.strBoss("bSpawn",player,damage)
elif isinstance(self.boss,HipsterBoss):
return self.handler.strBoss("hSpawn",player,damage)