Exemplo n.º 1
0
 def onEnable(self):
         pm = self.getServer().getPluginManager()
         respawn = RespawnListener()
         self.perms = PermissionsHandler(plugin)
         self.help = HelpMenu(self.perms)
         pm.registerEvent(Type.PLAYER_RESPAWN, respawn, Priority.Normal, self)
         print "RCDungeons version " + __Version__ + " is now loaded. :)"
Exemplo n.º 2
0
class RCDungeons(PythonPlugin):
        def onEnable(self):
                pm = self.getServer().getPluginManager()
                respawn = RespawnListener()
                self.perms = PermissionsHandler(plugin)
                self.help = HelpMenu(self.perms)
                pm.registerEvent(Type.PLAYER_RESPAWN, respawn, Priority.Normal, self)
                print "RCDungeons version " + __Version__ + " is now loaded. :)"

        def onDisable(self):
                print "RCDungeons version " + __Version__ + " is now unloaded. :("

        def onCommand(self, sender, command, label, args):
                if len(args) == 0:
                        self.help.send(sender)
                else:
                        print "You issued the following command: " + args[0]
                return 1;
Exemplo n.º 3
0
class TestHelpMenu(unittest.TestCase):

    help_menu = HelpMenu()

    # Tests help command with no other arguments
    def test_help(self):
        test_answer = self.help_menu.help()
        test_output = self.help_menu.help()
        self.assertEqual(test_answer, test_answer)

    def test_help_(self):
        test_answer = self.help_menu.HelpMenu.help()
        self.assertEqual(
            test_answer,
            "look\nUse the look command to look at the surroundings of the room you are in as well as its contents."
        )
Exemplo n.º 4
0
    def Render(self):
        # Get the content render
        render = Container.Render(self)

        # Build the <head> text
        self._headers += render.headers

        if self.js_header_end:
            head = "\n".join(
                filter(lambda l: not '<script' in l, uniq(self._headers)))
        else:
            head = "\n".join(uniq(self._headers))

        # Helps
        all_helps = self._helps
        all_helps += render.helps

        render_helps = HelpMenu(all_helps).Render().html

        # Javascript
        js = ''

        if self.js_header_end:
            js += "\n".join(
                filter(lambda l: '<script' in l, uniq(self._headers)))

        if render.js:
            js += formatter(HTML_JS_ON_READY_BLOCK, render.js)

        # Build the <body>
        body = render.html + render_helps
        if render.js:
            body += js

        # Set up the template
        self._template['head'] = head
        self._template['html'] = render.html
        self._template['js'] = js
        self._template['body'] = body
        self._template['helps'] = render_helps

        if not self._template['body_props']:
            self._template['body_props'] = ''

        txt = self._template.Render()
        return Postprocess(txt)