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