示例#1
0
    def test_autocmdsets(self):
        import evennia
        from evennia.commands.default.cmdset_account import AccountCmdSet
        from evennia.comms.channelhandler import CHANNEL_HANDLER
        testchannel = evennia.create_channel("channeltest",
                                             locks="listen:all();send:all()")
        CHANNEL_HANDLER.add(testchannel)
        CHANNEL_HANDLER.update()
        self.assertTrue(testchannel.connect(self.account))
        self.assertTrue(testchannel.has_connection(self.account))
        a, b, c, d = self.cmdset_a, self.cmdset_b, self.cmdset_c, self.cmdset_d
        self.set_cmdsets(self.account, a, b, c, d)
        deferred = cmdhandler.get_and_merge_cmdsets(self.session, self.session,
                                                    self.account, self.char1,
                                                    "session", "")

        def _callback(cmdset):
            pcmdset = AccountCmdSet()
            pcmdset.at_cmdset_creation()
            pcmds = [cmd.key for cmd in pcmdset.commands
                     ] + ["a", "b", "c", "d"] + ["out"]
            self.assertTrue(
                all(cmd.key or hasattr(cmd, "is_channel") in pcmds
                    for cmd in cmdset.commands))
            self.assertTrue(
                any(hasattr(cmd, "is_channel") for cmd in cmdset.commands))

        deferred.addCallback(_callback)
        return deferred
示例#2
0
    def basetype_setup(self):
        # delayed import of the channelhandler
        global _CHANNEL_HANDLER
        if not _CHANNEL_HANDLER:
            from evennia.comms.channelhandler import CHANNEL_HANDLER as _CHANNEL_HANDLER
        # register ourselves with the channelhandler.
        _CHANNEL_HANDLER.add(self)

        self.locks.add("send:all();listen:all();control:perm(Admin)")
示例#3
0
文件: comms.py 项目: Henddher/evennia
    def basetype_setup(self):
        # delayed import of the channelhandler
        global _CHANNEL_HANDLER
        if not _CHANNEL_HANDLER:
            from evennia.comms.channelhandler import CHANNEL_HANDLER as _CHANNEL_HANDLER
        # register ourselves with the channelhandler.
        _CHANNEL_HANDLER.add(self)

        self.locks.add("send:all();listen:all();control:perm(Admin)")
示例#4
0
    def at_channel_creation(self):
        """
        Called once, when the channel is first created.

        """
        # delayed import of the channelhandler
        global _CHANNEL_HANDLER
        if not _CHANNEL_HANDLER:
            from evennia.comms.channelhandler import CHANNEL_HANDLER as _CHANNEL_HANDLER
        # register ourselves with the channelhandler.
        _CHANNEL_HANDLER.add(self)
示例#5
0
    def at_channel_creation(self):
        """
        Called once, when the channel is first created.

        """
        # delayed import of the channelhandler
        global _CHANNEL_HANDLER
        if not _CHANNEL_HANDLER:
            from evennia.comms.channelhandler import CHANNEL_HANDLER as _CHANNEL_HANDLER
        # register ourselves with the channelhandler.
        _CHANNEL_HANDLER.add(self)
示例#6
0
 def test_autocmdsets(self):
     import evennia
     from evennia.commands.default.cmdset_player import PlayerCmdSet
     from evennia.comms.channelhandler import CHANNEL_HANDLER
     testchannel = evennia.create_channel("channeltest", locks="listen:all();send:all()")
     CHANNEL_HANDLER.add(testchannel)
     CHANNEL_HANDLER.update()
     self.assertTrue(testchannel.connect(self.player))
     self.assertTrue(testchannel.has_connection(self.player))
     a, b, c, d = self.cmdset_a, self.cmdset_b, self.cmdset_c, self.cmdset_d
     self.set_cmdsets(self.player, a, b, c, d)
     deferred = cmdhandler.get_and_merge_cmdsets(self.session, self.session, self.player, self.char1, "session", "")
     def _callback(cmdset):
         pcmdset = PlayerCmdSet()
         pcmdset.at_cmdset_creation()
         pcmds = [cmd.key for cmd in pcmdset.commands] + ["a", "b", "c", "d"] + ["out"]
         self.assertTrue(all(cmd.key or hasattr(cmd, "is_channel") in pcmds for cmd in cmdset.commands))
         self.assertTrue(any(hasattr(cmd, "is_channel") for cmd in cmdset.commands))
     deferred.addCallback(_callback)
     return deferred