diff orpg/dieroller/rollers/d20.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 81d0bfd5e800
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/orpg/dieroller/rollers/d20.py	Thu Dec 10 22:30:40 2009 -0600
@@ -0,0 +1,115 @@
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# --
+#
+# File: d20.py
+# Author: OpenRPG Dev Team
+# Maintainer:
+# Version:
+#   $Id: d20.py,v 1.9 2006/11/04 21:24:19 digitalxero Exp $
+#
+# Description: d20 die roller
+__version__ = "$Id: d20.py,v 1.9 2006/11/04 21:24:19 digitalxero Exp $"
+
+# d20 stands for "d20 system" not 20 sided die :)
+
+from std import std
+from orpg.dieroller.base import *
+
+class d20(std):
+    name = "d20"
+
+    def __init__(self,source=[]):
+        std.__init__(self,source)
+
+# these methods return new die objects for specific options
+
+    def attack(self,AC,mod,critical):
+        return d20attack(self,AC,mod,critical)
+
+    def dc(self,DC,mod):
+        return d20dc(self,DC,mod)
+
+die_rollers.register(d20)
+
+class d20dc(std):
+    def __init__(self,source=[],DC=10,mod=0):
+        std.__init__(self,source)
+        self.DC = DC
+        self.mod = mod
+        self.append(static_di(mod))
+
+    def is_success(self):
+        return ((self.sum() >= self.DC or self.data[0] == 20) and self.data[0] != 1)
+
+    def __str__(self):
+        myStr = "[" + str(self.data[0])
+        for a in self.data[1:]:
+            myStr += ","
+            myStr += str(a)
+        myStr += "] = (" + str(self.sum()) + ")"
+
+        myStr += " vs DC " + str(self.DC)
+
+        if self.is_success():
+            myStr += " Success!"
+        else:
+            myStr += " Failure!"
+
+        return myStr
+
+
+class d20attack(std):
+    def __init__(self,source=[],AC=10,mod=0,critical=20):
+        std.__init__(self,source)
+        self.mod = mod
+        self.critical = critical
+        self.AC = AC
+        self.append(static_di(mod))
+        self.critical_check()
+
+    def attack(AC=10,mod=0,critical=20):
+        self.mod = mod
+        self.critical = critical
+        self.AC = AC
+
+    def critical_check(self):
+        self.critical_result = 0
+        self.critical_roll = 0
+        if self.data[0] >= self.critical and self.is_hit():
+            self.critical_roll = die_base(20) + self.mod
+            if self.critical_roll.sum() >= self.AC:
+                self.critical_result = 1
+
+    def is_critical(self):
+        return self.critical_result
+
+    def is_hit(self):
+        return ((self.sum() >= self.AC or self.data[0] == 20) and self.data[0] != 1)
+
+    def __str__(self):
+        myStr = "[" + str(self.data[0])
+        for a in self.data[1:]:
+            myStr += ","
+            myStr += str(a)
+        myStr += "] = (" + str(self.sum()) + ")"
+
+        myStr += " vs AC " + str(self.AC)
+
+        if self.is_critical():
+            myStr += " Critical"
+
+        if self.is_hit():
+            myStr += " Hit!"
+        else:
+            myStr += " Miss!"
+
+        return myStr