171
|
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 __version__ = "$Id: hero.py,v 1.15 2006/11/04 21:24:19 digitalxero Exp $"
|
|
33
|
|
34 from time import time, clock
|
|
35 import random
|
|
36
|
|
37 from std import std
|
|
38 from orpg.dieroller.base import *
|
|
39
|
|
40 # Hero stands for "Hero system" not 20 sided die :)
|
|
41
|
|
42 class hero(std):
|
|
43 name = "hero"
|
|
44
|
|
45 def __init__(self,source=[]):
|
|
46 std.__init__(self,source)
|
|
47
|
|
48 # these methods return new die objects for specific options
|
|
49
|
|
50 def k(self,mod):
|
|
51 return herok(self,mod)
|
|
52
|
|
53 def hl(self):
|
|
54 return herohl(self)
|
|
55
|
|
56 def hk(self):
|
|
57 return herohk(self)
|
|
58
|
|
59 def n(self):
|
|
60 return heron(self)
|
|
61
|
|
62 def cv(self,cv,mod):
|
|
63 return herocv(self,cv,mod)
|
|
64
|
|
65 def sk(self,sk,mod):
|
|
66 return herosk(self,sk,mod)
|
|
67
|
|
68 die_rollers.register(hero)
|
|
69
|
|
70 class herocv(std):
|
|
71 def __init__(self,source=[],cv=10,mod=0):
|
|
72 std.__init__(self,source)
|
|
73 self.cv = cv
|
|
74 self.mod = mod
|
|
75
|
|
76
|
|
77 def __str__(self):
|
|
78 myStr = "[" + str(self.data[0])
|
|
79 for a in self.data[1:]:
|
|
80 myStr += ","
|
|
81 myStr += str(a)
|
|
82 myStr += "] = (" + str(self.sum()) + ")"
|
|
83
|
|
84 myStr += " with a CV of " + str(self.cv)
|
|
85 myStr += " and a modifier of " + str(self.mod)
|
|
86 cvhit = 11 + self.cv - self.sum() + self.mod
|
|
87 myStr += " hits up to <b>DCV <font color='#ff0000'>" + str(cvhit) + "</font></b>"
|
|
88 return myStr
|
|
89
|
|
90 class herosk(std):
|
|
91 def __init__(self,source=[],sk=11,mod=0):
|
|
92 std.__init__(self,source)
|
|
93 self.sk = sk
|
|
94 self.mod = mod
|
|
95
|
|
96 def is_success(self):
|
|
97 return (((self.sum()-self.mod) <= self.sk))
|
|
98
|
|
99 def __str__(self):
|
|
100 myStr = "[" + str(self.data[0])
|
|
101 for a in self.data[1:]:
|
|
102 myStr += ","
|
|
103 myStr += str(a)
|
|
104 strAdd="] - "
|
|
105 swapmod=self.mod
|
|
106 if self.mod < 0:
|
|
107 strAdd= "] + "
|
|
108 swapmod= -self.mod
|
|
109 myStr += strAdd + str(swapmod)
|
|
110 modSum = self.sum()-self.mod
|
|
111 myStr += " = (" + str(modSum) + ")"
|
|
112 myStr += " vs " + str(self.sk)
|
|
113
|
|
114 if self.is_success():
|
|
115 myStr += " or less <font color='#ff0000'>Success!"
|
|
116 else:
|
|
117 myStr += " or less <font color='#ff0000'>Failure!"
|
|
118
|
|
119 Diff = self.sk - modSum
|
|
120 myStr += " by " + str(Diff) +" </font>"
|
|
121
|
|
122 return myStr
|
|
123
|
|
124 class herok(std):
|
|
125 def __init__(self,source=[],mod=0):
|
|
126 std.__init__(self,source)
|
|
127 self.mod = mod
|
|
128
|
|
129 def __str__(self):
|
|
130 myStr = "[" + str(self.data[0])
|
|
131 for a in self.data[1:]:
|
|
132 myStr += ","
|
|
133 myStr += str(a)
|
|
134 myStr += "] = (<font color='#ff0000'><b>" + str(int(round(self.sum()))) + "</b></font>)"
|
|
135 stunx = random.randint(1,6)-1
|
|
136 if stunx <= 1:
|
|
137 stunx = 1
|
|
138 myStr += " <b>Body</b> and a stunx of (" + str(stunx)
|
|
139 stunx = stunx + self.mod
|
|
140 myStr += " + " + str(self.mod)
|
|
141 stunsum = round(self.sum()) * stunx
|
|
142 myStr += ") for a total of (<font color='#ff0000'><b>" + str(int(stunsum)) + "</b></font>) <b>Stun</b>"
|
|
143 return myStr
|
|
144
|
|
145 class herohl(std):
|
|
146 def __init__(self,source=[],mod=0):
|
|
147 std.__init__(self,source)
|
|
148 self.mod = mod
|
|
149
|
|
150 def __str__(self):
|
|
151 myStr = "[" + str(self.data[0])
|
|
152 side = random.randint(1,6)
|
|
153 sidestr = "Left "
|
|
154 if side >=4:
|
|
155 sidestr = "Right "
|
|
156 for a in self.data[1:]:
|
|
157 myStr += ","
|
|
158 myStr += str(a)
|
|
159 myStr += "] = (<font color='#ff0000'><b>" + str(int(round(self.sum()))) + "</b></font>) "
|
|
160 location = int(round(self.sum()))
|
|
161 if location <= 5:
|
|
162 myStr += "Location: <B>Head</B>, StunX:<B>x5</B>, NStun:<B>x2</B>, Bodyx:<B>x2</B>"
|
|
163 elif location == 6:
|
|
164 myStr += "Location: <B>" + sidestr + "Hand</B>, StunX:<B>x1</B>, NStun:<B>x1/2</B>, Bodyx:<B>x1/2</B>"
|
|
165 elif location == 7:
|
|
166 myStr += "Location: <B>" + sidestr + "Arm</B>, StunX:<B>x2</B>, NStun:<B>x1/2</B>, Bodyx:<B>x1/2</B>"
|
|
167 elif location == 8:
|
|
168 myStr += "Location: <B>" + sidestr + "Arm</B>, StunX:<B>x2</B>, NStun:<B>x1/2</B>, Bodyx:<B>x1/2</B>"
|
|
169 elif location == 9:
|
|
170 myStr += "Location: <B>" + sidestr + "Shoulder</B>, StunX:<B>x3</B>, NStun:<B>x1</B>, Bodyx:<B>x1</B>"
|
|
171 elif location == 10:
|
|
172 myStr += "Location: <B>Chest</B>, StunX:<B>x3</B>, NStun:<B>x1</B>, Bodyx:<B>x1</B>"
|
|
173 elif location == 11:
|
|
174 myStr += "Location: <B>Chest</B>, StunX:<B>x3</B>, NStun:<B>x1</B>, Bodyx:<B>x1</B>"
|
|
175 elif location == 12:
|
|
176 myStr += "Location: <B>Stomach</B>, StunX:<B>x4</B>, NStun:<B>x1 1/2</B>, Bodyx:<B>x1</B>"
|
|
177 elif location == 13:
|
|
178 myStr += "Location: <B>Vitals</B>, StunX:<B>x4</B>, NStun:<B>x1 1/2</B>, Bodyx:<B>x2</B>"
|
|
179 elif location == 14:
|
|
180 myStr += "Location: <B>" + sidestr + "Thigh</B>, StunX:<B>x2</B>, NStun:<B>x1</B>, Bodyx:<B>x1</B>"
|
|
181 elif location == 15:
|
|
182 myStr += "Location: <B>" + sidestr + "Leg</B>, StunX:<B>x2</B>, NStun:<B>x1/2</B>, Bodyx:<B>x1/2</B>"
|
|
183 elif location == 16:
|
|
184 myStr += "Location: <B>" + sidestr + "Leg</B>, StunX:<B>x2</B>, NStun:<B>x1/2</B>, Bodyx:<B>x1/2</B>"
|
|
185 elif location >= 17:
|
|
186 myStr += "Location: <B>" + sidestr + "Foot</B>, StunX:<B>x1</B>, NStun:<B>x1/2</B>, Bodyx:<B>x1/2</B>"
|
|
187 return myStr
|
|
188
|
|
189 class herohk(std):
|
|
190 def __init__(self,source=[],mod=0):
|
|
191 std.__init__(self,source)
|
|
192 self.mod = mod
|
|
193
|
|
194 def __str__(self):
|
|
195 myStr = "[" + str(self.data[0])
|
|
196 for a in self.data[1:]:
|
|
197 myStr += ","
|
|
198 myStr += str(a)
|
|
199 myStr += "] = (<font color='#ff0000'><b>" + str(int(round(self.sum()))) + "</b></font>)"
|
|
200 stunx = 1
|
|
201 myStr += " <b>Body</b> "
|
|
202 stunx = stunx + self.mod
|
|
203 stunsum = round(self.sum()) * stunx
|
|
204 myStr += " for a total of (<font color='#ff0000'><b>" + str(int(stunsum)) + "</b></font>) <b>Stun</b>"
|
|
205 return myStr
|
|
206
|
|
207 class heron(std):
|
|
208 def __init__(self,source=[],mod=0):
|
|
209 std.__init__(self,source)
|
|
210 self.bodtot=0
|
|
211
|
|
212 def __str__(self):
|
|
213 myStr = "[" + str(self.data[0])
|
|
214 if self.data[0] == 6:
|
|
215 self.bodtot=self.bodtot+2
|
|
216 else:
|
|
217 self.bodtot=self.bodtot+1
|
|
218 if self.data[0] <= 1:
|
|
219 self.bodtot=self.bodtot-1
|
|
220 for a in self.data[1:]:
|
|
221 myStr += ","
|
|
222 myStr += str(a)
|
|
223 if a == 6:
|
|
224 self.bodtot=self.bodtot+2
|
|
225 else:
|
|
226 self.bodtot=self.bodtot+1
|
|
227 if a <= 1:
|
|
228 self.bodtot=self.bodtot-1
|
|
229 myStr += "] = (<font color='#ff0000'><b>" + str(self.bodtot) + "</b></font>)"
|
|
230 myStr += " <b>Body</b> and "
|
|
231 myStr += "(<font color='#ff0000'><b>" + str(int(round(self.sum()))) + "</b></font>) <b>Stun</b>"
|
|
232 return myStr
|