comparison plugins/xxhiddendice.py @ 227:81d0bfd5e800 alpha

Traipse Alpha 'OpenRPG' {100612-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 (Preparing to close updates) New Features: New to Map, can re-order Grid, Miniatures, and Whiteboard layer draw order Fixes: Fix to InterParse that was causing an Infernal Loop with Namespace Internal Fix to XML data, removed old Minidom and switched to Element Tree Fix to Server that was causing eternal attempt to find a Server ID, in Register Rooms thread Fix to metaservers.xml file not being created
author sirebral
date Sat, 12 Jun 2010 03:50:37 -0500
parents c160f26ecf65
children
comparison
equal deleted inserted replaced
182:4b2884f29a72 227:81d0bfd5e800
1 import os 1 import os, re, wx
2 import re
3 import orpg.pluginhandler 2 import orpg.pluginhandler
3 from orpg.tools.InterParse import Parse
4 4
5 class Plugin(orpg.pluginhandler.PluginHandler): 5 class Plugin(orpg.pluginhandler.PluginHandler):
6 # Initialization subroutine. 6 # Initialization subroutine.
7 # 7 #
8 # !self : instance of self 8 # !self : instance of self
21 #You can set variables below here. Always set them to a blank value in this section. Use plugin_enabled 21 #You can set variables below here. Always set them to a blank value in this section. Use plugin_enabled
22 #to set their proper values. 22 #to set their proper values.
23 self.hiddenrolls = [] 23 self.hiddenrolls = []
24 self.dicere = "\{([0-9]*d[0-9]*.+)\}" 24 self.dicere = "\{([0-9]*d[0-9]*.+)\}"
25 25
26 def plugin_menu(self):
27 self.menu = wx.Menu()
28 self.toggle = self.menu.AppendCheckItem(wx.ID_ANY, 'On')
29 self.topframe.Bind(wx.EVT_MENU, self.plugin_toggle, self.toggle)
30 self.toggle.Check(True)
31
32 def plugin_toggle(self, evt):
33 pass
26 34
27 def plugin_enabled(self): 35 def plugin_enabled(self):
28 pass 36 pass
29 37
30
31 def plugin_disabled(self): 38 def plugin_disabled(self):
32 pass 39 pass
33 40
34
35 def pre_parse(self, text): 41 def pre_parse(self, text):
36 m = re.search(self.dicere, text) 42 if self.toggle.IsChecked() == True:
37 while m:
38 roll = "[" + m.group(1) + "]"
39 self.hiddenrolls += [self.chat.ParseDice(roll)]
40 text = text[:m.start()] + "(hidden roll)" + text[m.end():]
41 m = re.search(self.dicere, text) 43 m = re.search(self.dicere, text)
44 while m:
45 roll = "[" + m.group(1) + "]"
46 self.hiddenrolls += [Parse.Dice(roll)]
47 text = text[:m.start()] + "(hidden roll)" + text[m.end():]
48 m = re.search(self.dicere, text)
42 return text 49 return text
43 50
44 def post_msg(self, text, myself): 51 def post_msg(self, text, myself):
45 c = 0 52 if self.toggle.IsChecked() == True:
46 a = text.find("(hidden roll)") 53 c = 0
47
48 while len(self.hiddenrolls) > c and a > -1:
49 text = text[:a+14].replace("(hidden roll)", self.hiddenrolls[c]) + text[a+14:]
50 a = text.find("(hidden roll)") 54 a = text.find("(hidden roll)")
51 c += 1 55 while len(self.hiddenrolls) > c and a > -1:
52 if c > 0: 56 text = text[:a+14].replace("(hidden roll)", self.hiddenrolls[c]) + text[a+14:]
53 self.hiddenrolls = [] 57 a = text.find("(hidden roll)")
58 c += 1
59 if c > 0:
60 self.hiddenrolls = []
54 return text 61 return text