26e16c8e by Branden

#First Steps Coding, a new object

1 parent b440aa07
1 '''
2 Created on Dec 20, 2016
3
4 @author: Xorfos
5 '''
6
7 from random import import choice
8 from typeclasses.objects import Object
9
10 class WiseObject(Object):
11 """
12
13 An object speaking when someone looks at it. We
14 assume it looks like a stone in this example.
15 """
16
17 def at_object_creation(self):
18 "Called when object is first created"
19 self.db.wise_texts = \
20 ["Stones have feelings too.",
21 "To live like a stone is to not have lived at all."
22 "The world is like a rock of chocolate."]
23
24 def return_appearance(self, looker):
25 """
26 Called by the look command. We want to return
27 a wisdom when we get looked at.
28 """
29
30 #first get the base string from the
31 #parent's return_appearance'
32
33 string = super(WiseObject, self).return_appearance(looker)
34 wisewords = "\n\nlt grumbles and says: '%s'"
35 wisewords = wisewords % choice(self.db.wise_texts)
36 return string + wisewords
37
...\ No newline at end of file ...\ No newline at end of file