-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject.py
More file actions
38 lines (31 loc) · 1.02 KB
/
object.py
File metadata and controls
38 lines (31 loc) · 1.02 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
import printing
import asciipictures
class Object:
def __init__(self, name, description):
self.name = name
self.description = description
self.carryable = False
self.image = ""
self.pickup_cmd = []
def add_pickup_cmd(self, cmd):
self.pickup_cmd.append(cmd)
def make_carryable(self):
self.carryable = True
def add_image(self, image):
self.image = image
def show(self):
if self.image == "":
return "No pictures available"
else:
return asciipictures.display(self.image)
def pickup(self, this, key, stdscr):
stdscr.clear()
for cmd in self.pickup_cmd:
cmd.execute()
if self.carryable:
printing.print_at_speed("You pickup the " + self.name + ".\n", 100, stdscr)
this.inventory[key] = self
else:
printing.print_at_speed("Can't pickup " + self.name + "!\n", 100, stdscr)
stdscr.getch()
stdscr.refresh()