156
|
1 # (at your option) any later version.
|
|
2 #
|
|
3 # This program is distributed in the hope that it will be useful,
|
|
4 # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
5 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
6 # GNU General Public License for more details.
|
|
7 #
|
|
8 # You should have received a copy of the GNU General Public License
|
|
9 # along with this program; if not, write to the Free Software
|
|
10 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
11 # --
|
|
12 #
|
|
13 # File: Hero.py
|
|
14 # Version:
|
|
15 # $Id: Hero.py,v .3 DJM & Heroman
|
|
16 #
|
|
17 # Description: Hero System die roller originally based on Posterboy's D20 Dieroller
|
|
18 #
|
|
19 # Changelog:
|
|
20 # v.3 by Heroman
|
|
21 # Added hl() to show hit location (+side), and hk() for Hit Location killing damage
|
|
22 # (No random stun multiplier)
|
|
23 # v.2 DJM
|
|
24 # Removed useless modifiers from the Normal damage roller
|
|
25 # Changed Combat Value roller and SKill roller so that positive numbers are bonuses,
|
|
26 # negative numbers are penalties
|
|
27 # Changed Killing damage roller to correct stun multiplier bug
|
|
28 # Handled new rounding issues
|
|
29 #
|
|
30 # v.1 original release DJM
|
|
31
|
|
32 from die import *
|
|
33 from time import time, clock
|
|
34 import random
|
|
35
|
|
36 __version__ = "$Id: hero.py,v 1.15 2006/11/04 21:24:19 digitalxero Exp $"
|
|
37
|
|
38 # Hero stands for "Hero system" not 20 sided die :)
|
|
39
|
|
40 class hero(std):
|
|
41
|
|
42 def __init__(self,source=[]):
|
|
43 std.__init__(self,source)
|
|
44
|
|
45 # these methods return new die objects for specific options
|
|
46
|
|
47
|
|
48 def k(self,mod):
|
|
49 return herok(self,mod)
|
|
50
|
|
51
|
|
52 def hl(self):
|
|
53 return herohl(self)
|
|
54
|
|
55
|
|
56 def hk(self):
|
|
57 return herohk(self)
|
|
58
|
|
59
|
|
60 def n(self):
|
|
61 return heron(self)
|
|
62
|
|
63
|
|
64 def cv(self,cv,mod):
|
|
65 return herocv(self,cv,mod)
|
|
66
|
|
67
|
|
68 def sk(self,sk,mod):
|
|
69 return herosk(self,sk,mod)
|
|
70
|
|
71 class herocv(std):
|
|
72
|
|
73 def __init__(self,source=[],cv=10,mod=0):
|
|
74 std.__init__(self,source)
|
|
75 self.cv = cv
|
|
76 self.mod = mod
|
|
77
|
|
78
|
|
79
|
|
80 def __str__(self):
|
|
81 myStr = "[" + str(self.data[0])
|
|
82 for a in self.data[1:]:
|
|
83 myStr += ","
|
|
84 myStr += str(a)
|
|
85 myStr += "] = (" + str(self.sum()) + ")"
|
|
86
|
|
87 myStr += " with a CV of " + str(self.cv)
|
|
88 myStr += " and a modifier of " + str(self.mod)
|
|
89 cvhit = 11 + self.cv - self.sum() + self.mod
|
|
90 myStr += " hits up to <b>DCV <font color='#ff0000'>" + str(cvhit) + "</font></b>"
|
|
91 return myStr
|
|
92
|
|
93 class herosk(std):
|
|
94
|
|
95 def __init__(self,source=[],sk=11,mod=0):
|
|
96 std.__init__(self,source)
|
|
97 self.sk = sk
|
|
98 self.mod = mod
|
|
99
|
|
100
|
|
101 def is_success(self):
|
|
102 return (((self.sum()-self.mod) <= self.sk))
|
|
103
|
|
104
|
|
105 def __str__(self):
|
|
106 myStr = "[" + str(self.data[0])
|
|
107 for a in self.data[1:]:
|
|
108 myStr += ","
|
|
109 myStr += str(a)
|
|
110 strAdd="] - "
|
|
111 swapmod=self.mod
|
|
112 if self.mod < 0:
|
|
113 strAdd= "] + "
|
|
114 swapmod= -self.mod
|
|
115 myStr += strAdd + str(swapmod)
|
|
116 modSum = self.sum()-self.mod
|
|
117 myStr += " = (" + str(modSum) + ")"
|
|
118 myStr += " vs " + str(self.sk)
|
|
119
|
|
120 if self.is_success():
|
|
121 myStr += " or less <font color='#ff0000'>Success!"
|
|
122 else:
|
|
123 myStr += " or less <font color='#ff0000'>Failure!"
|
|
124
|
|
125 Diff = self.sk - modSum
|
|
126 myStr += " by " + str(Diff) +" </font>"
|
|
127
|
|
128 return myStr
|
|
129
|
|
130 class herok(std):
|
|
131
|
|
132 def __init__(self,source=[],mod=0):
|
|
133 std.__init__(self,source)
|
|
134 self.mod = mod
|
|
135
|
|
136
|
|
137 def __str__(self):
|
|
138 myStr = "[" + str(self.data[0])
|
|
139 for a in self.data[1:]:
|
|
140 myStr += ","
|
|
141 myStr += str(a)
|
|
142 myStr += "] = (<font color='#ff0000'><b>" + str(int(round(self.sum()))) + "</b></font>)"
|
|
143 stunx = random.randint(1,6)-1
|
|
144 if stunx <= 1:
|
|
145 stunx = 1
|
|
146 myStr += " <b>Body</b> and a stunx of (" + str(stunx)
|
|
147 stunx = stunx + self.mod
|
|
148 myStr += " + " + str(self.mod)
|
|
149 stunsum = round(self.sum()) * stunx
|
|
150 myStr += ") for a total of (<font color='#ff0000'><b>" + str(int(stunsum)) + "</b></font>) <b>Stun</b>"
|
|
151 return myStr
|
|
152
|
|
153 class herohl(std):
|
|
154
|
|
155 def __init__(self,source=[],mod=0):
|
|
156 std.__init__(self,source)
|
|
157 self.mod = mod
|
|
158
|
|
159
|
|
160 def __str__(self):
|
|
161 myStr = "[" + str(self.data[0])
|
|
162 side = random.randint(1,6)
|
|
163 sidestr = "Left "
|
|
164 if side >=4:
|
|
165 sidestr = "Right "
|
|
166 for a in self.data[1:]:
|
|
167 myStr += ","
|
|
168 myStr += str(a)
|
|
169 myStr += "] = (<font color='#ff0000'><b>" + str(int(round(self.sum()))) + "</b></font>) "
|
|
170 location = int(round(self.sum()))
|
|
171 if location <= 5:
|
|
172 myStr += "Location: <B>Head</B>, StunX:<B>x5</B>, NStun:<B>x2</B>, Bodyx:<B>x2</B>"
|
|
173 elif location == 6:
|
|
174 myStr += "Location: <B>" + sidestr + "Hand</B>, StunX:<B>x1</B>, NStun:<B>x1/2</B>, Bodyx:<B>x1/2</B>"
|
|
175 elif location == 7:
|
|
176 myStr += "Location: <B>" + sidestr + "Arm</B>, StunX:<B>x2</B>, NStun:<B>x1/2</B>, Bodyx:<B>x1/2</B>"
|
|
177 elif location == 8:
|
|
178 myStr += "Location: <B>" + sidestr + "Arm</B>, StunX:<B>x2</B>, NStun:<B>x1/2</B>, Bodyx:<B>x1/2</B>"
|
|
179 elif location == 9:
|
|
180 myStr += "Location: <B>" + sidestr + "Shoulder</B>, StunX:<B>x3</B>, NStun:<B>x1</B>, Bodyx:<B>x1</B>"
|
|
181 elif location == 10:
|
|
182 myStr += "Location: <B>Chest</B>, StunX:<B>x3</B>, NStun:<B>x1</B>, Bodyx:<B>x1</B>"
|
|
183 elif location == 11:
|
|
184 myStr += "Location: <B>Chest</B>, StunX:<B>x3</B>, NStun:<B>x1</B>, Bodyx:<B>x1</B>"
|
|
185 elif location == 12:
|
|
186 myStr += "Location: <B>Stomach</B>, StunX:<B>x4</B>, NStun:<B>x1 1/2</B>, Bodyx:<B>x1</B>"
|
|
187 elif location == 13:
|
|
188 myStr += "Location: <B>Vitals</B>, StunX:<B>x4</B>, NStun:<B>x1 1/2</B>, Bodyx:<B>x2</B>"
|
|
189 elif location == 14:
|
|
190 myStr += "Location: <B>" + sidestr + "Thigh</B>, StunX:<B>x2</B>, NStun:<B>x1</B>, Bodyx:<B>x1</B>"
|
|
191 elif location == 15:
|
|
192 myStr += "Location: <B>" + sidestr + "Leg</B>, StunX:<B>x2</B>, NStun:<B>x1/2</B>, Bodyx:<B>x1/2</B>"
|
|
193 elif location == 16:
|
|
194 myStr += "Location: <B>" + sidestr + "Leg</B>, StunX:<B>x2</B>, NStun:<B>x1/2</B>, Bodyx:<B>x1/2</B>"
|
|
195 elif location >= 17:
|
|
196 myStr += "Location: <B>" + sidestr + "Foot</B>, StunX:<B>x1</B>, NStun:<B>x1/2</B>, Bodyx:<B>x1/2</B>"
|
|
197 return myStr
|
|
198
|
|
199 class herohk(std):
|
|
200
|
|
201 def __init__(self,source=[],mod=0):
|
|
202 std.__init__(self,source)
|
|
203 self.mod = mod
|
|
204
|
|
205
|
|
206 def __str__(self):
|
|
207 myStr = "[" + str(self.data[0])
|
|
208 for a in self.data[1:]:
|
|
209 myStr += ","
|
|
210 myStr += str(a)
|
|
211 myStr += "] = (<font color='#ff0000'><b>" + str(int(round(self.sum()))) + "</b></font>)"
|
|
212 stunx = 1
|
|
213 myStr += " <b>Body</b> "
|
|
214 stunx = stunx + self.mod
|
|
215 stunsum = round(self.sum()) * stunx
|
|
216 myStr += " for a total of (<font color='#ff0000'><b>" + str(int(stunsum)) + "</b></font>) <b>Stun</b>"
|
|
217 return myStr
|
|
218
|
|
219 class heron(std):
|
|
220
|
|
221 def __init__(self,source=[],mod=0):
|
|
222 std.__init__(self,source)
|
|
223 self.bodtot=0
|
|
224
|
|
225
|
|
226 def __str__(self):
|
|
227 myStr = "[" + str(self.data[0])
|
|
228 if self.data[0] == 6:
|
|
229 self.bodtot=self.bodtot+2
|
|
230 else:
|
|
231 self.bodtot=self.bodtot+1
|
|
232 if self.data[0] <= 1:
|
|
233 self.bodtot=self.bodtot-1
|
|
234 for a in self.data[1:]:
|
|
235 myStr += ","
|
|
236 myStr += str(a)
|
|
237 if a == 6:
|
|
238 self.bodtot=self.bodtot+2
|
|
239 else:
|
|
240 self.bodtot=self.bodtot+1
|
|
241 if a <= 1:
|
|
242 self.bodtot=self.bodtot-1
|
|
243 myStr += "] = (<font color='#ff0000'><b>" + str(self.bodtot) + "</b></font>)"
|
|
244 myStr += " <b>Body</b> and "
|
|
245 myStr += "(<font color='#ff0000'><b>" + str(int(round(self.sum()))) + "</b></font>) <b>Stun</b>"
|
|
246 return myStr
|