annotate orpg/dieroller/rollers/d20.py @ 167:5c9a118476b2 alpha

Traipse Alpha '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 (Keeping up with 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 Parent Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added Dieroller structure from Core 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 Fixes to Alternity roller's attack roll. Uses a simple Tuple instead of a Splice
author sirebral
date Thu, 10 Dec 2009 10:53:33 -0600
parents
children dcae32e219f1 81d0bfd5e800
rev   line source
167
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
1 # (at your option) any later version.
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
2 #
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
3 # This program is distributed in the hope that it will be useful,
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
4 # but WITHOUT ANY WARRANTY; without even the implied warranty of
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
5 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
6 # GNU General Public License for more details.
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
7 #
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
8 # You should have received a copy of the GNU General Public License
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
9 # along with this program; if not, write to the Free Software
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
10 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
11 # --
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
12 #
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
13 # File: d20.py
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
14 # Author: OpenRPG Dev Team
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
15 # Maintainer:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
16 # Version:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
17 # $Id: d20.py,v 1.9 2006/11/04 21:24:19 digitalxero Exp $
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
18 #
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
19 # Description: d20 die roller
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
20 __version__ = "$Id: d20.py,v 1.9 2006/11/04 21:24:19 digitalxero Exp $"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
21
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
22 # d20 stands for "d20 system" not 20 sided die :)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
23
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
24 from std import std
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
25 from orpg.dieroller.base import *
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
26
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
27 class d20(std):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
28 name = "d20"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
29
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
30 def __init__(self,source=[]):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
31 std.__init__(self,source)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
32
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
33 # these methods return new die objects for specific options
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
34
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
35 def attack(self,AC,mod,critical):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
36 return d20attack(self,AC,mod,critical)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
37
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
38 def dc(self,DC,mod):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
39 return d20dc(self,DC,mod)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
40
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
41 die_rollers.register(d20)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
42
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
43 class d20dc(std):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
44 def __init__(self,source=[],DC=10,mod=0):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
45 std.__init__(self,source)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
46 self.DC = DC
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
47 self.mod = mod
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
48 self.append(static_di(mod))
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
49
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
50 def is_success(self):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
51 return ((self.sum() >= self.DC or self.data[0] == 20) and self.data[0] != 1)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
52
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
53 def __str__(self):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
54 myStr = "[" + str(self.data[0])
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
55 for a in self.data[1:]:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
56 myStr += ","
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
57 myStr += str(a)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
58 myStr += "] = (" + str(self.sum()) + ")"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
59
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
60 myStr += " vs DC " + str(self.DC)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
61
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
62 if self.is_success():
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
63 myStr += " Success!"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
64 else:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
65 myStr += " Failure!"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
66
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
67 return myStr
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
68
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
69
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
70 class d20attack(std):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
71 def __init__(self,source=[],AC=10,mod=0,critical=20):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
72 std.__init__(self,source)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
73 self.mod = mod
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
74 self.critical = critical
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
75 self.AC = AC
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
76 self.append(static_di(mod))
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
77 self.critical_check()
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
78
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
79 def attack(AC=10,mod=0,critical=20):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
80 self.mod = mod
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
81 self.critical = critical
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
82 self.AC = AC
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
83
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
84 def critical_check(self):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
85 self.critical_result = 0
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
86 self.critical_roll = 0
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
87 if self.data[0] >= self.critical and self.is_hit():
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
88 self.critical_roll = die_base(20) + self.mod
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
89 if self.critical_roll.sum() >= self.AC:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
90 self.critical_result = 1
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
91
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
92 def is_critical(self):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
93 return self.critical_result
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
94
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
95 def is_hit(self):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
96 return ((self.sum() >= self.AC or self.data[0] == 20) and self.data[0] != 1)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
97
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
98 def __str__(self):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
99 myStr = "[" + str(self.data[0])
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
100 for a in self.data[1:]:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
101 myStr += ","
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
102 myStr += str(a)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
103 myStr += "] = (" + str(self.sum()) + ")"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
104
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
105 myStr += " vs AC " + str(self.AC)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
106
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
107 if self.is_critical():
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
108 myStr += " Critical"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
109
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
110 if self.is_hit():
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
111 myStr += " Hit!"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
112 else:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
113 myStr += " Miss!"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
114
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
115 return myStr