wiseobject.py 1.01 KB
'''
Created on Dec 20, 2016

@author: Xorfos
'''

from random import import choice
from typeclasses.objects import Object

class WiseObject(Object):
    """
    
    An object speaking when someone looks at it. We
    assume it looks like a stone in this example.
    """
    
    def at_object_creation(self):
        "Called when object is first created"
        self.db.wise_texts = \
            ["Stones have feelings too.",
             "To live like a stone is to not have lived at all."
             "The world is like a rock of chocolate."]
    
    def return_appearance(self, looker):
        """
        Called by the look command. We want to return
        a wisdom when we get looked at.
        """
        
        #first get the base string from the
        #parent's return_appearance'
        
        string = super(WiseObject, self).return_appearance(looker)
        wisewords = "\n\nlt grumbles and says: '%s'"
        wisewords = wisewords % choice(self.db.wise_texts)
        return string + wisewords