annotate orpg/dieroller/wodex.py @ 159:033887bb8a86 alpha

Traipse Alpha 'OpenRPG' {091126-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 Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added 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. *Whiteboard from Core not showing* default_manifest.xml renamed to default_upmana.xml Fix to Update Manager; cleaner clode for saved repositories
author sirebral
date Thu, 26 Nov 2009 14:24:19 -0600
parents bf799efe7a8a
children
rev   line source
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
1 ## a vs die roller as used by WOD games
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
2 #!/usr/bin/env python
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
3 # Copyright (C) 2000-2001 The OpenRPG Project
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
4 #
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
5 # openrpg-dev@lists.sourceforge.net
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
6 #
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
7 # This program is free software; you can redistribute it and/or modify
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
8 # it under the terms of the GNU General Public License as published by
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
9 # the Free Software Foundation; either version 2 of the License, or
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
10 # (at your option) any later version.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
11 #
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
12 # This program is distributed in the hope that it will be useful,
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
15 # GNU General Public License for more details.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
16 #
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
17 # You should have received a copy of the GNU General Public License
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
18 # along with this program; if not, write to the Free Software
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
20 # --
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
21 #
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
22 # File: wodex.py
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
23 # Original Author: Darloth
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
24 # Maintainer:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
25 # Original Version: 1.0
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
26 #
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
27 # Description: A modified form of the World of Darkness die roller to
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
28 # conform to ShadowRun rules-sets, then modified back to the WoD for
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
29 # the new WoD system. Thanks to the ORPG team
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
30 # for the original die rollers.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
31 # Much thanks to whoever wrote the original shadowrun roller (akoman I believe)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
32
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
33
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
34 from die import *
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
35
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
36 __version__ = "$Id: wodex.py,v 1.9 2007/05/06 16:42:55 digitalxero Exp $"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
37
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
38 class wodex(std):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
39
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
40 def __init__(self,source=[]):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
41 std.__init__(self,source)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
42
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
43
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
44 def vs(self,actualtarget=6):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
45 return oldwodVs(self,actualtarget,(6))
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
46
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
47
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
48 def wod(self,actualtarget=8):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
49 return newwodVs(self,actualtarget,(8))
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
50
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
51
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
52 def exalt(self, actualtarget=7):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
53 return exaltVs(self, actualtarget)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
54
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
55
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
56 def exaltDmg(self, actualtarget=7):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
57 return exaltDmg(self, actualtarget)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
58
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
59
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
60 def vswide(self,actualtarget=6,maxtarget=10): #wide simply means it reports TNs from 2 to a specified max.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
61 return oldwodVs(self,actualtarget,2,maxtarget)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
62
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
63 class oldwodVs(std):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
64
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
65 def __init__(self,source=[],actualtarget=6,mintn=2,maxtn=10):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
66 std.__init__(self, source)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
67 if actualtarget > 10:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
68 actualtarget = 10
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
69 if mintn > 10:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
70 mintn = 10
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
71 if maxtn > 10:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
72 maxtn = 10
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
73 if actualtarget < 2:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
74 self.target = 2
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
75 else:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
76 self.target = actualtarget
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
77 #if the target number is higher than max (Mainly for wide rolls) then increase max to tn
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
78 if actualtarget > maxtn:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
79 maxtn = actualtarget
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
80 if actualtarget < mintn:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
81 mintn = actualtarget
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
82 #store minimum for later use as well, also in result printing section.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
83 if mintn < 2:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
84 self.mintn = 2
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
85 else:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
86 self.mintn = mintn
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
87 self.maxtn = maxtn #store for later use in printing results. (Yeah, these comments are now disordered)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
88
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
89 # WoD etc uses d10 but i've left it so it can roll anything openended
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
90 # self.openended(self[0].sides)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
91
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
92 #count successes, by looping through each die, and checking it against the currently set TN
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
93 #1's subtract successes.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
94
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
95 def __sum__(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
96 s = 0
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
97 for r in self.data:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
98 if r >= self.target:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
99 s += 1
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
100 elif r == 1:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
101 s -= 1
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
102 return s
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
103
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
104 #a modified sum, but this one takes a target argument, and is there because otherwise it is difficult to loop through
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
105 #tns counting successes against each one without changing target, which is rather dangerous as the original TN could
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
106 #easily be lost. 1s subtract successes from everything.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
107
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
108 def xsum(self,curtarget):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
109 s = 0
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
110 for r in self.data:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
111 if r >= curtarget:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
112 s += 1
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
113 elif r == 1:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
114 s -= 1
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
115 return s
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
116
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
117
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
118
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
119 def __str__(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
120 if len(self.data) > 0:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
121 myStr = "[" + str(self.data[0])
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
122 for a in self.data[1:]:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
123 myStr += ","
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
124 myStr += str(a)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
125 myStr += "] Results: "
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
126 #cycle through from mintn to maxtn, summing successes for each separate TN
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
127 for targ in range(self.mintn,self.maxtn+1):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
128 if (targ == self.target):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
129 myStr += "<b>"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
130 myStr += "(" + str(self.xsum(targ)) + "&nbsp;vs&nbsp;" + str(targ) + ") "
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
131 if (targ == self.target):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
132 myStr += "</b>"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
133 else:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
134 myStr = "[] = (0)"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
135
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
136 return myStr
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
137
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
138 class newwodVs(std):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
139
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
140 def __init__(self,source=[],actualtarget=8,mintn=8,maxtn=8):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
141 std.__init__(self, source)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
142 if actualtarget > 30:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
143 actualtarget = 30
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
144 if mintn > 10:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
145 mintn = 10
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
146 if maxtn > 10:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
147 maxtn = 10
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
148 if actualtarget < 2:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
149 self.target = 2
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
150 else:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
151 self.target = actualtarget
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
152 #if the target number is higher than max (Mainly for wide rolls) then increase max to tn
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
153 if actualtarget > maxtn:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
154 maxtn = actualtarget
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
155 if actualtarget < mintn:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
156 mintn = actualtarget
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
157 #store minimum for later use as well, also in result printing section.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
158 if mintn < 2:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
159 self.mintn = 2
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
160 else:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
161 self.mintn = mintn
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
162 self.maxtn = maxtn #store for later use in printing results. (Yeah, these comments are now disordered)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
163
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
164 # WoD etc uses d10 but i've left it so it can roll anything openended
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
165 # self.openended(self[0].sides)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
166
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
167 #a modified sum, but this one takes a target argument, and is there because otherwise it is difficult to loop through
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
168 #tns counting successes against each one without changing target, which is rather dangerous as the original TN could
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
169 #easily be lost. 1s subtract successes from original but not re-rolls.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
170
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
171 def xsum(self,curtarget,subones=1):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
172 s = 0
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
173 done = 1
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
174 for r in self.data:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
175 if r >= curtarget:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
176 s += 1
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
177 elif ((r == 1) and (subones == 1)):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
178 s -= 1
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
179 if r == 10:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
180 done = 0
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
181 subones = 0
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
182 self.append(di(10))
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
183 if done == 1:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
184 return s
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
185 else:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
186 return self.xsum(0)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
187
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
188
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
189 def openended(self,num):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
190 if num <= 1:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
191 self
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
192 done = 1
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
193 for i in range(len(self.data)):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
194 if self.data[i].lastroll() == num:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
195 self.data[i].extraroll()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
196 done = 0
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
197 if done:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
198 return self
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
199 else:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
200 return self.openended(num)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
201
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
202
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
203
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
204 def __str__(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
205 if len(self.data) > 0:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
206 myStr = "[" + str(self.data[0])
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
207 for a in self.data[1:]:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
208 myStr += ","
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
209 myStr += str(a)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
210 myStr += "] Results: "
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
211 #cycle through from mintn to maxtn, summing successes for each separate TN
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
212 for targ in range(self.mintn,self.maxtn+1):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
213 if (targ == self.target):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
214 myStr += "<b>"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
215 myStr += "(" + str(self.xsum(targ)) + "&nbsp;vs&nbsp;" + str(targ) + ") "
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
216 if (targ == self.target):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
217 myStr += "</b>"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
218 else:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
219 myStr = "[] = (0)"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
220
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
221 return myStr
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
222
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
223 class exaltVs(std):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
224
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
225 def __init__(self, source=[], actualtarget=7):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
226 std.__init__(self, source)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
227
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
228 if actualtarget > 10:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
229 actualtarget = 10
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
230
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
231 if actualtarget < 2:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
232 self.target = 2
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
233 else:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
234 self.target = actualtarget
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
235
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
236
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
237
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
238 def xsum(self, target):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
239 s = 0
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
240
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
241 for r in self.data:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
242 if r >= target:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
243 s += 1
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
244 if r == 10:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
245 s += 1
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
246
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
247 return s
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
248
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
249
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
250
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
251 def __str__(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
252 if len(self.data) > 0:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
253 myStr = str(self.data)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
254 myStr += " Results: "
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
255
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
256 succ = self.xsum(self.target)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
257 if succ == 0 and 1 in self.data:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
258 myStr += 'BOTCH!'
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
259 elif succ == 0:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
260 myStr += str(succ) + " Failure"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
261 elif succ == 1:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
262 myStr += str(succ) + " Success"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
263 else:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
264 myStr += str(succ) + " Successes"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
265
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
266 return myStr
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
267
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
268 class exaltDmg(std):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
269
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
270 def __init__(self, source=[], actualtarget=7):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
271 std.__init__(self, source)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
272 if actualtarget > 10:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
273 actualtarget = 10
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
274
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
275 if actualtarget < 2:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
276 self.target = 2
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
277 else:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
278 self.target = actualtarget
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
279
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
280
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
281 def xsum(self, target):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
282 s = 0
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
283
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
284 for r in self.data:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
285 if r >= target:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
286 s += 1
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
287 return s
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
288
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
289
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
290 def __str__(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
291 if len(self.data) > 0:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
292 myStr = str(self.data)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
293 myStr += " Results: "
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
294
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
295 succ = self.xsum(self.target)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
296
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
297 if succ == 0 and 1 in self.data:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
298 myStr += 'BOTCH!'
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
299 elif succ == 0:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
300 myStr += str(succ) + " Failure"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
301 elif succ == 1:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
302 myStr += str(succ) + " Success"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
303 else:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
304 myStr += str(succ) + " Successes"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
305
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
306 return myStr