Mercurial > traipse_dev
diff orpg/chat/chatwnd.py @ 96:65c1604e7949 alpha
Traipse Alpha 'OpenRPG' {090924-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:
00:
Update forwards to the 090909-02 Server code that now works.
New default Lobby Map, designed for Traipse. Feel free to change it.
Updates to Server GUI:
* Admin can Ban from Backend.
* Prework to modify Ban List in back end.
* Server GUI finds your Lobby Name
* New users default as Lurker unless a Role is set
New Addition to Chat Die Roll commands. Math Ordering. Ex. [(X+Y)dZ]. Currently does pairs only, no nesting either.
Cleaner TraipseSuiteAttention portability and clean up in Main (Beta!)
author | sirebral |
---|---|
date | Thu, 24 Sep 2009 02:05:08 -0500 |
parents | eb1b275699c4 |
children | bb22f0f1a7ec |
line wrap: on
line diff
--- a/orpg/chat/chatwnd.py Sat Sep 19 12:19:17 2009 -0500 +++ b/orpg/chat/chatwnd.py Thu Sep 24 02:05:08 2009 -0500 @@ -1853,7 +1853,8 @@ reg = re.compile("\[([^]]*?)\]") matches = reg.findall(s) for i in xrange(0,len(matches)): - newstr = self.PraseUnknowns(matches[i]) + newstr = self.PraseUnknowns(matches[i]) + newstr = self.ParseMathOrder(matches[i]) qmode = 0 newstr1 = newstr if newstr[0].lower() == 'q': @@ -1884,6 +1885,20 @@ if newstr == '': newstr = '0' s = s.replace(matches[i][0], newstr, 1).replace(matches[i][1], '', 1).replace(matches[i][2], '', 1) dlg.Destroy() + return s + + def ParseMathOrder(self, s): + ### Alpha ### New Code allows for Math Ordering with ()'s. Currently allows only pairs. + reg = re.compile("\(([^]]*?)\)") + matches = reg.findall(s) + for i in xrange(0,len(matches)): + node_math = self.ParseNode(matches[i]) + do_math = list(str(node_math)) + if do_math[1] == '+': math = int(do_math[0]) + int(do_math[2]) + if do_math[1] == '-': math = int(do_math[0]) - int(do_math[2]) + if do_math[1] == '*': math = int(do_math[0]) * int(do_math[2]) + if do_math[1] == '/': math = int(do_math[0]) / int(do_math[2]) + s = s.replace(matches[i], str(math)).replace('(', '').replace(')','') return s # This subroutine builds a chat display name. @@ -1933,10 +1948,10 @@ @debugging def resolve_loop(self, dom, nodeName, doLoop = False): - for node in dom: + for node in dom: if node._get_tagName() != 'nodehandler': continue - if doLoop and node.getAttribute('class') != 'textctrl_handler' and node.hasChildNodes(): + if doLoop and node.getAttribute('class') != 'textctrl_handler' and node.hasChildNodes(): (found, node) = self.resolve_loop(node.getChildren(), nodeName, doLoop) if not found: continue