1
# -*- test-case-name: examplegame.test.test_squeaky -*-
4
This module implements an L{ILinkAnnotator} which causes an object to squeak
5
when it is moved. It should serve as a simple example for overriding what
6
happens when an action is executed (in this case, 'take' and 'drop').
9
from zope.interface import implements
11
from axiom.item import Item
12
from axiom.attributes import reference
14
from imaginary.iimaginary import IMovementRestriction, IConcept
15
from imaginary.events import Success
16
from imaginary.enhancement import Enhancement
17
from imaginary.objects import Thing
20
class Squeaker(Item, Enhancement):
22
This is an L{Enhancement} which, when installed on a L{Thing}, causes that
23
L{Thing} to squeak when you pick it up.
26
implements(IMovementRestriction)
28
powerupInterfaces = [IMovementRestriction]
30
thing = reference(allowNone=False,
31
whenDeleted=reference.CASCADE,
35
def movementImminent(self, movee, destination):
37
The object enhanced by this L{Squeaker} is about to move - emit a
38
L{Success} event which describes its squeak.
40
Success(otherMessage=(IConcept(self.thing).capitalizeConcept(),
41
" emits a faint squeak."),
42
location=self.thing.location).broadcast()