comparison 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
comparison
equal deleted inserted replaced
95:af6bf998f425 96:65c1604e7949
1852 """Parses player input for embedded dice rolls""" 1852 """Parses player input for embedded dice rolls"""
1853 reg = re.compile("\[([^]]*?)\]") 1853 reg = re.compile("\[([^]]*?)\]")
1854 matches = reg.findall(s) 1854 matches = reg.findall(s)
1855 for i in xrange(0,len(matches)): 1855 for i in xrange(0,len(matches)):
1856 newstr = self.PraseUnknowns(matches[i]) 1856 newstr = self.PraseUnknowns(matches[i])
1857 newstr = self.ParseMathOrder(matches[i])
1857 qmode = 0 1858 qmode = 0
1858 newstr1 = newstr 1859 newstr1 = newstr
1859 if newstr[0].lower() == 'q': 1860 if newstr[0].lower() == 'q':
1860 newstr = newstr[1:] 1861 newstr = newstr[1:]
1861 qmode = 1 1862 qmode = 1
1882 dlg.SetTitle("Enter Value for " + matches[i][1]) 1883 dlg.SetTitle("Enter Value for " + matches[i][1])
1883 if dlg.ShowModal() == wx.ID_OK: newstr = dlg.GetValue() 1884 if dlg.ShowModal() == wx.ID_OK: newstr = dlg.GetValue()
1884 if newstr == '': newstr = '0' 1885 if newstr == '': newstr = '0'
1885 s = s.replace(matches[i][0], newstr, 1).replace(matches[i][1], '', 1).replace(matches[i][2], '', 1) 1886 s = s.replace(matches[i][0], newstr, 1).replace(matches[i][1], '', 1).replace(matches[i][2], '', 1)
1886 dlg.Destroy() 1887 dlg.Destroy()
1888 return s
1889
1890 def ParseMathOrder(self, s):
1891 ### Alpha ### New Code allows for Math Ordering with ()'s. Currently allows only pairs.
1892 reg = re.compile("\(([^]]*?)\)")
1893 matches = reg.findall(s)
1894 for i in xrange(0,len(matches)):
1895 node_math = self.ParseNode(matches[i])
1896 do_math = list(str(node_math))
1897 if do_math[1] == '+': math = int(do_math[0]) + int(do_math[2])
1898 if do_math[1] == '-': math = int(do_math[0]) - int(do_math[2])
1899 if do_math[1] == '*': math = int(do_math[0]) * int(do_math[2])
1900 if do_math[1] == '/': math = int(do_math[0]) / int(do_math[2])
1901 s = s.replace(matches[i], str(math)).replace('(', '').replace(')','')
1887 return s 1902 return s
1888 1903
1889 # This subroutine builds a chat display name. 1904 # This subroutine builds a chat display name.
1890 # 1905 #
1891 @debugging 1906 @debugging