comparison plugins/xxhiddendice.py @ 0:4385a7d0efd1 grumpy-goblin

Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
author sirebral
date Tue, 14 Jul 2009 16:41:58 -0500
parents
children c160f26ecf65
comparison
equal deleted inserted replaced
-1:000000000000 0:4385a7d0efd1
1 import os
2 import re
3 import orpg.pluginhandler
4
5 class Plugin(orpg.pluginhandler.PluginHandler):
6 # Initialization subroutine.
7 #
8 # !self : instance of self
9 # !openrpg : instance of the the base openrpg control
10 def __init__(self, plugindb, parent):
11 orpg.pluginhandler.PluginHandler.__init__(self, plugindb, parent)
12
13 # The Following code should be edited to contain the proper information
14 self.name = 'Hidden Dice'
15 self.author = 'mDuo13'
16 self.help = 'Roll with curly brackets to hide your roll,\n'
17 self.help += 'having it display only for you. Other players will\n'
18 self.help += 'get a message that only says you are rolling.\n'
19 self.help += 'Useful for GMs who want to roll secretly.'
20
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.
23 self.hiddenrolls = []
24 self.dicere = "\{([0-9]*d[0-9]*.+)\}"
25
26
27 def plugin_enabled(self):
28 pass
29
30
31 def plugin_disabled(self):
32 pass
33
34
35 def pre_parse(self, text):
36 m = re.search(self.dicere, text)
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)
42 return text
43
44 def post_msg(self, text, myself):
45 print "post_msg:\n\t" + text
46 c = 0
47 a = text.find("(hidden roll)")
48
49 while len(self.hiddenrolls) > c and a > -1:
50 text = text[:a+14].replace("(hidden roll)", self.hiddenrolls[c]) + text[a+14:]
51 a = text.find("(hidden roll)")
52 c += 1
53 if c > 0:
54 self.hiddenrolls = []
55 return text