Example #1
0
    def test_mouseStartsChallengingWhenPlayersArrive(self):
        """
        When a player arrives, the mouse should go into the 'I am
        challenging' state.
        """
        # Whitebox
        self.assertEquals(self.mousehood.challenging, False)

        evt = events.ArrivalEvent(actor=self.player)
        self.mouseActor.send(evt)

        self.assertEquals(self.mousehood.challenging, True)
Example #2
0
    def do(self, player, line, target):
        if target.location is not player.thing:
            raise eimaginary.ActionFailure(
                events.ThatDoesntMakeSense(
                    actor=player.thing, actorMessage="You can't drop that."))

        try:
            target.moveTo(
                player.thing.location,
                arrivalEventFactory=lambda target: events.ArrivalEvent(
                    actor=player.thing,
                    actorMessage=("You drop ", language.Noun(target).
                                  definiteNounPhrase(), "."),
                    target=target,
                    targetMessage=(player.thing, " drops you."),
                    otherMessage=(player.thing, " drops ", target, ".")))
        except eimaginary.DoesntFit:
            raise insufficientSpace(player.thing)
Example #3
0
    def test_mouseSqueaksAtIntruders(self):
        """
        When a mean old man walks into the mouse's clock, the mouse will squeak
        ruthlessly.
        """
        clock = task.Clock()
        self.mousehood._callLater = clock.callLater
        evt = events.ArrivalEvent(actor=self.player)
        self.mouseActor.send(evt)

        self.assertEquals(len(self.playerIntelligence.concepts), 0)
        clock.advance(0)

        self.assertEquals(len(self.playerIntelligence.concepts), 1)
        event = self.playerIntelligence.concepts[0]
        self.assertEquals(
            commandutils.flatten(event.otherMessage.plaintext(self.player)),
            u"SQUEAK!")
Example #4
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])