diff orpg/dieroller/utils.py @ 66:c54768cffbd4 ornery-dev

Traipse Dev 'OpenRPG' {090818-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: *Unstable* This is the first wave of Code Refinement updates. Includes new material from Core Beta; new debugger material (partially implemented), beginnings of switch to etree, TerminalWriter, and a little more. open_rpg has been renamed to component; functioning now as component.get(), component.add(), component.delete(). This version has known bugs, specifically with the gametree and nodes. I think the XML files where not removed during testing of Core and switching back.
author sirebral
date Tue, 18 Aug 2009 06:33:37 -0500
parents 4385a7d0efd1
children 449a8900f9ac
line wrap: on
line diff
--- a/orpg/dieroller/utils.py	Mon Aug 17 06:56:31 2009 -0500
+++ b/orpg/dieroller/utils.py	Tue Aug 18 06:33:37 2009 -0500
@@ -41,7 +41,8 @@
 from gurps import *
 from runequest import *
 from savage import *
-from trinity import *
+from trinity import *
+from orpg.orpgCore import component
 
 import re
 
@@ -49,17 +50,14 @@
 
 class roller_manager:
     def __init__(self,roller_class="d20"):
-        try:
-            self.setRoller(roller_class)
-        except:
-            self.roller_class = "std"
+        try: self.setRoller(roller_class)
+        except: self.roller_class = "std"
 
     def setRoller(self,roller_class):
         try:
             rollers.index(roller_class)
             self.roller_class = roller_class
-        except:
-            raise Exception, "Invalid die roller!"
+        except: raise Exception, "Invalid die roller!"
 
     def getRoller(self):
         return self.roller_class
@@ -71,15 +69,11 @@
         s = match.group(0)
         (num,sides) = s.split('d')
 
-        if sides.strip().upper() == 'F':
-            sides = "'f'"
-
+        if sides.strip().upper() == 'F': sides = "'f'"
         try:
             if int(num) > 100 or int(sides) > 10000:
                 return None
-        except:
-            pass
-
+        except: pass
         return "(" + num.strip() + "**" + self.roller_class + "(" + sides.strip() + "))"
 
     #  Use this to convert ndm-style (3d6) dice to d_base format
@@ -91,10 +85,9 @@
                 s2 = self.roller_class + "(0)." + s
                 test = eval(s2)
                 return s2
-            except:
-                pass
+            except: pass
         return result
 
-
     def proccessRoll(self,s):
         return str(eval(self.convertTheDieString(s)))
+#component.add('dieroller', roller_manager())