Ejemplo n.º 1
0
def makeTextServer(reactor, world=None):
    store = Store()
    if world is not None:
        world = loadWorld(world, store)
        actorThing = findActorThing(store)
    else:
        world = ImaginaryWorld(store=store)
        actorThing = world.create("player")

    tsb = ConsoleTextServer(Player(actorThing), sys.__stdin__.fileno())

    def winchAccess(signum, frame):
        reactor.callFromThread(tsb.terminalSize, *getTerminalSize()[::-1])

    signal.signal(signal.SIGWINCH, winchAccess)
    return tsb
Ejemplo n.º 2
0
    def test_creationEvent(self):
        """
        When a new L{Thing} is created via L{ImaginaryWorld.create}, its
        addition to L{ImaginaryWorld.origin} is broadcast to that location.
        """
        store = Store()
        world = ImaginaryWorld(store=store)
        observer = world.create(u"observer")

        # There really needs to be a way to get into the event dispatch
        # system.  It's so hard right now that I'm not even going to try,
        # instead I'll look at some strings that get written to a transport.
        observingPlayer = Player(observer)
        transport = StringTransport()
        observingPlayer.setProtocol(PlayerProtocol(transport))

        # Make another thing for the observer to watch the creation of.
        world.create(u"foo")

        self.assertEquals(transport.value(), "Foo arrives.\n")
Ejemplo n.º 3
0
 def play(self, character):
     self.player = Player(character)
     self.player.setProtocol(self)
     self.world.loggedIn(character)
     self._prepareDisplay()
     return 'COMMAND'