This repository was archived by the owner on May 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathobj.py
More file actions
47 lines (43 loc) · 1.33 KB
/
obj.py
File metadata and controls
47 lines (43 loc) · 1.33 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
import parser #for accessing local player data ==> from parser import player does not work
class Object:
"""
Object Class:
Interacable object within the world.
Exp:
a door
"""
def __init__(self, name, desc, data=None, break_desc=None, open_desc=None, blocking=None):
"""
data is the content if any of
break_desc/open_desc: if set obj is breakable/openable, also provied desc of the breaking/opening of obj
blocking shows the room this onject blocks
"""
self.name = name
self.desc = desc
#self.room = room <== not needed because its always the player room
self.data = data
self.break_desc = break_desc
self.open_desc = open_desc
self.blocking = blocking
def change_data(self, newdata):
self.data = newdata
# def set_room(self, room):<==same as above
# self.room = room
def trigger(self, op): # move method to room class!!
"""
is called as member function of the object it triggers
"""
if op == "break":
if self.break_desc == None:
print("You can't break this")
else:
print(self.break_desc)
self.blocking.open_access()
tmp_room = parser.player.get_room()
del tmp_room.objects[self.name]#deletes itself here? maybe move > see above
elif op == "open":
if self.open_desc == None:
print("You can't open this")
else:
print(self.open_desc)
self.blocking.open_access()