def create(self, name, **kw): """ Make a new character L{Thing} with the given name and return it. @type name: C{unicode} @rtype: L{Thing} """ if self.origin is None: self.origin = Thing(store=self.store, name=u"The Place") Container.createFor(self.origin, capacity=1000) if 'proper' not in kw: kw['proper'] = True character = Thing(store=self.store, weight=100, name=name, **kw) Container.createFor( character, capacity=10, contentsTemplate=u"{subject:pronoun} is carrying {contents}.") Actor.createFor(character) # Unfortunately, world -> garments -> creation -> action -> # world. See #2906. -exarkun from imaginary.garments import Wearer Wearer.createFor(character) character.moveTo( self.origin, lambda player: MovementArrivalEvent( thing=player, origin=None, direction=None)) return character
def create(self, name, **kw): """ Make a new character L{Thing} with the given name and return it. @type name: C{unicode} @rtype: L{Thing} """ if self.origin is None: self.origin = Thing(store=self.store, name=u"The Place") Container.createFor(self.origin, capacity=1000) character = Thing(store=self.store, weight=100, name=name, proper=True, **kw) Container.createFor(character, capacity=10) Actor.createFor(character) # Unfortunately, world -> garments -> creation -> action -> # world. See #2906. -exarkun from imaginary.garments import Wearer Wearer.createFor(character) character.moveTo( self.origin, lambda player: MovementArrivalEvent( thing=player, origin=None, direction=None)) return character
def setUp(self): """ Tether a ball to the room. """ CommandTestCaseMixin.setUp(self) self.ball = Thing(store=self.store, name=u'ball') self.ball.moveTo(self.location) self.tether = Tether.createFor(self.ball, to=self.location) self.otherPlace = Thing(store=self.store, name=u'elsewhere') Container.createFor(self.otherPlace, capacity=1000) Exit.link(self.location, self.otherPlace, u'north')
def applyEnhancement(self): """ Apply this enhancement to this L{Chair}'s thing, creating a L{Container} to hold the seated player, if necessary. """ super(Chair, self).applyEnhancement() container = IContainer(self.thing, None) if container is None: container = Container.createFor(self.thing, capacity=300) self.container = container
def setUp(self): """ Create a room with a L{GlassBox} in it, which itself contains a ball. """ CommandTestCaseMixin.setUp(self) self.box = Thing(store=self.store, name=u'box', description=u'The system under test.') self.ball = Thing(store=self.store, name=u'ball', description=u'an interesting object') self.container = Container.createFor(self.box) GlassBox.createFor(self.box) self.ball.moveTo(self.box) self.box.moveTo(self.location) self.container.closed = True
def test_squeakyContainer(self): """ If a container is squeaky, that shouldn't interfere with its function as a container. (i.e. let's make sure that links keep working even though we're using an annotator here.) """ cont = Container.createFor(self.squeaker) mcguffin = Thing(store=self.store, name=u"mcguffin") mcguffin.moveTo(cont) self.assertCommandOutput( "take mcguffin from squeaker", ["You take a mcguffin from the squeaker."], ["Test Player takes a mcguffin from the squeaker."])
def test_arrivalEvent(self): """ Test that when a thing is dropped, an ArrivalEvent instance is broadcast to the room it is dropped into. """ st = Store() player, actor, intelligence = createPlayer(st, u"Foo") place = Thing(store=st, name=u"soko") player.moveTo(Container.createFor(place, capacity=1000)) bauble = Thing(store=st, name=u"bauble") bauble.moveTo(player) Drop().runEventTransaction(player, None, dict(target=bauble.name)) self.assertEquals(len([concept for concept in intelligence.concepts if isinstance(concept, ArrivalEvent)]), 1)
def setUp(self): self.store = store.Store() self.bob = objects.Thing(store=self.store, name=u"bob") self.room = objects.Thing(store=self.store, name=u"a place") roomContainer = Container.createFor(self.room, capacity=1000) self.bob.moveTo(roomContainer) self.actor = objects.Actor.createFor(self.bob) self.player = player.Player(self.bob) self.player.useColors = False from twisted.test.proto_helpers import StringTransport self.transport = StringTransport() class Protocol: write = self.transport.write self.player.setProtocol(Protocol())
def test_arrivalEvent(self): """ Test that when a thing is dropped, an ArrivalEvent instance is broadcast to the room it is dropped into. """ st = Store() player, actor, intelligence = createPlayer(st, u"Foo") place = Thing(store=st, name=u"soko") player.moveTo(Container.createFor(place, capacity=1000)) bauble = Thing(store=st, name=u"bauble") bauble.moveTo(player) Drop().runEventTransaction(player, None, dict(target=bauble.name)) self.assertEquals( len([ concept for concept in intelligence.concepts if isinstance(concept, ArrivalEvent) ]), 1)
def room(name): it = Thing(store=store, name=name) Container.createFor(it, capacity=1000) return it