-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroom.py
105 lines (86 loc) · 3.16 KB
/
room.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
102
103
104
105
from monster import Monster
from endboss import Endboss
from bosslist import ByteBoss,HipsterBoss
from settings import Settings
from chest import Chest
import random, time,sys
from random import uniform
from colorama import init, Fore, Back, Style
from stringhandler import Stringhandler
class Room(object):
def __init__(self,difficulty,player):
self.hasMonster = False
self.hasBoss = False
self.hasChest = False
self.isDone = False
self.difficulty = difficulty
self.settings = Settings()
self.goal = self.settings.getGoal()
self.player = player
self.chest = Chest(self.player)
self.monster = Monster()
self.inspected = False
self.handler = Stringhandler()
self.boss = Endboss()
self.endboss = self.boss.randomBoss(player)
# Sets up a new Room and displays some "Intro Text"
def newRoom(self):
self.isDone = False
string = "\n\n#######################################"+"\n\n"+\
self.handler.strRoom("intro",self)+"\n\n"+\
"#######################################"+"\n\n"
for char in string:
time.sleep(uniform(0.05, 0.01))
sys.stdout.write('\033[35m'+char)
sys.stdout.flush()
print Fore.WHITE
# Decides whether the room gets a monster or a chest
if int(self.player.level) <= int(self.goal):
rnd = random.randint(0,10)
if rnd > 1:
self.hasMonster = True
else:
self.hasChest = True
# Setup monster
if self.hasMonster:
if self.difficulty == "easy":
self.monster.setup(1,self.player.level)
else:
self.monster.setup(2,self.player.level)
# Setup chest
elif self.hasChest:
if self.difficulty == "easy":
self.chest.level = random.randint(1,10)
return self.handler.strActions("roomEmpty",self.player,self)
else:
self.chest.level = random.randint(1,10)
else:
self.finish()
else:
self.hasBoss = True
return self.boss.spawn(self.player)
def getRoom(self,difficulty,player):
return Room(difficulty,player)
def getBoss(self):
return self.boss
# If the player has used "look around" the room should be set to inspected
def inspectRoom(self):
self.inspected = True
# Kills the monster in this Room, required for the player to be able to continue -> Room set to "Done"
def killMonster(self):
self.monster.kill()
self.player.lvlUp()
self.finish()
def attackMonster(self,player):
room = self
return self.monster.attack(room,player)
# Opens the chest, required for the player to be able to continue -> Room set to "Done"
def openChest(self):
self.finish()
return self.chest.open(self.player)
def is_done(self):
return self.isDone
def finish(self):
self.isDone = True
if self.hasChest:
self.chest.is_opened = True