annotate plugins/xxhiddendice.py @ 39:ed322725b928 ornery-orc tip

Traipse 'OpenRPG' {110114-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 (Closed) New Features: New to Map, can re-order Grid, Miniatures, and Whiteboard layer draw order New to Server GUI, can now clear log New Earthdawn Dieroller New IronClaw roller, sheet, and image New ShapeShifter PC Sheet Updates: Update to Warhammer PC Sheet. Rollers set as macros. Should work with little maintanence. Update to Browser Server window. Display rooms with ' " & cleaner Update to Server. Handles ' " & cleaner Update to Dieroller. Cleaner, more effecient expression system Update to Hidden Die plugin, allows for non standard dice rolls Update to location.py, allows for more portable references when starting Traipse Update to the Features node 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 Server, removing wxPython dependencies where not needed Fix to metaservers.xml file not being created Fix to Single and Double quotes in Whiteboard text Fix to Background images not showing when using the Image Server Fix to Duplicate chat names appearing Fix to Server GUI's logging output Fix to FNB.COLORFUL_TABS bug Fix to Gametree for XSLT Sheets Fix to Gametree for locating gametree files Fix to Send to Chat from Gametree Fix to Gametree, renaming and remapping operates correctly Fix to aliaslib, prevents error caused when SafeHTML is sent None
author sirebral
date Fri, 14 Jan 2011 05:24:52 -0600
parents d02e9197c066
children
rev   line source
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1 import os, re, wx
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2 import orpg.pluginhandler
31
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents: 28
diff changeset
3 from orpg.tools.InterParse import Parse
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 31
diff changeset
4 from orpg.dieroller.base import die_rollers
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 31
diff changeset
5 from orpg.dieroller.utils import roller_manager
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
6
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
7 class Plugin(orpg.pluginhandler.PluginHandler):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
8 # Initialization subroutine.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
9 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
10 # !self : instance of self
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
11 # !openrpg : instance of the the base openrpg control
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
12 def __init__(self, plugindb, parent):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
13 orpg.pluginhandler.PluginHandler.__init__(self, plugindb, parent)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
14
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
15 # The Following code should be edited to contain the proper information
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
16 self.name = 'Hidden Dice'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
17 self.author = 'mDuo13'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
18 self.help = 'Roll with curly brackets to hide your roll,\n'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
19 self.help += 'having it display only for you. Other players will\n'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
20 self.help += 'get a message that only says you are rolling.\n'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
21 self.help += 'Useful for GMs who want to roll secretly.'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
22
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
23 #You can set variables below here. Always set them to a blank value in this section. Use plugin_enabled
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
24 #to set their proper values.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
25 self.hiddenrolls = []
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 31
diff changeset
26 #self.dicere = "\{([0-9]*d[0-9]*.+)\}"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
27
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
28 def plugin_menu(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
29 self.menu = wx.Menu()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
30 self.toggle = self.menu.AppendCheckItem(wx.ID_ANY, 'On')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
31 self.topframe.Bind(wx.EVT_MENU, self.plugin_toggle, self.toggle)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
32 self.toggle.Check(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
33
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
34 def plugin_toggle(self, evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
35 pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
36
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
37 def plugin_enabled(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
38 pass
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
39
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
40 def plugin_disabled(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
41 pass
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
42
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
43 def pre_parse(self, text):
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
44 if self.toggle.IsChecked() == True:
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 31
diff changeset
45 ## Changes added for non standard dice rolls. Prof.Ebral (TaS)
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 31
diff changeset
46 math = '[\(0-9\/\*\-\+\)]+'
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 31
diff changeset
47 dicere = '\{('+math+'d\s*([0-9]+|'+math+'|[fF]))\}'
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 31
diff changeset
48 m = re.search(dicere, text)
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 31
diff changeset
49 if m is None:
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 31
diff changeset
50 dicere = '\{('+die_rollers._rollers[roller_manager().getRoller()].regExpression+')\}'
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 31
diff changeset
51 m = re.search(dicere, text)
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
52 while m:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
53 roll = "[" + m.group(1) + "]"
31
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents: 28
diff changeset
54 self.hiddenrolls += [Parse.Dice(roll)]
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
55 text = text[:m.start()] + "(hidden roll)" + text[m.end():]
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 31
diff changeset
56 m = re.search(dicere, text)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
57 return text
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
58
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
59 def post_msg(self, text, myself):
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
60 if self.toggle.IsChecked() == True:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
61 c = 0
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
62 a = text.find("(hidden roll)")
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
63 while len(self.hiddenrolls) > c and a > -1:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
64 text = text[:a+14].replace("(hidden roll)", self.hiddenrolls[c]) + text[a+14:]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
65 a = text.find("(hidden roll)")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
66 c += 1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
67 if c > 0:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
68 self.hiddenrolls = []
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
69 return text