annotate orpg/dieroller/srex.py @ 156:3b6888bb53b5 beta

Traipse Beta 'OpenRPG' {091125-02} 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) Added Bookmarks Fix to Remote Admin Commands Minor fix to text based Server Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core 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 default_manifest.xml renamed to default_upmana.xml Cleaner clode for saved repositories New TrueDebug Class in orpg_log (See documentation for usage) Mercurial's hgweb folder is ported to upmana Pretty important update that can help remove thousands of dead children from your gametree. Children, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height />, etc... are all tags now. Check your gametree and look for dead children!! New Gametree Recursion method, mapping, and context sensitivity. !Infinite Loops return error instead of freezing the software! New Syntax added for custom PC sheets Tip of the Day added, from Core and community Fixed Whiteboard ID to prevent random line or text deleting. Modified ID's to prevent non updated clients from ruining the fix.
author sirebral
date Wed, 25 Nov 2009 12:34:04 -0600
parents 449a8900f9ac
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: srex.py
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
23 # Original Author: Michael Edwards (AKA akoman)
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. Thanks to the ORPG team
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
29 # for the original die rollers.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
30 # Thanks to tdb30_ for letting me think out loud with him.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
31 # I take my hint from the HERO dieroller: It creates for wildly variant options
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
32 # Further, .vs and .open do not work together in any logical way. One method of
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
33 # chaining them results in a [Bad Dice Format] and the other results in a standard
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
34 # output from calling .open()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
35
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
36 # vs is a classic 'comparison' method function, with one difference. It uses a
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
37 # c&p'ed .open(int) from die.py but makes sure that once the target has been exceeded
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
38 # then it stops rerolling. The overhead from additional boolean checking is probably
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
39 # greater than the gains from not over-rolling. The behaviour is in-line with
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
40 # Shadowrun Third Edition which recommends not rolling once you've exceeded the target
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
41 # open is an override of .open(int) in die.py. The reason is pretty simple. In die.py open
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
42 # refers to 'open-ended rolling' whereas in Shadowrun it refers to an 'Open Test' where
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
43 # the objective is to find the highest die total out of rolled dice. This is then generally
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
44 # used as the target in a 'Success Test' (for which .vs functions)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
45
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
46 # Modified by: Darloth
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
47 # Mod Version: 1.1
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
48 # Modified Desc:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
49 # I've altered the vs call to make it report successes against every target number (tn)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
50 # in a specified (default 3) range, with the original as median.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
51 # This reduces rerolling if the TN was calculated incorrectly, and is also very useful
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
52 # when people are rolling against multiple TNs, which is the case with most area-effect spells.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
53 # To aid in picking the specified TN out from the others, it will be in bold.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
54 # vswide is a version which can be used with no arguments, or can be used to get a very wide range, by
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
55 # directly specifying the upper bound (Which is limited to 30)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
56
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
57 from die import *
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
58
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
59 __version__ = "1.1"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
60
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
61 class srex(std):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
62
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
63 def __init__(self,source=[]):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
64 std.__init__(self,source)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
65
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
66
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
67 def vs(self,actualtarget=4,tnrange=3): #reports all tns around specified, max distance of range
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
68 return srVs(self,actualtarget,(actualtarget-tnrange),(actualtarget+tnrange))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
69
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
70
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
71 def vswide(self,actualtarget=4,maxtarget=12): #wide simply means it reports TNs from 2 to a specified max.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
72 return srVs(self,actualtarget,2,maxtarget)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
73
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
74
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
75 def open(self): #unchanged from standard shadowrun open.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
76 return srOpen(self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
77
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
78 class srVs(std):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
79
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
80 def __init__(self,source=[],actualtarget=4,mintn=2,maxtn=12):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
81 std.__init__(self, source)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
82 if actualtarget > 30:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
83 actualtarget = 30
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
84 if mintn > 30:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
85 mintn = 30
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
86 if maxtn > 30:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
87 maxtn = 30
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
88 # In Shadowrun, not target number may be below 2. Any
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
89 # thing lower is scaled up.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
90 if actualtarget < 2:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
91 self.target = 2
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
92 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
93 self.target = actualtarget
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
94 #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
95 if actualtarget > maxtn:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
96 maxtn = actualtarget
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
97 #store minimum for later use as well, also in result printing section.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
98 if mintn < 2:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
99 self.mintn = 2
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
100 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
101 self.mintn = mintn
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
102 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
103
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
104 # Shadowrun was built to use the d6 but in the interests of experimentation I have
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
105 # made the dieroller generic enough to use any die type
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
106 self.openended(self[0].sides)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
107
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
108
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
109 def openended(self,num):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
110 if num <= 1:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
111 self
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
112 done = 1
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
113
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
114 #reroll dice if they hit the highest number, until they are greater than the max TN (recursive)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
115 for i in range(len(self.data)):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
116 if (self.data[i].lastroll() >= num) and (self.data[i] < self.maxtn):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
117 self.data[i].extraroll()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
118 done = 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
119 if done:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
120 return self
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
121 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
122 return self.openended(num)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
123
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
124 #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
125
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
126 def __sum__(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
127 s = 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
128 for r in self.data:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
129 if r >= self.target:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
130 s += 1
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
131 return s
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
132
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
133 #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
134 #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
135 #easily be lost.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
136
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
137 def xsum(self,curtarget):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
138 s = 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
139 for r in self.data:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
140 if r >= curtarget:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
141 s += 1
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
142 return s
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
143
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
144
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
145
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
146 def __str__(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
147 if len(self.data) > 0:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
148 myStr = "[" + str(self.data[0])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
149 for a in self.data[1:]:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
150 myStr += ","
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
151 myStr += str(a)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
152 myStr += "] Results: "
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
153 #cycle through from mintn to maxtn, summing successes for each separate TN
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
154 for targ in range(self.mintn,self.maxtn+1):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
155 if targ == self.target:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
156 myStr += "<b>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
157 myStr += "(" + str(self.xsum(targ)) + "&nbsp;vs&nbsp;" + str(targ) + ") "
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
158 if targ == self.target:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
159 myStr += "</b>"
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 myStr = "[] = (0)"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
162
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
163 return myStr
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
164
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
165 class srOpen(std):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
166
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
167 def __init__(self,source=[]):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
168 std.__init__(self,source)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
169 self.openended(self[0].sides)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
170
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
171
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
172 def openended(self,num):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
173 if num <= 1:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
174 self
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
175 done = 1
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
176 for i in range(len(self.data)):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
177 if self.data[i].lastroll() == num:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
178 self.data[i].extraroll()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
179 done = 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
180 if done:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
181 return self
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
182 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
183 return self.openended(num)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
184
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
185
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
186 def __sum__(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
187 s = 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
188 for r in self.data:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
189 if r > s:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
190 s = r
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
191 return s
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
192
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
193
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
194 def __str__(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
195 if len(self.data) > 0:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
196 myStr = "[" + str(self.data[0])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
197 for a in self.data[1:]:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
198 myStr += ","
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
199 myStr += str(a)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
200 self.takeHighest(1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
201 myStr += "] for a result of (" + str(self.__sum__().__int__()) + ")"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
202 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
203 myStr = "[] = (0)"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
204
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 71
diff changeset
205 return myStr