-
Notifications
You must be signed in to change notification settings - Fork 0
/
class_Room.py
141 lines (117 loc) · 4.17 KB
/
class_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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
from random import randint
from class_enemyGenerator import EnemyGenerator
from termcolor import colored
from class_happening import happening as hap, quest_
class Room:
def __init__(self, name, creatures=None, north=None, east=None, south=None, west=None, region='', proba=50, preposition='', item=None, room_lvl=1, counter_max=10000, quest=quest_()):
self.name = name
self.north = north
self.east = east
self.south = south
self.west = west
self.proba = proba
self.creatures = creatures
self.item = item
self.room_lvl = room_lvl
self.counter_max = counter_max
self.counter = 0
self.quest = quest
self.region = region
self.preposition = preposition
def set_north(self, room):
self.north = room
room.south = self
def set_south(self, room):
self.south = room
room.north = self
def set_west(self, room):
self.west = room
room.east = self
def set_east(self, room):
self.east = room
room.west = self
def happening(self, hero):
if self.counter < self.counter_max:
if randint(1, 100) <= self.proba and self.creatures != None:
opponent_index = self.creatures[randint(0, len(self.creatures)-1)]
opponent_ini = EnemyGenerator(opponent_index)
opponent = opponent_ini.generate(self.room_lvl, time=hero.time)
fighting = hero._fight(opponent)
if fighting == 0:
return 0
self.quest.first(hero)
if self.item != None:
pick = raw_input('you found an item: %s , do you wish to pick it up? y/n' % (colored(self.item.name, color='cyan')))
if pick == 'y':
hero.pickup(self.item)
print 'You picked up a %s !' % (colored(self.item.name, 'cyan'))
else:
print'you left the %s in the %s' % (colored(self.item.name, 'cyan'), colored(self.name, 'blue'))
def directions(self):
if self.north != None:
up = self.north.name
else:
up = 'No way'
if self.south != None:
down = self.south.name
else:
down = 'No way'
if self.east != None:
right = self.east.name
else:
right = 'No way'
if self.west != None:
left = self.west.name
else:
left = 'No way'
print'west -> %s ; north -> %s ; south -> %s,east -> %s' % (colored(left, 'yellow'), colored(up, 'blue'), colored(down, 'red'), colored(right, 'green'))
def print_place(self):
if self.region == 'Anaheim':
print('''
_ _ _
/ \ _ __ __ _| |__ ___(_)_ __ ___
/ _ \ | '_ \ / _` | '_ \ / _ \ | '_ ` _ |
/ ___ \| | | | (_| | | | | __/ | | | | | |
/_/ \_\_| |_|\__,_|_| |_|\___|_|_| |_| |_|
''')
elif self.region == 'Elanor':
print('''
_____ _
| ____| | __ _ _ __ ___ _ __
| _| | |/ _` | '_ \ / _ \| '__|
| |___| | (_| | | | | (_) | |
|_____|_|\__,_|_| |_|\___/|_|
''')
elif self.region == 'Plains':
print('''
____ _ _
| _ \| | __ _(_)_ __ ___
| |_) | |/ _` | | '_ \/ __|
| __/| | (_| | | | | \__ \.
|_| |_|\__,_|_|_| |_|___/
''')
elif self.region == 'Woods':
print('''
__ __ _
\ \ / /__ ___ __| |___
\ \ /\ / / _ \ / _ \ / _` / __|
\ V V / (_) | (_) | (_| \__ \.
\_/\_/ \___/ \___/ \__,_|___/
''')
elif self.region == 'Mountains':
print('''
__ __ _ _
| \/ | ___ _ _ _ __ | |_ __ _(_)_ __ ___
| |\/| |/ _ \| | | | '_ \| __/ _` | | '_ \/ __|
| | | | (_) | |_| | | | | || (_| | | | | \__ \.
|_| |_|\___/ \__,_|_| |_|\__\__,_|_|_| |_|___/
''')
elif self.region == 'swamps':
print('''
____
/ ___|_ ____ _ _ __ ___ _ __ ___
\___ \ \ /\ / / _` | '_ ` _ \| '_ \/ __|
___) \ V V / (_| | | | | | | |_) \__ \.
|____/ \_/\_/ \__,_|_| |_| |_| .__/|___/
|_|
''')