Exemplo n.º 1
0
    def test_oneManEnters(self):
        """
        Test that when a fellow jaunts into a venue inhabited by a mouse of the
        Nipponese persuasion, a hiragana allocution follows.
        """
        clock = task.Clock()

        closetContainer = commandutils.createLocation(self.store, u"Closet",
                                                      None)
        closet = closetContainer.thing

        mouse = mice.createHiraganaMouse(store=self.store,
                                         name=self.mouseName,
                                         proper=True)
        mouseActor = iimaginary.IActor(mouse)
        mousehood = mouseActor.getIntelligence()
        mousehood._callLater = clock.callLater
        mouse.moveTo(closet)

        objects.Exit.link(self.location, closet, u"north")

        self._test("north", [
            commandutils.E("[ Closet ]"),
            commandutils.E("( south )"),
            commandutils.E(u"Here, you see " + self.mouseName + u".")
        ], ["Test Player leaves north."])

        clock.advance(mousehood.challengeInterval)

        self._test(None, [self.speechPattern])
Exemplo n.º 2
0
    def test_creation(self):
        """
        Test the creation of a hiragana-speaking mouse using the thing creation
        plugin system.
        """
        self._test(
            u"create the 'hiragana mouse' named " + self.mouseName,
            [commandutils.E(u"You create " + self.mouseName + u".")],
            [commandutils.E(u"Test Player creates %s." % (self.mouseName,))])

        for thing in self.location.findProviders(iimaginary.IThing, 0):
            if thing.name == self.mouseName:
                break
        else:
            self.fail("Could not find the mouse!  Test bug.")

        clock = task.Clock()
        jimhood = iimaginary.IActor(thing).getIntelligence()
        jimhood._callLater = clock.callLater

        self._test(
            u"drop " + self.mouseName,
            [commandutils.E(u"You drop %s." % (self.mouseName,))],
            [commandutils.E(u"Test Player drops %s." % (self.mouseName,))])

        clock.advance(jimhood.challengeInterval)

        self._test(
            None,
            [self.speechPattern],
            [self.speechPattern])
Exemplo n.º 3
0
    def testSqueak(self):
        """
        Test that when someone walks into a room with a mouse, the mouse
        squeaks and the person who walked in hears it.
        """
        mouse = mice.createMouse(store=self.store, name=u"squeaker")
        clock = task.Clock()
        intelligence = iimaginary.IActor(mouse).getIntelligence()
        intelligence._callLater = clock.callLater

        elsewhere = commandutils.createLocation(
            self.store, u"Mouse Hole", None).thing

        objects.Exit.link(self.location, elsewhere, u"south")

        mouse.moveTo(elsewhere)

        self._test(
            "south",
            [commandutils.E("[ Mouse Hole ]"),
             commandutils.E("( north )"),
             commandutils.E("Here, you see a squeaker.")],
            ['Test Player leaves south.'])

        clock.advance(0)
        self._test(None, ["SQUEAK!"])
Exemplo n.º 4
0
    def testTorch(self):
        objects.LocationLighting.createFor(self.location, candelas=0)
        self._test("create a torch named torch", ["You create a torch."],
                   ["Test Player creates a torch."])

        self._test("look", [
            commandutils.E("[ Test Location ]"), "Location for testing.",
            "Here, you see Observer Player."
        ])
Exemplo n.º 5
0
 def test_actionWithTargetInAdjacentDarkRoom(self):
     """
     If a player is standing I{next} to a dark room, they should not be able
     to locate targets in the dark room, but the reporting in this case
     should be normal, not the "It's too dark to see" that would result if
     they were in the dark room themselves.
     """
     self.otherRoom = objects.Thing(store=self.store, name=u'Elsewhere')
     objects.Container.createFor(self.otherRoom, capacity=1000)
     objects.Exit.link(self.location, self.otherRoom, u'west')
     self.player.moveTo(self.otherRoom)
     self.observer.moveTo(self.otherRoom)
     self.assertCommandOutput("wear pants",
                              [commandutils.E(u"Who's that?")], [])
Exemplo n.º 6
0
    def test_creation(self):
        """
        Test the creation of a hiragana-speaking mouse using the thing creation
        plugin system.
        """
        self._test(
            u"create the 'hiragana mouse' named " + self.mouseName,
            [commandutils.E(u"You create " + self.mouseName + u".")],
            [commandutils.E(u"Test Player creates %s." % (self.mouseName, ))])

        [thing] = find(self.location.idea, distance=0, name=self.mouseName)

        clock = task.Clock()
        jimhood = iimaginary.IActor(thing).getIntelligence()
        jimhood._callLater = clock.callLater

        self._test(
            u"drop " + self.mouseName,
            [commandutils.E(u"You drop %s." % (self.mouseName, ))],
            [commandutils.E(u"Test Player drops %s." % (self.mouseName, ))])

        clock.advance(jimhood.challengeInterval)

        self._test(None, [self.speechPattern], [self.speechPattern])
Exemplo n.º 7
0
 def testLookingIntoDarkness(self):
     objects.LocationLighting.createFor(self.location, candelas=0)
     self._test("look", [
         commandutils.E("[ Blackness ]"),
         "You cannot see anything because it is very dark."
     ])