view plugins/xxhiddendice.py @ 100:7ed4979cc1cf beta

Traipse Beta 'OpenRPG' {090925-00} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc''s main goal is to offer more advanced features and enhance the productivity of the user. Update Summary: 090925-00: Adds menu changes to draw attention to important updates, errors, or other events. (image info coming soon) Traipse URL is not included in the repos tab and is set as default. Fixes Copy for Windows and Linux (finally!!) users. Fixes incomplete update to Grid and List nodes. Fixes incomplete update to Chat Commands. Fixes problems with Remote Image Upload. Fixes Drop and Drag of Minis to Map. CherryPy can now use any image in the webfiles/ folder and sub-folders. CherryPy can now Drop and Drag Minis to the Map. Minor changes to Update Manager's GUI. Expert recommendation warning added to Revision Update. Step down compatibility with open_rpg & component added to orpgCore. Fixes CherryPit misspelling. Makes Traipse Suite 'Attention' item portable, and executes it on 'Critical' debug notices. Adds incomplete Shift + Enter to Text Entry, currently creates a 'Critical' warning. New default Lobby Map, designed for Traipse. Feel free to change it. Updates to Server GUI: * Admin can Ban from Backend. * Admin can Modify Ban List and Un Ban users. * Server GUI finds your Lobby Name * New users default as Lurker unless a Role is set Cleaner TraipseSuiteAttention portability and clean up in Main. Die Roll Commands addition from Core code allowing Math Ordering with ()'s New About Dialog. A more uniform About Dialog. Corrects image loading of duplicate images.
author sirebral
date Fri, 25 Sep 2009 20:46:02 -0500
parents c160f26ecf65
children 15488fe94f52 81d0bfd5e800
line wrap: on
line source

import os
import re
import orpg.pluginhandler

class Plugin(orpg.pluginhandler.PluginHandler):
    # Initialization subroutine.
    #
    # !self : instance of self
    # !openrpg : instance of the the base openrpg control
    def __init__(self, plugindb, parent):
        orpg.pluginhandler.PluginHandler.__init__(self, plugindb, parent)

        # The Following code should be edited to contain the proper information
        self.name = 'Hidden Dice'
        self.author = 'mDuo13'
        self.help = 'Roll with curly brackets to hide your roll,\n'
        self.help += 'having it display only for you. Other players will\n'
        self.help += 'get a message that only says you are rolling.\n'
        self.help += 'Useful for GMs who want to roll secretly.'

        #You can set variables below here. Always set them to a blank value in this section. Use plugin_enabled
        #to set their proper values.
        self.hiddenrolls = []
        self.dicere = "\{([0-9]*d[0-9]*.+)\}"


    def plugin_enabled(self):
        pass


    def plugin_disabled(self):
        pass


    def pre_parse(self, text):
        m = re.search(self.dicere, text)
        while m:
            roll = "[" + m.group(1) + "]"
            self.hiddenrolls += [self.chat.ParseDice(roll)]
            text = text[:m.start()] + "(hidden roll)" + text[m.end():]
            m = re.search(self.dicere, text)
        return text

    def post_msg(self, text, myself):
        c = 0
        a = text.find("(hidden roll)")

        while len(self.hiddenrolls) > c and a > -1:
            text = text[:a+14].replace("(hidden roll)", self.hiddenrolls[c]) + text[a+14:]
            a = text.find("(hidden roll)")
            c += 1
        if c > 0:
            self.hiddenrolls = []
        return text