-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.py
51 lines (43 loc) · 1.42 KB
/
helpers.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
# helpers.py
class MapHelper:
@staticmethod
def get_room_by_id(room_id, rooms):
for row in rooms:
for room in row:
if room is not None and room.id == room_id:
return room
@staticmethod
def get_room_to_north_of(room, rooms):
for y in range(len(rooms)):
for x in range(len(rooms[y])):
if rooms[y][x] == room and y > 0:
return rooms[y - 1][x]
return None
@staticmethod
def get_room_to_south_of(room, rooms):
for y in range(len(rooms)):
for x in range(len(rooms[y])):
if rooms[y][x] == room and y < len(rooms) - 1:
return rooms[y + 1][x]
return None
@staticmethod
def get_room_to_west_of(room, rooms):
for y in range(len(rooms)):
for x in range(len(rooms[y])):
if rooms[y][x] == room and x > 0:
return rooms[y][x - 1]
return None
@staticmethod
def get_room_to_east_of(room, rooms):
for y in range(len(rooms)):
for x in range(len(rooms[y])):
if rooms[y][x] == room and x < len(rooms[y]) - 1:
return rooms[y][x + 1]
return None
class GameobjectHelper:
@staticmethod
def get_gameobject_by_id(list, id):
for i in list:
if i.id == id:
return i
return None