annotate orpg/dieroller/d20.py @ 164:d263c8ff4d7c beta

Traipse Beta 'OpenRPG' {091202-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 Wed, 02 Dec 2009 21:21:34 -0600
parents 3b6888bb53b5
children
rev   line source
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
1 # (at your option) any later version.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
2 #
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
3 # This program is distributed in the hope that it will be useful,
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
4 # but WITHOUT ANY WARRANTY; without even the implied warranty of
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
5 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
6 # GNU General Public License for more details.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
7 #
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
8 # You should have received a copy of the GNU General Public License
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
9 # along with this program; if not, write to the Free Software
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
10 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
11 # --
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
12 #
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
13 # File: d20.py
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
14 # Author: OpenRPG Dev Team
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
15 # Maintainer:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
16 # Version:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
17 # $Id: d20.py,v 1.9 2006/11/04 21:24:19 digitalxero Exp $
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
18 #
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
19 # Description: d20 die roller
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
20 #
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 0
diff changeset
21 from die import *
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
22
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
23 __version__ = "$Id: d20.py,v 1.9 2006/11/04 21:24:19 digitalxero Exp $"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
24
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
25 # d20 stands for "d20 system" not 20 sided die :)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
26
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
27 class d20(std):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
28
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
29 def __init__(self,source=[]):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
30 std.__init__(self,source)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
31
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
32 # these methods return new die objects for specific options
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
33
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
34
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
35 def attack(self,AC,mod,critical):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
36 return d20attack(self,AC,mod,critical)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
37
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
38
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
39 def dc(self,DC,mod):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
40 return d20dc(self,DC,mod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
41
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
42 class d20dc(std):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
43
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
44 def __init__(self,source=[],DC=10,mod=0):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
45 std.__init__(self,source)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
46 self.DC = DC
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
47 self.mod = mod
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
48 self.append(static_di(mod))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
49
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
50
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
51 def is_success(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
52 return ((self.sum() >= self.DC or self.data[0] == 20) and self.data[0] != 1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
53
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
54
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
55 def __str__(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
56 myStr = "[" + str(self.data[0])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
57 for a in self.data[1:]:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
58 myStr += ","
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
59 myStr += str(a)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
60 myStr += "] = (" + str(self.sum()) + ")"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
61
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
62 myStr += " vs DC " + str(self.DC)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
63
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
64 if self.is_success():
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
65 myStr += " Success!"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
66 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
67 myStr += " Failure!"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
68
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
69 return myStr
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
70
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
71
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
72 class d20attack(std):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
73
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
74 def __init__(self,source=[],AC=10,mod=0,critical=20):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
75 std.__init__(self,source)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
76 self.mod = mod
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
77 self.critical = critical
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
78 self.AC = AC
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
79 self.append(static_di(mod))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
80 self.critical_check()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
81
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
82
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
83 def attack(AC=10,mod=0,critical=20):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
84 self.mod = mod
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
85 self.critical = critical
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
86 self.AC = AC
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
87
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
88
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
89 def critical_check(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
90 self.critical_result = 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
91 self.critical_roll = 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
92 if self.data[0] >= self.critical and self.is_hit():
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
93 self.critical_roll = die_base(20) + self.mod
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
94 if self.critical_roll.sum() >= self.AC:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
95 self.critical_result = 1
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
96
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
97
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
98 def is_critical(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
99 return self.critical_result
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
100
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
101
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
102 def is_hit(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
103 return ((self.sum() >= self.AC or self.data[0] == 20) and self.data[0] != 1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
104
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
105
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
106 def __str__(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
107 myStr = "[" + str(self.data[0])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
108 for a in self.data[1:]:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
109 myStr += ","
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
110 myStr += str(a)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
111 myStr += "] = (" + str(self.sum()) + ")"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
112
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
113 myStr += " vs AC " + str(self.AC)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
114
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
115 if self.is_critical():
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
116 myStr += " Critical"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
117
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
118 if self.is_hit():
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
119 myStr += " Hit!"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
120 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
121 myStr += " Miss!"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
122
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
123 return myStr