diff orpg/dieroller/rollers/std.py @ 171:ff48c2741fe7 beta

Traipse Beta 'OpenRPG' {091210-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 (Beta) New Features: Added Bookmarks Added 'boot' command to remote admin Added confirmation window for sent nodes Minor changes to allow for portability to an OpenSUSE linux OS Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Zoom Mouse plugin added Images added to Plugin UI Switching to Element Tree Map efficiency, from FlexiRPG Added Status Bar to Update Manager New TrueDebug Class in orpg_log (See documentation for usage) Portable Mercurial Tip of the Day added, from Core and community New Reference Syntax added for custom PC sheets New Child Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added Added 7th Sea die roller method; ie [7k3] = [7d10.takeHighest(3).open(10)] New 'Mythos' System die roller added Added new vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)]. Includes support for Mythos roller. Fixes: Fix to Text based Server Fix to Remote Admin Commands Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Fix to Map from gametree not showing to all clients Fix to gametree about menus Fix to Password Manager check on startup Fix to PC Sheets from tool nodes. They now use the tabber_panel Fixed Whiteboard ID to prevent random line or text deleting. Modified ID's to prevent non updated clients from ruining the fix. default_manifest.xml renamed to default_upmana.xml Fix to Update Manager; cleaner clode for saved repositories Fixes made to Settings Panel and no reactive settings when Ok is pressed.
author sirebral
date Thu, 10 Dec 2009 22:30:40 -0600
parents
children dcae32e219f1 b633f4c64aae 81d0bfd5e800
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/orpg/dieroller/rollers/std.py	Thu Dec 10 22:30:40 2009 -0600
@@ -0,0 +1,83 @@
+from orpg.dieroller.base import die_base, die_rollers
+
+class std(die_base):
+    name = "std"
+
+    def __init__(self,source=[]):
+        die_base.__init__(self,source)
+
+    #  Examples of adding member functions through inheritance.
+
+    def ascending(self):
+        result = self[:]
+        result.sort()
+        return result
+
+    def descending(self):
+        result = self[:]
+        result.sort()
+        result.reverse()
+        return result
+
+    def takeHighest(self,num_dice):
+        return self.descending()[:num_dice]
+
+    def takeLowest(self,num_dice):
+        return self.ascending()[:num_dice]
+
+    def extra(self,num):
+        for i in range(len(self.data)):
+            if self.data[i].lastroll() >= num:
+                self.data[i].extraroll()
+        return self
+
+    def open(self,num):
+        if num <= 1:
+            self
+        done = 1
+        for i in range(len(self.data)):
+            if self.data[i].lastroll() >= num:
+                self.data[i].extraroll()
+                done = 0
+        if done:
+            return self
+        else:
+            return self.open(num)
+
+    def minroll(self,min):
+        for i in range(len(self.data)):
+            if self.data[i].lastroll() < min:
+                self.data[i].roll(min)
+        return self
+
+    def each(self,mod):
+        mod = int(mod)
+        for i in range(len(self.data)):
+            self.data[i].modify(mod)
+        return self
+
+
+    def vs(self, target):
+        for dn in self.data:
+            dn.target = target
+        return self
+
+
+    ## If we are testing against a saving throw, we check for
+    ## greater than or equal to against the target value and
+    ## we only return the number of successful saves.  A negative
+    ## value will never be generated.
+    def sum(self):
+        retValue = 0
+        for dn in self.data:
+            setValue = reduce( lambda x, y : int(x)+int(y), dn.history )
+            if dn.target:
+                if setValue >= dn.target:
+                    retValue += 1
+
+            else:
+                retValue += setValue
+
+        return retValue
+
+die_rollers.register(std)
\ No newline at end of file