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