view plugins/xxhiddendice.py @ 218:b8091ede042a alpha

Traipse Alpha 'OpenRPG' {100430-01} 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 (Patch-2) New Features: New Namespace method with two new syntaxes New Namespace Internal is context sensitive, always! New Namespace External is 'as narrow as you make it' New Namespace FutureCheck helps ensure you don't receive an incorrect node New PluginDB access for URL2Link plugin New to Forms, they now show their content in Design Mode New to Update Manager, checks Repo for updates on software start New to Mini Lin node, change title in design mode New to Game Tree, never lose a node, appends a number to the end of corrupted trees New to Server GUI, Traipse Suite's Debug Console Fixes: Fix to Server GUI startup errors Fix to Server GUI Rooms tab updating Fix to Chat and Settings if non existant die roller is picked Fix to Dieroller and .open() used with .vs(). Successes are correctly calculated Fix to Alias Lib's Export to Tree, Open, Save features Fix to alias node, now works properly Fix to Splitter node, minor GUI cleanup Fix to Backgrounds not loading through remote loader Fix to Node name errors Fix to rolling dice in chat Whispers Fix to Splitters Sizing issues Fix to URL2Link plugin, modified regex compilation should remove memory leak Fix to mapy.py, a roll back due to zoomed grid issues Fix to whiteboard_handler, Circles work by you clicking the center of the circle Fix to Servers parse_incoming_dom which was outdated and did not respect XML Fix to a broken link in the server welcome message Fix to InterParse and logger requiring traceback Fix to Update Manager Status Bar Fix to failed image and erroneous pop up Fix to Mini Lib node that was preventing use Fix to plugins that parce dice but did not call InterParse Fix to nodes for name changing by double click Fix to Game Tree, node ordering on drag and drop corrected Fix to Game Tree, corrupted error message was not showing
author sirebral
date Fri, 30 Apr 2010 11:37:37 -0500
parents 4dc11df853bf
children 72e0cce81a47
line wrap: on
line source

import os, re, wx
import orpg.pluginhandler
from orpg.tools.InterParse import Parse

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_menu(self):
        self.menu = wx.Menu()
        self.toggle = self.menu.AppendCheckItem(wx.ID_ANY, 'On')
        self.topframe.Bind(wx.EVT_MENU, self.plugin_toggle, self.toggle)
        self.toggle.Check(True)

    def plugin_toggle(self, evt):
        pass

    def plugin_enabled(self):
        pass

    def plugin_disabled(self):
        pass

    def pre_parse(self, text):
        if self.toggle.IsChecked() == True:
            m = re.search(self.dicere, text)
            while m:
                roll = "[" + m.group(1) + "]"
                self.hiddenrolls += [Parse.Dice(roll)]
                text = text[:m.start()] + "(hidden roll)" + text[m.end():]
                m = re.search(self.dicere, text)
        return text

    def post_msg(self, text, myself):
        if self.toggle.IsChecked() == True:
            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