コード例 #1
0
ファイル: test_japanese.py プロジェクト: ashfall/imaginary
    def test_twoMenLeave(self):
        """
        Test that when two players are near the mouse, the mouse doesn't
        unschedule its challenge until they both leave.
        """
        otherPlayer = commandutils.createPlayer(self.store,
                                                u"Polite Young Man")[0]
        otherPlayer.moveTo(self.clock)

        self.mousehood.startChallenging()

        firstEvent = events.DepartureEvent(location=self.clock,
                                           actor=self.player)
        secondEvent = events.DepartureEvent(location=self.clock,
                                            actor=otherPlayer)

        otherPlayer.moveTo(None)
        self.mouseActor.send(secondEvent)

        self.playerIntelligence.concepts = []

        self.reactorTime.advance(self.mousehood.challengeInterval)

        self.assertEquals(len(self.playerIntelligence.concepts), 1)
        self.assertChallenge(self.playerIntelligence.concepts[0])

        self.player.moveTo(None)
        self.mouseActor.send(firstEvent)

        self.failIf(self.mousehood.challenging)
コード例 #2
0
    def test_twoMenLeave(self):
        """
        Test that when two players are near the mouse, the mouse doesn't
        unschedule its challenge until they both leave.
        """
        otherPlayer = commandutils.createPlayer(self.store,
                                                u"Polite Young Man")[0]
        otherPlayer.moveTo(self.clock)

        self.mousehood.startChallenging()

        firstEvent = events.DepartureEvent(location=self.clock,
                                           actor=self.player)
        secondEvent = events.DepartureEvent(location=self.clock,
                                            actor=otherPlayer)

        otherPlayer.moveTo(None)
        self.mouseActor.send(secondEvent)

        self.playerIntelligence.concepts = []

        self.reactorTime.advance(self.mousehood.challengeInterval)

        self.assertEquals(len(self.playerIntelligence.concepts), 1)
        self.assertChallenge(self.playerIntelligence.concepts[0])

        self.player.moveTo(None)
        self.mouseActor.send(firstEvent)

        self.failIf(self.mousehood.challenging)
コード例 #3
0
ファイル: test_drop.py プロジェクト: ashfall/imaginary
    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)
コード例 #4
0
ファイル: test_japanese.py プロジェクト: ashfall/imaginary
    def test_twoMenEnter(self):
        """
        Test that when *TWO* players join, the mouse doesn't schedule too many
        challenges.
        """
        otherPlayer = commandutils.createPlayer(self.store,
                                                u"Polite Young Man")[0]

        # Send an arrival event because setUp doesn't
        firstEvent = events.ArrivalEvent(actor=self.player)

        self.mouseActor.send(firstEvent)
        otherPlayer.moveTo(self.clock, arrivalEventFactory=events.MovementArrivalEvent)

        self.playerIntelligence.concepts = []
        self.reactorTime.advance(self.mousehood.challengeInterval)

        self.assertEquals(len(self.playerIntelligence.concepts), 1)
        self.assertChallenge(self.playerIntelligence.concepts[0])
コード例 #5
0
    def test_twoMenEnter(self):
        """
        Test that when *TWO* players join, the mouse doesn't schedule too many
        challenges.
        """
        otherPlayer = commandutils.createPlayer(self.store,
                                                u"Polite Young Man")[0]

        # Send an arrival event because setUp doesn't
        firstEvent = events.ArrivalEvent(actor=self.player)

        self.mouseActor.send(firstEvent)
        otherPlayer.moveTo(self.clock, arrivalEventFactory=events.MovementArrivalEvent)

        self.playerIntelligence.concepts = []
        self.reactorTime.advance(self.mousehood.challengeInterval)

        self.assertEquals(len(self.playerIntelligence.concepts), 1)
        self.assertChallenge(self.playerIntelligence.concepts[0])
コード例 #6
0
    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)
コード例 #7
0
    def setUp(self):
        self.store = store.Store()

        self.clock = objects.Thing(store=self.store, name=u"Clock")
        self.clockContainer = objects.Container.createFor(self.clock,
                                                          capacity=10)

        self.mouseName = u"\N{KATAKANA LETTER PI}\N{KATAKANA LETTER SMALL YU}"
        self.mouse = mice.createHiraganaMouse(store=self.store,
                                              name=self.mouseName)
        self.mouseActor = iimaginary.IActor(self.mouse)
        self.mousehood = self.mouseActor.getIntelligence()
        self.mouse.moveTo(self.clock)

        (self.player, self.playerActor,
         self.playerIntelligence) = commandutils.createPlayer(
             self.store, u"Mean Old Man")

        self.player.moveTo(self.clock)

        self.reactorTime = task.Clock()
        self.mousehood._callLater = self.reactorTime.callLater
コード例 #8
0
ファイル: test_japanese.py プロジェクト: ashfall/imaginary
    def setUp(self):
        self.store = store.Store()

        self.clock = objects.Thing(store=self.store, name=u"Clock")
        self.clockContainer = objects.Container.createFor(self.clock, capacity=10)

        self.mouseName = u"\N{KATAKANA LETTER PI}\N{KATAKANA LETTER SMALL YU}"
        self.mouse = mice.createHiraganaMouse(
            store=self.store,
            name=self.mouseName)
        self.mouseActor = iimaginary.IActor(self.mouse)
        self.mousehood = self.mouseActor.getIntelligence()
        self.mouse.moveTo(self.clock)

        (self.player,
         self.playerActor,
         self.playerIntelligence) = commandutils.createPlayer(self.store,
                                                              u"Mean Old Man")


        self.player.moveTo(self.clock)

        self.reactorTime = task.Clock()
        self.mousehood._callLater = self.reactorTime.callLater